Browse Source

更新药品开单合理性的方法

MarkHuang 4 years ago
parent
commit
ce2dd0eeef

+ 31 - 0
src/main/java/com/diagbot/entity/node/Age.java

@@ -0,0 +1,31 @@
+package com.diagbot.entity.node;
+
+import com.diagbot.biz.push.entity.Pacs;
+import com.diagbot.entity.node.base.BaseNode;
+import lombok.Getter;
+import lombok.Setter;
+import org.neo4j.ogm.annotation.NodeEntity;
+import org.neo4j.ogm.annotation.Property;
+import org.neo4j.ogm.annotation.Relationship;
+
+import java.util.HashSet;
+import java.util.Set;
+
+@Setter
+@Getter
+@NodeEntity(label = "年龄")
+public class Age extends BaseNode  {
+
+	@Property(name = "最小值")
+	private Double minval;
+
+	@Property(name = "最大值")
+	private Double maxval;
+
+	@Property(name = "范围")
+	private Integer range;
+
+	@Relationship(type = "药品通用名称禁忌年龄", direction = Relationship.INCOMING)
+	private Set<Medicine> medicine = new HashSet<>();
+
+}

+ 2 - 0
src/main/java/com/diagbot/entity/node/Disease.java

@@ -31,4 +31,6 @@ public class Disease extends BaseNode  {
 	@Relationship(type = "辅助检查子项目名称禁忌疾病", direction = Relationship.INCOMING)
 	private Set<PacsSubName> pacssubnames = new HashSet<>();
 
+	@Relationship(type = "药品通用名称禁忌疾病", direction = Relationship.INCOMING)
+	private Set<Medicine> medicines = new HashSet<>();
 }

+ 3 - 0
src/main/java/com/diagbot/entity/node/Group.java

@@ -34,4 +34,7 @@ public class Group extends BaseNode  {
 	@Relationship(type = "辅助检查子项目名称禁忌禁忌人群", direction = Relationship.INCOMING)
 	private Set<PacsSubName> pacssubnames = new HashSet<>();
 
+	@Relationship(type = "药品通用名称禁忌禁忌人群", direction = Relationship.INCOMING)
+	private Set<Medicine> medicine = new HashSet<>();
+
 }

+ 2 - 0
src/main/java/com/diagbot/entity/node/MedAllergen.java

@@ -31,4 +31,6 @@ public class MedAllergen extends BaseNode  {
 	@Relationship(type = "联合项目禁忌药物过敏原", direction = Relationship.INCOMING)
 	private Set<CombiOperation> combioperations = new HashSet<>();
 
+	@Relationship(type = "药品通用名称禁忌药物过敏原", direction = Relationship.INCOMING)
+	private Set<Medicine> medicine = new HashSet<>();
 }

+ 11 - 0
src/main/java/com/diagbot/entity/node/Medicine.java

@@ -21,5 +21,16 @@ public class Medicine extends BaseNode  {
 	@Relationship(type = "化验提醒指标相关药品通用名称", direction = Relationship.INCOMING)
 	private Set<LisRemind> lisreminds = new HashSet<>();
 
+	@Relationship(type = "药品通用名称禁忌禁忌人群", direction = Relationship.OUTGOING)
+	private Set<Group> group = new HashSet<>();
+
+	@Relationship(type = "药品通用名称禁忌年龄", direction = Relationship.OUTGOING)
+	private Set<Age> age = new HashSet<>();
+
+	@Relationship(type = "药品通用名称禁忌疾病", direction = Relationship.OUTGOING)
+	private Set<Disease> disease = new HashSet<>();
+
+	@Relationship(type = "药品通用名称禁忌药物过敏原", direction = Relationship.OUTGOING)
+	private Set<MedAllergen> medAllergens = new HashSet<>();
 
 }

+ 14 - 2
src/main/java/com/diagbot/facade/NeoFacade.java

