|
@@ -5,6 +5,8 @@ import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.UUID;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.jfinal.core.Controller;
|
|
|
import com.jfinal.kit.HttpKit;
|
|
|
import com.jfinal.plugin.activerecord.Db;
|
|
@@ -15,7 +17,6 @@ import com.zskk.model.PatientInfos;
|
|
|
import com.zskk.model.Report;
|
|
|
import com.zskk.model.Studies;
|
|
|
import com.zskk.service.WeixinService;
|
|
|
-import com.zskk.tools.XmlHelper;
|
|
|
|
|
|
|
|
|
public class ViewController extends Controller {
|
|
@@ -53,72 +54,82 @@ public class ViewController extends Controller {
|
|
|
public void getReport() {
|
|
|
|
|
|
try {
|
|
|
-
|
|
|
+
|
|
|
String readData = HttpKit.readData(getRequest());
|
|
|
- XmlHelper xmlHelper = XmlHelper.of(readData);
|
|
|
-
|
|
|
- String studyuid = xmlHelper.getString("//studyuid");
|
|
|
+ JSONObject jsonObject = JSON.parseObject(readData);
|
|
|
+
|
|
|
+ String studyuid = jsonObject.getString("studyuid");
|
|
|
|
|
|
Studies studiesFind = Studies.dao.use("zskk").findFirst("SELECT * FROM studies WHERE studyuid=?", studyuid);
|
|
|
|
|
|
if (studiesFind != null) {
|
|
|
-
|
|
|
+ this.renderJson(Boolean.TRUE);
|
|
|
+ return;
|
|
|
}
|
|
|
+ String patientid = jsonObject.getString("patientid");
|
|
|
|
|
|
- PatientInfos patientInfos = new PatientInfos().use("zskk");
|
|
|
- patientInfos.setId(creatId());
|
|
|
+ PatientInfos patientInfosFind = PatientInfos.dao.use("zskk").findFirst("SELECT * FROM patient_infos WHERE temp_patient_id=?", patientid);
|
|
|
|
|
|
- String patientname = xmlHelper.getString("//patientname");
|
|
|
|
|
|
- patientInfos.setName(patientname);
|
|
|
-
|
|
|
- String patientsex = xmlHelper.getString("//patientsex");
|
|
|
+ String patientage = jsonObject.getString("patientage");
|
|
|
|
|
|
- patientInfos.setSex(patientsex);
|
|
|
-
|
|
|
- String idcard = xmlHelper.getString("//idcard");
|
|
|
+ String idcard = jsonObject.getString("idcard");
|
|
|
|
|
|
- patientInfos.setCardNum(idcard);
|
|
|
-
|
|
|
- String phone = xmlHelper.getString("//phone");
|
|
|
+ if (patientInfosFind == null) {
|
|
|
+ PatientInfos patientInfos = new PatientInfos().use("zskk");
|
|
|
|
|
|
- patientInfos.setPhone(phone);
|
|
|
-
|
|
|
- String birthdate = xmlHelper.getString("//birthdate");
|
|
|
+ patientInfos.setId(creatId());
|
|
|
+
|
|
|
+ String patientname = jsonObject.getString("patientname");
|
|
|
|
|
|
- patientInfos.setBirthday(birthdate);
|
|
|
-
|
|
|
- String patientage = xmlHelper.getString("//patientage");
|
|
|
+ patientInfos.setName(patientname);
|
|
|
+
|
|
|
+ String patientsex = jsonObject.getString("patientsex");
|
|
|
|
|
|
- patientInfos.setAge(patientage);
|
|
|
-
|
|
|
- String patientid = xmlHelper.getString("//patientid");
|
|
|
+ patientInfos.setSex(patientsex);
|
|
|
+
|
|
|
|
|
|
- patientInfos.setAge(patientid);
|
|
|
-
|
|
|
- patientInfos.setStatus(1);
|
|
|
-
|
|
|
- patientInfos.setInstitutionId("15000004");
|
|
|
-
|
|
|
- patientInfos.setCreatedAt(new Date());
|
|
|
-
|
|
|
- patientInfos.setUpdatedAt(new Date());
|
|
|
-
|
|
|
- patientInfos.save();
|
|
|
+ patientInfos.setCardNum(idcard);
|
|
|
+
|
|
|
+ String phone = jsonObject.getString("phone");
|
|
|
+
|
|
|
+ patientInfos.setPhone(phone);
|
|
|
+
|
|
|
+ String birthdate = jsonObject.getString("birthdate");
|
|
|
+
|
|
|
+ patientInfos.setBirthday(birthdate);
|
|
|
+
|
|
|
+
|
|
|
+ patientInfos.setAge(patientage);
|
|
|
+
|
|
|
+ patientInfos.setTempPatientId(patientid);
|
|
|
+
|
|
|
+ patientInfos.setStatus(1);
|
|
|
+
|
|
|
+ patientInfos.setInstitutionId("15000004");
|
|
|
+
|
|
|
+ patientInfos.setCreatedAt(new Date());
|
|
|
+
|
|
|
+ patientInfos.setUpdatedAt(new Date());
|
|
|
+
|
|
|
+ patientInfos.save();
|
|
|
+
|
|
|
+ patientInfosFind = patientInfos;
|
|
|
+ }
|
|
|
|
|
|
Studies studies = new Studies().use("zskk");
|
|
|
|
|
|
studies.setId(creatId());
|
|
|
|
|
|
- studies.setStudyid(studyuid);
|
|
|
+ studies.setStudyuid(studyuid);
|
|
|
|
|
|
- studies.setPatientId(patientInfos.getId());
|
|
|
+ studies.setPatientId(patientInfosFind.getId());
|
|
|
|
|
|
- String accessionNumber = xmlHelper.getString("//accessionNumber");
|
|
|
+ String accessionNumber = jsonObject.getString("accnum");
|
|
|
|
|
|
studies.setAccessionNum(accessionNumber);
|
|
|
|
|
|
- String modality = xmlHelper.getString("//modality");
|
|
|
+ String modality = jsonObject.getString("modality");
|
|
|
|
|
|
studies.setModality(modality);
|
|
|
|
|
@@ -138,7 +149,7 @@ public class ViewController extends Controller {
|
|
|
|
|
|
exams.setId(creatId());
|
|
|
|
|
|
- exams.setPatientId(patientInfos.getId());
|
|
|
+ exams.setPatientId(patientInfosFind.getId());
|
|
|
|
|
|
exams.setPatientNum(idcard);
|
|
|
|
|
@@ -158,14 +169,18 @@ public class ViewController extends Controller {
|
|
|
|
|
|
exams.setUpdatedAt(new Date());
|
|
|
|
|
|
- String department = xmlHelper.getString("//department");
|
|
|
+ String department = jsonObject.getString("department");
|
|
|
|
|
|
exams.setApplicationDepartment(department);
|
|
|
|
|
|
- String clinicaldoctor = xmlHelper.getString("//clinicaldoctor");
|
|
|
+ String clinicaldoctor = jsonObject.getString("clinicaldoctor");
|
|
|
|
|
|
exams.setApplicationDoctor(clinicaldoctor);
|
|
|
|
|
|
+ String operateuserid = jsonObject.getString("operateuserid");
|
|
|
+
|
|
|
+ exams.setRegister(operateuserid);
|
|
|
+
|
|
|
exams.setExamStatus(9);
|
|
|
|
|
|
exams.save();
|
|
@@ -174,17 +189,13 @@ public class ViewController extends Controller {
|
|
|
|
|
|
report.setId(creatId());
|
|
|
|
|
|
- String reportdate = xmlHelper.getString("//reportdate");
|
|
|
+ String reportdate = jsonObject.getString("reportdate");
|
|
|
|
|
|
report.setReportDatetime(parseStringToDate(reportdate));
|
|
|
|
|
|
- String description = xmlHelper.getString("//description");
|
|
|
+ String description = jsonObject.getString("description");
|
|
|
|
|
|
- String impression = xmlHelper.getString("//impression");
|
|
|
-
|
|
|
- if (impression == null && description == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
+ String impression = jsonObject.getString("diagnosis");
|
|
|
|
|
|
report.setImpression(impression);
|
|
|
|
|
@@ -192,11 +203,11 @@ public class ViewController extends Controller {
|
|
|
report.setExamId(exams.getId());
|
|
|
report.setCreatedAt(new Date());
|
|
|
|
|
|
- String reportdoctor = xmlHelper.getString("//reportdoctor");
|
|
|
+ String reportdoctor = jsonObject.getString("reportdoctor");
|
|
|
|
|
|
report.setReportDoctorId(getDoctorIdByName(reportdoctor));
|
|
|
|
|
|
- String reviewdoctor = xmlHelper.getString("//reviewdoctor");
|
|
|
+ String reviewdoctor = jsonObject.getString("reviewdoctor");
|
|
|
|
|
|
report.setReviewDoctorId(getDoctorIdByName(reviewdoctor));
|
|
|
report.setReviewDatetime(parseStringToDate(reportdate));
|
|
@@ -206,7 +217,7 @@ public class ViewController extends Controller {
|
|
|
|
|
|
WeixinService wService = new WeixinService();
|
|
|
wService.requestWeixinQrcode(report.getId());
|
|
|
- this.renderText(readData);
|
|
|
+ this.renderJson(Boolean.TRUE);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
// TODO Auto-generated catch block
|
|
@@ -224,21 +235,30 @@ public class ViewController extends Controller {
|
|
|
|
|
|
private String getDoctorIdByName(String name) {
|
|
|
if (name == null) {
|
|
|
- return "1";
|
|
|
+ return null;
|
|
|
}
|
|
|
Doctors doctors = Doctors.dao.use("zskk").findFirst("SELECT * FROM doctors where instr(?,realname) and institution_id=15000004 and realname<>''", name);
|
|
|
if (doctors == null) {
|
|
|
- return "1";
|
|
|
+ Doctors newDoctors = new Doctors().use("zskk");
|
|
|
+ newDoctors.setId(creatId());
|
|
|
+ newDoctors.setUsername("none");
|
|
|
+ newDoctors.setRealname(name);
|
|
|
+ newDoctors.setPassword("123456");
|
|
|
+ newDoctors.setInstitutionId("15000004");
|
|
|
+ newDoctors.setCreatedAt(new Date());
|
|
|
+ newDoctors.setUpdatedAt(new Date());
|
|
|
+ newDoctors.save();
|
|
|
+ return newDoctors.getId();
|
|
|
}
|
|
|
return doctors.getId();
|
|
|
}
|
|
|
|
|
|
|
|
|
- private static Date parseStringToDate(String dateStr) {
|
|
|
+ private Date parseStringToDate(String dateStr) {
|
|
|
if (dateStr == null) {
|
|
|
return new Date();
|
|
|
}
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
Date date = null;
|
|
|
try {
|
|
|
date = sdf.parse(dateStr);
|