Bladeren bron

开单合理项维护

zhaops 4 jaren geleden
bovenliggende
commit
d68e2cf147
1 gewijzigde bestanden met toevoegingen van 63 en 62 verwijderingen
  1. 63 62
      src/main/java/com/diagbot/facade/BillManFacade.java

+ 63 - 62
src/main/java/com/diagbot/facade/BillManFacade.java

@@ -281,63 +281,64 @@ public class BillManFacade {
     public Boolean saveRecord(BillSaveVO billSaveVO) {
         //文本类型: 开单项-[]->条件明细
         //数值类型: 开单项-[]->开单项+禁忌+条件明细
-        String relationType = billSaveVO.getConcept().getConceptLabel() + "禁忌" + billSaveVO.getCondition().getConditionLabel();
-        BillItem existRelation = new BillItem();
+        String relationType
+                = billSaveVO.getConcept().getConceptLabel() + "禁忌" + billSaveVO.getCondition().getConditionLabel();
+        BillConcept concept = billSaveVO.getConcept();
+        BillCondition condition = billSaveVO.getCondition();
 
-        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);
+        String conditionName = condition.getName();
+        String conditionName_new = concept.getName() + "禁忌" + condition.getName();
+        String conditionName_save = conditionName;
+
+        BillItem existRelation = billManRepository.isExistRelation(billSaveVO.getConcept().getName(),
+                conditionName,
+                relationType);
+        BillItem existRelation_new = billManRepository.isExistRelation(billSaveVO.getConcept().getName(),
+                conditionName_new,
+                relationType);
+
+        //条件名称
+        if (billSaveVO.getRuleType().equals(2)) {
+            if (billSaveVO.getRelationId() == null) {
+                conditionName_save = conditionName_new;
+            } else {
+                if (!(existRelation != null &&
+                        billSaveVO.getRelationId().equals(existRelation.getRelationId()))) {
+                    conditionName_save = conditionName_new;
+                }
+            }
         }
+
         //新增已存在
-        if (billSaveVO.getRelationId() == null
-                && existRelation != null) {
-            throw new CommonException(CommonErrorCode.IS_EXISTS, "规则已存在");
-        }
-        //修改成已存在规则
-        if (billSaveVO.getRelationId() != null
-                && existRelation != null
-                && !billSaveVO.getRelationId().equals(existRelation.getRelationId())) {
-            throw new CommonException(CommonErrorCode.IS_EXISTS, "规则已存在");
+        if (billSaveVO.getRelationId() == null) {
+            if ((billSaveVO.getRuleType().equals(1) && existRelation != null)
+                    || (billSaveVO.getRuleType().equals(2) && existRelation_new != null)) {
+                throw new CommonException(CommonErrorCode.IS_EXISTS, "规则已存在");
+            }
+        } else {
+            if (!(existRelation != null
+                    && billSaveVO.getRelationId().equals(existRelation.getRelationId()))) {
+                if (existRelation_new != null
+                        && !billSaveVO.getRelationId().equals(existRelation_new.getRelationId())) {
+                    throw new CommonException(CommonErrorCode.IS_EXISTS, "规则已存在");
+                }
+            }
         }
 
         //数值类型特殊处理
         if (billSaveVO.getRuleType() != null
                 && billSaveVO.getRuleType().equals(2)) {
-            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);
+            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);
             } else {
-                tempCondition.setRange(0);
+                condition.setRange(0);
             }
-            billSaveVO.setCondition(tempCondition);
-        }
-
-        BillConcept concept = billSaveVO.getConcept();
-        BillCondition condition = billSaveVO.getCondition();
-
-        String conditionName = "";
-        //数值类型规则编辑时名称不拼接
-        if (billSaveVO.getRuleType().equals(2)
-                && billSaveVO.getRelationId() != null
-                && existRelation != null
-                && billSaveVO.getRelationId().equals(existRelation.getRelationId())) {
-            conditionName = condition.getName();
-
-        } else {
-            conditionName = billSaveVO.getRuleType().equals(2)
-                    ? concept.getName() + "禁忌" + condition.getName()
-                    : condition.getName();
+            billSaveVO.setCondition(condition);
         }
 
         //条件明细节点更新
