Преглед изворни кода

需进模型数据写入数据库

hujing пре 5 година
родитељ
комит
02416b2de3

+ 3 - 3
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/ThreeLevelWardAI.java

@@ -132,7 +132,7 @@ public class ThreeLevelWardAI extends ModelAI {
      * @param threeLevelWardDocs
      * @return
      */
-    private List<Map<String, String>> putDirectorDifficultRecord(InputInfo inputInfo, List<ThreeLevelWardDoc> threeLevelWardDocs) {
+    public List<Map<String, String>> putDirectorDifficultRecord(InputInfo inputInfo, List<ThreeLevelWardDoc> threeLevelWardDocs) {
         List<Map<String, String>> record = new ArrayList<>();
         List<DifficultCaseDiscussDoc> difficultCaseDiscussDocs = inputInfo.getDifficultCaseDiscussDocs(); //疑难病例讨论记录
         Map<Date, Map<String, String>> dateRecord = new TreeMap<>(new Comparator<Date>() {
@@ -195,7 +195,7 @@ public class ThreeLevelWardAI extends ModelAI {
      * @param threeLevelWardDocs
      * @return
      */
-    private List<Map<String, String>> putDirectorRescueRecord(InputInfo inputInfo, List<ThreeLevelWardDoc> threeLevelWardDocs) {
+    public List<Map<String, String>> putDirectorRescueRecord(InputInfo inputInfo, List<ThreeLevelWardDoc> threeLevelWardDocs) {
         List<Map<String, String>> record = new ArrayList<>();
         List<RescueDoc> rescueDocs = inputInfo.getRescueDocs(); //抢救记录
         Map<Date, Map<String, String>> dateRecord = new TreeMap<>(new Comparator<Date>() {
@@ -281,7 +281,7 @@ public class ThreeLevelWardAI extends ModelAI {
      * @param threeLevelWardDocs
      * @return
      */
-    private Map<String, String> getLastCourseRecord(List<ThreeLevelWardDoc> threeLevelWardDocs) {
+    public Map<String, String> getLastCourseRecord(List<ThreeLevelWardDoc> threeLevelWardDocs) {
         Map<Date, Map<String, String>> dateRecord = new TreeMap<>(new Comparator<Date>() {
             @Override
             public int compare(Date o1, Date o2) {

+ 271 - 0
kernel/src/main/java/com/lantone/qc/kernel/util/ModelDataUtil.java

@@ -0,0 +1,271 @@
+package com.lantone.qc.kernel.util;
+
+import com.lantone.qc.kernel.structure.ai.ThreeLevelWardAI;
+import com.lantone.qc.pub.Content;
+import com.lantone.qc.pub.jdbc.MysqlJdbc;
+import com.lantone.qc.pub.model.InputInfo;
+import com.lantone.qc.pub.model.doc.BeHospitalizedDoc;
+import com.lantone.qc.pub.model.doc.FirstCourseRecordDoc;
+import com.lantone.qc.pub.model.doc.LeaveHospitalDoc;
+import com.lantone.qc.pub.model.doc.ThreeLevelWardDoc;
+import com.lantone.qc.pub.model.doc.operation.OperationDiscussionDoc;
+import com.lantone.qc.pub.model.doc.operation.OperationDoc;
+import com.lantone.qc.pub.model.vo.QueryVo;
+import com.lantone.qc.pub.util.ListUtil;
+import com.lantone.qc.pub.util.PropertiesUtil;
+import com.lantone.qc.trans.TransDispatch;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description: 长兴医院进模型数据
+ * @Author: HUJING
+ * @Date: 2020/4/1 17:23
+ */
+public class ModelDataUtil {
+    private Logger logger = LoggerFactory.getLogger(ModelDataUtil.class);
+
+    public void executor(String caseNumber, QueryVo queryVo) {
+        InputInfo inputInfo = TransDispatch.trans(queryVo);
+        if (inputInfo == null) {
+            return;
+        }
+        Map<String, Map<String, String>> changxDocs = new LinkedHashMap<>();
+        beHospitalized(inputInfo, changxDocs, "入院记录");
+        firstCourseRecord(inputInfo, changxDocs, "首次病程录");
+        operationDiscussion(inputInfo, changxDocs, "术后首次病程及谈话记录文档");
+        threeLevelWard(inputInfo, changxDocs, "三级查房记录");
+        leaveHospital(inputInfo, changxDocs, "出院小结");
+        insertDB(caseNumber, changxDocs);
+    }
+
+    public void insertDB(String caseNumber, Map<String, Map<String, String>> changxDocs) {
+        PropertiesUtil propertiesUtil = new PropertiesUtil("kernel.properties");
+        MysqlJdbc mysqlJdbc = new MysqlJdbc(propertiesUtil.getProperty("mysql.test.user"),
+                propertiesUtil.getProperty("mysql.local.password"),
+                propertiesUtil.getProperty("mysql.local.url"));
+        Connection connect = null;
+        PreparedStatement pst = null;
+        String sql = "INSERT INTO qc_model_input_info(case_number,title,sub_title,text) VALUES(?,?,?,?)";
+        try {
+            connect = mysqlJdbc.connect();
+            connect.setAutoCommit(false);
+            pst = connect.prepareStatement(sql);
+            for (Map.Entry<String, Map<String, String>> changxDoc : changxDocs.entrySet()) {
+                int i = 0;
+                String model = changxDoc.getKey();
+                for (Map.Entry<String, String> doc : changxDoc.getValue().entrySet()) {
+                    pst.setString(1, caseNumber);
+                    pst.setString(2, model);
+                    pst.setString(3, doc.getKey());
+                    pst.setString(4, doc.getValue());
+                    pst.addBatch();
+                    i++;
+                    if ((i != 0 && i % 1000 == 0) || i == changxDoc.getValue().size() - 1) {
+                        pst.executeBatch();
+                        connect.commit();
+                        pst.clearBatch();
+                    }
+                }
+            }
+        } catch (Exception e) {
+            System.out.println(e.getMessage());
+        } finally {
+            try {
+                pst.close();
+                connect.close();
+            } catch (SQLException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    /**
+     * 入院记录
+     *
+     * @param inputInfo
+     * @param changxDocs
+     * @param model
+     */
+    public void beHospitalized(InputInfo inputInfo, Map<String, Map<String, String>> changxDocs, String model) {
+        if (inputInfo == null) {
+            return;
+        }
+        BeHospitalizedDoc beHospitalizedDoc = inputInfo.getBeHospitalizedDoc();
+        if (beHospitalizedDoc != null) {
+            Map<String, String> changxDoc = new LinkedHashMap<>();
+            String chiefText = beHospitalizedDoc.getChiefLabel().getText();
+            String presentText = beHospitalizedDoc.getPresentLabel().getText();
+            String pastText = beHospitalizedDoc.getPastLabel().getText();
+            String personalText = beHospitalizedDoc.getPersonalLabel().getText();
+            String familyText = beHospitalizedDoc.getFamilyLabel().getText();
+            String pacsText = beHospitalizedDoc.getPacsLabel().getText();
+            String initialDiagText = beHospitalizedDoc.getInitialDiagLabel().getText();   //初步诊断
+            String revisedDiagText = beHospitalizedDoc.getRevisedDiagLabel().getText();   //修正诊断
+            String suppleDiagText = beHospitalizedDoc.getSuppleDiagLabel().getText();    //补充诊断
+            String menstrualText = beHospitalizedDoc.getMenstrualLabel().getText();    //月经史
+            String maritalText = beHospitalizedDoc.getMaritalLabel().getText();    //婚育史
+            String vitalText = beHospitalizedDoc.getVitalLabel().getText();        //一般体格检查
+            String vitalSpecialText = beHospitalizedDoc.getVitalLabelSpecial().getText();  //专科体格检查
+            putDoc(changxDoc, Content.chief, chiefText);
+            putDoc(changxDoc, Content.present, presentText);
+            putDoc(changxDoc, Content.past, pastText);
+            putDoc(changxDoc, Content.personal, personalText);
+            putDoc(changxDoc, Content.family, familyText);
+            putDoc(changxDoc, Content.pacs, pacsText);
+            putDoc(changxDoc, Content.initial_diag, initialDiagText);
+            putDoc(changxDoc, Content.revised_diag, revisedDiagText);
+            putDoc(changxDoc, Content.supple_diag, suppleDiagText);
+            putDoc(changxDoc, Content.menses, menstrualText);
+            putDoc(changxDoc, Content.marriage, maritalText);
+            putDoc(changxDoc, Content.phys_exam, vitalText);
+            putDoc(changxDoc, Content.special_exam, vitalSpecialText);
+            changxDocs.put(model, changxDoc);
+        }
+    }
+
+    /**
+     * 首次病程录
+     *
+     * @param inputInfo
+     * @param changxDocs
+     * @param model
+     */
+    public void firstCourseRecord(InputInfo inputInfo, Map<String, Map<String, String>> changxDocs, String model) {
+        if (inputInfo == null) {
+            return;
+        }
+        FirstCourseRecordDoc firstCourseRecordDoc = inputInfo.getFirstCourseRecordDoc();
+        if (firstCourseRecordDoc != null) {
+            Map<String, String> changxDoc = new LinkedHashMap<>();
+            //病历特点
+            putDoc(changxDoc, Content.case_feature, firstCourseRecordDoc.getCaseCharacteristicLabel().getText());
+            //初步诊断
+            putDoc(changxDoc, Content.initial_diag, firstCourseRecordDoc.getInitialDiagLabel().getText());
+            //诊断依据
+            putDoc(changxDoc, Content.diag_basis, firstCourseRecordDoc.getDiagnosisLabel().getText());
+            //鉴别诊断
+            putDoc(changxDoc, Content.differential_diag_basis, firstCourseRecordDoc.getDifferentialDiagLabel().getText());
+            //诊疗计划
+            putDoc(changxDoc, Content.treat_plan, firstCourseRecordDoc.getTreatPlanLabel().getText());
+            changxDocs.put(model, changxDoc);
+        }
+    }
+
+    /**
+     * 术后首次病程及谈话记录文档
+     *
+     * @param inputInfo
+     * @param changxDocs
+     * @param model
+     */
+    public void operationDiscussion(InputInfo inputInfo, Map<String, Map<String, String>> changxDocs, String model) {
+        if (inputInfo == null) {
+            return;
+        }
+        List<OperationDoc> operationDocs = inputInfo.getOperationDocs();
+        if (ListUtil.isEmpty(operationDocs)) {
+            return;
+        }
+        Map<String, String> changxDoc = new LinkedHashMap<>();
+        for (int i = 0; i < operationDocs.size(); i++) {
+            if (operationDocs.get(i).getOperationDiscussionDoc() == null) {
+                continue;
+            }
+            OperationDiscussionDoc operationDiscussionDoc = operationDocs.get(i).getOperationDiscussionDoc();
+            putDoc(changxDoc, Content.operation_Discussion + i, operationDiscussionDoc.getText());
+        }
+        changxDocs.put(model, changxDoc);
+    }
+
+    /**
+     * 查房记录
+     *
+     * @param inputInfo
+     * @param changxDocs
+     * @param model
+     */
+    public void threeLevelWard(InputInfo inputInfo, Map<String, Map<String, String>> changxDocs, String model) {
+        if (inputInfo == null) {
+            return;
+        }
+        List<ThreeLevelWardDoc> threeLevelWardDocs = inputInfo.getThreeLevelWardDocs();
+        if (threeLevelWardDocs.size() == 0) {
+            return;
+        }
+        ThreeLevelWardAI threeLevelWardAI = new ThreeLevelWardAI();
+        Map<String, String> changxDoc = new LinkedHashMap<>();
+        //主治/主任首次查房记录
+        Map<String, Map<String, String>> firstWardRecord = CatalogueUtil.extractWardRecord(threeLevelWardDocs);
+        //主治医师首次查房记录
+        if (firstWardRecord.get(Content.indications) != null) {
+            putDoc(changxDoc, Content.indications + "首次查房记录", firstWardRecord.get(Content.indications).get("病情记录"));
+        }
+        //主任医师首次查房记录
+        if (firstWardRecord.get(Content.director) != null) {
+            putDoc(changxDoc, Content.director + "首次查房记录", firstWardRecord.get(Content.director).get("病情记录"));
+        }
+        Map<String, String> lastCourseRecord = threeLevelWardAI.getLastCourseRecord(threeLevelWardDocs);
+        //主任医师最后一次查房记录
+        putDoc(changxDoc, Content.director + "末次查房记录", lastCourseRecord.get("病情记录"));
+
+        List<Map<String, String>> directorDifficultRecord = new ArrayList<>();
+        //疑难患者副高及以上查房记录
+        if (inputInfo.getDifficultCaseDiscussDocs().size() > 0) {
+            directorDifficultRecord = threeLevelWardAI.putDirectorDifficultRecord(inputInfo, threeLevelWardDocs);
+            for (int i = 0; i < directorDifficultRecord.size(); i++) {
+                putDoc(changxDoc, Content.difficultPatients + i, directorDifficultRecord.get(i).get("病情记录"));
+            }
+        }
+        List<Map<String, String>> directorRescueRecord = new ArrayList<>();
+        //抢救患者副高及以上查房记录
+        if (inputInfo.getRescueDocs().size() > 0) {
+            directorRescueRecord = threeLevelWardAI.putDirectorRescueRecord(inputInfo, threeLevelWardDocs);
+            for (int i = 0; i < directorRescueRecord.size(); i++) {
+                putDoc(changxDoc, Content.rescuingPatients + i, directorRescueRecord.get(i).get("病情记录"));
+            }
+        }
+        changxDocs.put(model, changxDoc);
+    }
+
+    /**
+     * 出院小结
+     *
+     * @param inputInfo
+     * @param changxDocs
+     * @param model
+     */
+    public void leaveHospital(InputInfo inputInfo, Map<String, Map<String, String>> changxDocs, String model) {
+        if (inputInfo == null) {
+            return;
+        }
+        LeaveHospitalDoc leaveHospitalDoc = inputInfo.getLeaveHospitalDoc();
+        if (leaveHospitalDoc != null) {
+            Map<String, String> changxDoc = new LinkedHashMap<>();
+            putDoc(changxDoc, Content.discharge, leaveHospitalDoc.getText());
+            changxDocs.put(model, changxDoc);
+        }
+    }
+
+    private void putDoc(Map<String, String> changxDoc, String title, String content) {
+        if (CatalogueUtil.isEmpty(content)) {
+            return;
+        }
+        if (title.contains("、")) {
+            title = title.split("、")[1];
+        }
+        if (changxDoc.containsKey(title)) {
+            logger.info(title + "已存在");
+            return;
+        }
+        changxDoc.put(title, content);
+    }
+}

+ 11 - 7
kernel/src/main/java/com/lantone/qc/kernel/web/controller/QCTestController.java

@@ -3,10 +3,10 @@ package com.lantone.qc.kernel.web.controller;
 import com.google.common.collect.Lists;
 import com.lantone.qc.kernel.analysis.QCAnalysis;
 import com.lantone.qc.kernel.util.CacheFileManager;
+import com.lantone.qc.kernel.util.ModelDataUtil;
 import com.lantone.qc.kernel.util.KernelConstants;
 import com.lantone.qc.pub.jdbc.MysqlJdbc;
 import com.lantone.qc.pub.model.OutputInfo;
-import com.lantone.qc.pub.model.entity.Lis;
 import com.lantone.qc.pub.model.vo.MedrecVo;
 import com.lantone.qc.pub.model.vo.QueryVo;
 import com.lantone.qc.pub.res.Response;
@@ -41,6 +41,7 @@ public class QCTestController {
     private QCAnalysis qCAnalysis;
 
     private Map<String, List<String>> inputLabelMap = new HashMap<>();
+
     {
         inputLabelMap.put("入院记录", Lists.newArrayList("姓名", "性别", "年龄", "民族", "职业", "出生地", "婚姻", "联系地址", "病史陈述者", "出生日期", "户口地址", "电话", "入院日期", "记录日期", "主诉", "现病史", "既往史", "个人史", "婚育史", "月经史", "家族史", "体格检查(一)", "体格检查(二)", "辅助检查", "初步诊断", "修正诊断", "医师签名", "补充诊断"));
     }
@@ -57,6 +58,7 @@ public class QCTestController {
         }
         //key = 患者就诊号
         Map<String, QueryVo> queryVoMap = createQueryVo(cid, hospitalId, caseNumber);
+        ModelDataUtil modelDataUtil = new ModelDataUtil();
         //key = 患者就诊号
         Map<String, Map<String, String>> inputCaseMappingMap = createInputCaseMapping(hospitalId, caseNumber);
 
@@ -64,6 +66,7 @@ public class QCTestController {
         List<Map<String, Object>> wheres = new ArrayList<>();
         for (Map.Entry<String, QueryVo> entry : queryVoMap.entrySet()) {
             System.out.println("患者就诊号:" + entry.getKey() + "..........");
+            modelDataUtil.executor(entry.getKey(), entry.getValue());//AI所需模块数据存入DB
             OutputInfo outputInfo = qCAnalysis.anlysis(entry.getValue());
 
             Map<String, String> passMap = inputCaseMappingMap.get(entry.getKey());
@@ -135,7 +138,7 @@ public class QCTestController {
                 r1 = rs.getString(1);
                 r2 = rs.getString(2);
                 Map<String, String> m = new HashMap<>();
-                m.put("precond","");
+                m.put("precond", "");
                 m.put("name", r2);
                 m.put("code", r1);
                 inputCatalogueMap.put(r1, m);
@@ -238,7 +241,7 @@ public class QCTestController {
             st = conn.createStatement();
             String sql = "SELECT qim.id, q.case_number, qc.code FROM qc_inputcases_mapping_all qim, qc_cases_number q, qc_cases_entry qc " +
                     "where qim.case_number_id = q.id and qim.cases_entry_id = qc.id and q.is_deleted = 'N' " +
-                    "and q.hospital_id = " + hospitalId ;
+                    "and q.hospital_id = " + hospitalId;
             if (StringUtils.isNotEmpty(caseNumber)) {
                 sql = sql + " and q.case_number = '" + caseNumber + "' ";
             }
@@ -322,8 +325,10 @@ public class QCTestController {
             List<String> caseList = new ArrayList<>();
             List<Map<String, String>> updateList = new ArrayList<>();
             List<String> textIdList = new ArrayList<>();
-            String textId = ""; int index = 0;
-            String text = ""; String caseName = "";
+            String textId = "";
+            int index = 0;
+            String text = "";
+            String caseName = "";
             while (rs.next()) {
                 r1 = rs.getString(1);
                 r2 = rs.getString(2);
@@ -365,7 +370,7 @@ public class QCTestController {
                 Map<String, Object> content = new HashMap<>();
                 content.put("content", textList.get(i));
                 medrecVo.setContent(content);
-                if (caseList.get(i).equals("入院记录")){
+                if (caseList.get(i).equals("入院记录")) {
                     medrecVo.setLabel(Lists.newArrayList("姓名", "性别", "年龄", "民族", "职业", "出生地", "婚姻", "联系地址", "病史陈述者", "出生日期", "户口地址", "电话", "入院日期", "记录日期", "主诉", "现病史", "既往史", "个人史", "婚育史", "月经史", "家族史", "体格检查(一)", "体格检查(二)", "辅助检查", "初步诊断", "修正诊断", "医师签名", "补充诊断"));
                 }
 
@@ -400,7 +405,6 @@ public class QCTestController {
             mysqlJdbc.update("qc_inputcases_mapping_all", updates, wheres);
 
 
-
             CacheFileManager cacheFileManager = new CacheFileManager();
             cacheFileManager.insertFeature(KernelConstants.clinicModificationList, "kl_modification", "name");
             cacheFileManager.insertFeature(KernelConstants.clinicNameList, "kl_clinic", "name");