Explorar o código

用药及手术禁忌规则

kwzbigdata %!s(int64=4) %!d(string=hai) anos
pai
achega
60bf6f2308
Modificáronse 1 ficheiros con 39 adicións e 12 borrados
  1. 39 12
      src/main/java/com/diagbot/process/BillProcess.java

+ 39 - 12
src/main/java/com/diagbot/process/BillProcess.java

@@ -9,12 +9,10 @@ import com.diagbot.dto.IndicationDTO;
 import com.diagbot.dto.NodeNeoDTO;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.enums.NeoEnum;
-import com.diagbot.model.entity.Clinical;
-import com.diagbot.model.entity.Diag;
-import com.diagbot.model.entity.Medicine;
-import com.diagbot.model.entity.Operation;
+import com.diagbot.model.entity.*;
 import com.diagbot.model.label.ChiefLabel;
 import com.diagbot.model.label.DiagLabel;
+import com.diagbot.model.label.PastLabel;
 import com.diagbot.model.label.PresentLabel;
 import com.diagbot.rule.AgeRule;
 import com.diagbot.rule.DiagRule;
@@ -23,6 +21,7 @@ import com.diagbot.rule.PacsRule;
 import com.diagbot.rule.SexRule;
 import com.diagbot.util.BeanUtil;
 import com.diagbot.util.ListUtil;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
@@ -93,10 +92,12 @@ public class BillProcess {
         DiagLabel diagLabel = wordCrfDTO.getDiagLabel();
         ChiefLabel chiefLabel = wordCrfDTO.getChiefLabel();
         PresentLabel presentLabel = wordCrfDTO.getPresentLabel();
+        PastLabel pastLabel = wordCrfDTO.getPastLabel();
         List<Diag> diags = new ArrayList<>();
         List<Clinical> clinicals = new ArrayList<>();
-        List<Operation> operations = presentLabel.getOperations();
-        List<Medicine> medicines = presentLabel.getMedicines();
+        List<Operation> operations_present = presentLabel.getOperations();
+        List<Operation> operations_past = pastLabel.getOperations();
+        operations_present.addAll(operations_past);
         if(diagLabel != null){
             diags = diagLabel.getDiags();
         }
@@ -130,16 +131,42 @@ public class BillProcess {
             //临床表现
             DiagRule.compareDiseaseWithBill(bill.getClinicfindings(), clinicals, bill, billMsgList, NeoEnum.clinicfindings.getName());
 
-            //手术
-            DiagRule.compareDiseaseWithBill(bill.getOperations(), operations, bill, billMsgList, NeoEnum.operations.getName());
+            //手术(既往史、现病史)
+            DiagRule.compareDiseaseWithBill(bill.getOperations(), operations_present, bill, billMsgList, NeoEnum.operations.getName());
 
-            //禁忌过敏药品
-            DiagRule.compareDiseaseWithBill(bill.getAllergicmeds(), medicines, bill, billMsgList, NeoEnum.allergicmeds.getName());
+            //禁忌过敏药品(既往史)
+            DiagRule.compareDiseaseWithBill(bill.getAllergicmeds(), pastLabel.getAllergyMedicines(), bill, billMsgList, NeoEnum.allergicmeds.getName());
 
-            //服用药品
-            DiagRule.compareDiseaseWithBill(bill.getOralmeds(), medicines, bill, billMsgList, NeoEnum.oralmeds.getName());
+            //服用药品(现病史一般情况后的药品)
+            DiagRule.compareDiseaseWithBill(bill.getOralmeds(), takeMedicine(presentLabel), bill, billMsgList, NeoEnum.oralmeds.getName());
 
         }
         indicationDTO.setBillMsgList(billMsgList);
     }
+
+    /**
+     * 一般情况以后的药品
+     * @param presentLabel
+     */
+    public List<Medicine> takeMedicine(PresentLabel presentLabel){
+        List<Medicine> takems = new ArrayList<>();
+        List<GeneralDesc> generals = presentLabel.getGenerals();
+        List<Medicine> medicines = presentLabel.getMedicines();
+        if (generals.size() > 0) {
+            String presentText = presentLabel.getText();
+            if (StringUtils.isNotBlank(presentText) && medicines != null && medicines.size() > 0) {
+                String lastGeneral = generals.get(generals.size() - 1).getName();
+                int lastGeneralIndex = presentText.lastIndexOf(lastGeneral);
+                for (Medicine medicine : medicines) {
+                    /* 现病史中一般情况之后的药品名称,并且不包含不详 */
+                    int medicine_index = presentText.indexOf(medicine.getName());
+                    if (medicine_index > lastGeneralIndex && !medicine.getName().contains("不详")) {
+                        takems.add(medicine);
+                    }
+                }
+            }
+        }
+        return takems;
+
+    }
 }