|
@@ -2,6 +2,7 @@ package com.diagbot.facade;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.alibaba.fastjson.TypeReference;
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
import com.baomidou.mybatisplus.annotation.TableName;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -43,6 +44,7 @@ import com.google.common.collect.Maps;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.cglib.beans.BeanMap;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
@@ -277,7 +279,7 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
|
|
|
* @param analyzeVO
|
|
|
* @return
|
|
|
*/
|
|
|
- public QueryVo dealCommonData(Long hospitalId, AnalyzeVO analyzeVO) {
|
|
|
+ public QueryVo dealCommonData(Long hospitalId, AnalyzeVO analyzeVO) throws Exception {
|
|
|
// 获取质控条目
|
|
|
List<QcCasesEntryDTO> qcCasesEntryDTOList = qcCasesEntryFacade.getQcCasesEntry(analyzeVO);
|
|
|
if (ListUtil.isEmpty(qcCasesEntryDTOList)) {
|
|
@@ -597,27 +599,27 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
|
|
|
*/
|
|
|
|
|
|
// 会诊记录
|
|
|
- addDataWithKey("会诊记录", recMap, medrecVoList,
|
|
|
- Arrays.asList("会诊记录"));
|
|
|
+ specialDataWithKey("会诊", recMap, medrecVoList, "会诊记录",
|
|
|
+ null);
|
|
|
|
|
|
//会诊申请单
|
|
|
if (ListUtil.isNotEmpty(medConsultationApplyList)) {
|
|
|
- newAddData("会诊申请单", medConsultationApplyList, recMap, medrecVoList);
|
|
|
+ specialData("会诊", medConsultationApplyList, recMap, medrecVoList, "会诊申请单");
|
|
|
} else {
|
|
|
- addDataWithKey("会诊申请单", recMap, medrecVoList,
|
|
|
+ specialDataWithKey("会诊", recMap, medrecVoList, "会诊申请单",
|
|
|
Arrays.asList("会诊申请单"));
|
|
|
}
|
|
|
//会诊结果单
|
|
|
if (ListUtil.isNotEmpty(medConsultationResultList)) {
|
|
|
- newAddData("会诊结果单", medConsultationResultList, recMap, medrecVoList);
|
|
|
+ specialData("会诊", medConsultationResultList, recMap, medrecVoList, "会诊结果单");
|
|
|
} else {
|
|
|
- addDataWithKey("会诊结果单", recMap, medrecVoList,
|
|
|
+ specialDataWithKey("会诊", recMap, medrecVoList, "会诊结果单",
|
|
|
Arrays.asList("会诊记录", "会诊结果单", "会诊申请单"));
|
|
|
}
|
|
|
|
|
|
//会诊单(申请和结果)
|
|
|
if (ListUtil.isNotEmpty(medConsultationNoteList)) {
|
|
|
- newAddData("会诊单(申请和结果)", medConsultationNoteList, recMap, medrecVoList);
|
|
|
+ specialData("会诊", medConsultationNoteList, recMap, medrecVoList, "会诊单(申请和结果)");
|
|
|
}
|
|
|
//入院记录
|
|
|
if (ListUtil.isNotEmpty(medAdmissionNoteList)) {
|
|
@@ -699,18 +701,18 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
|
|
|
|
|
|
//术后首程
|
|
|
if (ListUtil.isNotEmpty(medOperativeFirstRecordList)) {
|
|
|
- newAddData("术后首程", medOperativeFirstRecordList, recMap, medrecVoList);
|
|
|
+ specialData("手术", medOperativeFirstRecordList, recMap, medrecVoList, "术后首程");
|
|
|
} else {
|
|
|
- addDataWithKey("术后首次病程及谈话记录", recMap, medrecVoList,
|
|
|
- Arrays.asList("术后首次病程及谈话记录"));
|
|
|
+ specialDataWithKey("手术", recMap, medrecVoList, "术后首次病程及谈话记录",
|
|
|
+ null);
|
|
|
}
|
|
|
|
|
|
//手术记录
|
|
|
if (ListUtil.isNotEmpty(medOperativeNoteList)) {
|
|
|
- newAddData("手术记录", medOperativeNoteList, recMap, medrecVoList);
|
|
|
+ specialData("手术", medOperativeNoteList, recMap, medrecVoList, "手术记录");
|
|
|
} else {
|
|
|
- addDataWithKey("手术记录", recMap, medrecVoList,
|
|
|
- Arrays.asList("手术记录"));
|
|
|
+ specialDataWithKey("手术", recMap, medrecVoList, "手术记录",
|
|
|
+ null);
|
|
|
}
|
|
|
|
|
|
//阶段小结
|
|
@@ -722,10 +724,10 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
|
|
|
|
|
|
//术前讨论小结
|
|
|
if (ListUtil.isNotEmpty(medPreoperativeDiscussionList)) {
|
|
|
- newAddData("术前讨论小结", medPreoperativeDiscussionList, recMap, medrecVoList);
|
|
|
+ specialData("手术", medPreoperativeDiscussionList, recMap, medrecVoList, "术前讨论小结");
|
|
|
} else {
|
|
|
- addDataWithKey("术前讨论、术前小结", recMap, medrecVoList,
|
|
|
- Arrays.asList("术前讨论、术前小结"));
|
|
|
+ specialDataWithKey("手术", recMap, medrecVoList, "术前讨论、术前小结",
|
|
|
+ null);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -738,18 +740,18 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
|
|
|
|
|
|
//转入记录
|
|
|
if (ListUtil.isNotEmpty(medTransferInNoteList)) {
|
|
|
- newAddData("转入记录", medTransferInNoteList, recMap, medrecVoList);
|
|
|
+ specialData("转科", medTransferInNoteList, recMap, medrecVoList, "转入记录");
|
|
|
} else {
|
|
|
- addDataWithKey("转入记录", recMap, medrecVoList,
|
|
|
- Arrays.asList("转入记录"));
|
|
|
+ specialDataWithKey("转科", recMap, medrecVoList, "转入记录",
|
|
|
+ null);
|
|
|
}
|
|
|
|
|
|
//转出记录
|
|
|
if (ListUtil.isNotEmpty(medTransferOutNoteList)) {
|
|
|
- newAddData("转出记录", medTransferOutNoteList, recMap, medrecVoList);
|
|
|
+ specialData("转科", medTransferOutNoteList, recMap, medrecVoList, "转出记录");
|
|
|
} else {
|
|
|
- addDataWithKey("转出记录", recMap, medrecVoList,
|
|
|
- Arrays.asList("转出记录"));
|
|
|
+ specialDataWithKey("转科", recMap, medrecVoList, "转出记录",
|
|
|
+ null);
|
|
|
}
|
|
|
|
|
|
//查房记录
|
|
@@ -760,11 +762,29 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
|
|
|
}
|
|
|
|
|
|
//==============非结构化表拥有,文书单独查出来====================
|
|
|
- addDataWithKey("手术知情同意书", recMap, medrecVoList,
|
|
|
- Arrays.asList("手术知情同意书"));
|
|
|
+ specialDataWithKey("手术", recMap, medrecVoList, "手术知情同意书",
|
|
|
+ null);
|
|
|
+
|
|
|
+ specialDataWithKey("手术", recMap, medrecVoList, "手术安全核查表",
|
|
|
+ null);
|
|
|
+
|
|
|
+
|
|
|
+//=========================================
|
|
|
+ /* // 会诊记录
|
|
|
+ addDataWithKey("会诊", recMap, medrecVoList,
|
|
|
+ Arrays.asList("会诊记录", "会诊结果单", "会诊申请单"));
|
|
|
+
|
|
|
+ // 手术
|
|
|
+ addDataWithKey("手术", recMap, medrecVoList,
|
|
|
+ Arrays.asList("术后首次病程及谈话记录", "手术记录",
|
|
|
+ "术前讨论、术前小结", "手术知情同意书", "手术安全核查表"));
|
|
|
+
|
|
|
+ // 转科
|
|
|
+ addDataWithKey("转科", recMap, medrecVoList,
|
|
|
+ Arrays.asList("转入记录", "转出记录"));
|
|
|
+*/
|
|
|
+// ==================================
|
|
|
|
|
|
- addDataWithKey("手术安全核查表", recMap, medrecVoList,
|
|
|
- Arrays.asList("手术安全核查表"));
|
|
|
|
|
|
addData("病理检验送检单", recMap, medrecVoList);
|
|
|
|
|
@@ -824,7 +844,12 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
|
|
|
analyzeVO.setHospitalId(hospitalId);
|
|
|
|
|
|
// 处理公共数据
|
|
|
- QueryVo queryVo = dealCommonData(hospitalId, analyzeVO);
|
|
|
+ QueryVo queryVo = null;
|
|
|
+ try {
|
|
|
+ queryVo = dealCommonData(hospitalId, analyzeVO);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(),e);
|
|
|
+ }
|
|
|
queryVo.setUseCrfCache(analyzeVO.isUseCrfCache());
|
|
|
// 调用质控接口
|
|
|
Response<OutputInfo> response = qcServiceClient.extract(queryVo);
|
|
@@ -873,8 +898,9 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
|
|
|
* @param recMap
|
|
|
* @param medrecVoList
|
|
|
*/
|
|
|
- public void addData(String key, Map<String, List<RecordContentDTO>> recMap, List<MedrecVo> medrecVoList) {
|
|
|
+ public void addData(String key, Map<String, List<RecordContentDTO>> recMap, List<MedrecVo> medrecVoList) throws Exception {
|
|
|
List<RecordContentDTO> list = recMap.get(key);
|
|
|
+ List<Map<String, Object>> returnData = new ArrayList<>();
|
|
|
if (ListUtil.isNotEmpty(list)) {
|
|
|
MedrecVo medrecVo = new MedrecVo();
|
|
|
String k = key;
|
|
@@ -892,13 +918,116 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
|
|
|
}
|
|
|
|
|
|
Map<String, Object> content = new HashMap<>();
|
|
|
- content.put("content", list);
|
|
|
+ for (RecordContentDTO recordContentDTO : list) {
|
|
|
+ Map<String, Object> objectMap = MapUtil.objectToMap(recordContentDTO);
|
|
|
+ returnData.add(objectMap);
|
|
|
+ }
|
|
|
+ content.put("content", returnData);
|
|
|
medrecVo.setTitle(k);
|
|
|
medrecVo.setContent(content);
|
|
|
medrecVoList.add(medrecVo);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 1.5.0拼接数据(手术、会诊)
|
|
|
+ *
|
|
|
+ * @param key
|
|
|
+ * @param recMap
|
|
|
+ * @param medrecVoList
|
|
|
+ */
|
|
|
+ public void specialDataWithKey(String key, Map<String, List<RecordContentDTO>> recMap,
|
|
|
+ List<MedrecVo> medrecVoList, String keyTagert, List<String> keyList) throws Exception {
|
|
|
+ MedrecVo medrecVo = new MedrecVo();
|
|
|
+ Map<String, Object> specialContent = new HashMap<String, Object>();
|
|
|
+ List<Map<String, Object>> returnData = new ArrayList<>();
|
|
|
+ List<Map<String, Object>> objectFile = new ArrayList<>();
|
|
|
+ List<Map<String, Object>> applyFile = new ArrayList<>();
|
|
|
+ List<Map<String, Object>> mapList = new ArrayList<>();
|
|
|
+ Map<String, Object> content = new HashMap<>();
|
|
|
+ Map<String, Object> Map = new HashMap<>();
|
|
|
+ Map<String, Object> objectMap = new HashMap<>();
|
|
|
+ Map<String, Object> applyMap = new HashMap<>();
|
|
|
+ Boolean flag = false;
|
|
|
+ String m = key;
|
|
|
+ if ("术前讨论、术前小结".equals(key)) {
|
|
|
+ m = "术前讨论小结";
|
|
|
+ }
|
|
|
+ if ("术后首次病程及谈话记录".equals(key)) {
|
|
|
+ m = "术后首程";
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(keyList)) {
|
|
|
+ for (String k : keyList) {
|
|
|
+ if (ListUtil.isNotEmpty(recMap.get(k))) {
|
|
|
+ Map.put(k, recMap.get(k));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ List<RecordContentDTO> recordContentDTOS = recMap.get(keyTagert);
|
|
|
+ if (ListUtil.isNotEmpty(recordContentDTOS)) {
|
|
|
+ for (RecordContentDTO recordContentDTO : recordContentDTOS) {
|
|
|
+ objectMap = MapUtil.objectToMap(recordContentDTO);
|
|
|
+ objectFile.add(objectMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(keyList) && keyList.size() == 3) {
|
|
|
+ List<RecordContentDTO> recordContentList = recMap.get("会诊申请单");
|
|
|
+ for (RecordContentDTO contentDTO : recordContentList) {
|
|
|
+ applyMap = MapUtil.objectToMap(contentDTO);
|
|
|
+ applyFile.add(applyMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (MedrecVo medrec : medrecVoList) {
|
|
|
+ if (key.equals(medrec.getTitle())) {
|
|
|
+ Map<String, Object> keyContent = medrec.getContent();
|
|
|
+ if (ListUtil.isNotEmpty(keyList) && keyList.size() == 3) {
|
|
|
+ if (Map.get("会诊申请单") != null && Map.get("会诊结果单") == null && !applyFile.isEmpty()) {
|
|
|
+ specialContent.put(keyTagert, applyFile);
|
|
|
+ } else if (Map.get("会诊结果单") != null && !objectFile.isEmpty()) {
|
|
|
+ specialContent.put(keyTagert, objectFile);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (!objectFile.isEmpty()) {
|
|
|
+ specialContent.put(keyTagert, objectFile);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ mapList = JSON.parseObject(JSON.toJSONString(keyContent.get("content")), new TypeReference<List<Map<String, Object>>>() {
|
|
|
+ });
|
|
|
+ if (!specialContent.isEmpty()) {
|
|
|
+ mapList.add(specialContent);
|
|
|
+ keyContent.put("content", mapList);
|
|
|
+ flag = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!flag) {
|
|
|
+ if (ListUtil.isNotEmpty(keyList) && keyList.size() == 3) {
|
|
|
+ if (Map.get("会诊申请单") != null && Map.get("会诊结果单") == null && !applyFile.isEmpty()) {
|
|
|
+ specialContent.put(keyTagert, applyFile);
|
|
|
+ } else if (Map.get("会诊结果单") != null && !objectFile.isEmpty()) {
|
|
|
+ specialContent.put(keyTagert, objectFile);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (!objectFile.isEmpty()) {
|
|
|
+ specialContent.put(keyTagert, objectFile);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!specialContent.isEmpty()) {
|
|
|
+ returnData.add(specialContent);
|
|
|
+ content.put("content", returnData);
|
|
|
+ medrecVo.setTitle(m);
|
|
|
+ medrecVo.setContent(content);
|
|
|
+ medrecVoList.add(medrecVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 拼接数据(例如:手术)
|
|
|
*
|
|
@@ -998,12 +1127,6 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
|
|
|
if ("病重通知单".equals(key)) {
|
|
|
k = "病重通知书";
|
|
|
}
|
|
|
- if ("术后首程".equals(key)) {
|
|
|
- k = "术后首次病程及谈话记录";
|
|
|
- }
|
|
|
- if ("术前讨论小结".equals(key)) {
|
|
|
- k = "术前讨论、术前小结";
|
|
|
- }
|
|
|
if ("输血记录".equals(key)) {
|
|
|
k = "输血/血制品病程记录";
|
|
|
}
|
|
@@ -1053,6 +1176,85 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 1.5.0拼接数据(手术、会诊)
|
|
|
+ *
|
|
|
+ * @param key
|
|
|
+ * @param list
|
|
|
+ * @param medrecVoList
|
|
|
+ */
|
|
|
+ public <T> void specialData(String key, List<T> list, Map<String, List<RecordContentDTO>> recMap, List<MedrecVo> medrecVoList, String keyTagert) {
|
|
|
+ MedrecVo medrecVo = new MedrecVo();
|
|
|
+ Map<String, Object> content = new HashMap<String, Object>();
|
|
|
+ Map<String, Object> specialContent = new HashMap<String, Object>();
|
|
|
+ List<Map<String, Object>> specialFile = new ArrayList<>();
|
|
|
+ List<RePlaceData> contents = new ArrayList<>();
|
|
|
+ List<Map<String, Object>> returnData = new ArrayList<>();
|
|
|
+ //从结构化表中取出应用数据
|
|
|
+ for (T bean : list) {
|
|
|
+ try {
|
|
|
+ RePlaceData rePlaceData = new RePlaceData();
|
|
|
+ Map<String, Object> objectMap = MapUtil.objectToMap(bean);
|
|
|
+ String recId = (String) objectMap.get("recId");
|
|
|
+ rePlaceData.setRecId(recId);
|
|
|
+ Long hospitalId = (Long) objectMap.get("hospitalId");
|
|
|
+ rePlaceData.setHospitalId(hospitalId);
|
|
|
+ String jsonData = (String) objectMap.get("wholeData");
|
|
|
+ rePlaceData.setJsonData(jsonData);
|
|
|
+ contents.add(rePlaceData);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //将文书xml替换成结构化数据
|
|
|
+ if (ListUtil.isNotEmpty(recMap.get(keyTagert))) {
|
|
|
+ Boolean flag = true;
|
|
|
+ List<RecordContentDTO> recordContentDTOS = recMap.get(keyTagert);
|
|
|
+ for (RecordContentDTO recordContentDTO : recordContentDTOS) {
|
|
|
+ if (ListUtil.isNotEmpty(contents)) {
|
|
|
+ for (RePlaceData rePlaceData : contents) {
|
|
|
+ if (StringUtil.isNotEmpty(recordContentDTO.getRecId()) &&
|
|
|
+ rePlaceData.getRecId().equals(recordContentDTO.getRecId()) &&
|
|
|
+ rePlaceData.getHospitalId().equals(recordContentDTO.getHospitalId())) {
|
|
|
+ recordContentDTO.setXmlText(rePlaceData.getJsonData());
|
|
|
+ recordContentDTO.setIsParsed(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ Map<String, Object> objectMap = MapUtil.objectToMap(recordContentDTO);
|
|
|
+ specialFile.add(objectMap);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (MedrecVo medrec : medrecVoList) {
|
|
|
+ if (key.equals(medrec.getTitle())) {
|
|
|
+ Map<String, Object> keyContent = medrec.getContent();
|
|
|
+ specialContent.put(keyTagert, specialFile);
|
|
|
+ try {
|
|
|
+ List<Map<String, Object>> mapList = JSON.parseObject(JSON.toJSONString(keyContent.get("content")), new TypeReference<List<Map<String, Object>>>() {
|
|
|
+ });
|
|
|
+ mapList.add(specialContent);
|
|
|
+ keyContent.put("content", mapList);
|
|
|
+ flag = false;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (flag) {
|
|
|
+ medrecVo.setTitle(key);
|
|
|
+ specialContent.put(keyTagert, specialFile);
|
|
|
+ returnData.add(specialContent);
|
|
|
+ content.put("content", returnData);
|
|
|
+ medrecVo.setContent(content);
|
|
|
+ medrecVoList.add(medrecVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 拼接数据,从数据字典获取信息转换
|
|
|
*
|
|
@@ -1381,7 +1583,12 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
|
|
|
Long hospitalId = analyzeVO.getHospitalId();
|
|
|
|
|
|
// 处理公共数据
|
|
|
- QueryVo queryVo = dealCommonData(hospitalId, analyzeVO);
|
|
|
+ QueryVo queryVo = null;
|
|
|
+ try {
|
|
|
+ queryVo = dealCommonData(hospitalId, analyzeVO);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(),e);
|
|
|
+ }
|
|
|
// 调用质控接口
|
|
|
Response<OutputInfo> response = qcServiceClient.extract(queryVo);
|
|
|
if (response == null || response.getData() == null) {
|