Sfoglia il codice sorgente

1、修改华卓导入接口,只导入数据完整的信息

louhr 5 anni fa
parent
commit
efb9a3e940

+ 67 - 4
kernel/src/test/java/com/lantone/qc/kernel/TaizDataImportApiTest.java

@@ -32,6 +32,8 @@ public class TaizDataImportApiTest {
 
     private Map<String,String> caseMap = new HashMap<>();
 
+    private List<String> deletePatient = new ArrayList<>();
+
     public static void main(String[] args) {
         TaizDataImportApiTest test = new TaizDataImportApiTest();
         //模块映射
@@ -66,9 +68,16 @@ public class TaizDataImportApiTest {
         List<Map<String, Object>> list = new ArrayList<>();
 
         for (Map.Entry<String, String> entry : patientMap.entrySet()) {
+            if ("ZY010000656840".equals(entry.getKey())) {
+                System.out.println();
+            }
             List<PatientText> patientTexts = new ArrayList<>();
             //病人的病案首页内容
             JSONArray firstPageJsonArray = DataTest.loadHomePage(entry.getKey());
+            if (firstPageJsonArray.isEmpty()) { //没病案首页直接不导入
+                deletePatient.add(entry.getKey()); //没病案首页的患者也要删除
+                continue;
+            }
             Map<String, Object> firstPageTextMap = new HashMap<>();
             firstPageTextMap.put("case_number", entry.getKey());
             firstPageTextMap.put("case_number_id", patientMap.get(entry.getKey()));
@@ -82,7 +91,6 @@ public class TaizDataImportApiTest {
                 pagetext = pagetext + "【" + e.getKey() + "】:" + e.getValue().toString() + "\n";
             }
             firstPageTextMap.put("text", pagetext);
-            list.add(firstPageTextMap);
 
             if ("changx".equals(cid)) {
                 patientTexts = loadChangxOraclePatientTexts(entry.getKey());
@@ -90,13 +98,18 @@ public class TaizDataImportApiTest {
             if ("taizhou".equals(cid)) {
                 patientTexts = loadTaizhouOraclePatientTexts(entry.getKey());
             }
+            if (!wholePatientRecord(patientTexts, modelMap) || patientTexts.size() == 0) {
+                continue;
+            }
+            //数据完整后才放入病案首页
+            list.add(firstPageTextMap);
             for (PatientText patientText : patientTexts) {
-System.out.println(patientText.getBrzyid() + "  " + patientText.getBljlmc());
+//System.out.println(patientText.getBrzyid() + "  " + patientText.getBljlmc());
                 Map<String, Object> patientTextMap = new HashMap<>();
                 patientTextMap.put("case_number", patientText.getBrzyid());
                 patientTextMap.put("case_number_id", patientMap.get(patientText.getBrzyid()));
                 patientTextMap.put("hospital_id", hospitalId);
-System.out.println("******" + patientText.getBljlmc() + "**" + caseMap.get(patientText.getBljlmc()));
+//System.out.println("******" + patientText.getBljlmc() + "**" + caseMap.get(patientText.getBljlmc()));
                 patientTextMap.put("mode_id", modelMap.get(caseMap.get(patientText.getBljlmc())));
 
                 if (patientTextMap.get("mode_id") == null) {
@@ -107,7 +120,7 @@ System.out.println("******" + patientText.getBljlmc() + "**" + caseMap.get(patie
                 String text = "";
                 Map<String, String> textMap = new HashMap<>();
                 if ("changx".equals(cid)) {
-
+                    textMap = CxXmlUtil.beHospitalizedXmlToMap(patientText.getBljlnr(), caseMap.get(patientText.getBljlmc()));
                 }
                 if ("taizhou".equals(cid)) {
                     textMap = TzXmlUtil.getXmlToMapForTZ(patientText.getBljlnr());
@@ -120,6 +133,35 @@ System.out.println("******" + patientText.getBljlmc() + "**" + caseMap.get(patie
             }
         }
         initMysqlJdbc().insert(list, "qc_model_mapping", new String[]{"case_number", "case_number_id", "origin_text", "mode_id", "text"});
+
+        deletePatientInfos(deletePatient);
+    }
+
+    /**
+     * 验证数据完整性
+     * @param patientTexts
+     * @param modelMap
+     * @return
+     */
+    private boolean wholePatientRecord(List<PatientText> patientTexts, Map<String, String> modelMap) {
+        Map<String, String> m = new HashMap<>();
+        for (PatientText patientText : patientTexts) {
+            String modelId = modelMap.get(caseMap.get(patientText.getBljlmc()));
+            if (StringUtils.isEmpty(modelId)) {
+                continue;
+            }
+            if (modelId.equals("1") && patientText.getBljlnr().indexOf("<") != 0) {
+                deletePatient.add(patientTexts.get(0).getBrzyid());
+                return false;
+            }
+            m.put(modelId, modelId);
+        }
+        if (m.get("1") != null && m.get("2") != null && m.get("4") != null && m.get("5") != null) {
+            return true;
+        } else {
+            deletePatient.add(patientTexts.get(0).getBrzyid());
+        }
+        return false;
     }
 
     private List<Patient> loadOraclePatients(String tableName) {
@@ -321,6 +363,27 @@ System.out.println("******" + patientText.getBljlmc() + "**" + caseMap.get(patie
         }
     }
 
+    private void deletePatientInfos(List<String> caseNumbers) {
+        MysqlJdbc mysqlJdbc = initMysqlJdbc();
+        Connection conn = mysqlJdbc.connect();
+        Statement st = null;
+        ResultSet rs = null;
+        String r1, r2;
+        try {
+            st = conn.createStatement();
+            for (String caseNumber : caseNumbers) {
+                String sql = "delete from qc_cases_number where case_number = '" + caseNumber + "'";
+                st.execute(sql);
+            }
+        } catch (SQLException sqle) {
+            sqle.printStackTrace();
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            mysqlJdbc.close(rs, st, conn);
+        }
+    }
+
     private MysqlJdbc initMysqlJdbc() {
         PropertiesUtil propertiesUtil = new PropertiesUtil("kernel.properties");
         MysqlJdbc mysqlJdbc = new MysqlJdbc(propertiesUtil.getProperty("mysql.test.user"),

+ 59 - 46
trans/src/main/java/com/lantone/qc/trans/changx/util/CxXmlUtil.java

@@ -7,6 +7,7 @@ import org.dom4j.Document;
 import org.dom4j.DocumentHelper;
 import org.dom4j.Element;
 
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -28,15 +29,24 @@ public class CxXmlUtil {
     }
 
     public static Map<String, String> beHospitalizedXmlToMap(String xml) {
+        return beHospitalizedXmlToMap(xml, "");
+    }
+
+    public static Map<String, String> beHospitalizedXmlToMap(String xml, String modelName) {
         Map<String, String> retMap = Maps.newLinkedHashMap();
         try {
             String helpTip, contentText;
             Element contentTextElement;
             Document doc = DocumentHelper.parseText(xml);
-            Element rootElement = doc.getRootElement();
+            Element rootElement = doc.getRootElement().element("DocObjContent");
+
+            if (modelName.equals("首次病程录") || modelName.equals("查房记录")) {
+                retMap.put("内容", rootElement.element("Region").element("Content_Text").getText());
+                return retMap;
+            }
 
             List<Element> sectionElements = rootElement.elements("Section");
-            Map<String, String> sectionMap = Maps.newHashMap();
+            Map<String, String> sectionMap = Maps.newLinkedHashMap();
             for (Element sectionElement : sectionElements) {
                 helpTip = sectionElement.attributeValue("HelpTip");
                 if (StringUtil.isBlank(helpTip)) {
@@ -52,7 +62,7 @@ public class CxXmlUtil {
             }
 
             List<Element> newCtrlElements = rootElement.elements("NewCtrl");
-            Map<String, String> newCtrlMap = Maps.newHashMap();
+            Map<String, String> newCtrlMap = Maps.newLinkedHashMap();
             for (Element newCtrlElement : newCtrlElements) {
                 helpTip = newCtrlElement.attributeValue("HelpTip");
                 if (StringUtil.isBlank(helpTip)) {
@@ -67,50 +77,53 @@ public class CxXmlUtil {
                 newCtrlMap.put(helpTip, contentText);
             }
 
-            retMap.put("姓名", newCtrlMap.get("姓名"));
-            retMap.put("性别", newCtrlMap.get("性别"));
-            retMap.put("年龄", newCtrlMap.get("年龄"));
-            retMap.put("民族", newCtrlMap.get("民族"));
-            retMap.put("职业", newCtrlMap.get("职业"));
-            retMap.put("出生地", newCtrlMap.get("出生地"));
-            retMap.put("婚姻", newCtrlMap.get("婚姻状况"));
-            retMap.put("联系地址", "");
-            retMap.put("病史陈述者", newCtrlMap.get("供史者"));
-            retMap.put("出生日期", newCtrlMap.get("出生日期"));
-            retMap.put("户口地址", newCtrlMap.get("户口地址"));
-            retMap.put("电话", newCtrlMap.get("联系电话"));
-            retMap.put("入院日期", newCtrlMap.get("入院日期"));
-            retMap.put("记录日期", newCtrlMap.get("记录日期"));
-            retMap.put("辅助检查", newCtrlMap.get("辅助检查"));
-            retMap.put("初步诊断", newCtrlMap.get("初步诊断"));
-            retMap.put("修正诊断", newCtrlMap.get("修正诊断"));
-            retMap.put("补充诊断", newCtrlMap.get("补充诊断"));
-            retMap.put("主诉", newCtrlMap.get("主诉"));
-            retMap.put("现病史", newCtrlMap.get("现病史"));
-
-            retMap.put("既往史", sectionMap.get("既往史"));
-            retMap.put("个人史", sectionMap.get("个人史"));
-            retMap.put("婚育史", sectionMap.get("婚育史:"));
-            retMap.put("月经史", sectionMap.get("月经史"));
-            retMap.put("家族史", sectionMap.get("家族史"));
-            retMap.put("专科体格检查", sectionMap.get("体格检查"));
+            retMap.putAll(sectionMap);
+            retMap.putAll(newCtrlMap);
 
-            String tgjc = sectionMap.get("一般情况") + "。"
-                    + sectionMap.get("皮肤情况") + "。"
-                    + newCtrlMap.get("淋巴") + "。"
-                    + sectionMap.get("头部检查") + "。"
-                    + sectionMap.get("颈部") + "。"
-                    + sectionMap.get("胸部检查") + "。"
-                    + sectionMap.get("肺部检查") + "。"
-                    + sectionMap.get("心脏检查") + "。"
-                    + newCtrlMap.get("血管") + "。"
-                    + sectionMap.get("腹部检查") + "。"
-                    + newCtrlMap.get("外生殖器") + "。"
-                    + newCtrlMap.get("直肠肛门") + "。"
-                    + sectionMap.get("四肢脊柱检查") + "。"
-                    + sectionMap.get("神经系统检查") + "。"
-                    + newCtrlMap.get("其他说明") + "。";
-            retMap.put("体格检查", tgjc);
+//            retMap.put("姓名", newCtrlMap.get("姓名"));
+//            retMap.put("性别", newCtrlMap.get("性别"));
+//            retMap.put("年龄", newCtrlMap.get("年龄"));
+//            retMap.put("民族", newCtrlMap.get("民族"));
+//            retMap.put("职业", newCtrlMap.get("职业"));
+//            retMap.put("出生地", newCtrlMap.get("出生地"));
+//            retMap.put("婚姻", newCtrlMap.get("婚姻状况"));
+//            retMap.put("联系地址", "");
+//            retMap.put("病史陈述者", newCtrlMap.get("供史者"));
+//            retMap.put("出生日期", newCtrlMap.get("出生日期"));
+//            retMap.put("户口地址", newCtrlMap.get("户口地址"));
+//            retMap.put("电话", newCtrlMap.get("联系电话"));
+//            retMap.put("入院日期", newCtrlMap.get("入院日期"));
+//            retMap.put("记录日期", newCtrlMap.get("记录日期"));
+//            retMap.put("辅助检查", newCtrlMap.get("辅助检查"));
+//            retMap.put("初步诊断", newCtrlMap.get("初步诊断"));
+//            retMap.put("修正诊断", newCtrlMap.get("修正诊断"));
+//            retMap.put("补充诊断", newCtrlMap.get("补充诊断"));
+//            retMap.put("主诉", newCtrlMap.get("主诉"));
+//            retMap.put("现病史", newCtrlMap.get("现病史"));
+//
+//            retMap.put("既往史", sectionMap.get("既往史"));
+//            retMap.put("个人史", sectionMap.get("个人史"));
+//            retMap.put("婚育史", sectionMap.get("婚育史:"));
+//            retMap.put("月经史", sectionMap.get("月经史"));
+//            retMap.put("家族史", sectionMap.get("家族史"));
+//            retMap.put("专科体格检查", sectionMap.get("体格检查"));
+//
+//            String tgjc = sectionMap.get("一般情况") + "。"
+//                    + sectionMap.get("皮肤情况") + "。"
+//                    + newCtrlMap.get("淋巴") + "。"
+//                    + sectionMap.get("头部检查") + "。"
+//                    + sectionMap.get("颈部") + "。"
+//                    + sectionMap.get("胸部检查") + "。"
+//                    + sectionMap.get("肺部检查") + "。"
+//                    + sectionMap.get("心脏检查") + "。"
+//                    + newCtrlMap.get("血管") + "。"
+//                    + sectionMap.get("腹部检查") + "。"
+//                    + newCtrlMap.get("外生殖器") + "。"
+//                    + newCtrlMap.get("直肠肛门") + "。"
+//                    + sectionMap.get("四肢脊柱检查") + "。"
+//                    + sectionMap.get("神经系统检查") + "。"
+//                    + newCtrlMap.get("其他说明") + "。";
+//            retMap.put("体格检查", tgjc);
         } catch (Exception e) {
         }
         return retMap;