瀏覽代碼

1、数据导入程序修改

louhr 5 年之前
父節點
當前提交
7c7ff34ab0

+ 13 - 14
kernel/src/test/java/com/lantone/qc/kernel/DataTest.java

@@ -6,10 +6,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.lantone.qc.pub.util.PropertiesUtil;
 
 import java.sql.*;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Properties;
+import java.util.*;
 
 /**
  * @ClassName : DataTest
@@ -22,11 +19,11 @@ public class DataTest {
 
     }
 
-    public static Map<String, String> loadHomePage(String patientId) {
+    public static List<Map<String, String>> loadHomePage(String tableName, String patientId) {
         Connection conn = null;
         Statement stmt = null;
         ResultSet rs = null;
-        Map<String, String> js = null;
+        List<Map<String, String>> resultList = null;
         try {
             PropertiesUtil propertiesUtil = new PropertiesUtil("kernel.properties");
             Class.forName(propertiesUtil.getProperty("oracle.test.driver"));
@@ -46,7 +43,7 @@ public class DataTest {
             stmt = conn.createStatement();
 
             DatabaseMetaData dmd = conn.getMetaData();
-            ResultSet dmdRs = dmd.getColumns(null, null, "BR_RECHOME", null);
+            ResultSet dmdRs = dmd.getColumns(null, null, tableName, null);
 
             Map<String, String> colMap = new LinkedHashMap<>();
             while(dmdRs.next()){
@@ -54,8 +51,8 @@ public class DataTest {
             }
             dmdRs.close();
 
-            rs = stmt.executeQuery("select * from br_rechome where brzyid = '" + patientId + "'");
-            js = resultSetToJson(rs, colMap);
+            rs = stmt.executeQuery("select * from " + tableName + " where brzyid = '" + patientId + "'");
+            resultList = resultSetToJson(rs, colMap);
         } catch (SQLException ex) {
             ex.printStackTrace();
         } catch (Exception e) {
@@ -78,24 +75,26 @@ public class DataTest {
                 e.printStackTrace();
             }
         }
-        return js;
+        return resultList;
     }
 
-    public static Map<String, String> resultSetToJson(ResultSet rs, Map<String, String> map) throws SQLException, JSONException {
+    public static List<Map<String, String>> resultSetToJson(ResultSet rs, Map<String, String> map) throws SQLException, JSONException {
         // 获取列数
         ResultSetMetaData metaData = (ResultSetMetaData) rs.getMetaData();
         int columnCount = metaData.getColumnCount();
-        // 遍历ResultSet中的每条数据
-        Map<String, String> result = new LinkedHashMap<>();
+        List<Map<String, String>> resultList = new ArrayList<>();
         while (rs.next()) {
+            // 遍历ResultSet中的每条数据
+            Map<String, String> result = new LinkedHashMap<>();
             // 遍历每一列
             for (int i = 1; i <= columnCount; i++) {
                 String columnName = metaData.getColumnLabel(i);
                 String value = rs.getString(columnName) == null ? "" : rs.getString(columnName);
                 result.put(map.get(columnName), value);
             }
+            resultList.add(result);
         }
-        return result;
+        return resultList;
     }
 
 }

+ 20 - 0
kernel/src/test/java/com/lantone/qc/kernel/Doctor.java

@@ -0,0 +1,20 @@
+package com.lantone.qc.kernel;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @ClassName : Doctor
+ * @Description :
+ * @Author : 楼辉荣
+ * @Date: 2020-04-04 13:17
+ */
+@Getter
+@Setter
+public class Doctor {
+    private String doctorId;
+    private String doctorName;
+    private String deptId;
+    private String deptName;
+    private String professor;
+}

+ 73 - 25
kernel/src/test/java/com/lantone/qc/kernel/TaizDataImportApiTest.java

@@ -1,19 +1,19 @@
 package com.lantone.qc.kernel;
 
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.google.gson.JsonObject;
 import com.lantone.qc.pub.jdbc.MysqlJdbc;
 import com.lantone.qc.pub.util.FastJsonUtils;
 import com.lantone.qc.pub.util.PropertiesUtil;
 import com.lantone.qc.trans.changx.util.CxXmlUtil;