@@ -346,9 +347,9 @@ public class BillManFacade {
         } else if (billSaveVO.getRuleType().equals(2)) {
             switch (condition.getConditionLabel()) {
                 case "实验室检查":
-                    Lis lis = lisRepository.createOrUpdate(conditionName,
+                    Lis lis = lisRepository.createOrUpdate(conditionName_save,
                             0,
-                            Cn2SpellUtil.converterToFirstSpell(conditionName),
+                            Cn2SpellUtil.converterToFirstSpell(conditionName_save),
                             1,
                             condition.getMaxValue(),
                             condition.getMinValue(),
@@ -357,9 +358,9 @@ public class BillManFacade {
                             condition.getName());
                     break;
                 case "临床表现":
-                    ClinicalFinding clinicalFinding = clinicalFindingRepository.createOrUpdate(conditionName,
+                    ClinicalFinding clinicalFinding = clinicalFindingRepository.createOrUpdate(conditionName_save,
                             0,
-                            Cn2SpellUtil.converterToFirstSpell(conditionName),
+                            Cn2SpellUtil.converterToFirstSpell(conditionName_save),
                             1,
                             condition.getMaxValue(),
                             condition.getMinValue(),
@@ -368,9 +369,9 @@ public class BillManFacade {
                             condition.getName());
                     break;
                 case "禁忌人群":
-                    Group group = groupRepository.createOrUpdate(conditionName,
+                    Group group = groupRepository.createOrUpdate(conditionName_save,
                             0,
-                            Cn2SpellUtil.converterToFirstSpell(conditionName),
+                            Cn2SpellUtil.converterToFirstSpell(conditionName_save),
                             1,
                             condition.getMaxValue(),
                             condition.getMinValue(),
@@ -379,9 +380,9 @@ public class BillManFacade {
                             condition.getName());
                     break;
                 case "体征":
-                    Vital vital = vitalRepository.createOrUpdate(conditionName,
+                    Vital vital = vitalRepository.createOrUpdate(conditionName_save,
                             0,
-                            Cn2SpellUtil.converterToFirstSpell(conditionName),
+                            Cn2SpellUtil.converterToFirstSpell(conditionName_save),
                             1,
                             condition.getMaxValue(),
                             condition.getMinValue(),
@@ -390,9 +391,9 @@ public class BillManFacade {
                             condition.getName());
                     break;
                 case "年龄":
-                    Age age = ageRepository.createOrUpdate(conditionName,
+                    Age age = ageRepository.createOrUpdate(conditionName_save,
                             0,
-                            Cn2SpellUtil.converterToFirstSpell(conditionName),
+                            Cn2SpellUtil.converterToFirstSpell(conditionName_save),
                             1,
                             condition.getMaxValue(),
                             condition.getMinValue(),
@@ -431,23 +432,23 @@ public class BillManFacade {
         switch (concept.getConceptLabel()) {
             case "实验室检查套餐名":
                 LisSet lisSet = lisSetRepository.findByNameIs(concept.getName()).get(0);
-                lisSetNode.updateRelationExt(lisSet, relationType, 1, billSaveVO.getRuleType(), conditionName, lisSetRepository);
+                lisSetNode.updateRelationExt(lisSet, relationType, 1, billSaveVO.getRuleType(), conditionName_save, lisSetRepository);
                 break;
             case "辅助检查名称":
                 PacsName pacsName = pacsNameRepository.findByNameIs(concept.getName()).get(0);
-                pacsNameNode.updateRelationExt(pacsName, relationType, 1, billSaveVO.getRuleType(), conditionName, pacsNameRepository);
+                pacsNameNode.updateRelationExt(pacsName, relationType, 1, billSaveVO.getRuleType(), conditionName_save, pacsNameRepository);
                 break;
             case "辅助检查子项目名称":
                 PacsSubName pacsSubName = pacsSubNameRepository.findByNameIs(concept.getName()).get(0);
-                pacsSubNameNode.updateRelationExt(pacsSubName, relationType, 1, billSaveVO.getRuleType(), conditionName, pacsSubNameRepository);
+                pacsSubNameNode.updateRelationExt(pacsSubName, relationType, 1, billSaveVO.getRuleType(), conditionName_save, pacsSubNameRepository);
                 break;
             case "医保手术和操作名称":
                 YiBaoOperationName yiBaoOperationName = yiBaoOperationNameRepository.findByNameIs(concept.getName()).get(0);
-                yiBaoOperationNameNode.updateRelationExt(yiBaoOperationName, relationType, 1, billSaveVO.getRuleType(), conditionName, yiBaoOperationNameRepository);
+                yiBaoOperationNameNode.updateRelationExt(yiBaoOperationName, relationType, 1, billSaveVO.getRuleType(), conditionName_save, yiBaoOperationNameRepository);
                 break;
             case "药品注册名称":
                 MedRegName medRegName = medRegNameRepository.findByNameIs(concept.getName()).get(0);
-                medRegNameNode.updateRelationExt(medRegName, relationType, 1, billSaveVO.getRuleType(), conditionName, medRegNameRepository);
+                medRegNameNode.updateRelationExt(medRegName, relationType, 1, billSaveVO.getRuleType(), conditionName_save, medRegNameRepository);
                 break;
             default:
                 break;