소스 검색

病案首页数据拼接

zhoutg 5 년 전
부모
커밋
6736e5f3f6
2개의 변경된 파일50개의 추가작업 그리고 19개의 파일을 삭제
  1. 48 19
      src/main/java/com/diagbot/facade/BehospitalInfoFacade.java
  2. 2 0
      src/main/java/com/diagbot/web/BehospitalInfoController.java

+ 48 - 19
src/main/java/com/diagbot/facade/BehospitalInfoFacade.java

@@ -5,8 +5,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.client.QcServiceClient;
 import com.diagbot.dto.AlgorithmDTO;
-import com.diagbot.dto.BehosDTO;
 import com.diagbot.dto.AnalyzeDTO;
+import com.diagbot.dto.BehosDTO;
 import com.diagbot.dto.BehospitalInfoDTO;
 import com.diagbot.dto.MsgDTO;
 import com.diagbot.dto.OutputInfo;
@@ -24,6 +24,7 @@ import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
 import com.diagbot.service.impl.BehospitalInfoServiceImpl;
 import com.diagbot.util.BeanUtil;
+import com.diagbot.util.DateUtil;
 import com.diagbot.util.EntityUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.MapUtil;
@@ -204,7 +205,10 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
                         "术前讨论、术前小结", "手术知情同意书", "手术安全核查表"));
 
         // 医嘱
-        addDataWithKeyConvert("医嘱信息", doctorAdviceList, medrecVoList, dicMap.get("1"));
+        if (ListUtil.isNotEmpty(doctorAdviceList)) {
+            addDataWithKeyConvert("医嘱信息", doctorAdviceList, medrecVoList,
+                    dicMap.get("1"), Arrays.asList("daStartDate", "daStopDate"));
+        }
 
         // 病案首页
         addDataWithFirstPage("病案首页",  homePage, medrecVoList, dicMap,
@@ -312,10 +316,9 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
      * @param map
      */
     public void addDataWithKeyConvert(String key,  List<DoctorAdvice> list,
-                               List<MedrecVo> medrecVoList, Map<String, String> map) {
+                               List<MedrecVo> medrecVoList, Map<String, String> map, List<String> dateList) {
         MedrecVo medrecVo = new MedrecVo();
         medrecVo.setTitle(key);
-
         Map<String, Object> content = new HashMap<>();
         List<String> contents = new ArrayList<>();
 
@@ -325,7 +328,12 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
                 Map<String, Object> objectMap = MapUtil.objectToMap(doctorAdvice);
                 for (String objKey : objectMap.keySet()) {
                     if (map.get(objKey) != null) {
-                        res.put(map.get(objKey), String.valueOf(objectMap.get(objKey)));
+                        if (dateList.contains(objKey)) {
+                            Date date = (Date)objectMap.get(objKey);
+                            res.put(map.get(objKey), DateUtil.formatDateTime(date).replaceAll("null", ""));
+                        } else {
+                            res.put(map.get(objKey), String.valueOf(objectMap.get(objKey)).replaceAll("null", ""));
+                        }
                     }
                 }
                 String jsonStr = JSON.toJSONString(res);
@@ -341,6 +349,29 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
     }
 
 
+    /**
+     * 对象key转换
+     *
+     * @param dateList
+     * @param dicMap
+     * @param objectMap
+     * @return
+     */
+    public Map<String, Object> objcetKeyConvert(List<String> dateList, Map<String, String> dicMap, Map<String, Object> objectMap) {
+        Map<String, Object> res = new HashMap<>();
+        for (String objKey : objectMap.keySet()) {
+            if (dicMap.containsKey(objKey)) {
+                if (dateList.contains(objKey)) {
+                    Date date = (Date)objectMap.get(objKey);
+                    res.put(dicMap.get(objKey), DateUtil.formatDateTime(date).replaceAll("null", ""));
+                } else {
+                    res.put(dicMap.get(objKey), String.valueOf(objectMap.get(objKey)).replaceAll("null", ""));
+                }
+            }
+        }
+        return res;
+    }
+
     /**
      * 拼接数据(病案首页),从数据字典获取信息转换
      * @param key
@@ -359,9 +390,15 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
         Map<String, Object> content = new HashMap<>();
         try {
             Map<String, Object> objectMap = MapUtil.objectToMap(homePage);
+            List<String> firstPageDate = Arrays.asList("birthday", "behospitalDate", "leaveHospitalDate", "qcDate");
             for (String objKey : objectMap.keySet()) {
                 if (map.containsKey(objKey)) {
-                    content.put(map.get(objKey), String.valueOf(objectMap.get(objKey)));
+                    if (firstPageDate.contains(objKey)) {
+                        Date date = (Date)objectMap.get(objKey);
+                        content.put(map.get(objKey), DateUtil.formatDateTime(date).replaceAll("null", ""));
+                    } else {
+                        content.put(map.get(objKey), String.valueOf(objectMap.get(objKey)).replaceAll("null", ""));
+                    }
                 }
             }
 
@@ -369,15 +406,11 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
             if (ListUtil.isNotEmpty(homeOperationInfoList)) {
                 Map<String, String> dic3 = dicMap.get("3"); // 病案首页手术信息
                 List<Map> mapList = new ArrayList<>();
+                List<String> operatDate = Arrays.asList("operationDate");
                 for (HomeOperationInfo homeOperationInfo : homeOperationInfoList) {
                     try {
-                        Map<String, Object> objectMapOpe = MapUtil.objectToMap(homeOperationInfo);
-                        for (String objKey : objectMapOpe.keySet()) {
-                            if (dic3.get(objKey) != null) {
-                                objectMapOpe.put(dic3.get(objKey) ,objectMapOpe.remove(objKey)); // 替换
-                            }
-                        }
-                        mapList.add(objectMapOpe);
+                        Map operatMap = objcetKeyConvert(operatDate, dic3, MapUtil.objectToMap(homeOperationInfo));
+                        mapList.add(operatMap);
                     } catch (Exception e) {
                         e.printStackTrace();
                     }
@@ -389,14 +422,10 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
             if (ListUtil.isNotEmpty(homeDiagnoseInfoList)) {
                 Map<String, String> dic4 = dicMap.get("4"); // 病案首页诊断信息
                 List<Map> mapList = new ArrayList<>();
+                List<String> diagnoseDate = Arrays.asList("");
                 for (HomeDiagnoseInfo homeDiagnoseInfo : homeDiagnoseInfoList) {
                     try {
-                        Map<String, Object> objectMapDiag = MapUtil.objectToMap(homeDiagnoseInfo);
-                        for (String objKey : objectMapDiag.keySet()) {
-                            if (dic4.get(objKey) != null) {
-                                objectMapDiag.put(dic4.get(objKey) ,objectMapDiag.remove(objKey)); // 替换
-                            }
-                        }
+                        Map objectMapDiag = objcetKeyConvert(diagnoseDate, dic4, MapUtil.objectToMap(homeDiagnoseInfo));
                         mapList.add(objectMapDiag);
                     } catch (Exception e) {
                         e.printStackTrace();

+ 2 - 0
src/main/java/com/diagbot/web/BehospitalInfoController.java

@@ -14,6 +14,7 @@ import com.diagbot.vo.QcresultVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -67,6 +68,7 @@ public class BehospitalInfoController {
             notes = "")
     @PostMapping("/analyze")
     @SysLogger("analyze")
+    @Transactional
     public RespDTO<AnalyzeDTO> analyze(@RequestBody AnalyzeVO analyzeVO) {
         return RespDTO.onSuc(behospitalInfoFacade.analyze(analyzeVO));
     }