|
@@ -0,0 +1,205 @@
|
|
|
+package com.zskk.task;
|
|
|
+
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.jfinal.json.JFinalJson;
|
|
|
+import com.jfinal.kit.PropKit;
|
|
|
+import com.jfinal.plugin.activerecord.Db;
|
|
|
+import com.jfinal.plugin.activerecord.Record;
|
|
|
+import com.jfinal.plugin.cron4j.ITask;
|
|
|
+import com.zskk.service.DataService;
|
|
|
+import com.zskk.service.ServiceFactory;
|
|
|
+import com.zskk.service.ThreadPoolService;
|
|
|
+
|
|
|
+public class USReportTask implements ITask {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+ DataService dService = ServiceFactory.getService(DataService.class);
|
|
|
+
|
|
|
+ List<Record> records = Db.use("connected").find("SELECT * FROM (select * from reportinfo where STUDYSTATUS = '诊断完成' and MODALITY = 'US' and REVIEWDATE>to_date(?,'YYYY-MM-DD HH24:MI:SS')and rownum < 80)ORDER BY REVIEWDATE DESC", getNowDate());
|
|
|
+ for (Record record : records) {
|
|
|
+ Record recordus = Db.use("local").findFirst("select * from usexam where code = ?", record.getStr("DIAGRPTID"));
|
|
|
+ if (recordus != null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ //创建登记
|
|
|
+ Map<String, String> params = new HashMap<>();
|
|
|
+
|
|
|
+ params.put("institution_id", PropKit.get("institution_id"));
|
|
|
+
|
|
|
+ params.put("name", record.getStr("PATIENTNAME"));
|
|
|
+
|
|
|
+ params.put("exam_class", record.getStr("MODALITY"));
|
|
|
+
|
|
|
+ params.put("application_department", record.getStr("DEPARTMENT")==null?"":record.getStr("DEPARTMENT"));
|
|
|
+
|
|
|
+ params.put("phone", record.getStr("PHONE")==null?"":record.getStr("PHONE"));
|
|
|
+
|
|
|
+ params.put("is_dcm", "2");
|
|
|
+
|
|
|
+ params.put("exam_datetime", parseStringToDate(record.getStr("REVIEWDATE")));
|
|
|
+
|
|
|
+ params.put("patient_num", record.getStr("PATIENTID"));
|
|
|
+
|
|
|
+ params.put("accession_num", record.getStr("EXAMNO"));
|
|
|
+
|
|
|
+ String examid = dService.createRegisterInfo(params);
|
|
|
+
|
|
|
+ if (examid == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //匹配报告
|
|
|
+ Map<String, String> paramsreport = new HashMap<>();
|
|
|
+ paramsreport.put("type", "1");
|
|
|
+
|
|
|
+ paramsreport.put("institution_id", PropKit.get("institution_id"));
|
|
|
+
|
|
|
+ paramsreport.put("code", examid);
|
|
|
+ //报告医生姓名
|
|
|
+ paramsreport.put("report_doctor_name", record.getStr("REPORTDOCTOR"));
|
|
|
+ //报告时间
|
|
|
+ paramsreport.put("report_datetime", record.getStr("REPORTDATE"));
|
|
|
+ //审核医生姓名
|
|
|
+ paramsreport.put("review_doctor_name", record.getStr("REVIEWDOCTOR"));
|
|
|
+ //审核时间
|
|
|
+ paramsreport.put("review_datetime", record.getStr("REVIEWDATE"));
|
|
|
+ //确认医生姓名
|
|
|
+ paramsreport.put("confirm_doctor_name", record.getStr("REVIEWDOCTOR"));
|
|
|
+ //确认时间
|
|
|
+ paramsreport.put("confirm_datetime", record.getStr("REVIEWDATE"));
|
|
|
+ //意见建议
|
|
|
+ paramsreport.put("impression", record.getStr("IMPRESSION"));
|
|
|
+ //影像所见
|
|
|
+ paramsreport.put("description", record.getStr("DESCRIPTION"));
|
|
|
+ //exams表
|
|
|
+ //申请科室
|
|
|
+ paramsreport.put("application_department", record.getStr("DEPARTMENT")==null?"":record.getStr("DEPARTMENT"));
|
|
|
+ //申请医生
|
|
|
+ paramsreport.put("application_doctor", record.getStr("CLINICALDOCTOR")==null?"":record.getStr("CLINICALDOCTOR"));
|
|
|
+ //临床诊断
|
|
|
+ paramsreport.put("clin_diag", record.getStr("DIAGNOSIS")==null?"":record.getStr("DIAGNOSIS"));
|
|
|
+ //症状
|
|
|
+ paramsreport.put("clin_symp", record.getStr("ILLNESS")==null?"":record.getStr("ILLNESS"));
|
|
|
+ //patient_infos表
|
|
|
+ //患者姓名
|
|
|
+ paramsreport.put("name", record.getStr("PATIENTNAME"));
|
|
|
+ //患者手机号
|
|
|
+ paramsreport.put("phone", record.getStr("PHONE")==null?"":record.getStr("PHONE"));
|
|
|
+ //患者身份证号
|
|
|
+ paramsreport.put("card_num", record.getStr("IDCARD")==null?"":record.getStr("IDCARD"));
|
|
|
+ //检查结果1阴2阳
|
|
|
+ paramsreport.put("report_result", "0");
|
|
|
+ //门诊号住院号
|
|
|
+ paramsreport.put("hopitalized_no", record.getStr("INPATIENTNUM")==null?"":record.getStr("INPATIENTNUM"));
|
|
|
+ paramsreport.put("out_patient", record.getStr("OUTPATIENTNUM")==null?"":record.getStr("OUTPATIENTNUM"));
|
|
|
+ //病人ID
|
|
|
+ paramsreport.put("his_patient_id", record.getStr("PATIENTID")==null?"":record.getStr("PATIENTID"));
|
|
|
+ //检查方法
|
|
|
+ paramsreport.put("exam_project", record.getStr("PROJECT")==null?"":record.getStr("PROJECT"));
|
|
|
+ //1急诊 (out_patient)2住院(hopitalized_no)3门诊(out_patient)4体检(out_patient)
|
|
|
+ switch (record.getStr("SOURCE")) {
|
|
|
+ case "门诊":
|
|
|
+ paramsreport.put("patient_source", "3");
|
|
|
+ break;
|
|
|
+ case "体检":
|
|
|
+ paramsreport.put("patient_source", "4");
|
|
|
+ break;
|
|
|
+ case "住院":
|
|
|
+ paramsreport.put("patient_source", "2");
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ ThreadPoolService tService = ServiceFactory.getService(ThreadPoolService.class);
|
|
|
+ tService.execute(() -> {
|
|
|
+ dService.saveReport(paramsreport);
|
|
|
+ });
|
|
|
+
|
|
|
+ //上传报告附件
|
|
|
+ Map<String, String> annex_params = new HashMap<>();
|
|
|
+ annex_params.put("institution_id", PropKit.get("institution_id"));
|
|
|
+ annex_params.put("type", "1");
|
|
|
+ annex_params.put("code", examid);
|
|
|
+ //附件类型1.mp4 2.pdf 3.jpeg
|
|
|
+ annex_params.put("annex_class_code", "3");
|
|
|
+ dService.saveAnnex(annex_params, record.getStr("RPTURL"));
|
|
|
+ Record usinfo = new Record().set("code", record.getStr("DIAGRPTID"))
|
|
|
+ .set("createAt", parseStringToDateTime()).set("updateAt", parseStringToDateTime());
|
|
|
+ Db.use("local").save("usexam", usinfo);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // TODO: handle exception
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void stop() {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 日期字符串格式转换年月日时分秒
|
|
|
+ *
|
|
|
+ * @param dateStr
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String parseStringToDateTime() {
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ Date date = new Date();
|
|
|
+ String daString = sdf.format(date);
|
|
|
+ return daString;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 日期字符串格式转换
|
|
|
+ *
|
|
|
+ * @param dateStr
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String parseStringToDate(String datestr) {
|
|
|
+ SimpleDateFormat sdfstart = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
+ Date date = null;
|
|
|
+ try {
|
|
|
+ date = sdfstart.parse(datestr);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ String daString = sdf.format(date);
|
|
|
+ return daString;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取当前时间
|
|
|
+ * @param dateStr
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String getNowDate() {
|
|
|
+ SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ Date date = new Date();
|
|
|
+ //4小时
|
|
|
+ Date lastDate = new Date(date.getTime()-7200000);
|
|
|
+ String timeString = null;
|
|
|
+ timeString = sdf.format(lastDate);
|
|
|
+ return timeString;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|