|
@@ -3,9 +3,13 @@ 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.changx.util.CxXmlUtil;
|
|
|
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.Connection;
|
|
|
import java.sql.ResultSet;
|
|
|
import java.sql.SQLException;
|
|
@@ -14,6 +18,7 @@ import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.zip.GZIPInputStream;
|
|
|
|
|
|
/**
|
|
|
* @ClassName : TaizDataImportApiTest
|
|
@@ -22,16 +27,23 @@ import java.util.Map;
|
|
|
* @Date: 2020-03-31 19:34
|
|
|
*/
|
|
|
public class TaizDataImportApiTest {
|
|
|
- private static String hospitalId = "3";
|
|
|
+ private static String hospitalId = "1";
|
|
|
+ private static String cid = "changx";
|
|
|
|
|
|
private Map<String,String> caseMap = new HashMap<>();
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
TaizDataImportApiTest test = new TaizDataImportApiTest();
|
|
|
- //台州模块映射
|
|
|
- test.loadTaizhouModelHospital();
|
|
|
+ //模块映射
|
|
|
+ test.loadModelHospital();
|
|
|
+ //长兴患者信息
|
|
|
+ if (cid.equals("changx")) {
|
|
|
+ test.insertPatient(test.loadOraclePatients("BR_INPATIENTINFO_CX20200327"));
|
|
|
+ }
|
|
|
//台州患者信息
|
|
|
- test.insertPatient(test.loadOraclePatients("BR_INPATIENTINFO_TZ20200330"));
|
|
|
+ if (cid.equals("taizhou")) {
|
|
|
+ test.insertPatient(test.loadOraclePatients("BR_INPATIENTINFO_TZ20200330"));
|
|
|
+ }
|
|
|
//病人流水号获取
|
|
|
Map<String, String> patientMap = test.loadPatients(hospitalId);
|
|
|
Map<String, String> modelMap = test.loadModel();
|
|
@@ -53,7 +65,13 @@ public class TaizDataImportApiTest {
|
|
|
List<Map<String, Object>> list = new ArrayList<>();
|
|
|
|
|
|
for (Map.Entry<String, String> entry : patientMap.entrySet()) {
|
|
|
- List<PatientText> patientTexts = loadOraclePatientTexts(entry.getKey());
|
|
|
+ List<PatientText> patientTexts = new ArrayList<>();
|
|
|
+ if ("changx".equals(cid)) {
|
|
|
+ patientTexts = loadChangxOraclePatientTexts(entry.getKey());
|
|
|
+ }
|
|
|
+ if ("taizhou".equals(cid)) {
|
|
|
+ patientTexts = loadTaizhouOraclePatientTexts(entry.getKey());
|
|
|
+ }
|
|
|
for (PatientText patientText : patientTexts) {
|
|
|
System.out.println(patientText.getBrzyid() + " " + patientText.getBljlmc());
|
|
|
Map<String, Object> patientTextMap = new HashMap<>();
|
|
@@ -69,7 +87,13 @@ System.out.println("******" + patientText.getBljlmc() + "**" + caseMap.get(patie
|
|
|
patientTextMap.put("origin_text", patientText.getBljlnr());
|
|
|
|
|
|
String text = "";
|
|
|
- Map<String, String> textMap = TzXmlUtil.getXmlToMapForTZ(patientText.getBljlnr());
|
|
|
+ Map<String, String> textMap = new HashMap<>();
|
|
|
+ if ("changx".equals(cid)) {
|
|
|
+
|
|
|
+ }
|
|
|
+ if ("taizhou".equals(cid)) {
|
|
|
+ textMap = TzXmlUtil.getXmlToMapForTZ(patientText.getBljlnr());
|
|
|
+ }
|
|
|
for (Map.Entry<String, String> e : textMap.entrySet()) {
|
|
|
text = text + "【" + e.getKey() + "】:" + e.getValue() + "\n";
|
|
|
}
|
|
@@ -107,7 +131,7 @@ System.out.println("******" + patientText.getBljlmc() + "**" + caseMap.get(patie
|
|
|
return patients;
|
|
|
}
|
|
|
|
|
|
- private List<PatientText> loadOraclePatientTexts(String brzyid) {
|
|
|
+ private List<PatientText> loadTaizhouOraclePatientTexts(String brzyid) {
|
|
|
MysqlJdbc mysqlJdbc = initOracleJdbc();
|
|
|
Connection conn = mysqlJdbc.connect();
|
|
|
Statement st = null;
|
|
@@ -118,7 +142,7 @@ System.out.println("******" + patientText.getBljlmc() + "**" + caseMap.get(patie
|
|
|
st = conn.createStatement();
|
|
|
String sql = "select brzyid,bljlmc,bljlnr from mr_medicalrecords_TZ20200330 a " +
|
|
|
"left join mr_mrcontent_TZ20200330 b on a.bljlid=b.bljlid " +
|
|
|
- "where bljlnr is not null " +
|
|
|
+ "where bljlnr is not null and brzyid = '" + brzyid + "' " +
|
|
|
"order by brzyid";
|
|
|
rs = st.executeQuery(sql);
|
|
|
while (rs.next()) {
|
|
@@ -141,6 +165,69 @@ System.out.println("******" + patientText.getBljlmc() + "**" + caseMap.get(patie
|
|
|
return patientTexts;
|
|
|
}
|
|
|
|
|
|
+ private List<PatientText> loadChangxOraclePatientTexts(String brzyid) {
|
|
|
+ MysqlJdbc mysqlJdbc = initOracleJdbc();
|
|
|
+ Connection conn = mysqlJdbc.connect();
|
|
|
+ Statement st = null;
|
|
|
+ ResultSet rs = null;
|
|
|
+ String r1, r2;
|
|
|
+ List<PatientText> patientTexts = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ st = conn.createStatement();
|
|
|
+ String sql = "select brzyid,bljlmc,bljlnr from MR_MEDICALRECORDS_CX20200327 a " +
|
|
|
+ "left join MR_MRCONTENT_CX20200327 b on a.bljlid=b.bljlid " +
|
|
|
+ "where bljlnr is not null and brzyid = '" + brzyid + "' " +
|
|
|
+ "order by brzyid";
|
|
|
+ rs = st.executeQuery(sql);
|
|
|
+ while (rs.next()) {
|
|
|
+ r1 = rs.getString(1);
|
|
|
+ r2 = rs.getString(2);
|
|
|
+ java.sql.Blob blob = rs.getBlob(3);
|
|
|
+
|
|
|
+ InputStream in = blob.getBinaryStream();
|
|
|
+
|
|
|
+ GZIPInputStream ginzip = new GZIPInputStream(in);
|
|
|
+
|
|
|
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
|
+ byte[] buffer = new byte[1024];
|
|
|
+ int offset = -1;
|
|
|
+ while ((offset = ginzip.read(buffer)) != -1) {
|
|
|
+ out.write(buffer, 0, offset);
|
|
|
+ }
|
|
|
+ String decompressed = out.toString();
|
|
|
+ in.close();
|
|
|
+ out.close();
|
|
|
+ ginzip.close();
|
|
|
+
|
|
|
+ PatientText patientText = new PatientText();
|
|
|
+ patientText.setBrzyid(r1);
|
|
|
+ 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();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ mysqlJdbc.close(rs, st, conn);
|
|
|
+ }
|
|
|
+ return patientTexts;
|
|
|
+ }
|
|
|
+
|
|
|
private Map<String, String> loadPatients(String hospitalId) {
|
|
|
MysqlJdbc mysqlJdbc = initMysqlJdbc();
|
|
|
Connection conn = mysqlJdbc.connect();
|
|
@@ -150,7 +237,7 @@ System.out.println("******" + patientText.getBljlmc() + "**" + caseMap.get(patie
|
|
|
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";
|
|
|
+ String sql = "select id, case_number from qc_cases_number where hospital_id = " + hospitalId;
|
|
|
rs = st.executeQuery(sql);
|
|
|
while (rs.next()) {
|
|
|
r1 = rs.getString(1);
|
|
@@ -193,7 +280,7 @@ System.out.println("******" + patientText.getBljlmc() + "**" + caseMap.get(patie
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- private void loadTaizhouModelHospital() {
|
|
|
+ private void loadModelHospital() {
|
|
|
MysqlJdbc mysqlJdbc = initMysqlJdbc();
|
|
|
Connection conn = mysqlJdbc.connect();
|
|
|
Statement st = null;
|
|
@@ -201,7 +288,7 @@ System.out.println("******" + patientText.getBljlmc() + "**" + caseMap.get(patie
|
|
|
String r1, r2;
|
|
|
try {
|
|
|
st = conn.createStatement();
|
|
|
- String sql = "select hospital_model_name, stand_model_name from qc_model_hospital_taizhou where stand_model_name is not null";
|
|
|
+ String sql = "select hospital_model_name, stand_model_name from qc_model_hospital where stand_model_name is not null and hospital_id = " + hospitalId;
|
|
|
rs = st.executeQuery(sql);
|
|
|
while (rs.next()) {
|
|
|
r1 = rs.getString(1);
|