@@ -396,6 +396,7 @@ public class NeoFacade {
             billNeoDTOs.addAll(getLisBill(billNeoVO.getLisList()));
             billNeoDTOs.addAll(getOperationBill(billNeoVO.getOperationList()));
             billNeoDTOs.addAll(getCombiOpBill(billNeoVO.getCombiopList()));
+//            billNeoDTOs.addAll(getMedicineBill(bill))
             billNeoDTOs.addAll(getTransfusionBill(billNeoVO.getTransfusionList()));
         }
         catch (Exception ex) {
@@ -569,8 +570,8 @@ public class NeoFacade {
      */
     public List<BillNeoDTO> getDrugBill(Map<String, String> medsterm) {
 
-        MedicineCodeNode medicineNode = new MedicineCodeNode();
-        List<BillNeoDTO> billNeoDTOs = medicineNode.getDrugBill(medsterm, medicineCodeRepository);
+        MedicineNode medicineNode = new MedicineNode();
+        List<BillNeoDTO> billNeoDTOs = medicineNode.getMedicineBill(medsterm, medicineRepository);
 
         return billNeoDTOs;
     }
@@ -637,6 +638,17 @@ public class NeoFacade {
     }
 
 
+    /**
+     * 处理药品开单合理性
+     */
+    public List<BillNeoDTO> getMedicineBill(Map<String, String> term) {
+        MedicineNode medicineNode = new MedicineNode();
+        List<BillNeoDTO> billNeoDTOS = medicineNode.getMedicineBill(term, medicineRepository);
+
+        return billNeoDTOS;
+    }
+
+
     /**
      * 处理输血开单合理性
      */

+ 64 - 7
src/main/java/com/diagbot/repository/MedicineNode.java

@@ -6,26 +6,83 @@ import com.diagbot.util.ListUtil;
 import com.diagbot.util.NeoUtil;
 
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 
 public class MedicineNode {
 
 
-    public DrugBillNeoDTO MedicinetoDrugDTO(Medicine medicine) {
+    public DrugBillNeoDTO MedicinetoDrugDTO(Medicine medicine, MedicineRepository medicineRepository) {
         DrugBillNeoDTO drugBillNeoDTO = new DrugBillNeoDTO();
         NodeInfo nodeInfo = new NodeInfo();
 
+        Set<Age> ages = medicine.getAge();
+        for (Age age : ages) {
+            NodeNeoDTO nodeNeoDTO = fillNodeNeoDTO(age, medicineRepository.getKeys());
+            drugBillNeoDTO.setAgeNeoDTO(nodeNeoDTO);
+        }
+
+        Set<Group> groups = medicine.getGroup();
+        for (Group group : groups) {
+            NodeNeoDTO nodeNeoDTO = new NodeNeoDTO();
+            nodeInfo.setName(group.getName());
+            nodeInfo.setTypeval(Constants.group);
+            drugBillNeoDTO.getGroup().add(nodeNeoDTO);
+        }
+
+
+        Set<MedAllergen> medAllergens = medicine.getMedAllergens();
+        for (MedAllergen medAllergen : medAllergens) {
+            NodeNeoDTO nodeNeoDTO = new NodeNeoDTO();
+            nodeInfo.setName(medAllergen.getName());
+            nodeInfo.setTypeval(Constants.medallergen);
+            drugBillNeoDTO.getAllergicmeds().add(nodeNeoDTO);
+        }
+
+
+        Set<Disease> diseases = medicine.getDisease();
+        for (Disease disease : diseases) {
+            NodeNeoDTO nodeNeoDTO = new NodeNeoDTO();
+            nodeInfo.setName(disease.getName());
+            nodeInfo.setTypeval(Constants.disease);
+            drugBillNeoDTO.getDisease().add(nodeNeoDTO);
+        }
+
         return drugBillNeoDTO;
     }
 
 
+    public NodeNeoDTO fillNodeNeoDTO(Age age, List<String> keys) {
+        NodeNeoDTO nodeNeoDTO = new NodeNeoDTO();
+        Integer range;
+        BigDecimal max, min;
+
+        nodeNeoDTO.setName(age.getName());
+        for (String key : keys) {
+            switch (key) {
+                case "最大值":
+                    max = (age.getMaxval()==null)?null:new BigDecimal(age.getMaxval());
+                    nodeNeoDTO.setMax(max);
+                    break;
+                case "最小值":
+                    min = (age.getMinval()==null)?null:new BigDecimal(age.getMinval());
+                    nodeNeoDTO.setMin(min);
+                    break;
+                case "范围":
+                    range = (age.getRange()==null)?0:age.getRange();
+                    nodeNeoDTO.setValType(range);
+                    break;
+            }
+        }
+
+        return nodeNeoDTO;
+    }
+
+
+
     /**
      * 处理处方开单合理性
      */
-    public List<BillNeoDTO> getDrugBill(Map<String, String> medsterm, MedicineRepository medicineRepository) {
+    public List<BillNeoDTO> getMedicineBill(Map<String, String> medsterm, MedicineRepository medicineRepository) {
         List<BillNeoDTO> billNeoDTOs = new ArrayList<>();
         BillNeoDTO billNeoDTO;
 
@@ -45,7 +102,7 @@ public class MedicineNode {
             medicine = medicineRepository.findByNameIs(medname);
 
             if (medicine != null && medicine.size() > 0) {
-                drugBillNeoDTO = MedicinetoDrugDTO(medicine.get(0));
+                drugBillNeoDTO = MedicinetoDrugDTO(medicine.get(0), medicineRepository);
 
                 billNeoDTO.setDrugBillNeoDTO(drugBillNeoDTO);
 

+ 5 - 0
src/main/java/com/diagbot/repository/MedicineRepository.java

@@ -1,6 +1,7 @@
 package com.diagbot.repository;
 
 import com.diagbot.entity.node.Medicine;
+import org.springframework.data.neo4j.annotation.Query;
 import org.springframework.data.neo4j.repository.Neo4jRepository;
 
 import java.util.List;
@@ -13,5 +14,9 @@ public interface MedicineRepository extends Neo4jRepository<Medicine, Long> {
     List<Medicine> findByNameContaining(String name);
 
     List<Medicine> findByNameIn(List<String> names);
+
+    @Query("MATCH (n:药品通用名称) RETURN DISTINCT(KEYS(n))")
+    List<String> getKeys();
+
 }