+import com.lantone.qc.trans.changx.util.CxXmlUtilTemp;
 import com.lantone.qc.trans.taizhou.util.TzXmlUtil;
-import com.lantone.qc.trans.util.http.HttpApi;
 import org.apache.commons.lang3.StringUtils;
 
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
-import java.sql.*;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -41,10 +41,12 @@ public class TaizDataImportApiTest {
         //长兴患者信息
         if (cid.equals("changx")) {
             test.insertPatient(test.loadOraclePatients("BR_INPATIENTINFO_CX"));
+            test.insertDoctor(test.loadOracleDoctorInfos("GI_USERINFO", "HI_DEPTINFO"));
         }
         //台州患者信息
         if (cid.equals("taizhou")) {
             test.insertPatient(test.loadOraclePatients("BR_INPATIENTINFO_TZ20200330"));
+            test.insertDoctor(test.loadOracleDoctorInfos("GI_USERINFO", "HI_DEPTINFO"));
         }
         //病人流水号获取    病历号--->id
         Map<String, String> patientMap = test.loadPatients(hospitalId);
@@ -64,13 +66,27 @@ public class TaizDataImportApiTest {
         initMysqlJdbc().insert(list, "qc_cases_number_copy", new String[]{"hospital_id", "case_number"});
     }
 
+    private void insertDoctor(List<Doctor> doctors) {
+        List<Map<String, Object>> list = new ArrayList<>();
+        for (Doctor doctor : doctors) {
+            Map<String, Object> doctorMap = new HashMap<>();
+            doctorMap.put("doctor_id", doctor.getDoctorId());
+            doctorMap.put("doctor_name", doctor.getDoctorName());
+            doctorMap.put("dept_id", doctor.getDeptId());
+            doctorMap.put("dept_name", doctor.getDeptName());
+            doctorMap.put("professor", doctor.getProfessor());
+            list.add(doctorMap);
+        }
+        initMysqlJdbc().insert(list, "qc_doctor_info", new String[]{"doctor_id", "doctor_name", "dept_id", "dept_name", "professor"});
+    }
+
     private void insertPatientText(Map<String, String> patientMap, Map<String, String> modelMap) {
         List<Map<String, Object>> list = new ArrayList<>();
 
         for (Map.Entry<String, String> entry : patientMap.entrySet()) {
             List<PatientText> patientTexts = new ArrayList<>();
             //病人的病案首页内容
-            Map<String, String> homePageMap = DataTest.loadHomePage(entry.getKey());
+            List<Map<String, String>> homePageMap = DataTest.loadHomePage("BR_RECHOME_CX", entry.getKey());
             if (homePageMap == null || homePageMap.isEmpty()) { //没病案首页直接不导入
                 deletePatient.add(entry.getKey()); //没病案首页的患者也要删除
                 continue;
@@ -81,13 +97,12 @@ public class TaizDataImportApiTest {
             firstPageTextMap.put("hospital_id", hospitalId);
             firstPageTextMap.put("mode_id", 6);
             firstPageTextMap.put("origin_mode", "病案首页");
-            firstPageTextMap.put("origin_text", FastJsonUtils.getBeanToJson(homePageMap));
+            firstPageTextMap.put("origin_text", FastJsonUtils.getBeanToJson(homePageMap.get(0)));
             String pagetext = "";
-            for (Map.Entry<String, String> e : homePageMap.entrySet()) {
+            for (Map.Entry<String, String> e : homePageMap.get(0).entrySet()) {
                 pagetext = pagetext + "【" + e.getKey() + "】:" + e.getValue().toString() + "\n";
             }
             firstPageTextMap.put("text", pagetext);
-
             if ("changx".equals(cid)) {
                 patientTexts = loadChangxOraclePatientTexts(entry.getKey());
             }
@@ -99,13 +114,30 @@ public class TaizDataImportApiTest {
             }
             //数据完整后才放入病案首页
             list.add(firstPageTextMap);
+
+            //病人医嘱信息
+            List<Map<String, String>> docAdviceMap = DataTest.loadHomePage("BR_DOCTADVICE_CX", entry.getKey());
+            for (Map<String, String> docMap : docAdviceMap) {
+                Map<String, Object> docAdviceTextMap = new HashMap<>();
+                docAdviceTextMap.put("case_number", entry.getKey());
+                docAdviceTextMap.put("case_number_id", patientMap.get(entry.getKey()));
+                docAdviceTextMap.put("hospital_id", hospitalId);
+                docAdviceTextMap.put("mode_id", 8);
+                docAdviceTextMap.put("origin_mode", "医嘱信息");
+                docAdviceTextMap.put("origin_text", FastJsonUtils.getBeanToJson(docMap));
+                pagetext = "";
+                for (Map.Entry<String, String> e : docMap.entrySet()) {
+                    pagetext = pagetext + "【" + e.getKey() + "】:" + e.getValue().toString() + "\n";
+                }
+                docAdviceTextMap.put("text", pagetext);
+                list.add(docAdviceTextMap);
+            }
+            //病人其他文书信息
             for (PatientText patientText : patientTexts) {
-//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()));
                 patientTextMap.put("mode_id", modelMap.get(caseMap.get(patientText.getBljlmc())));
                 patientTextMap.put("origin_mode", patientText.getBljlmc());
                 if (patientTextMap.get("mode_id") == null) {
@@ -116,7 +148,7 @@ public class TaizDataImportApiTest {
                 String text = "";
                 Map<String, String> textMap = new HashMap<>();
                 if ("changx".equals(cid)) {
-                    textMap = CxXmlUtil.firstLevelNodeValue(patientText.getBljlnr(), caseMap.get(patientText.getBljlmc()));
+                    textMap = CxXmlUtilTemp.beHospitalizedXmlToMap(patientText.getBljlnr(), caseMap.get(patientText.getBljlmc()));
                 }
                 if ("taizhou".equals(cid)) {
                     textMap = TzXmlUtil.getXmlToMapForTZ(patientText.getBljlnr());
@@ -187,6 +219,35 @@ public class TaizDataImportApiTest {
         return patients;
     }
 
+    private List<Doctor> loadOracleDoctorInfos(String tableUser, String tableDept) {
+        MysqlJdbc mysqlJdbc = initOracleJdbc();
+        Connection conn = mysqlJdbc.connect();
+        Statement st = null;
+        ResultSet rs = null;
+        List<Doctor> doctors = new ArrayList<>();
+        try {
+            st = conn.createStatement();
+            String sql = "select u.yhrydm, u.yhrymc, u.yhryzc, dept.zzksid, dept.zzksmc from " + tableDept + " dept, " + tableUser + " u where u.zzksid = dept.zzksid";
+            rs = st.executeQuery(sql);
+            while (rs.next()) {
+                Doctor doctor = new Doctor();
+                doctor.setDoctorId(rs.getString(1));
+                doctor.setDoctorName(rs.getString(2));
+                doctor.setProfessor(rs.getString(3));
+                doctor.setDeptId(rs.getString(4));
+                doctor.setDeptName(rs.getString(5));
+                doctors.add(doctor);
+            }
+        } catch (SQLException sqle) {
+            sqle.printStackTrace();
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            mysqlJdbc.close(rs, st, conn);
+        }
+        return doctors;
+    }
+
     private List<PatientText> loadTaizhouOraclePatientTexts(String brzyid) {
         MysqlJdbc mysqlJdbc = initOracleJdbc();
         Connection conn = mysqlJdbc.connect();
@@ -259,19 +320,6 @@ public class TaizDataImportApiTest {
                 patientText.setBljlmc(r2);
                 patientText.setBljlnr(decompressed);
                 patientTexts.add(patientText);
-
-//                String[] decos = decompressed.split("<\\?");
-//                for (String s : decos) {
-//                    if (StringUtils.isEmpty(s)) continue;
-//                    PatientText patientText = new PatientText();
-//                    patientText.setBrzyid(r1);
-//                    patientText.setBljlmc(r2);
-//
-//                    s = "<?" + s;
-//                    s = CxXmlUtil.cutXml(s);
-//                    patientText.setBljlnr(s);
-//                    patientTexts.add(patientText);
-//                }
             }
         } catch (SQLException sqle) {
             sqle.printStackTrace();

+ 153 - 0
trans/src/main/java/com/lantone/qc/trans/changx/util/CxXmlUtilTemp.java

@@ -0,0 +1,153 @@
+package com.lantone.qc.trans.changx.util;
+
+import com.google.common.collect.Maps;
+import com.lantone.qc.pub.util.FileUtil;
+import com.lantone.qc.pub.util.StringUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.dom4j.Document;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description: xml解析工具
+ * @author: rengb
+ * @time: 2020/3/28 14:23
+ */
+public class CxXmlUtilTemp {
+
+    public static String cutXml(String xml) {
+        try {
+            Document doc = DocumentHelper.parseText(xml);
+            return doc.getRootElement().element("DocObjContent").asXML();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    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("DocObjContent");
+
+            if (modelName.equals("首次病程录") || modelName.equals("查房记录") || modelName.equals("会诊记录") || modelName.equals("输血记录")
+                    || modelName.equals("术前讨论小结") || modelName.equals("阶段小结") || modelName.equals("术后首次谈话及病程录")
+                    || modelName.equals("转出记录") || modelName.equals("输血后效果评价") || modelName.equals("输血后效果评价") || modelName.equals("危急值记录")) {
+                if (rootElement.element("Region") != null && rootElement.element("Region").element("Content_Text") != null) {
+                    retMap.put("内容", rootElement.element("Region").element("Content_Text").getText());
+                    return retMap;
+                }
+            }
+
+            List<Element> sectionElements = rootElement.elements("Section");
+            Map<String, String> sectionMap = Maps.newLinkedHashMap();
+            for (Element sectionElement : sectionElements) {
+                helpTip = sectionElement.attributeValue("HelpTip");
+                if (StringUtil.isBlank(helpTip)) {
+                    continue;
+                }
+                contentTextElement = sectionElement.element("Content_Text");
+                if (contentTextElement == null) {
+                    contentText = sectionElement.getStringValue().trim();
+                } else {
+                    contentText = contentTextElement.getTextTrim();
+                }
+                sectionMap.put(helpTip, contentText);
+            }
+
+            List<Element> newCtrlElements = rootElement.elements("NewCtrl");
+            Map<String, String> newCtrlMap = Maps.newLinkedHashMap();
+            for (Element newCtrlElement : newCtrlElements) {
+                helpTip = newCtrlElement.attributeValue("HelpTip");
+                if (StringUtil.isBlank(helpTip)) {
+                    continue;
+                }
+                contentTextElement = newCtrlElement.element("Content_Text");
+                if (contentTextElement == null) {
+                    contentText = newCtrlElement.getStringValue().trim();
+                } else {
+                    contentText = contentTextElement.getTextTrim();
+                }
+                newCtrlMap.put(helpTip, contentText);
+            }
+            retMap.putAll(newCtrlMap);
+            retMap.putAll(sectionMap);
+
+
+//            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;
+    }
+
+    public static Map<String, String> firstLevelNodeValue(String a, String x) {
+        return null;
+    }
+
+    public static String getTextByNodePath(String a, String x) {
+        return null;
+    }
+
+    public static void main(String[] args) {
+        String msg = FileUtil.fileRead("C:\\Users\\RGB\\Desktop\\调试\\入院记录.txt");
+        Map<String, String> map = beHospitalizedXmlToMap(msg);
+        map.keySet().forEach(key -> {
+            System.out.println(key + "---" + map.get(key));
+        });
+    }
+
+}