|
@@ -1,15 +1,42 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
import com.diagbot.dto.DictionaryInfoDTO;
|
|
|
+import com.diagbot.entity.node.Age;
|
|
|
import com.diagbot.entity.node.BillConcept;
|
|
|
import com.diagbot.entity.node.BillCondition;
|
|
|
import com.diagbot.entity.node.BillItem;
|
|
|
+import com.diagbot.entity.node.ClinicalFinding;
|
|
|
+import com.diagbot.entity.node.Gender;
|
|
|
+import com.diagbot.entity.node.Group;
|
|
|
+import com.diagbot.entity.node.Lis;
|
|
|
+import com.diagbot.entity.node.MedAllergen;
|
|
|
+import com.diagbot.entity.node.PacsName;
|
|
|
+import com.diagbot.entity.node.Vital;
|
|
|
+import com.diagbot.entity.relationship.PacsNameAllergen;
|
|
|
+import com.diagbot.entity.relationship.PacsNameClinicalFinding;
|
|
|
+import com.diagbot.entity.relationship.PacsNameConflictDevice;
|
|
|
+import com.diagbot.entity.relationship.PacsNameDisease;
|
|
|
+import com.diagbot.entity.relationship.PacsNameGender;
|
|
|
+import com.diagbot.entity.relationship.PacsNameGroup;
|
|
|
+import com.diagbot.entity.relationship.PacsNameLis;
|
|
|
+import com.diagbot.entity.relationship.PacsNameMedAllergen;
|
|
|
+import com.diagbot.entity.relationship.PacsNameOralMedicine;
|
|
|
+import com.diagbot.entity.relationship.PacsNamePacsDescribe;
|
|
|
+import com.diagbot.entity.relationship.PacsNameVital;
|
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
|
+import com.diagbot.repository.AgeRepository;
|
|
|
import com.diagbot.repository.BillManRepository;
|
|
|
+import com.diagbot.repository.ClinicalFindingRepository;
|
|
|
+import com.diagbot.repository.GenderRepository;
|
|
|
+import com.diagbot.repository.GroupRepository;
|
|
|
+import com.diagbot.repository.LisRepository;
|
|
|
+import com.diagbot.repository.MedAllergenRepository;
|
|
|
+import com.diagbot.repository.PacsNameRepository;
|
|
|
+import com.diagbot.repository.VitalRepository;
|
|
|
+import com.diagbot.util.Cn2SpellUtil;
|
|
|
import com.diagbot.util.EntityUtil;
|
|
|
import com.diagbot.util.ListUtil;
|
|
|
-import com.diagbot.util.StringUtil;
|
|
|
import com.diagbot.vo.BillPageVO;
|
|
|
import com.diagbot.vo.BillSaveVO;
|
|
|
import com.diagbot.vo.ConceptIndexVO;
|
|
@@ -24,6 +51,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -37,6 +65,26 @@ public class BillManFacade {
|
|
|
BillManRepository billManRepository;
|
|
|
@Autowired
|
|
|
DictionaryFacade dictionaryFacade;
|
|
|
+ @Autowired
|
|
|
+ PacsNameRepository pacsNameRepository;
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ MedAllergenRepository medAllergenRepository;
|
|
|
+ @Autowired
|
|
|
+ GenderRepository genderRepository;
|
|
|
+ @Autowired
|
|
|
+ LisRepository lisRepository;
|
|
|
+ @Autowired
|
|
|
+ GroupRepository groupRepository;
|
|
|
+ @Autowired
|
|
|
+ ClinicalFindingRepository clinicalFindingRepository;
|
|
|
+ @Autowired
|
|
|
+ VitalRepository vitalRepository;
|
|
|
+ @Autowired
|
|
|
+ AgeRepository ageRepository;
|
|
|
+
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 获取开单合理项列表
|
|
@@ -68,8 +116,8 @@ public class BillManFacade {
|
|
|
billPageVO.getRelationStatus(),
|
|
|
pageable);
|
|
|
|
|
|
- for(BillItem billItem:page.getContent()){
|
|
|
- billItem.setRuleName(billItem.getRuleName()+"test");
|
|
|
+ for (BillItem billItem : page.getContent()) {
|
|
|
+ billItem.setRuleName(billItem.getRuleName() + "test");
|
|
|
}
|
|
|
return page;
|
|
|
}
|
|
@@ -88,23 +136,19 @@ public class BillManFacade {
|
|
|
= EntityUtil.makeMapWithKeyValue(dicTypeConvert, "name", "val");
|
|
|
Map<String, String> dicIndicationManTypeMap
|
|
|
= EntityUtil.makeMapWithKeyValue(dicIndicationManType, "val", "name");
|
|
|
+ Map<String,String> dicBillConditionTypeMap
|
|
|
+ =EntityUtil.makeMapWithKeyValue(dicBillConditionType,"name","val");
|
|
|
if (dicIndicationManTypeMap.containsKey(conditionIndexVO.getType().toString())
|
|
|
&& dicTypeConvertMap.containsKey(dicIndicationManTypeMap.get(conditionIndexVO.getType().toString()))) {
|
|
|
conditionIndexVO.setConceptLabel(dicTypeConvertMap.get(dicIndicationManTypeMap.get(conditionIndexVO.getType().toString())));
|
|
|
}
|
|
|
//条件明细筛选范围
|
|
|
List<String> conditionLabels = Lists.newArrayList();
|
|
|
- /*if (ListUtil.isNotEmpty(dicBillConditionType)) {
|
|
|
- conditionLabels = dicBillConditionType.stream()
|
|
|
- .map(i -> i.getName())
|
|
|
- .distinct()
|
|
|
- .collect(Collectors.toList());
|
|
|
- }*/
|
|
|
List<String> relationTypes = billManRepository.getRelationTypes(conditionIndexVO.getConceptLabel());
|
|
|
if (ListUtil.isNotEmpty(relationTypes)) {
|
|
|
for (String relationType : relationTypes) {
|
|
|
int index = relationType.indexOf("禁忌");
|
|
|
- if (index > 0) {
|
|
|
+ if (index > 0 && dicBillConditionTypeMap.containsKey(relationType.substring(index + 2))) {
|
|
|
conditionLabels.add(relationType.substring(index + 2));
|
|
|
}
|
|
|
}
|
|
@@ -202,18 +246,21 @@ public class BillManFacade {
|
|
|
}
|
|
|
|
|
|
public Boolean saveRecord(BillSaveVO billSaveVO) {
|
|
|
- //验证关系是否已存在
|
|
|
- //开单项-[]->条件明细
|
|
|
- //开单项-[]->开单项+禁忌+条件明细
|
|
|
+ //文本类型: 开单项-[]->条件明细
|
|
|
+ //数值类型: 开单项-[]->开单项+禁忌+条件明细
|
|
|
String relationType = billSaveVO.getConcept().getConceptLabel() + "禁忌" + billSaveVO.getCondition().getConditionLabel();
|
|
|
- BillItem existRelation = billManRepository.isExistRelation(billSaveVO.getConcept().getName(),
|
|
|
- billSaveVO.getCondition().getName(),
|
|
|
- relationType);
|
|
|
- BillCondition existCondition = billManRepository.isExistCondition(billSaveVO.getConcept().getName(),
|
|
|
- billSaveVO.getConcept().getConceptLabel(),
|
|
|
- relationType,
|
|
|
- billSaveVO.getCondition().getName(),
|
|
|
- billSaveVO.getCondition().getConditionLabel());
|
|
|
+ BillItem existRelation = new BillItem();
|
|
|
+
|
|
|
+ if (billSaveVO.getRuleType().equals(1)) {
|
|
|
+ existRelation = billManRepository.isExistRelation(billSaveVO.getConcept().getName(),
|
|
|
+ billSaveVO.getCondition().getName(),
|
|
|
+ relationType);
|
|
|
+ } else if (billSaveVO.getRuleType().equals(2)) {
|
|
|
+ String conditionName = billSaveVO.getConcept().getName() + "禁忌" + billSaveVO.getCondition().getName();
|
|
|
+ existRelation = billManRepository.isExistRelation(billSaveVO.getConcept().getName(),
|
|
|
+ conditionName,
|
|
|
+ relationType);
|
|
|
+ }
|
|
|
//新增已存在
|
|
|
if (billSaveVO.getRelationId() == null
|
|
|
&& existRelation != null) {
|
|
@@ -226,35 +273,131 @@ public class BillManFacade {
|
|
|
}
|
|
|
|
|
|
//数值类型
|
|
|
- if (StringUtil.isNotBlank(billSaveVO.getRuleType())
|
|
|
+ if (billSaveVO.getRuleType() != null
|
|
|
&& billSaveVO.getRuleType().equals("2")) {
|
|
|
- BillCondition condition = billSaveVO.getCondition();
|
|
|
- if (condition.getMinValue() != null
|
|
|
- && condition.getMaxValue() != null
|
|
|
- && condition.getMinValue() > condition.getMaxValue()) {
|
|
|
- Double minValue = condition.getMinValue();
|
|
|
- condition.setMinValue(condition.getMaxValue());
|
|
|
- condition.setMaxValue(minValue);
|
|
|
- condition.setRange(1);
|
|
|
+ BillCondition tempCondition = billSaveVO.getCondition();
|
|
|
+ if (tempCondition.getMinValue() != null
|
|
|
+ && tempCondition.getMaxValue() != null
|
|
|
+ && tempCondition.getMinValue() > tempCondition.getMaxValue()) {
|
|
|
+ Double minValue = tempCondition.getMinValue();
|
|
|
+ tempCondition.setMinValue(tempCondition.getMaxValue());
|
|
|
+ tempCondition.setMaxValue(minValue);
|
|
|
+ tempCondition.setRange(1);
|
|
|
} else {
|
|
|
- condition.setRange(0);
|
|
|
+ tempCondition.setRange(0);
|
|
|
}
|
|
|
- billSaveVO.setCondition(condition);
|
|
|
+ billSaveVO.setCondition(tempCondition);
|
|
|
}
|
|
|
|
|
|
+ BillConcept concept = billSaveVO.getConcept();
|
|
|
+ BillCondition condition = billSaveVO.getCondition();
|
|
|
+
|
|
|
if (billSaveVO.getRelationId() == null) {
|
|
|
//新增
|
|
|
- if(billSaveVO.getRuleType().equals("1")){
|
|
|
- //文本类型,新建关系
|
|
|
- Long relationId=billManRepository.createRelation(billSaveVO.getConcept().getName(),
|
|
|
- billSaveVO.getConcept().getConceptLabel(),
|
|
|
- billSaveVO.getCondition().getName(),
|
|
|
- billSaveVO.getCondition().getConditionLabel(),
|
|
|
- relationType,
|
|
|
- billSaveVO.getRuleType());
|
|
|
+ //ruleType=1 文本类型,ruleType=2 数值类型
|
|
|
+ if (billSaveVO.getRuleType().equals(1)) {
|
|
|
+ switch (concept.getConceptLabel()) {
|
|
|
+ case "实验室检查名称":
|
|
|
+ break;
|
|
|
+ case "辅助检查名称":
|
|
|
+ PacsName pacsName = pacsNameRepository.findByNameIs(billSaveVO.getConcept().getName()).get(0);
|
|
|
+ updateRelation(pacsName, relationType, 1, billSaveVO.getRuleType(), billSaveVO.getCondition().getName(), pacsNameRepository);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ } else if (billSaveVO.getRuleType().equals(2)) {
|
|
|
+ String name = billSaveVO.getConcept().getName() + "禁忌" + billSaveVO.getCondition().getName();
|
|
|
+ switch (condition.getConditionLabel()) {
|
|
|
+ case "性别":
|
|
|
+ break;
|
|
|
+ case "实验室检查":
|
|
|
+ Lis lis = new Lis();
|
|
|
+ lis.setName(name);
|
|
|
+ lis.setIs_kl(0);
|
|
|
+ lis.setPycode(Cn2SpellUtil.converterToFirstSpell(name));
|
|
|
+ lis.setStatus(1);
|
|
|
+ lis.setMaxval(condition.getMaxValue());
|
|
|
+ lis.setMinval(condition.getMinValue());
|
|
|
+ lis.setRange(condition.getRange());
|
|
|
+ lis.setUnit(condition.getUnit());
|
|
|
+ lis = lisRepository.save(lis);
|
|
|
+ break;
|
|
|
+ case "临床表现":
|
|
|
+ ClinicalFinding clinicalFinding = new ClinicalFinding();
|
|
|
+ clinicalFinding.setName(name);
|
|
|
+ clinicalFinding.setIs_kl(0);
|
|
|
+ clinicalFinding.setPycode(Cn2SpellUtil.converterToFirstSpell(name));
|
|
|
+ clinicalFinding.setStatus(1);
|
|
|
+ clinicalFinding.setMaxval(condition.getMaxValue());
|
|
|
+ clinicalFinding.setMinval(condition.getMinValue());
|
|
|
+ clinicalFinding.setRange(condition.getRange());
|
|
|
+ clinicalFinding.setUnit(condition.getUnit());
|
|
|
+ clinicalFinding = clinicalFindingRepository.save(clinicalFinding);
|
|
|
+ break;
|
|
|
+ case "辅助检查名称描述":
|
|
|
+ break;
|
|
|
+ case "疾病":
|
|
|
+ break;
|
|
|
+ case "服用药品":
|
|
|
+ break;
|
|
|
+ case "药物过敏原":
|
|
|
+ break;
|
|
|
+ case "食物过敏原":
|
|
|
+ break;
|
|
|
+ case "手术":
|
|
|
+ break;
|
|
|
+ case "禁忌人群":
|
|
|
+ Group group = groupRepository.saveNode(name, 0, Cn2SpellUtil.converterToFirstSpell(name), 1,
|
|
|
+ condition.getMaxValue(), condition.getMinValue(),
|
|
|
+ condition.getRange() == null ? 0 : condition.getRange(), condition.getUnit(),
|
|
|
+ condition.getName());
|
|
|
+ break;
|
|
|
+ case "过敏原":
|
|
|
+ break;
|
|
|
+ case "体征":
|
|
|
+ Vital vital = new Vital();
|
|
|
+ vital.setName(name);
|
|
|
+ vital.setIs_kl(0);
|
|
|
+ //vital.setLabels();
|
|
|
+ vital.setPycode(Cn2SpellUtil.converterToFirstSpell(name));
|
|
|
+ vital.setStatus(1);
|
|
|
+ vital.setMaxval(condition.getMaxValue());
|
|
|
+ vital.setMinval(condition.getMinValue());
|
|
|
+ vital.setRange(condition.getRange());
|
|
|
+ vital.setUnit(condition.getUnit());
|
|
|
+ vital = vitalRepository.save(vital);
|
|
|
+ break;
|
|
|
+ case "禁忌医疗器械及物品":
|
|
|
+ break;
|
|
|
+ case "年龄":
|
|
|
+ Age age = new Age();
|
|
|
+ age.setName(name);
|
|
|
+ age.setIs_kl(0);
|
|
|
+ age.setPycode(Cn2SpellUtil.converterToFirstSpell(name));
|
|
|
+ age.setStatus(1);
|
|
|
+ age.setMaxval(condition.getMaxValue());
|
|
|
+ age.setMinval(condition.getMinValue());
|
|
|
+ age.setRange(condition.getRange());
|
|
|
+ age.setUnit(condition.getUnit());
|
|
|
+ age = ageRepository.save(age);
|
|
|
+ break;
|
|
|
+ case "给药途径":
|
|
|
+ break;
|
|
|
+ case "开单项互斥":
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
- }else if(billSaveVO.getRuleType().equals("2")){
|
|
|
- //数值类型
|
|
|
+ switch (concept.getConceptLabel()) {
|
|
|
+ case "实验室检查名称":
|
|
|
+ break;
|
|
|
+ case "辅助检查名称":
|
|
|
+ PacsName pacsName = pacsNameRepository.findByNameIs(billSaveVO.getConcept().getName()).get(0);
|
|
|
+ updateRelation(pacsName, relationType, 1, billSaveVO.getRuleType(), name, pacsNameRepository);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -262,10 +405,103 @@ public class BillManFacade {
|
|
|
//修改
|
|
|
}
|
|
|
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
- //体征和实验室检查、实验室检查名称新增一个节点
|
|
|
+ /**
|
|
|
+ * 更新关系状态属性
|
|
|
+ */
|
|
|
+ public void updateRelation(PacsName pacsName, String relname, Integer status, Integer ruleType,String e_name, PacsNameRepository pacsNameRepository) {
|
|
|
|
|
|
+ try {
|
|
|
+ switch (relname) {
|
|
|
+ case "辅助检查名称禁忌性别":
|
|
|
+ Gender gender = genderRepository.findByNameIs(e_name).get(0);
|
|
|
+ PacsNameGender pacsNameGender = new PacsNameGender();
|
|
|
+ pacsNameGender.setGender(gender);
|
|
|
+ pacsNameGender.setPacsName(pacsName);
|
|
|
+ pacsNameGender.setStatus(status);
|
|
|
+ pacsNameGender.setRuleType(ruleType);
|
|
|
+ pacsName.setPacsNameGender(pacsNameGender);
|
|
|
+ pacsNameRepository.save(pacsName, 1);
|
|
|
+ break;
|
|
|
+ case "辅助检查名称禁忌禁忌人群":
|
|
|
+ Group group = groupRepository.findByNameIs(e_name).get(0);
|
|
|
+ Set<PacsNameGroup> pacsNameGroupSet = pacsName.getPacsNameGroups();
|
|
|
+ PacsNameGroup pacsNameGroup = new PacsNameGroup();
|
|
|
+ pacsNameGroup.setGroup(group);
|
|
|
+ pacsNameGroup.setPacsName(pacsName);
|
|
|
+ pacsNameGroup.setStatus(status);
|
|
|
+ pacsNameGroup.setRuleType(ruleType);
|
|
|
+ pacsNameGroupSet.add(pacsNameGroup);
|
|
|
+ pacsName.setPacsNameGroups(pacsNameGroupSet);
|
|
|
+ pacsNameRepository.save(pacsName, 1);
|
|
|
+ break;
|
|
|
+ case "辅助检查名称禁忌药物过敏原":
|
|
|
+ MedAllergen medAllergen = medAllergenRepository.findByNameIs(e_name).get(0);
|
|
|
+ Set<PacsNameMedAllergen> pacsNameMedAllergenSet = pacsName.getPacsNameMedallergens();
|
|
|
+ PacsNameMedAllergen pacsNameMedAllergen = new PacsNameMedAllergen();
|
|
|
+ pacsNameMedAllergen.setMedAllergen(medAllergen);
|
|
|
+ pacsNameMedAllergen.setPacsName(pacsName);
|
|
|
+ pacsNameMedAllergen.setStatus(status);
|
|
|
+ pacsNameMedAllergen.setRuleType(ruleType);
|
|
|
+ pacsNameMedAllergenSet.add(pacsNameMedAllergen);
|
|
|
+ pacsName.setPacsNameMedallergens(pacsNameMedAllergenSet);
|
|
|
+ pacsNameRepository.save(pacsName, 1);
|
|
|
+ break;
|
|
|
+ case "辅助检查名称禁忌临床表现":
|
|
|
+ ClinicalFinding clinicalFinding = clinicalFindingRepository.findByNameIs(e_name).get(0);
|
|
|
+ Set<PacsNameClinicalFinding> pacsNameClinicalFindingSet = pacsName.getPacsNameClinicalfindings();
|
|
|
+ PacsNameClinicalFinding pacsNameClinicalFinding = new PacsNameClinicalFinding();
|
|
|
+ pacsNameClinicalFinding.setClinicalFinding(clinicalFinding);
|
|
|
+ pacsNameClinicalFinding.setPacsName(pacsName);
|
|
|
+ pacsNameClinicalFinding.setStatus(status);
|
|
|
+ pacsNameClinicalFinding.setRuleType(ruleType);
|
|
|
+ pacsNameClinicalFindingSet.add(pacsNameClinicalFinding);
|
|
|
+ pacsName.setPacsNameClinicalfindings(pacsNameClinicalFindingSet);
|
|
|
+ pacsNameRepository.save(pacsName, 1);
|
|
|
+ break;
|
|
|
+ case "辅助检查名称禁忌实验室检查名称":
|
|
|
+ break;
|
|
|
+ case "辅助检查名称禁忌实验室检查":
|
|
|
+ Lis lis = lisRepository.findByNameIs(e_name).get(0);
|
|
|
+ Set<PacsNameLis> pacsNameLisSet = pacsName.getPacsNameLis();
|
|
|
+ PacsNameLis pacsNameLis = new PacsNameLis();
|
|
|
+ pacsNameLis.setLis(lis);
|
|
|
+ pacsNameLis.setPacsName(pacsName);
|
|
|
+ pacsNameLis.setStatus(status);
|
|
|
+ pacsNameLis.setRuleType(ruleType);
|
|
|
+ pacsNameLisSet.add(pacsNameLis);
|
|
|
+ pacsName.setPacsNameLis(pacsNameLisSet);
|
|
|
+ pacsNameRepository.save(pacsName, 1);
|
|
|
+ break;
|
|
|
+ case "辅助检查名称禁忌疾病":
|
|
|
+ List<PacsNameDisease> pacsNameDiseases = pacsName.getPacsNameDiseases().stream().filter(x -> x.getDisease().getName() == e_name).collect(Collectors.toList());
|
|
|
+ break;
|
|
|
+ case "辅助检查名称禁忌禁忌医疗器械及物品":
|
|
|
+ List<PacsNameConflictDevice> pacsNameConflictDevices = pacsName.getPacsNameConflictdevices().stream().filter(x -> x.getConflictDevice().getName() == e_name).collect(Collectors.toList());
|
|
|
+ break;
|
|
|
+ case "辅助检查名称禁忌体征":
|
|
|
+ List<PacsNameVital> pacsNameVitals = pacsName.getPacsNameVitals().stream().filter(x -> x.getVital().getName() == e_name).collect(Collectors.toList());
|
|
|
+ break;
|
|
|
+ case "辅助检查名称禁忌服用药品":
|
|
|
+ List<PacsNameOralMedicine> pacsNameOralMedicines = pacsName.getPacsNameOralmedicines().stream().filter(x -> x.getOralMedicine().getName() == e_name).collect(Collectors.toList());
|
|
|
+ break;
|
|
|
+ case "辅助检查名称禁忌辅助检查名称描述":
|
|
|
+ List<PacsNamePacsDescribe> pacsNamePacsDescribes = pacsName.getPacsNamePacsdescribes().stream().filter(x -> x.getPacsDescribe().getName() == e_name).collect(Collectors.toList());
|
|
|
+ break;
|
|
|
+ case "辅助检查名称禁忌过敏原":
|
|
|
+ List<PacsNameAllergen> pacsNameAllergens = pacsName.getPacsNameAllergens().stream().filter(x -> x.getAllergen().getName() == e_name).collect(Collectors.toList());
|
|
|
+ break;
|
|
|
+ case "辅助检查名称禁忌开单项互斥":
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex) {
|
|
|
+ ex.printStackTrace();
|
|
|
+ }
|
|
|
+ finally {
|
|
|
|
|
|
- return true;
|
|
|
+ }
|
|
|
}
|
|
|
}
|