|
@@ -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();
|