|
@@ -0,0 +1,254 @@
|
|
|
+package com.diagbot.facade;
|
|
|
+
|
|
|
+import com.diagbot.client.TranServiceClient;
|
|
|
+import com.diagbot.client.bean.HosCodeVO;
|
|
|
+import com.diagbot.dto.LisResult;
|
|
|
+import com.diagbot.dto.PacsResult;
|
|
|
+import com.diagbot.dto.RespDTO;
|
|
|
+import com.diagbot.dto.SysSetInfoDTO;
|
|
|
+import com.diagbot.enums.FeatureTypeEnum;
|
|
|
+import com.diagbot.enums.LisSourceEnum;
|
|
|
+import com.diagbot.enums.SysTypeEnum;
|
|
|
+import com.diagbot.util.BeanUtil;
|
|
|
+import com.diagbot.util.EntityUtil;
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
+import com.diagbot.util.RespDTOUtil;
|
|
|
+import com.diagbot.util.StringUtil;
|
|
|
+import com.diagbot.vo.DiseaseIcdVO;
|
|
|
+import com.diagbot.vo.HospitalSetVO;
|
|
|
+import com.diagbot.vo.LisConfigVO;
|
|
|
+import com.diagbot.vo.PacsConfigVO;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description:
|
|
|
+ * @Author:zhaops
|
|
|
+ * @time: 2019/11/11 14:14
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class TransferFacade {
|
|
|
+ @Autowired
|
|
|
+ private TranServiceClient tranServiceClient;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询对接状态
|
|
|
+ *
|
|
|
+ * @param hosCode
|
|
|
+ * @param sysType
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Boolean isConnect(String hosCode, Integer sysType) {
|
|
|
+ Boolean isConnect = false;
|
|
|
+ if (StringUtil.isNotBlank(hosCode)) {
|
|
|
+ HosCodeVO hosCodeVO = new HosCodeVO();
|
|
|
+ hosCodeVO.setHosCode(hosCode);
|
|
|
+ HospitalSetVO hospitalSetVO = new HospitalSetVO();
|
|
|
+ hospitalSetVO.setHospitalCode(hosCode);
|
|
|
+ hospitalSetVO.setCode("connect");
|
|
|
+ if (sysType != null) {
|
|
|
+ hospitalSetVO.setSysType(sysType);
|
|
|
+ } else {
|
|
|
+ hospitalSetVO.setSysType(SysTypeEnum.AIPT_SERVICE.getKey());
|
|
|
+ }
|
|
|
+ RespDTO<List<SysSetInfoDTO>> sysSetInfoListRes = tranServiceClient.getSysSetInfoDatas(hospitalSetVO);
|
|
|
+ if (RespDTOUtil.respIsOK(sysSetInfoListRes)) {
|
|
|
+ List<SysSetInfoDTO> sysSetInfoList = sysSetInfoListRes.data;
|
|
|
+ if (ListUtil.isNotEmpty(sysSetInfoList)) {
|
|
|
+ if (sysSetInfoList.get(0).getValue().equals(1)) {
|
|
|
+ isConnect = true;
|
|
|
+ } else {
|
|
|
+ isConnect = false;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ isConnect = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return isConnect;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 化验结果增肌公表名
|
|
|
+ *
|
|
|
+ * @param lisResults
|
|
|
+ * @param hosCode
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<LisResult> addLisUniqueName(List<LisResult> lisResults, String hosCode) {
|
|
|
+ List<LisResult> retLisResults = Lists.newLinkedList();
|
|
|
+ //化验项转公表内容,参数处理
|
|
|
+ if (ListUtil.isNotEmpty(lisResults)) {
|
|
|
+ List<String> mealNameList = lisResults
|
|
|
+ .stream()
|
|
|
+ .map(lisResult -> lisResult.getName()).collect(Collectors.toList());
|
|
|
+ LisConfigVO lisConfigVO = new LisConfigVO();
|
|
|
+ lisConfigVO.setHosCode(hosCode);
|
|
|
+ lisConfigVO.setMealNameList(mealNameList);
|
|
|
+ RespDTO<Map<String, Map<String, List<String>>>> lisConfigRes
|
|
|
+ = tranServiceClient.getLisConfigByMealNameAndHosCode(lisConfigVO);
|
|
|
+ Map<String, Map<String, List<String>>> lisConfigMap = new LinkedHashMap<>();
|
|
|
+ if (RespDTOUtil.respIsOK(lisConfigRes)) {
|
|
|
+ lisConfigMap = lisConfigRes.data;
|
|
|
+ }
|
|
|
+ for (LisResult lisResult : lisResults) {
|
|
|
+ if (!lisResult.getSource().equals(LisSourceEnum.Outer.getKey())) {
|
|
|
+ retLisResults.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) {
|
|
|
+ LisResult lisResult_new = new LisResult();
|
|
|
+ BeanUtil.copyProperties(lisResult, lisResult_new);
|
|
|
+ lisResult_new.setUniqueName(uniqueName);
|
|
|
+ retLisResults.add(lisResult_new);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ retLisResults.add(lisResult);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return retLisResults;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 辅检结果增加公表名(辅检项目名称)
|
|
|
+ *
|
|
|
+ * @param pacsArr
|
|
|
+ * @param hosCode
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<PacsResult> addPacsUniqueName(List<PacsResult> pacsArr, String hosCode) {
|
|
|
+ Map<String, PacsResult> pacsOriginalMap = EntityUtil.makeEntityMap(pacsArr, "name");
|
|
|
+ List<PacsResult> convertPacsArr = Lists.newLinkedList();
|
|
|
+ PacsConfigVO pacsConfigVO = new PacsConfigVO();
|
|
|
+ pacsConfigVO.setHosCode(hosCode);
|
|
|
+ pacsConfigVO.setMealNameList(pacsArr
|
|
|
+ .stream()
|
|
|
+ .map(pacsResult -> pacsResult.getName())
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList()));
|
|
|
+ RespDTO<Map<String, List<String>>> pacsRespDTO = tranServiceClient.getPacsConfig(pacsConfigVO);
|
|
|
+ if (RespDTOUtil.respIsOK(pacsRespDTO)) {
|
|
|
+ Map<String, List<String>> pacsMap = pacsRespDTO.data;
|
|
|
+ for (Map.Entry<String, PacsResult> entry : pacsOriginalMap.entrySet()) {
|
|
|
+ if (ListUtil.isNotEmpty(pacsMap.get(entry.getKey()))) {
|
|
|
+ for (String uniqueName : pacsMap.get(entry.getKey())) {
|
|
|
+ PacsResult pacsResult = new PacsResult();
|
|
|
+ BeanUtil.copyProperties(entry.getValue(), pacsResult);
|
|
|
+ pacsResult.setUniqueName(uniqueName);
|
|
|
+ convertPacsArr.add(pacsResult);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ convertPacsArr.add(entry.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return convertPacsArr;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取化验公表映射关系
|
|
|
+ *
|
|
|
+ * @param nameList
|
|
|
+ * @param hosCode
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String, Map<String, List<String>>> getLisConfigByMealNameAndHosCode(List<String> nameList, String hosCode) {
|
|
|
+ Map<String, Map<String, List<String>>> lisConfigMap = new LinkedHashMap<>();
|
|
|
+ if (ListUtil.isNotEmpty(nameList) && StringUtil.isNotBlank(hosCode)) {
|
|
|
+ LisConfigVO lisConfigVO = new LisConfigVO();
|
|
|
+ lisConfigVO.setHosCode(hosCode);
|
|
|
+ lisConfigVO.setMealNameList(nameList);
|
|
|
+ RespDTO<Map<String, Map<String, List<String>>>> lisConfigRes
|
|
|
+ = tranServiceClient.getLisConfigByMealNameAndHosCode(lisConfigVO);
|
|
|
+ if (RespDTOUtil.respIsOK(lisConfigRes)) {
|
|
|
+ lisConfigMap = lisConfigRes.data;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return lisConfigMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 外部项目名称转内部名称-字符串格式
|
|
|
+ *
|
|
|
+ * @param originalStr 原始数据
|
|
|
+ * @param hosCode 医院编码
|
|
|
+ * @param type 5-化验(仅限套餐),6-辅检,7-诊断
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String strConvert(String originalStr, String hosCode, Integer type) {
|
|
|
+ String retStr = "";
|
|
|
+ if (StringUtil.isBlank(originalStr)) {
|
|
|
+ return retStr;
|
|
|
+ }
|
|
|
+ String[] strArr = originalStr
|
|
|
+ .replace(" ", "")
|
|
|
+ .split(",|,|;|;");
|
|
|
+ List<String> strList = Arrays.asList(strArr);
|
|
|
+ strList = strList
|
|
|
+ .stream()
|
|
|
+ .filter(str -> StringUtil.isNotBlank(str))
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (type.equals(FeatureTypeEnum.Feature_Type_Lis.getKey())) {
|
|
|
+ Map<String, Map<String, List<String>>> map = getLisConfigByMealNameAndHosCode(strList, hosCode);
|
|
|
+ if (map != null) {
|
|
|
+ for (String lis : strList) {
|
|
|
+ Map<String, List<String>> itemMap = map.get(lis);
|
|
|
+ if (itemMap != null && itemMap.get("") != null) {
|
|
|
+ retStr += String.join(",", itemMap.get("")) + ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (type.equals(FeatureTypeEnum.Feature_Type_Pacs.getKey())) {
|
|
|
+ PacsConfigVO pacsConfigVO = new PacsConfigVO();
|
|
|
+ pacsConfigVO.setHosCode(hosCode);
|
|
|
+ pacsConfigVO.setMealNameList(strList);
|
|
|
+ RespDTO<Map<String, List<String>>> pacsRespDTO = tranServiceClient.getPacsConfig(pacsConfigVO);
|
|
|
+ if (RespDTOUtil.respIsOK(pacsRespDTO)) {
|
|
|
+ Map<String, List<String>> pacsMap = pacsRespDTO.data;
|
|
|
+ for (Map.Entry<String, List<String>> entry : pacsMap.entrySet()) {
|
|
|
+ if (ListUtil.isNotEmpty(entry.getValue())) {
|
|
|
+ retStr += String.join(",", entry.getValue()) + ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (type.equals(FeatureTypeEnum.Feature_Type_Disease.getKey())) {
|
|
|
+ DiseaseIcdVO diseaseIcdVO = new DiseaseIcdVO();
|
|
|
+ diseaseIcdVO.setHosCode(hosCode);
|
|
|
+ diseaseIcdVO.setDiseaseNameList(strList);
|
|
|
+ Map<String, String> disMap = new LinkedHashMap<>();
|
|
|
+ RespDTO<Map<String, String>> disRespDTO = tranServiceClient.getDiseaseIcdMap(diseaseIcdVO);
|
|
|
+ if (RespDTOUtil.respIsOK(disRespDTO)) {
|
|
|
+ disMap = disRespDTO.data;
|
|
|
+ for (String diseaseName : strList) {
|
|
|
+ if (StringUtil.isNotBlank(disMap.get(diseaseName))) {
|
|
|
+ retStr += disMap.get(diseaseName) + ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (retStr.endsWith(",")) {
|
|
|
+ retStr = retStr.substring(0, retStr.length() - 1);
|
|
|
+ }
|
|
|
+ return retStr;
|
|
|
+ }
|
|
|
+}
|