|
@@ -6,6 +6,7 @@ import com.lantone.qc.kernel.util.CacheFileManager;
|
|
import com.lantone.qc.kernel.util.KernelConstants;
|
|
import com.lantone.qc.kernel.util.KernelConstants;
|
|
import com.lantone.qc.pub.jdbc.MysqlJdbc;
|
|
import com.lantone.qc.pub.jdbc.MysqlJdbc;
|
|
import com.lantone.qc.pub.model.OutputInfo;
|
|
import com.lantone.qc.pub.model.OutputInfo;
|
|
|
|
+import com.lantone.qc.pub.model.keys.ModelStandardKeys;
|
|
import com.lantone.qc.pub.model.vo.MedrecVo;
|
|
import com.lantone.qc.pub.model.vo.MedrecVo;
|
|
import com.lantone.qc.pub.model.vo.QueryVo;
|
|
import com.lantone.qc.pub.model.vo.QueryVo;
|
|
import com.lantone.qc.pub.res.Response;
|
|
import com.lantone.qc.pub.res.Response;
|
|
@@ -38,6 +39,200 @@ public class QCTestController {
|
|
@Autowired
|
|
@Autowired
|
|
private QCAnalysis qCAnalysis;
|
|
private QCAnalysis qCAnalysis;
|
|
|
|
|
|
|
|
+ private Map<String, List<String>> inputLabelMap = new HashMap<>();
|
|
|
|
+ {
|
|
|
|
+ inputLabelMap.put("入院记录", Lists.newArrayList("姓名", "性别", "年龄", "民族", "职业", "出生地", "婚姻", "联系地址", "病史陈述者", "出生日期", "户口地址", "电话", "入院日期", "记录日期", "主诉", "现病史", "既往史", "个人史", "婚育史", "月经史", "家族史", "体格检查(一)", "体格检查(二)", "辅助检查", "初步诊断", "修正诊断", "医师签名", "补充诊断"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "质控测试接口,无需token信息", notes = "")
|
|
|
|
+ @PostMapping("qc_test")
|
|
|
|
+ public Response<OutputInfo> qc(String cid, String caseNumber, String hospitalId) {
|
|
|
|
+ Response response = new Response();
|
|
|
|
+ if (StringUtils.isEmpty(hospitalId)) {
|
|
|
|
+ response.setData("未填写医院流水号(hospitalId)......");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isEmpty(cid)) {
|
|
|
|
+ response.setData("未填写医院缩写(cid)......");
|
|
|
|
+ }
|
|
|
|
+ //key = 患者就诊号
|
|
|
|
+ Map<String, QueryVo> queryVoMap = createQueryVo(cid, hospitalId, caseNumber);
|
|
|
|
+ //key = 患者就诊号
|
|
|
|
+ Map<String, Map<String, String>> inputCaseMappingMap = createInputCaseMapping(hospitalId, caseNumber);
|
|
|
|
+
|
|
|
|
+ List<Map<String, Object>> updates = new ArrayList<>();
|
|
|
|
+ List<Map<String, Object>> wheres = new ArrayList<>();
|
|
|
|
+ for (Map.Entry<String, QueryVo> entry : queryVoMap.entrySet()) {
|
|
|
|
+ OutputInfo outputInfo = qCAnalysis.anlysis(entry.getValue());
|
|
|
|
+
|
|
|
|
+ Map<String, String> passMap = inputCaseMappingMap.get(entry.getKey());
|
|
|
|
+ for (Map.Entry<String, String> e : passMap.entrySet()) {
|
|
|
|
+ Map<String, Object> m = new HashMap<>();
|
|
|
|
+ Map<String, Object> w = new HashMap<>();
|
|
|
|
+ if (outputInfo.getResult().get(e.getKey()) == null) {
|
|
|
|
+ m.put("check_label", "-2");
|
|
|
|
+ } else {
|
|
|
|
+ m.put("check_label", outputInfo.getResult().get(e.getKey()).get("status"));
|
|
|
|
+ }
|
|
|
|
+ w.put("id", e.getValue());
|
|
|
|
+
|
|
|
|
+ updates.add(m);
|
|
|
|
+ wheres.add(w);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ 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"));
|
|
|
|
+ mysqlJdbc.update("qc_inputcases_mapping_all", updates, wheres);
|
|
|
|
+ return response;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public Map<String, QueryVo> createQueryVo(String cid, String hospitalId, String caseNumber) {
|
|
|
|
+ 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"));
|
|
|
|
+ Connection conn = mysqlJdbc.connect();
|
|
|
|
+ Statement st = null;
|
|
|
|
+ ResultSet rs = null;
|
|
|
|
+ String r1, r2, r3, r4, r5;
|
|
|
|
+
|
|
|
|
+ Map<String, QueryVo> queryVoMap = new HashMap<>();
|
|
|
|
+ QueryVo queryVo = new QueryVo();
|
|
|
|
+ List<MedrecVo> medrec = new ArrayList<>();
|
|
|
|
+ try {
|
|
|
|
+ st = conn.createStatement();
|
|
|
|
+ String sql = "select case_number from qc_cases_number where hospital_id = " + hospitalId; //查询医院所有病历号
|
|
|
|
+ rs = st.executeQuery(sql);
|
|
|
|
+ List<String> numbers = new ArrayList<>();
|
|
|
|
+ while (rs.next()) {
|
|
|
|
+ r1 = rs.getString(1);
|
|
|
|
+ numbers.add(r1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ sql = "select id from qc_mode"; //查询数据模块
|
|
|
|
+ rs = st.executeQuery(sql);
|
|
|
|
+ List<String> modeIds = new ArrayList<>();
|
|
|
|
+ while (rs.next()) {
|
|
|
|
+ r1 = rs.getString(1);
|
|
|
|
+ modeIds.add(r1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ sql = "select code, name from qc_cases_entry"; //查询所有条目
|
|
|
|
+ rs = st.executeQuery(sql);
|
|
|
|
+ Map<String, Map<String, String>> inputCatalogueMap = new HashMap<>();
|
|
|
|
+ while (rs.next()) {
|
|
|
|
+ r1 = rs.getString(1);
|
|
|
|
+ r2 = rs.getString(2);
|
|
|
|
+ Map<String, String> m = new HashMap<>();
|
|
|
|
+ m.put("precond","");
|
|
|
|
+ m.put("name", r2);
|
|
|
|
+ m.put("code", r1);
|
|
|
|
+ inputCatalogueMap.put(r1, m);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ sql = "SELECT h.code, n.case_number, q.name, qmm.text " +
|
|
|
|
+ "FROM qc_model_mapping qmm, qc_mode q, qc_cases_number n, qc_hospital_info h " +
|
|
|
|
+ "where qmm.case_number_id = n.id and qmm.mode_id = q.id and n.hospital_id = h.id and n.is_deleted = 'N' ";
|
|
|
|
+ if (StringUtils.isNotEmpty(caseNumber)) {
|
|
|
|
+ sql = sql + " and n.case_number = " + caseNumber;
|
|
|
|
+ }
|
|
|
|
+ sql = sql + " order by n.id, q.id";
|
|
|
|
+ rs = st.executeQuery(sql);
|
|
|
|
+ String tempCaseNumber = "", label = "";
|
|
|
|
+ List<String> details = new ArrayList<>();
|
|
|
|
+ while (rs.next()) {
|
|
|
|
+ r1 = rs.getString(1);
|
|
|
|
+ r2 = rs.getString(2);
|
|
|
|
+ r3 = rs.getString(3);
|
|
|
|
+ r4 = rs.getString(4);
|
|
|
|
+ if (!tempCaseNumber.equals(String.valueOf(r2)) && StringUtils.isNotEmpty(tempCaseNumber)) {
|
|
|
|
+ queryVo.setCid(cid);
|
|
|
|
+ queryVo.setMedrec(medrec);
|
|
|
|
+ queryVo.setInputCatalogueMap(inputCatalogueMap);
|
|
|
|
+ queryVoMap.put(r1, queryVo);
|
|
|
|
+ //新的一份病历记录
|
|
|
|
+ medrec = new ArrayList<>();
|
|
|
|
+ queryVo = new QueryVo();
|
|
|
|
+ }
|
|
|
|
+ if (r3.equals("入院记录") || r3.equals("首次病程录") || r3.equals("死亡病例讨论记录") || r3.equals("出院小结") || r3.equals("死亡记录")) {
|
|
|
|
+ MedrecVo medrecVo = new MedrecVo();
|
|
|
|
+ medrecVo.setTitle(r3);
|
|
|
|
+ Map<String, Object> m = new HashMap<>();
|
|
|
|
+ m.put("content", r4);
|
|
|
|
+ medrecVo.setContent(m);
|
|
|
|
+ medrec.add(medrecVo);
|
|
|
|
+ } else if (r3.equals("查房记录") || r3.equals("会诊记录") || r3.equals("医嘱信息") || r3.equals("值班交接制度") || r3.equals("输血/血制品病程记录")
|
|
|
|
+ || r3.equals("抢救记录") || r3.equals("危急值记录") || r3.equals("病危通知书") || r3.equals("阶段小结") || r3.equals("疑难病例讨论记录") || r3.equals("病重通知书")
|
|
|
|
+ || r3.equals("术前讨论、术前小结") || r3.equals("麻醉记录") || r3.equals("麻醉知情同意书") || r3.equals("麻醉术前访视记录")
|
|
|
|
+ || r3.equals("麻醉术后访视记录") || r3.equals("手术知情同意书") || r3.equals("手术记录") || r3.equals("术后首次病程及谈话记录")
|
|
|
|
+ || r3.equals("手术风险评估表") || r3.equals("手术安全核查表") || r3.equals("转科记录(转入)") || r3.equals("转科记录(转出)")) {
|
|
|
|
+ if (!label.equals(String.valueOf(r3)) && StringUtils.isNotEmpty(label)) {
|
|
|
|
+ MedrecVo medrecVo = new MedrecVo();
|
|
|
|
+ medrecVo.setTitle(label);
|
|
|
|
+ Map<String, Object> m = new HashMap<>();
|
|
|
|
+ m.put("content", details);
|
|
|
|
+ medrecVo.setContent(m);
|
|
|
|
+ medrec.add(medrecVo);
|
|
|
|
+ details = new ArrayList<>();
|
|
|
|
+ }
|
|
|
|
+ details.add(r4);
|
|
|
|
+ label = r3;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } catch (SQLException sqle) {
|
|
|
|
+ sqle.printStackTrace();
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ } finally {
|
|
|
|
+ mysqlJdbc.close(rs, st, conn);
|
|
|
|
+ }
|
|
|
|
+ return queryVoMap;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public Map<String, Map<String, String>> createInputCaseMapping(String hospitalId, String caseNumber) {
|
|
|
|
+ Map<String, Map<String, String>> result = new HashMap<>();
|
|
|
|
+ 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"));
|
|
|
|
+ Connection conn = mysqlJdbc.connect();
|
|
|
|
+ Statement st = null;
|
|
|
|
+ ResultSet rs = null;
|
|
|
|
+ String r1, r2, r3, r4, r5;
|
|
|
|
+ try {
|
|
|
|
+ st = conn.createStatement();
|
|
|
|
+ String sql = "SELECT qim.id, qim.case_number_id, qc.code FROM qc_inputcases_mapping qim, qc_cases_number q, qc_cases_entry qc " +
|
|
|
|
+ "where qim.case_number_id = q.id and qim.cases_entry_id = qc.id and q.is_deleted = 'N' " +
|
|
|
|
+ "and q.hospital_id = " + hospitalId ;
|
|
|
|
+ if (StringUtils.isNotEmpty(caseNumber)) {
|
|
|
|
+ sql = sql + " and q.case_number = " + caseNumber;
|
|
|
|
+ }
|
|
|
|
+ sql = sql + " order by q.id, qim.cases_id ";
|
|
|
|
+ rs = st.executeQuery(sql);
|
|
|
|
+
|
|
|
|
+ String caseNumberId = "";
|
|
|
|
+ Map<String, String> m = new HashMap<>();
|
|
|
|
+ while (rs.next()) {
|
|
|
|
+ r1 = rs.getString(1);
|
|
|
|
+ r2 = rs.getString(2);
|
|
|
|
+ r3 = rs.getString(3);
|
|
|
|
+ if (!caseNumberId.equals(String.valueOf(r2)) && StringUtils.isNotEmpty(caseNumberId)) {
|
|
|
|
+ result.put(r2, m);
|
|
|
|
+ m = new HashMap<>();
|
|
|
|
+ }
|
|
|
|
+ m.put(r3, r1);
|
|
|
|
+ }
|
|
|
|
+ } catch (SQLException sqle) {
|
|
|
|
+ sqle.printStackTrace();
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ } finally {
|
|
|
|
+ mysqlJdbc.close(rs, st, conn);
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
@ApiOperation(value = "质控测试接口,无需token信息", notes = "")
|
|
@ApiOperation(value = "质控测试接口,无需token信息", notes = "")
|
|
@PostMapping("rec_test")
|
|
@PostMapping("rec_test")
|
|
public Response<OutputInfo> extract(String caseIds, int length, String cid, String txtId, String hospitalId) {
|
|
public Response<OutputInfo> extract(String caseIds, int length, String cid, String txtId, String hospitalId) {
|