|
@@ -0,0 +1,157 @@
|
|
|
+package com.diagbot.facade;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.diagbot.biz.push.entity.Item;
|
|
|
+import com.diagbot.dto.PushPlanDTO;
|
|
|
+import com.diagbot.dto.PushPlanDetailDTO;
|
|
|
+import com.diagbot.dto.PushPlansDTO;
|
|
|
+import com.diagbot.entity.FollowupPlanDetail;
|
|
|
+import com.diagbot.entity.FollowupPlanDetailHospital;
|
|
|
+import com.diagbot.entity.FollowupPlanInfo;
|
|
|
+import com.diagbot.enums.IsDeleteEnum;
|
|
|
+import com.diagbot.exception.CommonErrorCode;
|
|
|
+import com.diagbot.exception.CommonException;
|
|
|
+import com.diagbot.service.impl.FollowupPlanInfoServiceImpl;
|
|
|
+import com.diagbot.util.DateUtil;
|
|
|
+import com.diagbot.util.EntityUtil;
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
+import com.diagbot.util.StringUtil;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description:
|
|
|
+ * @Author:zhaops
|
|
|
+ * @time: 2020/9/18 15:39
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class FollowupPlanInfoFacade extends FollowupPlanInfoServiceImpl {
|
|
|
+ @Autowired
|
|
|
+ FollowupPlanDetailFacade followupPlanDetailFacade;
|
|
|
+ @Autowired
|
|
|
+ FollowupPlanDetailHospitalFacade followupPlanDetailHospitalFacade;
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param operationName
|
|
|
+ * @param hospitalId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public PushPlanDTO getFollowUpPlans(Item operationName, Long hospitalId) {
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ PushPlanDTO pushPlanDTO = new PushPlanDTO();
|
|
|
+ List<PushPlansDTO> pushPlans = new ArrayList<>();
|
|
|
+ if (operationName == null
|
|
|
+ || StringUtil.isBlank(operationName.getUniqueName())
|
|
|
+ || StringUtil.isBlank(operationName.getDateValue())) {
|
|
|
+ return pushPlanDTO;
|
|
|
+ }
|
|
|
+ Date date = null;
|
|
|
+ try {
|
|
|
+ date = dateFormat.parse(operationName.getDateValue());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_ERROR, "开单日期格式错误,请转成(yyyy-MM-dd HH:mm:ss)格式");
|
|
|
+ }
|
|
|
+
|
|
|
+ PushPlansDTO pushPlansDTO = new PushPlansDTO();
|
|
|
+ pushPlansDTO.setItem(operationName);
|
|
|
+ List<PushPlanDetailDTO> pushPlanDetails = Lists.newLinkedList();
|
|
|
+
|
|
|
+ QueryWrapper<FollowupPlanInfo> followupPlanInfoQueryWrapper = new QueryWrapper<>();
|
|
|
+ followupPlanInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("operation_name", operationName.getUniqueName());
|
|
|
+ FollowupPlanInfo followupPlanInfo = this.getOne(followupPlanInfoQueryWrapper, false);
|
|
|
+ if (followupPlanInfo != null) {
|
|
|
+ List<FollowupPlanDetailHospital> followupPlanDetailHospitalList = Lists.newLinkedList();
|
|
|
+ List<FollowupPlanDetail> followupPlanDetailList = Lists.newLinkedList();
|
|
|
+ Map<String, Map<String, List<String>>> itemMap = new HashMap<>();
|
|
|
+ if (hospitalId != null) {
|
|
|
+ QueryWrapper<FollowupPlanDetailHospital> followupPlanDetailHospitalQueryWrapper = new QueryWrapper<>();
|
|
|
+ followupPlanDetailHospitalQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id", hospitalId)
|
|
|
+ .eq("follow_up_plan_id", followupPlanInfo.getId())
|
|
|
+ .orderByAsc("interval_month", "order_no");
|
|
|
+ followupPlanDetailHospitalList = followupPlanDetailHospitalFacade.list(followupPlanDetailHospitalQueryWrapper);
|
|
|
+ }
|
|
|
+ if (ListUtil.isEmpty(followupPlanDetailHospitalList)) {
|
|
|
+ QueryWrapper<FollowupPlanDetail> followupPlanDetailQueryWrapper = new QueryWrapper<>();
|
|
|
+ followupPlanDetailQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("follow_up_plan_id", followupPlanInfo.getId())
|
|
|
+ .orderByAsc("interval_month", "order_no");
|
|
|
+ followupPlanDetailList = followupPlanDetailFacade.list(followupPlanDetailQueryWrapper);
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(followupPlanDetailHospitalList)) {
|
|
|
+ Map<Integer, List<FollowupPlanDetailHospital>> detailMap
|
|
|
+ = EntityUtil.makeEntityListMap(followupPlanDetailHospitalList, "intervalMonth");
|
|
|
+ for (Map.Entry<Integer, List<FollowupPlanDetailHospital>> entry : detailMap.entrySet()) {
|
|
|
+
|
|
|
+ if (ListUtil.isNotEmpty(entry.getValue())) {
|
|
|
+ PushPlanDetailDTO pushPlanDetailDTO = new PushPlanDetailDTO();
|
|
|
+ pushPlanDetailDTO.setExamineDate(DateUtil.addMonth(date, entry.getKey()));
|
|
|
+ pushPlanDetailDTO.setDescription(entry.getValue().get(0).getFollowUpTime());
|
|
|
+ Map<Integer, List<FollowupPlanDetailHospital>> itemTypeMap
|
|
|
+ = EntityUtil.makeEntityListMap(entry.getValue(), "itemType");
|
|
|
+ //检验
|
|
|
+ if (itemTypeMap.containsKey(1)) {
|
|
|
+ pushPlanDetailDTO.setLis(itemTypeMap.get(1)
|
|
|
+ .stream()
|
|
|
+ .map(i -> i.getItemName())
|
|
|
+ .collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ //检查
|
|
|
+ if (itemTypeMap.containsKey(2)) {
|
|
|
+ pushPlanDetailDTO.setPacs(itemTypeMap.get(2)
|
|
|
+ .stream()
|
|
|
+ .map(i -> i.getItemName())
|
|
|
+ .collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ pushPlanDetails.add(pushPlanDetailDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (ListUtil.isNotEmpty(followupPlanDetailList)) {
|
|
|
+ Map<Integer, List<FollowupPlanDetail>> detailMap
|
|
|
+ = EntityUtil.makeEntityListMap(followupPlanDetailList, "intervalMonth");
|
|
|
+ for (Map.Entry<Integer, List<FollowupPlanDetail>> entry : detailMap.entrySet()) {
|
|
|
+
|
|
|
+ if (ListUtil.isNotEmpty(entry.getValue())) {
|
|
|
+ PushPlanDetailDTO pushPlanDetailDTO = new PushPlanDetailDTO();
|
|
|
+ pushPlanDetailDTO.setExamineDate(DateUtil.addMonth(date, entry.getKey()));
|
|
|
+ pushPlanDetailDTO.setDescription(entry.getValue().get(0).getFollowUpTime());
|
|
|
+ Map<Integer, List<FollowupPlanDetail>> itemTypeMap
|
|
|
+ = EntityUtil.makeEntityListMap(entry.getValue(), "itemType");
|
|
|
+ //检验
|
|
|
+ if (itemTypeMap.containsKey(1)) {
|
|
|
+ pushPlanDetailDTO.setLis(itemTypeMap.get(1)
|
|
|
+ .stream()
|
|
|
+ .map(i -> i.getItemName())
|
|
|
+ .collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ //检查
|
|
|
+ if (itemTypeMap.containsKey(2)) {
|
|
|
+ pushPlanDetailDTO.setPacs(itemTypeMap.get(2)
|
|
|
+ .stream()
|
|
|
+ .map(i -> i.getItemName())
|
|
|
+ .collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ pushPlanDetails.add(pushPlanDetailDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ pushPlansDTO.setPushPlanDetails(pushPlanDetails);
|
|
|
+ pushPlans.add(pushPlansDTO);
|
|
|
+ pushPlanDTO.setPushPlans(pushPlans);
|
|
|
+ return pushPlanDTO;
|
|
|
+ }
|
|
|
+}
|