In the Diabetes Patient Information Management system, the introduction of patient information Function! Form form submission data (Excel file), in the background cannot get file files, workaround:
Private file FilePath;//Files
Private String FileName; Filename
Private String FileType; File type
Note: Above filepath must have, otherwise get filepath as empty below!
/**
* Import patient information and insert user information
*/
Public String importpatient () throws Exception {
if (FilePath! = null) {
FileInputStream fis = new FileInputStream (filePath);
Workbook READWB = Workbook.getworkbook (FIS);
Get sheet
Sheet readsheet = readwb.getsheet (0);
How many columns do you get
int rscolumns = Readsheet.getcolumns ();
How many lines do you get
int rsrows = Readsheet.getrows ();
Cell
Cell cell;
Instantiating patient objects
Patient Patient = new Patient ();
Sysuser sysuser = new Sysuser ();
Map<integer, string> map = new Hashmap<integer, string> ();
for (int i = 1; i < rsrows; i++) {
for (int j = 0; J < Rscolumns; J + +) {
Cell = Readsheet.getcell (j, I);
Map.put (J, Cell.getcontents ());
}
UUID uuid = Uuid.randomuuid ();
String Patientid = uuid.tostring ();
Patient.setid (Patientid);
User Information
Sysuser.setid (Uuid.tostring ());
Sysuser.setusername (Map.get (5));
Sysuser.setpassword (Md5keybean.getkeybeanofstr ("123456"));
Sysuser.setnickname (Map.get (1));
Sysuser.setphone (Map.get (5));
1: not locked by default; 0: Locked
Sysuser.setstatus ("1");
Role ID
list<sysrole> sysroles = Sysroleservice.findallsysroles ();
if (Sysroles.size () >0) {
for (int j = 0; J < Sysroles.size (); j + +) {
if ("Patient". Equals (Sysroles.get (j). GetName ())) {
Sysuser.setsysrole (Sysroles.get (j));
}
}
}
Patient ID
Sysuser.setflagid (Patientid);
Sysuser.setcreatetime (New Date ());
Sysuserservice.savesysuser (Sysuser);
Patient.setnumber (map.get (0));
Patient.setrealname (Map.get (1));
Patient.setage (Integer.parseint (Map.get (2)));
Gender: 1 Male 0 female
if ("Male". Equals (Map.get (3))) {
Patient.setsex ("1");
} else if ("female". Equals (Map.get (3))) {
Patient.setsex ("0");
} else {
Patient.setsex ("1");
}
Patient.setnation (Map.get (4));
Patient.setphone (Map.get (5));
Marital Status: 1: Married 0: Unmarried
if ("Married". Equals (Map.get (6))) {
Patient.setstatemarriage ("1");
} else if ("unmarried". Equals (Map.get (6))) {
Patient.setstatemarriage ("0");
} else {
Patient.setstatemarriage ("1");
}
Patient.setbirthadress (Map.get (7));
Patient.setaddress (Map.get (8));
Patient.setorganize (Map.get (9));
Patient.setnumberid (Map.get (10));
Type of illness
String Diseasetype = map.get (11);
list<diseasetype> diseasetypes = Diseasetypeservice
. Findalldiseasetypes ();
if (diseasetypes.size () > 0) {
for (int j = 0; J < Diseasetypes.size (); j + +) {
if (Diseasetype.equals (Diseasetypes.get (j)
. Getdiseasetype ())) {
Patient.setdiseasetypeid (Diseasetypes.get (j)
. GetId ());
}
}
}
Patientservice.savepatient (patient);
}
}
return "Listaction";
}
JSP Code:
<!--batch import of patient information--
<form class= "Form-horizontal" method= "post" action= "${pagecontext.request.contextpath}/sys/patientaction_ Importpatient.do "id=" FileUpload "name=" FileUpload "enctype=" Multipart/form-data ">
<style type= "Text/css" >
. file {
position:relative;
Display:inline-block;
Background: #78CD51;
border:1px solid #99D3F5;
border-radius:4px;
PADDING:4PX 12px;
Color: #FFFFFF;
Text-decoration:none;
text-indent:0;
line-height:25px;
}
. File Input {
Position:absolute;
width:120px;
right:0;
top:0;
opacity:0;
}
. file:hover {
Background: #78CD51;
Border-color: #78C3F3;
Color: #FFFFFF;
Text-decoration:none;
}
</style>
<script type= "Text/javascript" language= "JavaScript" >
function Submitfile () {
document.getElementById ("FileUpload"). Submit ();
}
</script>
<a href= "javascript:;" class= "File" > Bulk Import patient Information
<input type= "File"name= "FilePath"Id= "Excelfile" onchange= "Submitfile ()" >
</a>
</form>
FileInputStream is a inputstream subclass and cannot be converted directly, but FileInputStream can be used as a inputstream.
This batch import and kindergarten management system import is not quite the same!
In the Diabetes Patient Information Management system, the introduction of patient information Function!