|
@@ -1,17 +1,5 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
-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;
|
|
|
-
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
-
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.diagbot.dto.IndexDataDTO;
|
|
|
import com.diagbot.dto.ItemIndexDTO;
|
|
@@ -19,15 +7,24 @@ import com.diagbot.entity.IndexData;
|
|
|
import com.diagbot.enums.IsDeleteEnum;
|
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
|
-import com.diagbot.service.IndexDataService;
|
|
|
import com.diagbot.service.impl.IndexDataServiceImpl;
|
|
|
import com.diagbot.util.DateUtil;
|
|
|
import com.diagbot.vo.IndexDataFindVO;
|
|
|
import com.diagbot.vo.IndexDataSaveVO;
|
|
|
import com.diagbot.vo.IndexDataVO;
|
|
|
+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;
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
* @author wangfeng
|
|
|
* @Description: TODO
|
|
|
* @date 2019年3月11日 下午4:20:33
|
|
@@ -35,98 +32,96 @@ import com.diagbot.vo.IndexDataVO;
|
|
|
@Component
|
|
|
public class IndexDataFacade extends IndexDataServiceImpl {
|
|
|
|
|
|
- @Autowired
|
|
|
- IndexDataService indexDataService;
|
|
|
- @Autowired
|
|
|
- IndexConfigFacade indexConfigFacade;
|
|
|
+ @Autowired
|
|
|
+ IndexConfigFacade indexConfigFacade;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据疾病id和用户id,开始时间和结束时间 查询用户指标数据
|
|
|
+ *
|
|
|
+ * @param indexDataFindVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<ItemIndexDTO> getIndexDataAll(IndexDataFindVO indexDataFindVO) {
|
|
|
|
|
|
- /**
|
|
|
- * 根据疾病id和用户id,开始时间和结束时间 查询用户指标数据
|
|
|
- *
|
|
|
- * @param indexDataAllVO
|
|
|
- * @return
|
|
|
- */
|
|
|
- public List<ItemIndexDTO> getIndexDataAll(IndexDataFindVO indexDataFindVO) {
|
|
|
+ Map<String, Object> indexDataMap = new HashMap<>();
|
|
|
+ indexDataMap.put("diseaseId", indexDataFindVO.getDiseaseId());
|
|
|
+ indexDataMap.put("patientId", indexDataFindVO.getPatientId());
|
|
|
+ indexDataMap.put("startTime", indexDataFindVO.getStartTime());
|
|
|
+ indexDataMap.put("endTime", indexDataFindVO.getEndTime());
|
|
|
+ //获取慢病指标数据
|
|
|
+ List<IndexDataDTO> data = this.getIndexDataAll(indexDataMap);
|
|
|
+ List<ItemIndexDTO> list = new ArrayList<ItemIndexDTO>();
|
|
|
+ // 根据公表名分组
|
|
|
+ Map<String, List<IndexDataDTO>> dataMap = data.stream()
|
|
|
+ .collect(Collectors.groupingBy(IndexDataDTO::getIndexUnique));
|
|
|
|
|
|
- Map<String, Object> indexDataMap = new HashMap<>();
|
|
|
- indexDataMap.put("diseaseId", indexDataFindVO.getDiseaseId());
|
|
|
- indexDataMap.put("patientId", indexDataFindVO.getPatientId());
|
|
|
- indexDataMap.put("startTime", indexDataFindVO.getStartTime());
|
|
|
- indexDataMap.put("endTime", indexDataFindVO.getEndTime());
|
|
|
- //获取慢病指标数据
|
|
|
- List<IndexDataDTO> data = indexDataService.getIndexDataAll(indexDataMap);
|
|
|
- List<ItemIndexDTO> list = new ArrayList<ItemIndexDTO>();
|
|
|
- // 根据公表名分组
|
|
|
- Map<String, List<IndexDataDTO>> dataMap = data.stream()
|
|
|
- .collect(Collectors.groupingBy(IndexDataDTO::getIndexUnique));
|
|
|
+ for (String key : dataMap.keySet()) {
|
|
|
+ ItemIndexDTO itemIndexDTO = new ItemIndexDTO();
|
|
|
+ itemIndexDTO.setItemName(key);
|
|
|
+ List<String> indexUnits = new ArrayList<String>();
|
|
|
+ List<String> indexValues = new ArrayList<String>();
|
|
|
+ List<Integer> isAbnormals = new ArrayList<Integer>();
|
|
|
+ List<Date> creatTimes = new ArrayList<Date>();
|
|
|
+ List<IndexDataDTO> indexDatas = dataMap.get(key);
|
|
|
+ for (IndexDataDTO indexDataDTO : indexDatas) {
|
|
|
+ indexUnits.add(indexDataDTO.getIndexUnit());
|
|
|
+ indexValues.add(indexDataDTO.getIndexValue());
|
|
|
+ isAbnormals.add(indexDataDTO.getIsAbnormal());
|
|
|
+ creatTimes.add(indexDataDTO.getCreatTime());
|
|
|
+ }
|
|
|
+ itemIndexDTO.setIndexUnit(indexUnits);
|
|
|
+ itemIndexDTO.setIndexValue(indexValues);
|
|
|
+ itemIndexDTO.setIsAbnormal(isAbnormals);
|
|
|
+ itemIndexDTO.setCreatTime(creatTimes);
|
|
|
+ list.add(itemIndexDTO);
|
|
|
|
|
|
- for (String key : dataMap.keySet()) {
|
|
|
- ItemIndexDTO itemIndexDTO = new ItemIndexDTO();
|
|
|
- itemIndexDTO.setItemName(key);
|
|
|
- List<String> indexUnits = new ArrayList<String>();
|
|
|
- List<String> indexValues = new ArrayList<String>();
|
|
|
- List<Integer> isAbnormals = new ArrayList<Integer>();
|
|
|
- List<Date> creatTimes = new ArrayList<Date>();
|
|
|
- List<IndexDataDTO> indexDatas = dataMap.get(key);
|
|
|
- for (IndexDataDTO indexDataDTO : indexDatas) {
|
|
|
- indexUnits.add(indexDataDTO.getIndexUnit());
|
|
|
- indexValues.add(indexDataDTO.getIndexValue());
|
|
|
- isAbnormals.add(indexDataDTO.getIsAbnormal());
|
|
|
- creatTimes.add(indexDataDTO.getCreatTime());
|
|
|
- }
|
|
|
- itemIndexDTO.setIndexUnit(indexUnits);
|
|
|
- itemIndexDTO.setIndexValue(indexValues);
|
|
|
- itemIndexDTO.setIsAbnormal(isAbnormals);
|
|
|
- itemIndexDTO.setCreatTime(creatTimes);
|
|
|
- list.add(itemIndexDTO);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
- return list;
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 保存指标数据
|
|
|
+ *
|
|
|
+ * @param indexDataSaveVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public boolean saveIndexDatas(IndexDataSaveVO indexDataSaveVO) {
|
|
|
+ // 先查询该用户相同就诊号所保留的数据,将其删除
|
|
|
+ UpdateWrapper<IndexData> IndexDataUpdate = new UpdateWrapper<>();
|
|
|
+ Map<String, Object> mapAll = new HashMap<>();
|
|
|
+ mapAll.put("inquiry_code", indexDataSaveVO.getInquiryCode());
|
|
|
+ mapAll.put("patient_id", indexDataSaveVO.getPatientId());
|
|
|
+ IndexDataUpdate.allEq(mapAll).eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .set("is_deleted", IsDeleteEnum.Y.getKey())
|
|
|
+ // .set("modifier",UserUtils.getCurrentPrincipleID())
|
|
|
+ .set("gmt_modified", DateUtil.now());
|
|
|
+ boolean res = update(new IndexData(), IndexDataUpdate);
|
|
|
|
|
|
- /**
|
|
|
- * 保存指标数据
|
|
|
- *
|
|
|
- * @param indexDataSaveVO
|
|
|
- * @return
|
|
|
- */
|
|
|
- public boolean saveIndexDatas(IndexDataSaveVO indexDataSaveVO) {
|
|
|
- // 先查询该用户相同就诊号所保留的数据,将其删除
|
|
|
- UpdateWrapper<IndexData> IndexDataUpdate = new UpdateWrapper<>();
|
|
|
- Map<String, Object> mapAll = new HashMap<>();
|
|
|
- mapAll.put("inquiry_code", indexDataSaveVO.getInquiryCode());
|
|
|
- mapAll.put("patient_id", indexDataSaveVO.getPatientId());
|
|
|
- IndexDataUpdate.allEq(mapAll).eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .set("is_deleted", IsDeleteEnum.Y.getKey())
|
|
|
- // .set("modifier",UserUtils.getCurrentPrincipleID())
|
|
|
- .set("gmt_modified", DateUtil.now());
|
|
|
- boolean res = update(new IndexData(), IndexDataUpdate);
|
|
|
+ // 遍历数据进行保存
|
|
|
+ List<IndexData> IndexDataList = new ArrayList<IndexData>();
|
|
|
+ List<IndexDataVO> indexDatas = indexDataSaveVO.getIndexData();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ for (IndexDataVO indexDataNew : indexDatas) {
|
|
|
+ IndexData indexData = new IndexData();
|
|
|
+ indexData.setCreator(indexDataSaveVO.getDoctorId().toString());
|
|
|
+ indexData.setGmtCreate(DateUtil.now());
|
|
|
+ indexData.setIndexUnique(indexDataNew.getIndexUnique());
|
|
|
+ try {
|
|
|
+ indexData.setCreatTime(sdf.parse(indexDataNew.getCreatTime()));
|
|
|
+ } catch (ParseException e) {
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "时间格式有误");
|
|
|
+ }
|
|
|
+ indexData.setIndexUnit(indexDataNew.getIndexUnit());
|
|
|
+ indexData.setIndexValue(indexDataNew.getIndexValue());
|
|
|
+ indexData.setInquiryCode(indexDataSaveVO.getInquiryCode());
|
|
|
+ indexData.setIsAbnormal(indexDataNew.getIsAbnormal());
|
|
|
+ indexData.setPatientId(indexDataSaveVO.getPatientId());
|
|
|
+ IndexDataList.add(indexData);
|
|
|
+ }
|
|
|
|
|
|
- // 遍历数据进行保存
|
|
|
- List<IndexData> IndexDataList = new ArrayList<IndexData>();
|
|
|
- List<IndexDataVO> indexDatas = indexDataSaveVO.getIndexData();
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- for (IndexDataVO indexDataNew : indexDatas) {
|
|
|
- IndexData indexData = new IndexData();
|
|
|
- indexData.setCreator(indexDataSaveVO.getDoctorId().toString());
|
|
|
- indexData.setGmtCreate(DateUtil.now());
|
|
|
- indexData.setIndexUnique(indexDataNew.getIndexUnique());
|
|
|
- try {
|
|
|
- indexData.setCreatTime(sdf.parse(indexDataNew.getCreatTime()));
|
|
|
- } catch (ParseException e) {
|
|
|
- throw new CommonException(CommonErrorCode.NOT_EXISTS, "时间格式有误");
|
|
|
- }
|
|
|
- indexData.setIndexUnit(indexDataNew.getIndexUnit());
|
|
|
- indexData.setIndexValue(indexDataNew.getIndexValue());
|
|
|
- indexData.setInquiryCode(indexDataSaveVO.getInquiryCode());
|
|
|
- indexData.setIsAbnormal(indexDataNew.getIsAbnormal());
|
|
|
- indexData.setPatientId(indexDataSaveVO.getPatientId());
|
|
|
- IndexDataList.add(indexData);
|
|
|
- }
|
|
|
+ res = insertIndexDataList(IndexDataList);
|
|
|
|
|
|
- res = insertIndexDataList(IndexDataList);
|
|
|
-
|
|
|
- return res;
|
|
|
- }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
|
|
|
}
|