|
@@ -1,23 +1,39 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.diagbot.client.QcServiceClient;
|
|
|
import com.diagbot.dto.BehospitalInfoDTO;
|
|
|
import com.diagbot.dto.OutputInfo;
|
|
|
import com.diagbot.dto.QcCasesEntryDTO;
|
|
|
+import com.diagbot.dto.RecordContentDTO;
|
|
|
import com.diagbot.dto.Response;
|
|
|
+import com.diagbot.entity.DoctorAdvice;
|
|
|
+import com.diagbot.entity.HomeDiagnoseInfo;
|
|
|
+import com.diagbot.entity.HomeOperationInfo;
|
|
|
+import com.diagbot.entity.HomePage;
|
|
|
+import com.diagbot.enums.IsDeleteEnum;
|
|
|
import com.diagbot.service.impl.BehospitalInfoServiceImpl;
|
|
|
+import com.diagbot.util.BeanUtil;
|
|
|
+import com.diagbot.util.EntityUtil;
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
import com.diagbot.util.SysUserUtils;
|
|
|
import com.diagbot.vo.AnalyzeVO;
|
|
|
import com.diagbot.vo.BehospitalPageVO;
|
|
|
+import com.diagbot.vo.MedrecVo;
|
|
|
import com.diagbot.vo.QueryVo;
|
|
|
+import com.diagbot.vo.RecordContentVO;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Description:
|
|
@@ -30,11 +46,23 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
|
|
|
@Autowired
|
|
|
QcServiceClient qcServiceClient;
|
|
|
@Autowired
|
|
|
+ DoctorAdviceFacade doctorAdviceFacade;
|
|
|
+ @Autowired
|
|
|
+ HomePageFacade homePageFacade;
|
|
|
+ @Autowired
|
|
|
private QcCasesEntryFacade qcCasesEntryFacade;
|
|
|
+ @Autowired
|
|
|
+ HomeDiagnoseInfoFacade homeDiagnoseInfoFacade;
|
|
|
+ @Autowired
|
|
|
+ HomeOperationInfoFacade homeOperationInfoFacade;
|
|
|
+ @Autowired
|
|
|
+ MedicalRecordFacade medicalRecordFacade;
|
|
|
+ @Autowired
|
|
|
+ BasHospitalInfoFacade basHospitalInfoFacade;
|
|
|
|
|
|
public IPage<BehospitalInfoDTO> pageFac(BehospitalPageVO behospitalPageVO) {
|
|
|
|
|
|
- behospitalPageVO.setHospitalId(SysUserUtils.getCurrentHospitalID());
|
|
|
+ behospitalPageVO.setHospitalId(Long.parseLong(SysUserUtils.getCurrentHospitalID()));
|
|
|
IPage<BehospitalInfoDTO> res = getPage(behospitalPageVO);
|
|
|
List<BehospitalInfoDTO> behospitalInfoDTOList = res.getRecords();
|
|
|
for (BehospitalInfoDTO behospitalInfo : behospitalInfoDTOList) {
|
|
@@ -48,15 +76,85 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
|
|
|
|
|
|
public Map<String, Object> analyze(AnalyzeVO analyzeVO) {
|
|
|
|
|
|
- //获取质控条目
|
|
|
+// Long hospitalId = Long.parseLong(SysUserUtils.getCurrentHospitalID());
|
|
|
+ Long hospitalId = 1L; // 写死
|
|
|
+ analyzeVO.setHospitalId(hospitalId);
|
|
|
+ // 获取质控条目
|
|
|
List<QcCasesEntryDTO> qcCasesEntryDTOList = qcCasesEntryFacade.getQcCasesEntry(analyzeVO);
|
|
|
|
|
|
// TODO 获取病历所有数据
|
|
|
+ // 获取文书信息
|
|
|
+ RecordContentVO recordContentVO = new RecordContentVO();
|
|
|
+ BeanUtil.copyProperties(analyzeVO, recordContentVO);
|
|
|
+ List<RecordContentDTO> recordContentDTOList = medicalRecordFacade.getRecordContentFac(recordContentVO);
|
|
|
+ Map<String, List<RecordContentDTO>> recMap = EntityUtil.makeEntityListMap(recordContentDTOList, "standModelName");
|
|
|
+
|
|
|
+ // 获取医嘱
|
|
|
+ List<DoctorAdvice> doctorAdviceList = doctorAdviceFacade.list(new QueryWrapper<DoctorAdvice>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id", hospitalId)
|
|
|
+ .eq("behospital_code", analyzeVO.getBehospitalCode())
|
|
|
+ );
|
|
|
|
|
|
- // TODO 拼接数据
|
|
|
+ // 获取病案首页
|
|
|
+ HomePage homePage = homePageFacade.getOne(new QueryWrapper<HomePage>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id", hospitalId)
|
|
|
+ .eq("behospital_code", analyzeVO.getBehospitalCode()), false
|
|
|
+ );
|
|
|
|
|
|
- // TODO 调用质控接口
|
|
|
+ if (homePage != null) {
|
|
|
+ // 获取首页出院诊断、病理诊断
|
|
|
+ List<HomeDiagnoseInfo> homePageList = homeDiagnoseInfoFacade.list(new QueryWrapper<HomeDiagnoseInfo>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id", hospitalId)
|
|
|
+ .eq("home_page_id", homePage.getHomePageId())
|
|
|
+ );
|
|
|
+
|
|
|
+ // 获取首页手术信息
|
|
|
+ List<HomeOperationInfo> homeOperationInfoList = homeOperationInfoFacade.list(new QueryWrapper<HomeOperationInfo>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id", hospitalId)
|
|
|
+ .eq("home_page_id", homePage.getHomePageId())
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ // 拼接数据
|
|
|
+ String hosCode = basHospitalInfoFacade.getHosCode(hospitalId);
|
|
|
QueryVo queryVo = new QueryVo();
|
|
|
+ queryVo.setCid(hosCode); // 设置医院编码
|
|
|
+ queryVo.setInputCatalogueMap(getInputCatalogueMap(qcCasesEntryDTOList)); // 设置质控条目编码
|
|
|
+ List<MedrecVo> medrecVoList = new ArrayList<>(); // 设置内容
|
|
|
+
|
|
|
+ addData("入院记录", recMap, medrecVoList);
|
|
|
+ addData("病危通知书", recMap, medrecVoList);
|
|
|
+ addData("阶段小结", recMap, medrecVoList);
|
|
|
+ addData("抢救记录", recMap, medrecVoList);
|
|
|
+ addData("查房记录", recMap, medrecVoList);
|
|
|
+ addData("首次病程录", recMap, medrecVoList);
|
|
|
+ addData("输血/血制品病程记录", recMap, medrecVoList);
|
|
|
+ addData("输血后效果评价", recMap, medrecVoList);
|
|
|
+ addData("死亡病例讨论记录", recMap, medrecVoList);
|
|
|
+ addData("死亡记录", recMap, medrecVoList);
|
|
|
+ addData("危急值记录", recMap, medrecVoList);
|
|
|
+
|
|
|
+ // 会诊记录
|
|
|
+ addDataWithKey("会诊记录", recMap, medrecVoList,
|
|
|
+ Arrays.asList("会诊记录", "会诊结果单", "会诊申请单"));
|
|
|
+
|
|
|
+ // 手术
|
|
|
+ addDataWithKey("手术", recMap, medrecVoList,
|
|
|
+ Arrays.asList("术后首次病程及谈话记录", "手术记录",
|
|
|
+ "术前讨论、术前小结", "手术知情同意书", "手术安全核查表"));
|
|
|
+
|
|
|
+
|
|
|
+ // 医嘱
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ queryVo.setMedrec(medrecVoList); // 设置
|
|
|
+
|
|
|
+ // 调用质控接口
|
|
|
Response<OutputInfo> response = qcServiceClient.extract(queryVo);
|
|
|
|
|
|
// 评分,保存
|
|
@@ -65,6 +163,94 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 拼接数据
|
|
|
+ *
|
|
|
+ * @param key
|
|
|
+ * @param recMap
|
|
|
+ * @param medrecVoList
|
|
|
+ */
|
|
|
+ public void addData(String key, Map<String, List<RecordContentDTO>> recMap, List<MedrecVo> medrecVoList) {
|
|
|
+ List<RecordContentDTO> list = recMap.get(key);
|
|
|
+ Map<String, List<String>> listMap = new HashMap<>();
|
|
|
+ if (ListUtil.isNotEmpty(list)) {
|
|
|
+ MedrecVo medrecVo = new MedrecVo();
|
|
|
+ medrecVo.setTitle(key);
|
|
|
+ Map<String, Object> content = new HashMap<>();
|
|
|
+ content.put("content", list.stream().map(r -> r.getContentText()).collect(Collectors.toList()));
|
|
|
+ medrecVo.setContent(content);
|
|
|
+ medrecVoList.add(medrecVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 拼接数据(例如:手术)
|
|
|
+ *
|
|
|
+ * @param key
|
|
|
+ * @param recMap
|
|
|
+ * @param medrecVoList
|
|
|
+ */
|
|
|
+ public void addDataWithKey(String key, Map<String, List<RecordContentDTO>> recMap,
|
|
|
+ List<MedrecVo> medrecVoList, List<String> keyList) {
|
|
|
+ MedrecVo medrecVo = new MedrecVo();
|
|
|
+ medrecVo.setTitle(key);
|
|
|
+ Map<String, Object> content = new HashMap<>();
|
|
|
+ Map<String, List<String>> listMap = new HashMap<>();
|
|
|
+ Boolean flag = false;
|
|
|
+ for (String k : keyList) {
|
|
|
+ if (ListUtil.isNotEmpty(recMap.get(k))) {
|
|
|
+ listMap.put(k, recMap.get(k).stream().map(r -> r.getContentText()).collect(Collectors.toList()));
|
|
|
+ flag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (flag) {
|
|
|
+ content.put("content", listMap);
|
|
|
+ medrecVo.setContent(content);
|
|
|
+ medrecVoList.add(medrecVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 拼接医嘱数据
|
|
|
+ *
|
|
|
+ * @param key
|
|
|
+ * @param doctorAdviceList
|
|
|
+ * @param medrecVoList
|
|
|
+ */
|
|
|
+ public void addDataWithDocAdv(String key, List<DoctorAdvice> doctorAdviceList, List<MedrecVo> medrecVoList) {
|
|
|
+ if (ListUtil.isNotEmpty(doctorAdviceList)) {
|
|
|
+ MedrecVo medrecVo = new MedrecVo();
|
|
|
+ medrecVo.setTitle(key);
|
|
|
+ Map<String, Object> content = new HashMap<>();
|
|
|
+ // TODO 医嘱信息
|
|
|
+// content.put("content", list.stream().map(r -> r.getContentText()).collect(Collectors.toList()));
|
|
|
+ medrecVo.setContent(content);
|
|
|
+ medrecVoList.add(medrecVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取质控条目编码
|
|
|
+ *
|
|
|
+ * @param qcCasesEntryDTOList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String, Map<String, String>> getInputCatalogueMap(List<QcCasesEntryDTO> qcCasesEntryDTOList) {
|
|
|
+ Map<String, Map<String, String>> res = new HashMap<>();
|
|
|
+ for (QcCasesEntryDTO qc : qcCasesEntryDTOList) {
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("code", qc.getCode());
|
|
|
+ map.put("precond", null);
|
|
|
+ map.put("name", qc.getMsg());
|
|
|
+ res.put(qc.getCode(), map);
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 通过日期计算年龄
|
|
|
*
|