hujing пре 5 година
родитељ
комит
0c0237b282

+ 2 - 1
kernel/src/main/java/com/lantone/qc/kernel/catalogue/leavehospital/LEA0149.java

@@ -3,6 +3,7 @@ package com.lantone.qc.kernel.catalogue.leavehospital;
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
+import com.lantone.qc.pub.model.entity.Chief;
 import com.lantone.qc.pub.model.entity.General;
 import com.lantone.qc.pub.model.label.LeaveHospitalLabel;
 import com.lantone.qc.pub.util.ListUtil;
@@ -23,7 +24,7 @@ public class LEA0149 extends QCCatalogue {
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
         LeaveHospitalLabel leaveHospitalLabel = inputInfo.getLeaveHospitalDoc().getLeaveHospitalLabel();
         if (leaveHospitalLabel != null) {
-            List<General> chiefs = leaveHospitalLabel.getChiefs();
+            List<Chief> chiefs = leaveHospitalLabel.getChiefs();
             if (ListUtil.isNotEmpty(chiefs)) {
                 long count = chiefs.stream().filter(i -> i != null && StringUtil.isNotBlank(i.getName())).count();
                 if (count > 0) {

+ 5 - 6
kernel/src/main/java/com/lantone/qc/kernel/catalogue/leavehospital/LEA0155.java

@@ -1,6 +1,7 @@
 package com.lantone.qc.kernel.catalogue.leavehospital;
 
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
+import com.lantone.qc.kernel.util.CatalogueUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.entity.DoctorAdvice;
@@ -21,14 +22,12 @@ public class LEA0155 extends QCCatalogue {
 
     @Override
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
+        status = "0";
         LeaveHospitalLabel leaveHospitalLabel = inputInfo.getLeaveHospitalDoc().getLeaveHospitalLabel();
         if (leaveHospitalLabel != null) {
-            List<DoctorAdvice> doctorAdvices = leaveHospitalLabel.getDoctorAdvices();
-            if (ListUtil.isNotEmpty(doctorAdvices)) {
-                long count = doctorAdvices.stream().filter(i -> i != null && StringUtil.isNotBlank(i.getName())).count();
-                if (count > 0) {
-                    status = "0";
-                }
+            DoctorAdvice doctorAdvices = leaveHospitalLabel.getDoctorAdvices();
+            if (CatalogueUtil.isEmpty(doctorAdvices.getName())) {
+                status = "-1";
             }
         }
     }

+ 4 - 4
kernel/src/main/java/com/lantone/qc/kernel/catalogue/leavehospital/LEA0156.java

@@ -3,7 +3,7 @@ package com.lantone.qc.kernel.catalogue.leavehospital;
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
-import com.lantone.qc.pub.model.entity.Notice;
+import com.lantone.qc.pub.model.entity.Notes;
 import com.lantone.qc.pub.model.label.LeaveHospitalLabel;
 import com.lantone.qc.pub.util.ListUtil;
 import com.lantone.qc.pub.util.StringUtil;
@@ -23,9 +23,9 @@ public class LEA0156 extends QCCatalogue {
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
         LeaveHospitalLabel leaveHospitalLabel = inputInfo.getLeaveHospitalDoc().getLeaveHospitalLabel();
         if (leaveHospitalLabel != null) {
-            List<Notice> notices = leaveHospitalLabel.getNotices();
-            if (ListUtil.isNotEmpty(notices)) {
-                long count = notices.stream().filter(i -> i != null && StringUtil.isNotBlank(i.getName())).count();
+            List<Notes> notes = leaveHospitalLabel.getNotes();
+            if (ListUtil.isNotEmpty(notes)) {
+                long count = notes.stream().filter(i -> i != null && StringUtil.isNotBlank(i.getName())).count();
                 if (count > 0) {
                     status = "0";
                 }

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

@@ -12,13 +12,17 @@ public class AIAnalyze {
 
     private CRFServiceClient crfServiceClient;
     BeHospitalizedAI beHospitalizedAI = new BeHospitalizedAI();
+    FirstCourseRecordAI firstCourseRecordAI = new FirstCourseRecordAI();
+    LeaveHospitalAI leaveHospitalAI = new LeaveHospitalAI();
 
     public AIAnalyze(CRFServiceClient crfService) {
         this.crfServiceClient = crfService;
     }
-    public void AIprocess(InputInfo inputInfo){
-            beHospitalizedAI.medrec(inputInfo, crfServiceClient);
 
+    public void AIprocess(InputInfo inputInfo) {
+        beHospitalizedAI.medrec(inputInfo, crfServiceClient);
+        firstCourseRecordAI.medrec(inputInfo, crfServiceClient);
+        leaveHospitalAI.medrec(inputInfo, crfServiceClient);
     }
 
 

+ 4 - 3
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/BeHospitalizedAI.java

@@ -36,11 +36,12 @@ public class BeHospitalizedAI extends ModelAI {
      * PersonalHistory_cx[个人史(月经史、婚育史)]
      * HPIForCX_cx[主诉、现病史、专科检查]
      * GeneralVital_cx[一般体格检查]
-     * chief_present[邵逸夫医院主诉现病史]
+     * chief_present[邵逸夫医院主诉]
      * primary_diag[诊断]
+     * Present_cx[现病史]
      */
     public static List<String> medicalTextType = Arrays.asList("FirstCourseRecord_cx", "PastFamily_cx", "PersonalHistory_cx", "HPIForCX_cx",
-            "GeneralVital_cx", "chief_present", "Diagnoses_cx");
+            "GeneralVital_cx", "chief_present", "Diagnoses_cx","Present_cx");
     public static String entityRelationObject = "entity_relation_object";
     public static String outputs = "outputs";
 
@@ -68,7 +69,7 @@ public class BeHospitalizedAI extends ModelAI {
             //主诉
             putContent(crfContent, medicalTextType.get(3), chief_text, Content.chief);
             //现病史
-            putContent(crfContent, medicalTextType.get(3), present_text, Content.present);
+            putContent(crfContent, medicalTextType.get(7), present_text, Content.present);
             //专科检查
             putContent(crfContent, medicalTextType.get(3), vitalSpecial_text, Content.special_exam);
             //既往史

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

@@ -29,6 +29,7 @@ public class FirstCourseRecordAI extends ModelAI {
     public static List<String> medicalTextType = Arrays.asList("FirstCoursera_cx", "Diagnoses_cx");
     public static String entityRelationObject = "entity_relation_object";
     public static String outputs = "outputs";
+    public static String content = "content";
 
     public void medrec(InputInfo inputInfo, CRFServiceClient crfServiceClient) {
         JSONArray crfContent = new JSONArray();
@@ -56,11 +57,12 @@ public class FirstCourseRecordAI extends ModelAI {
 
     /**
      * 病历特点
+     *
      * @param jsonObject
      * @param inputInfo
      */
     public void putCaseCharacteristicCrfData(JSONObject jsonObject, InputInfo inputInfo) {
-        JSONObject aiOut = loadEntity(jsonObject, entityRelationObject, outputs);
+        JSONObject aiOut = loadEntity(jsonObject, entityRelationObject, outputs, content);
         //使用现病史结构来处理病历特点
         EntityProcessClinic entityProcessClinic = new EntityProcessClinic();
         PresentLabel presentLabel = entityProcessClinic.extractEntity(aiOut);
@@ -70,11 +72,12 @@ public class FirstCourseRecordAI extends ModelAI {
 
     /**
      * 初步诊断
+     *
      * @param jsonObject
      * @param inputInfo
      */
     public void putInitialDiagCrfData(JSONObject jsonObject, InputInfo inputInfo) {
-        JSONObject aiOut = loadEntity(jsonObject, entityRelationObject, outputs);
+        JSONObject aiOut = loadEntity(jsonObject, entityRelationObject, outputs, content);
         //诊断信息
         EntityProcessDiag entityProcessDiag = new EntityProcessDiag();
         List<Diag> diags = entityProcessDiag.extractEntity(aiOut);
@@ -83,11 +86,12 @@ public class FirstCourseRecordAI extends ModelAI {
 
     /**
      * 诊断依据
+     *
      * @param jsonObject
      * @param inputInfo
      */
     public void putDiagnosisCrfData(JSONObject jsonObject, InputInfo inputInfo) {
-        JSONObject aiOut = loadEntity(jsonObject, entityRelationObject, outputs);
+        JSONObject aiOut = loadEntity(jsonObject, entityRelationObject, outputs, content);
         //使用现病史结构来处理诊断依据
         EntityProcessClinic entityProcessClinic = new EntityProcessClinic();
         PresentLabel presentLabel = entityProcessClinic.extractEntity(aiOut);
@@ -97,11 +101,12 @@ public class FirstCourseRecordAI extends ModelAI {
 
     /**
      * 鉴别诊断
+     *
      * @param jsonObject
      * @param inputInfo
      */
     public void putDifferentialDiagCrfData(JSONObject jsonObject, InputInfo inputInfo) {
-        JSONObject aiOut = loadEntity(jsonObject, entityRelationObject, outputs);
+        JSONObject aiOut = loadEntity(jsonObject, entityRelationObject, outputs, content);
         //诊断信息
         EntityProcessDiag entityProcessDiag = new EntityProcessDiag();
         List<Diag> diags = entityProcessDiag.extractEntity(aiOut);
@@ -110,11 +115,12 @@ public class FirstCourseRecordAI extends ModelAI {
 
     /**
      * 诊疗计划
+     *
      * @param jsonObject
      * @param inputInfo
      */
     public void putTreatPlanCrfData(JSONObject jsonObject, InputInfo inputInfo) {
-        JSONObject aiOut = loadEntity(jsonObject, entityRelationObject, outputs);
+        JSONObject aiOut = loadEntity(jsonObject, entityRelationObject, outputs, content);
         //诊疗计划
         EntityProcessTreatPlan entityProcessTreatPlan = new EntityProcessTreatPlan();
         TreatPlanLabel treatPlanLabel = entityProcessTreatPlan.extractEntity(aiOut);

+ 52 - 5
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/LeaveHospitalAI.java

@@ -1,10 +1,57 @@
 package com.lantone.qc.kernel.structure.ai;
 
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.lantone.qc.kernel.client.CRFServiceClient;
+import com.lantone.qc.kernel.structure.ai.process.EntityProcessLeaveHospital;
+import com.lantone.qc.pub.Content;
+import com.lantone.qc.pub.model.InputInfo;
+import com.lantone.qc.pub.model.doc.LeaveHospitalDoc;
+import com.lantone.qc.pub.model.label.LeaveHospitalLabel;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Arrays;
+import java.util.List;
+
 /**
- * @ClassName : LeaveHospitalAI
- * @Description : 出院小结
- * @Author : 楼辉荣
- * @Date: 2020-03-20 10:33
+ * @ClassName : DischargeAI
+ * @Description :
+ * @Author : 胡敬
+ * @Date: 2020-03-20 11:00
  */
-public class LeaveHospitalAI {
+public class LeaveHospitalAI extends ModelAI {
+    /**
+     *
+     */
+    public static List<String> medicalTextType = Arrays.asList("DischargeQA_cx");
+    public static String entityRelationObject = "entity_relation_object";
+    public static String outputs = "outputs";
+    public static String content = "content";
+
+    public void medrec(InputInfo inputInfo, CRFServiceClient crfServiceClient) {
+        JSONArray crfContent = new JSONArray();
+        LeaveHospitalDoc leaveHospitalDoc = inputInfo.getLeaveHospitalDoc();
+        if (leaveHospitalDoc != null && StringUtils.isNotEmpty(leaveHospitalDoc.getText())) {
+            //出院小结全部文本
+            putContent(crfContent, medicalTextType.get(0), leaveHospitalDoc.getText(), Content.discharge);
+
+            JSONObject midData = loadAI(crfContent, crfServiceClient);//crf返回数据
+            putDischargeCrfData(midData.getJSONObject(Content.discharge), inputInfo);//出院小结
+        }
+    }
+
+    /**
+     * 病历特点
+     *
+     * @param jsonObject
+     * @param inputInfo
+     */
+    public void putDischargeCrfData(JSONObject jsonObject, InputInfo inputInfo) {
+        JSONObject aiOut = loadEntity(jsonObject, entityRelationObject, outputs, content);
+        //使用现病史结构来处理病历特点
+        EntityProcessLeaveHospital entityProcessLeaveHospital = new EntityProcessLeaveHospital();
+        LeaveHospitalLabel leaveHospitalLabel = entityProcessLeaveHospital.extractEntity(aiOut);
+        //临床表现
+        inputInfo.getLeaveHospitalDoc().setLeaveHospitalLabel(leaveHospitalLabel);
+    }
 }

+ 3 - 2
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/ModelAI.java

@@ -33,11 +33,12 @@ public class ModelAI {
         return midData;
     }
 
-    protected JSONObject loadEntity(JSONObject jsonObject, String entityRelationObject, String outputs) {
-        if(jsonObject ==null) {
+    protected JSONObject loadEntity(JSONObject jsonObject, String entityRelationObject, String outputs, String content) {
+        if (jsonObject == null) {
             return new JSONObject();
         }
         JSONObject aiOut = jsonObject.getJSONObject(entityRelationObject).getJSONObject(outputs);
+        aiOut.put(content, jsonObject.getJSONObject(entityRelationObject).getJSONObject(content));
         return aiOut;
     }
 

+ 3 - 2
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/model/EntityEnum.java

@@ -8,7 +8,7 @@ package com.lantone.qc.kernel.structure.ai.model;
 public enum EntityEnum {
     CLINICAL_FEATURE("临床表现"), DIEASE("疾病名称"), BODY("身体部位"), SIGN("体征"), INDEX_VALUE("指标值"),
     LABORATORY("实验室检查"), LABORATORY_VALUE("实验室检查值"), AUXILIARY_EXAMINATION("辅助检查"), AUXILIARY_DESCRIPT("辅助检查描述"),
-        NEGATIVE("否定"), POSSIBLE("可能的"), TIME("时间"), CAUSE("诱因"), MODIFICATION("修饰"),
+    NEGATIVE("否定"), POSSIBLE("可能的"), TIME("时间"), CAUSE("诱因"), MODIFICATION("修饰"),
     PROPERTY("性质"), DEGREE("程度"), AGGRAVATE("加重情况"), RELIEF("缓解情况"), BEHOSPITALIZEDWAY("入院途径"),
     TREND("趋势"), FREQUENCY("频率"), QUANTITY("数量"), SIZE("尺寸"), CURE("治疗"), DRUG("药物名称"),
     DOSE("药品剂量"), OPERATION("手术名称"), GENERAL("一般情况"), GENERAL_DESCRIPT("一般情况描述"),
@@ -21,7 +21,8 @@ public enum EntityEnum {
     OCCUPATION("职业"), LOCATION("地点"), DEAD("死亡"), DEAD_REASON("死亡原因"),
     SIMILAR_DISEASE_KEYWORD("相似疾病"), GENETIC_DISEASE_KEYWORD("家族遗传病"), EPIDEMIC_AREA_HISTORY("疫区史"), SPECIAL_HOBBY("特殊嗜好"),
     CONTACT_HISTORY("接触史"), MARITAL_HISTORY("冶游史"), MARITAL_STATUS("婚姻情况"), MARRYIAGE("结婚年龄"), NEAR_RELATION("近亲史"),
-    CURE_AIM("治疗目的"), OTHER("其他"),OUTERCOURTYARD("外院"),NURSINGLEVEL("护理级别");
+    CURE_AIM("治疗目的"), OTHER("其他"), OUTERCOURTYARD("外院"), NURSINGLEVEL("护理级别"), CHIEF("主诉"), NOTES("注意事项"),
+    KEY_WORD_FOR_DOCTOR_ADVICES("出院医嘱标题"), DOCTORADVICE("医嘱"), KEY_WORD_FOR_PART("大标题"), OUTCOME("转归情况");
 
     private String value;
 

+ 74 - 0
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/process/EntityProcessLeaveHospital.java

@@ -0,0 +1,74 @@
+package com.lantone.qc.kernel.structure.ai.process;
+
+import com.alibaba.fastjson.JSONObject;
+import com.lantone.qc.kernel.structure.ai.model.EntityEnum;
+import com.lantone.qc.kernel.structure.ai.model.Lemma;
+import com.lantone.qc.pub.model.entity.Chief;
+import com.lantone.qc.pub.model.entity.DoctorAdvice;
+import com.lantone.qc.pub.model.entity.Medicine;
+import com.lantone.qc.pub.model.entity.Notes;
+import com.lantone.qc.pub.model.entity.NursingLevel;
+import com.lantone.qc.pub.model.entity.Outcome;
+import com.lantone.qc.pub.model.label.LeaveHospitalLabel;
+import com.lantone.qc.pub.model.label.TreatPlanLabel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @ClassName : EntityProcessLeaveHospital
+ * @Description : 出院小结
+ * @Author : 胡敬
+ * @Date: 2020-03-20 11:20
+ */
+public class EntityProcessLeaveHospital extends EntityProcess {
+    public LeaveHospitalLabel extractEntity(JSONObject aiOut) {
+        LeaveHospitalLabel leaveHospitalLabel = new LeaveHospitalLabel();
+        //主诉
+        List<Lemma> chiefLemmas = createEntityTree(aiOut, EntityEnum.CHIEF.toString());
+        List<Chief> chiefs = new ArrayList<>();
+        for (Lemma lemma : chiefLemmas) {
+            Chief chief = new Chief();
+            chief.setName(lemma.getText());
+            chiefs.add(chief);
+        }
+        leaveHospitalLabel.setChiefs(chiefs);
+        //注意事项
+        List<Lemma> notesLemmas = createEntityTree(aiOut, EntityEnum.NOTES.toString());
+        List<Notes> noteses = new ArrayList<>();
+        for (Lemma lemma : notesLemmas) {
+            Notes notes = new Notes();
+            notes.setName(lemma.getText());
+            noteses.add(notes);
+        }
+        leaveHospitalLabel.setNoteses(noteses);
+        //医嘱
+        List<Lemma> keyWordForDoctorAdvicesesLemmas = createEntityTree(aiOut, EntityEnum.KEY_WORD_FOR_DOCTOR_ADVICES.toString());
+        List<Lemma> keyWordForPartLemmas = createEntityTree(aiOut, EntityEnum.KEY_WORD_FOR_PART.toString());
+        DoctorAdvice doctorAdvice = new DoctorAdvice();
+        int keyWordForDoctorAdvicesesStart = 0, partStart = 0, minPart = 0;
+        for (Lemma doctorAdviceLemma : keyWordForDoctorAdvicesesLemmas) {
+            keyWordForDoctorAdvicesesStart = Integer.parseInt(doctorAdviceLemma.getPosition());
+            for (Lemma part : keyWordForPartLemmas) {
+                partStart = Integer.parseInt(part.getPosition());
+                if (minPart == 0 || partStart > keyWordForDoctorAdvicesesStart && partStart < minPart) {
+                    minPart = partStart;
+                }
+            }
+        }
+        String content = aiOut.getString("content");
+        String doctorAdviceContent = content.substring(keyWordForDoctorAdvicesesStart, minPart);
+        doctorAdvice.setName(doctorAdviceContent);
+        leaveHospitalLabel.setDoctorAdvices(doctorAdvice);
+        //转归情况
+        List<Lemma> outcomeLemmas = createEntityTree(aiOut, EntityEnum.OUTCOME.toString());
+        List<Outcome> outcomes = new ArrayList<>();
+        for (Lemma lemma : outcomeLemmas) {
+            Outcome outcome = new Outcome();
+            outcome.setName(lemma.getText());
+            outcomes.add(outcome);
+        }
+        leaveHospitalLabel.setOutcomes(outcomes);
+        return leaveHospitalLabel;
+    }
+}

+ 2 - 0
public/src/main/java/com/lantone/qc/pub/Content.java

@@ -114,6 +114,8 @@ public class Content {
     public static final String differential_diag_basis = "四、鉴别诊断";
     public static final String treat_plan = "五、诊疗计划";
 
+    public static final String discharge = "出院小结";
+
 
     public static final String name_medical_institution = "医疗机构名称";
     public static final String code_medical_institution = "医疗机构代码";

+ 16 - 0
public/src/main/java/com/lantone/qc/pub/model/entity/Chief.java

@@ -0,0 +1,16 @@
+package com.lantone.qc.pub.model.entity;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @ClassName : Chief
+ * @Description : 主诉
+ * @Author : 胡敬
+ * @Date: 2020-03-20 10:52
+ */
+
+@Getter
+@Setter
+public class Chief extends General {
+}

+ 1 - 1
public/src/main/java/com/lantone/qc/pub/model/entity/Notice.java

@@ -6,5 +6,5 @@ package com.lantone.qc.pub.model.entity;
  * @Author : 楼辉荣
  * @Date: 2020-03-18 15:54
  */
-public class Notice extends General {
+public class Notes extends General {
 }

+ 14 - 0
public/src/main/java/com/lantone/qc/pub/model/entity/Outcome.java

@@ -0,0 +1,14 @@
+package com.lantone.qc.pub.model.entity;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 转归情况
+@Setter
+@Getter
+*/
+@Setter
+@Getter
+public class Outcome extends General{
+}

+ 7 - 5
public/src/main/java/com/lantone/qc/pub/model/label/LeaveHospitalLabel.java

@@ -1,8 +1,9 @@
 package com.lantone.qc.pub.model.label;
 
+import com.lantone.qc.pub.model.entity.Chief;
 import com.lantone.qc.pub.model.entity.DoctorAdvice;
-import com.lantone.qc.pub.model.entity.General;
-import com.lantone.qc.pub.model.entity.Notice;
+import com.lantone.qc.pub.model.entity.Notes;
+import com.lantone.qc.pub.model.entity.Outcome;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -18,7 +19,8 @@ import java.util.List;
 @Getter
 @Setter
 public class LeaveHospitalLabel {
-    List<General> chiefs = new ArrayList<>();   //主诉
-    List<Notice> notices = new ArrayList<>();   //注意事项
-    List<DoctorAdvice> doctorAdvices = new ArrayList<>();   //医嘱信息
+    List<Chief> chiefs = new ArrayList<>();   //主诉
+    List<Notes> noteses = new ArrayList<>();   //注意事项
+    DoctorAdvice doctorAdvices;   //医嘱信息
+    List<Outcome> outcomes = new ArrayList<>();   //转归情况
 }