|
@@ -0,0 +1,194 @@
|
|
|
+package com.lantone.qc.kernel;
|
|
|
+
|
|
|
+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.taizhou.util.TzXmlUtil;
|
|
|
+import com.lantone.qc.trans.util.http.HttpApi;
|
|
|
+
|
|
|
+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;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @ClassName : TaizDataImportApiTest
|
|
|
+ * @Description :
|
|
|
+ * @Author : 楼辉荣
|
|
|
+ * @Date: 2020-03-31 19:34
|
|
|
+ */
|
|
|
+public class TaizDataImportApiTest {
|
|
|
+ private static String hospitalId = "3";
|
|
|
+
|
|
|
+ private Map<String,String> caseMap = new HashMap<>();
|
|
|
+ {
|
|
|
+ caseMap.put("0010 入院记录(新生儿)", "入院记录");
|
|
|
+ caseMap.put("0160 术后首次病程录02", "术后首次谈话及病程录");
|
|
|
+ caseMap.put("0330 危急值处置记录", "危急值记录");
|
|
|
+ caseMap.put("0300 首次病程录02", "首次病程录");
|
|
|
+ caseMap.put("0010 入院记录(女)", "入院记录");
|
|
|
+ caseMap.put("0220 转出记录","转出记录");
|
|
|
+ caseMap.put("0310 会诊记录","会诊记录");
|
|
|
+ caseMap.put("0010 再次入院(男)","入院记录");
|
|
|
+ caseMap.put("0120 上级查房记录","查房记录");
|
|
|
+ caseMap.put("0010 入院记录(儿)","入院记录");
|
|
|
+ caseMap.put("0130 普通病程录","查房记录");
|
|
|
+ caseMap.put("0010 入院记录(产科)","入院记录");
|
|
|
+ caseMap.put("0433 病危(重)通知","病危通知书");
|
|
|
+ caseMap.put("会诊结果","会诊结果单");
|
|
|
+ caseMap.put("0290 术前讨论兼术前小结","术前讨论小结");
|
|
|
+ caseMap.put("0300 首次病程录(中医)","首次病程录");
|
|
|
+ caseMap.put("0900 手术记录02","手术记录");
|
|
|
+ caseMap.put("0010 入院记录(男)","入院记录");
|
|
|
+ caseMap.put("0010 入院记录(中医 女)","入院记录");
|
|
|
+ caseMap.put("0310 会诊申请","会诊申请单");
|
|
|
+ caseMap.put("0110 查房记录(SOAP)","查房记录");
|
|
|
+ caseMap.put("0840 出院记录(手术)","出院小结");
|
|
|
+ caseMap.put("0840 出院记录(非手术)","出院小结");
|
|
|
+ caseMap.put("0011 入院记录(神经外科--女)","入院记录");
|
|
|
+ caseMap.put("0073 (日间)手术及术后首次病程记录","术后首次谈话及病程录");
|
|
|
+ caseMap.put("0010 入院记录(中医 男)","入院记录");
|
|
|
+ caseMap.put("住院病案首页02(病人存档及卫生统计用)","病案首页");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ TaizDataImportApiTest test = new TaizDataImportApiTest();
|
|
|
+ test.insertPatient(test.importPatient());
|
|
|
+ //病人流水号获取
|
|
|
+ Map<String, String> patientMap = test.loadPatients(hospitalId);
|
|
|
+ Map<String, String> modelMap = test.loadModel();
|
|
|
+ test.insertPatientText(patientMap, modelMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Patient> importPatient() {
|
|
|
+ try {
|
|
|
+ String result = HttpApi.get("http://192.168.3.241:11000/api/inpatientlist");
|
|
|
+ List<Patient> patients = FastJsonUtils.getJsonToList(result, Patient.class);
|
|
|
+ return patients;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<PatientText> importPatientText(String patientId) {
|
|
|
+ try {
|
|
|
+ String result = HttpApi.get("http://192.168.3.241:11000/api/GetMedrecords?brzyid=" + patientId);
|
|
|
+// String s = result.substring(result.indexOf("[") + 1, result.lastIndexOf("]"));
|
|
|
+// s = s.replaceAll("\\[","<");
|
|
|
+// s = s.replaceAll("\\]",">");
|
|
|
+//
|
|
|
+// s = "[" + s + "]";
|
|
|
+ List<PatientText> patientTexts = FastJsonUtils.getJsonToList(result, PatientText.class);
|
|
|
+ return patientTexts;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void insertPatient(List<Patient> patients) {
|
|
|
+ List<Map<String, Object>> list = new ArrayList<>();
|
|
|
+ for (Patient patient : patients) {
|
|
|
+ Map<String, Object> patientMap = new HashMap<>();
|
|
|
+ patientMap.put("case_number", patient.getBrzyid());
|
|
|
+ patientMap.put("hospital_id", hospitalId);
|
|
|
+ list.add(patientMap);
|
|
|
+ }
|
|
|
+ initJdbc().insert(list, "qc_cases_number", new String[]{"hospital_id", "case_number"});
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 = importPatientText(entry.getKey());
|
|
|
+ for (PatientText patientText : patientTexts) {
|
|
|
+ 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);
|
|
|
+ patientTextMap.put("mode_id", modelMap.get(caseMap.get(patientText.getBljlmc())));
|
|
|
+
|
|
|
+ if (patientTextMap.get("mode_id") == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ patientTextMap.put("origin_text", patientText.getBljlnr());
|
|
|
+
|
|
|
+ String text = "";
|
|
|
+ Map<String, String> textMap = TzXmlUtil.getXmlToMapForTZ(patientText.getBljlnr());
|
|
|
+ for (Map.Entry<String, String> e : textMap.entrySet()) {
|
|
|
+ text = text + "【" + e.getKey() + "】:" + e.getValue() + "\n";
|
|
|
+ }
|
|
|
+ patientTextMap.put("text", text);
|
|
|
+ list.add(patientTextMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ initJdbc().insert(list, "qc_model_mapping", new String[]{"case_number", "case_number_id", "origin_text", "mode_id", "text"});
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, String> loadPatients(String hospitalId) {
|
|
|
+ MysqlJdbc mysqlJdbc = initJdbc();
|
|
|
+ Connection conn = mysqlJdbc.connect();
|
|
|
+ Statement st = null;
|
|
|
+ ResultSet rs = null;
|
|
|
+ String r1, r2;
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ try {
|
|
|
+ st = conn.createStatement();
|
|
|
+ String sql = "select id, case_number from qc_cases_number where hospital_id = " + hospitalId + " limit 0, 10";
|
|
|
+ rs = st.executeQuery(sql);
|
|
|
+ while (rs.next()) {
|
|
|
+ r1 = rs.getString(1);
|
|
|
+ r2 = rs.getString(2);
|
|
|
+ map.put(r2, r1);
|
|
|
+ }
|
|
|
+ } catch (SQLException sqle) {
|
|
|
+ sqle.printStackTrace();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ mysqlJdbc.close(rs, st, conn);
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, String> loadModel() {
|
|
|
+ MysqlJdbc mysqlJdbc = initJdbc();
|
|
|
+ Connection conn = mysqlJdbc.connect();
|
|
|
+ Statement st = null;
|
|
|
+ ResultSet rs = null;
|
|
|
+ String r1, r2;
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ try {
|
|
|
+ st = conn.createStatement();
|
|
|
+ String sql = "select id, name from qc_mode";
|
|
|
+ rs = st.executeQuery(sql);
|
|
|
+ while (rs.next()) {
|
|
|
+ r1 = rs.getString(1);
|
|
|
+ r2 = rs.getString(2);
|
|
|
+ map.put(r2, r1);
|
|
|
+ }
|
|
|
+ } catch (SQLException sqle) {
|
|
|
+ sqle.printStackTrace();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ mysqlJdbc.close(rs, st, conn);
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ private MysqlJdbc initJdbc() {
|
|
|
+ PropertiesUtil propertiesUtil = new PropertiesUtil("kernel.properties");
|
|
|
+ MysqlJdbc mysqlJdbc = new MysqlJdbc(propertiesUtil.getProperty("mysql.test.user"),
|
|
|
+ propertiesUtil.getProperty("mysql.test.password"),
|
|
|
+ propertiesUtil.getProperty("mysql.test.url"));
|
|
|
+ return mysqlJdbc;
|
|
|
+ }
|
|
|
+}
|