|
@@ -0,0 +1,121 @@
|
|
|
|
+package com.diagbot.facade;
|
|
|
|
+
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.diagbot.biz.push.entity.Lis;
|
|
|
|
+import com.diagbot.entity.TranLisConfigIcss;
|
|
|
|
+import com.diagbot.enums.IsDeleteEnum;
|
|
|
|
+import com.diagbot.icss5.LisConfigVO;
|
|
|
|
+import com.diagbot.icss5.LisSourceEnum;
|
|
|
|
+import com.diagbot.service.impl.TranLisConfigIcssServiceImpl;
|
|
|
|
+import com.diagbot.util.BeanUtil;
|
|
|
|
+import com.diagbot.util.EntityUtil;
|
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
|
+import com.google.common.collect.Lists;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
+
|
|
|
|
+import java.util.LinkedHashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @author kwz
|
|
|
|
+ * @date 2020/11/17
|
|
|
|
+ * @time 15:25
|
|
|
|
+ * ICSS 化验转换
|
|
|
|
+ */
|
|
|
|
+@Component
|
|
|
|
+public class TranLisConfigIcssFacade {
|
|
|
|
+ @Autowired
|
|
|
|
+ TranLisConfigIcssServiceImpl tranLisConfigIcssService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据医院编码获取化验公表映射关系 Map<mealName,Map<itemName,List<uniqueName>>>
|
|
|
|
+ *
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public Map<String, Map<String, List<String>>> getLisConfigByMealNameAndHosCode(LisConfigVO lisConfigVO) {
|
|
|
|
+ Map<String, Map<String, List<String>>> retMap = new LinkedHashMap<>();
|
|
|
|
+ QueryWrapper<TranLisConfigIcss> lisConfigIcssQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ lisConfigIcssQueryWrapper
|
|
|
|
+ .select("hospital_code,meal_name,ifnull(item_name,'') as item_name,unique_name,unique_id")
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("hospital_code", lisConfigVO.getHosCode());
|
|
|
|
+ if (ListUtil.isNotEmpty(lisConfigVO.getMealNameList())) {
|
|
|
|
+ lisConfigIcssQueryWrapper.in("meal_name", lisConfigVO.getMealNameList());
|
|
|
|
+ }
|
|
|
|
+ List<TranLisConfigIcss> lisConfigList = tranLisConfigIcssService.list(lisConfigIcssQueryWrapper);
|
|
|
|
+ Map<String, List<TranLisConfigIcss>> lisConfigMap
|
|
|
|
+ = EntityUtil.makeEntityListMap(lisConfigList, "mealName");
|
|
|
|
+ for (Map.Entry<String, List<TranLisConfigIcss>> entry : lisConfigMap.entrySet()) {
|
|
|
|
+ if (entry.getValue().size() > 0) {
|
|
|
|
+ Map<String, List<TranLisConfigIcss>> itemMap
|
|
|
|
+ = EntityUtil.makeEntityListMap(entry.getValue(), "itemName");
|
|
|
|
+ Map<String, List<String>> itemNameMap = new LinkedHashMap<>();
|
|
|
|
+ for (Map.Entry<String, List<TranLisConfigIcss>> itemEntry : itemMap.entrySet()) {
|
|
|
|
+ if (ListUtil.isNotEmpty(itemEntry.getValue())) {
|
|
|
|
+ itemNameMap.put(itemEntry.getKey(), itemEntry
|
|
|
|
+ .getValue()
|
|
|
|
+ .stream()
|
|
|
|
+ .map(lisConfig -> lisConfig.getUniqueName())
|
|
|
|
+ .collect(Collectors.toList()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ retMap.put(entry.getKey(), itemNameMap);
|
|
|
|
+ } else {
|
|
|
|
+ retMap.put(entry.getKey(), null);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return retMap;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 化验结果增加公表名
|
|
|
|
+ *
|
|
|
|
+ * @param lis
|
|
|
|
+ * @param hosCode
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public List<Lis> addLisUniqueName(List<Lis> lis, String hosCode) {
|
|
|
|
+ if (ListUtil.isEmpty(lis)) {
|
|
|
|
+ return Lists.newLinkedList();
|
|
|
|
+ }
|
|
|
|
+ List<Lis> retLis = Lists.newLinkedList();
|
|
|
|
+ //化验项转公表内容,参数处理
|
|
|
|
+ List<String> mealNameList = lis
|
|
|
|
+ .stream()
|
|
|
|
+ .map(lisResult -> lisResult.getName()).collect(Collectors.toList());
|
|
|
|
+ LisConfigVO lisConfigVO = new LisConfigVO();
|
|
|
|
+ lisConfigVO.setHosCode(hosCode);
|
|
|
|
+ lisConfigVO.setMealNameList(mealNameList);
|
|
|
|
+ Map<String, Map<String, List<String>>> lisConfigMap = getLisConfigByMealNameAndHosCode(lisConfigVO);
|
|
|
|
+ for (Lis lisResult : lis) {
|
|
|
|
+ lisResult.setSource(1);
|
|
|
|
+ //内部数据,获取标签时映射, 不二次映射
|
|
|
|
+ if (lisResult.getSource() == null || lisResult.getSource().equals(LisSourceEnum.Inner.getKey())) {
|
|
|
|
+ retLis.add(lisResult);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if (lisResult.getDetailName() == null) {
|
|
|
|
+ lisResult.setDetailName("");
|
|
|
|
+ }
|
|
|
|
+ Map<String, List<String>> itemMap = lisConfigMap.get(lisResult.getName());
|
|
|
|
+ if (itemMap != null) {
|
|
|
|
+ List<String> uniqueNameList = itemMap.get(lisResult.getDetailName());
|
|
|
|
+ if (ListUtil.isNotEmpty(uniqueNameList)) {
|
|
|
|
+ //化验公表映射出多项时,拆分成多个公表项数据,指标值保持一致
|
|
|
|
+ for (String uniqueName : uniqueNameList) {
|
|
|
|
+ Lis lisResult_new = new Lis();
|
|
|
|
+ BeanUtil.copyProperties(lisResult, lisResult_new);
|
|
|
|
+ lisResult_new.setUniqueName(uniqueName);
|
|
|
|
+ retLis.add(lisResult_new);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ retLis.add(lisResult);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return retLis;
|
|
|
|
+ }
|
|
|
|
+}
|