Przeglądaj źródła

字段标准化修改-台州邵逸夫入北仑

rengb 4 lat temu
rodzic
commit
9d34008997

+ 2 - 0
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/AIAnalyze.java

@@ -15,6 +15,7 @@ public class AIAnalyze {
     LeaveHospitalAI leaveHospitalAI = new LeaveHospitalAI();
     ThreeLevelWardAI threeLevelWardAI = new ThreeLevelWardAI();
     OperationAI operationAI = new OperationAI();
+    ConsultationAI consultationAI = new ConsultationAI();
 
     public AIAnalyze(CRFServiceClient crfService, SimilarityServiceClient similarityServiceClient) {
         this.crfServiceClient = crfService;
@@ -27,6 +28,7 @@ public class AIAnalyze {
         leaveHospitalAI.medrec(inputInfo, crfServiceClient);
         threeLevelWardAI.medrec(inputInfo, crfServiceClient);
         operationAI.medrec(inputInfo, crfServiceClient);
+        consultationAI.medrec(inputInfo, crfServiceClient);
     }
 
 }

+ 20 - 7
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/BeHospitalizedAI.java

@@ -13,7 +13,6 @@ import com.lantone.qc.kernel.structure.ai.process.EntityProcessPacs;
 import com.lantone.qc.kernel.structure.ai.process.EntityProcessPast;
 import com.lantone.qc.kernel.structure.ai.process.EntityProcessPersonal;
 import com.lantone.qc.kernel.structure.ai.process.EntityProcessVital;
-import com.lantone.qc.kernel.util.CatalogueUtil;
 import com.lantone.qc.pub.Content;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.doc.BeHospitalizedDoc;
@@ -31,7 +30,6 @@ import com.lantone.qc.pub.model.label.PastLabel;
 import com.lantone.qc.pub.model.label.PersonalLabel;
 import com.lantone.qc.pub.model.label.PresentLabel;
 import com.lantone.qc.pub.util.StringUtil;
-import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Component;
 
 import java.util.Arrays;
@@ -54,9 +52,10 @@ public class BeHospitalizedAI extends ModelAI {
      * chief_present[邵逸夫医院主诉]
      * Diagnoses_cx[诊断]
      * Present_cx[现病史]
+     * DiagnoseInAssistant[辅助检查]
      */
     public static List<String> medicalTextType = Arrays.asList("FirstCourseRecord_cx", "PastFamily_cx", "PersonalHistory_cx", "HPIForCX_cx",
-            "GeneralVital_cx", "chief_present", "Diagnoses_cx", "Present_cx");
+            "GeneralVital_cx", "chief_present", "Diagnoses_cx", "Present_cx", "DiagnoseInAssistant");
     public static String entityRelationObject = "entity_relation_object";
     public static String outputs = "outputs";
 
@@ -105,15 +104,16 @@ public class BeHospitalizedAI extends ModelAI {
                 String familyText = beHospitalizedDoc.getFamilyLabel().getText();
                 putContent(crfContent, medicalTextType.get(1), familyText, Content.family);
             }
-            /* 辅助检查(暂用主诉现病史模型,之后会新训练单独模型再做修改) */
+            /* 辅助检查 */
             if (beHospitalizedDoc.getPacsLabel() != null && beHospitalizedDoc.getPacsLabel().isCrfLabel()) {
                 String pacsText = beHospitalizedDoc.getPacsLabel().getText();
-                putContent(crfContent, medicalTextType.get(3), pacsText, Content.pacs);
+                putContent(crfContent, medicalTextType.get(3), pacsText, Content.pacs + "含时间地点");
+                putContent(crfContent, medicalTextType.get(8), pacsText, Content.pacs);
             }
             /* 专科检查(专科体格检查) */
             if (beHospitalizedDoc.getVitalLabelSpecial() != null && beHospitalizedDoc.getVitalLabelSpecial().isCrfLabel()) {
                 String vitalSpecialText = beHospitalizedDoc.getVitalLabelSpecial().getText();
-                putContent(crfContent, medicalTextType.get(3), vitalSpecialText, Content.special_exam);
+                putContent(crfContent, medicalTextType.get(7), vitalSpecialText, Content.special_exam);
             }
             /* 一般体格检查(存放一般查体) */
             if (beHospitalizedDoc.getVitalLabel() != null && beHospitalizedDoc.getVitalLabel().isCrfLabel()) {
@@ -154,6 +154,7 @@ public class BeHospitalizedAI extends ModelAI {
             /* 处理现病史 */
             if (beHospitalizedDoc.getPresentLabel() != null && beHospitalizedDoc.getPresentLabel().isCrfLabel()) {
                 putPresentCrfData(midData.getJSONObject(Content.present), inputInfo);
+                beHospitalizedDoc.getPresentLabel().setCrfOutput(midData.getJSONObject(Content.present));
             }
             /* 处理既往史 */
             if (beHospitalizedDoc.getPastLabel() != null && beHospitalizedDoc.getPastLabel().isCrfLabel()) {
@@ -187,8 +188,14 @@ public class BeHospitalizedAI extends ModelAI {
             if (beHospitalizedDoc.getSuppleDiagLabel() != null && beHospitalizedDoc.getSuppleDiagLabel().isCrfLabel()) {
                 putSuppleDiagCrfData(midData.getJSONObject(Content.supple_diag), inputInfo);
             }
+            /* 处理专科体格检查 */
+            if (beHospitalizedDoc.getVitalLabelSpecial() != null && beHospitalizedDoc.getVitalLabelSpecial().isCrfLabel()) {
+                beHospitalizedDoc.getVitalLabelSpecial().setCrfOutput(midData.getJSONObject(Content.special_exam));
+            }
             /* 处理辅助检查 */
             if (beHospitalizedDoc.getPacsLabel() != null && beHospitalizedDoc.getPacsLabel().isCrfLabel()) {
+                /* 辅检提取时间、地点和提取疾病分为两个模型 */
+                putPacsCrfData(midData.getJSONObject(Content.pacs + "含时间地点"), inputInfo);
                 putPacsCrfData(midData.getJSONObject(Content.pacs), inputInfo);
             }
         }
@@ -437,7 +444,13 @@ public class BeHospitalizedAI extends ModelAI {
         }
         //放置入inputinfo
         PacsLabel pacsLabel = inputInfo.getBeHospitalizedDoc().getPacsLabel();
-        pacsLabel.setPacses(loadPacses(aiOut));
+        if (pacsLabel.getPacses() == null) {
+            pacsLabel.setPacses(loadPacses(aiOut));
+        } else {
+            List<Pacs> pacses = pacsLabel.getPacses();
+            pacses.addAll(loadPacses(aiOut));
+            pacsLabel.setPacses(pacses);
+        }
     }
 
     /**

+ 33 - 5
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/FirstCourseRecordAI.java

@@ -7,12 +7,15 @@ import com.lantone.qc.kernel.client.CRFServiceClient;
 import com.lantone.qc.kernel.client.SimilarityServiceClient;
 import com.lantone.qc.kernel.structure.ai.process.EntityProcessClinic;
 import com.lantone.qc.kernel.structure.ai.process.EntityProcessDiag;
+import com.lantone.qc.kernel.structure.ai.process.EntityProcessDrug;
 import com.lantone.qc.kernel.structure.ai.process.EntityProcessTreatPlan;
 import com.lantone.qc.kernel.util.CatalogueUtil;
 import com.lantone.qc.pub.Content;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.doc.FirstCourseRecordDoc;
 import com.lantone.qc.pub.model.entity.Diag;
+import com.lantone.qc.pub.model.entity.Drug;
+import com.lantone.qc.pub.model.label.DrugLabel;
 import com.lantone.qc.pub.model.label.PresentLabel;
 import com.lantone.qc.pub.model.label.TreatPlanLabel;
 import com.lantone.qc.pub.util.StringUtil;
@@ -32,7 +35,8 @@ public class FirstCourseRecordAI extends ModelAI {
     /**
      *
      */
-    public static List<String> medicalTextType = Arrays.asList("FirstCoursera_cx", "Diagnoses_cx", "FirstCourseTreatment_cx");
+    public static List<String> medicalTextType = Arrays.asList("FirstCoursera_cx", "Diagnoses_cx"
+            , "FirstCourseTreatment_cx", "CourseRecordSRR");
     public static String entityRelationObject = "entity_relation_object";
     public static String outputs = "outputs";
     public static String content = "content";
@@ -82,6 +86,9 @@ public class FirstCourseRecordAI extends ModelAI {
             if (treatPlanLabel != null && StringUtil.isNotBlank(treatPlanLabel.getAiText())) {
                 putContent(crfContent, medicalTextType.get(2), treatPlanLabel.getAiText(), "诊疗计划");
             }
+
+            String drugContent = CatalogueUtil.structureMapJoin(structureMap, Lists.newArrayList("治疗计划"));
+            putContent(crfContent, medicalTextType.get(3), drugContent, "药品");
             /*
             if (StringUtils.isNotEmpty(structureMap.get("诊疗计划")) && StringUtils.isNotEmpty(structureMap.get("需求评估"))) {
                 putContent(crfContent, medicalTextType.get(2), structureMap.get("诊疗计划") + structureMap.get("需求评估"), "诊疗计划");
@@ -102,11 +109,10 @@ public class FirstCourseRecordAI extends ModelAI {
                 //先从结构化数据找病例特点
                 if (StringUtil.isNotBlank(structureMap.get("现病史"))) {
                     putContent(similarContent, structureMap.get("现病史"), inputInfo.getBeHospitalizedDoc().getPresentLabel().getText());
+                } else if (firstCourseRecordDoc.getCaseCharacteristicLabel() != null && StringUtil.isNotBlank(firstCourseRecordDoc.getCaseCharacteristicLabel().getText())) {
+                    //再从doc找病例特点
+                    putContent(similarContent, firstCourseRecordDoc.getCaseCharacteristicLabel().getText(), inputInfo.getBeHospitalizedDoc().getPresentLabel().getText());
                 }
-                //                else if (firstCourseRecordDoc.getCaseCharacteristicLabel() != null && StringUtil.isNotBlank(firstCourseRecordDoc.getCaseCharacteristicLabel().getText())) {
-                //                    //再从doc找病例特点
-                //                    putContent(similarContent, firstCourseRecordDoc.getCaseCharacteristicLabel().getText(), inputInfo.getBeHospitalizedDoc().getPresentLabel().getText());
-                //                }
             }
 
             JSONObject midData = loadAI(inputInfo.isUseCrfCache(), inputInfo.getMedicalRecordInfoDoc().getStructureMap().get("behospitalCode"), crfContent, crfServiceClient);//crf返回数据
@@ -125,6 +131,9 @@ public class FirstCourseRecordAI extends ModelAI {
             if (midData.containsKey("诊疗计划")) {
                 putTreatPlanCrfData(midData.getJSONObject("诊疗计划"), inputInfo);//处理诊疗计划
             }
+            if (midData.containsKey("药品")) {
+                putDrugCrfData(midData.getJSONObject("药品"), inputInfo);
+            }
 
             double likeRate = loadSimilarAI(similarContent, similarityServiceClient);
             putCaseCharacteristicSimilarData(likeRate, inputInfo);//存放与现病史文本相似度
@@ -229,4 +238,23 @@ public class FirstCourseRecordAI extends ModelAI {
         treatPlanLabel.setText(inputInfo.getFirstCourseRecordDoc().getTreatPlanLabel().getText());
         inputInfo.getFirstCourseRecordDoc().setTreatPlanLabel(treatPlanLabel);
     }
+
+    /**
+     * 存放抓取的药品
+     *
+     * @param jsonObject
+     * @param inputInfo
+     */
+    public void putDrugCrfData(JSONObject jsonObject, InputInfo inputInfo) {
+        JSONObject aiOut = loadEntity(jsonObject, entityRelationObject, outputs, content);
+        if (aiOut == null) {
+            return;
+        }
+        EntityProcessDrug entityProcessDrug = new EntityProcessDrug();
+        List<Drug> drugs = entityProcessDrug.extractEntity(aiOut);
+        FirstCourseRecordDoc firstCourseRecordDoc = inputInfo.getFirstCourseRecordDoc();
+        DrugLabel label = new DrugLabel();
+        label.setDrugs(drugs);
+        firstCourseRecordDoc.setDrugLabel(label);
+    }
 }