浏览代码

个人史关系解读后结构化

louhr 5 年之前
父节点
当前提交
f4fb096074

+ 15 - 6
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/BeHospitalizedAI.java

@@ -88,7 +88,7 @@ public class BeHospitalizedAI {
         //处理既往史
         putPastCrfData(midData.getJSONObject(Content.past), inputInfo);
         //处理个人史
-        putPersonCrfData(midData.getJSONObject(Content.personal), inputInfo);
+        putPersonalCrfData(midData.getJSONObject(Content.personal), inputInfo);
         //处理家族史
         putFamilyCrfData(midData.getJSONObject(Content.family),inputInfo);
 
@@ -146,6 +146,7 @@ public class BeHospitalizedAI {
         EntityProcessFamily entityProcess = new EntityProcessFamily();
         FamilyLabel familyLabel = entityProcess.extractEntity(aiOut);
         familyLabel.setText(inputInfo.getBeHospitalizedDoc().getFamilyLabel().getText());
+        inputInfo.getBeHospitalizedDoc().setFamilyLabel(familyLabel);
     }
 
     /**
@@ -162,6 +163,7 @@ public class BeHospitalizedAI {
         EntityProcessMarital entityProcess = new EntityProcessMarital();
         MaritalLabel maritalLabel = entityProcess.extractEntity(aiOut);
         maritalLabel.setText(inputInfo.getBeHospitalizedDoc().getMaritalLabel().getText());
+        inputInfo.getBeHospitalizedDoc().setMaritalLabel(maritalLabel);
     }
 
     public void putPastCrfData(JSONObject jsonObject, InputInfo inputInfo){
@@ -174,15 +176,22 @@ public class BeHospitalizedAI {
         inputInfo.getBeHospitalizedDoc().setPastLabel(entityProcessPast.extractEntity(aiOut));
 
     }
-    public void putPersonCrfData(JSONObject jsonObject, InputInfo inputInfo){
+
+    /**
+     * 个人史信息提取
+     * @param jsonObject
+     * @param inputInfo
+     */
+    public void putPersonalCrfData(JSONObject jsonObject, InputInfo inputInfo){
         if (jsonObject == null) {
             return;
         }
         JSONObject aiOut = jsonObject.getJSONObject(entityRelationObject).getJSONObject(BeHospitalizedAI.outputs);
-        //放置入inputinfo
-        PersonalLabel personalLabel = inputInfo.getBeHospitalizedDoc().getPersonalLabel();
-        personalLabel.setDiags(loadDiags(aiOut));
-
+        //个人史信息提取
+        EntityProcessPersonal entityProcessPersonal = new EntityProcessPersonal();
+        PersonalLabel personalLabel = entityProcessPersonal.extractEntity(aiOut);
+        personalLabel.setText(inputInfo.getBeHospitalizedDoc().getPersonalLabel().getText());;
+        inputInfo.getBeHospitalizedDoc().setPersonalLabel(personalLabel);
     }
     /**
      * 关系抽取临床表现信息

+ 119 - 0
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/process/EntityProcessPersonal.java

@@ -0,0 +1,119 @@
+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.*;
+import com.lantone.qc.pub.model.label.MaritalLabel;
+import com.lantone.qc.pub.model.label.PersonalLabel;
+
+import java.util.List;
+
+import static com.lantone.qc.pub.Content.family;
+
+/**
+ * @ClassName : EntityProcessPersonal
+ * @Description : 个人史
+ * @Author : 楼辉荣
+ * @Date: 2020-03-10 10:20
+ */
+public class EntityProcessPersonal extends EntityProcess {
+    public PersonalLabel extractEntity(JSONObject aiOut) {
+        PersonalLabel personalLabel = new PersonalLabel();
+        //地点
+        List<Lemma> addressLemmas = createEntityTree(aiOut, EntityEnum.LOCATION.toString());
+        for (Lemma lemma :addressLemmas) {
+            Address address = new Address();
+            address.setName(lemma.getText());
+            personalLabel.setAddress(address);
+        }
+        //职业
+        List<Lemma> occupationLemmas = createEntityTree(aiOut, EntityEnum.OCCUPATION.toString());
+        for (Lemma lemma :occupationLemmas) {
+            Occupation occupation = new Occupation();
+            occupation.setName(lemma.getText());
+            personalLabel.setOccupation(occupation);
+        }
+        //疫区史
+        List<Lemma> fertilityLemmas = createEntityTree(aiOut, EntityEnum.EPIDEMIC_AREA_HISTORY.toString());
+        for (Lemma lemma :fertilityLemmas) {
+            EpidemicArea epidemicArea = new EpidemicArea();
+            epidemicArea.setName(lemma.getText());
+            personalLabel.setEpidemicArea(epidemicArea);
+        }
+        //接触史
+        List<Lemma> contactLemmas = createEntityTree(aiOut, EntityEnum.CONTACT_HISTORY.toString());
+        for (Lemma lemma :contactLemmas) {
+            Contact contact = new Contact();
+            contact.setName(lemma.getText());
+            personalLabel.setContact(contact);
+        }
+        //吸烟史
+        List<Lemma> smokingLemmas = createEntityTree(aiOut, EntityEnum.SMOKING_HISTORY.toString());
+        for (Lemma lemma :smokingLemmas) {
+            Smoking smoking = new Smoking();
+            smoking.setName(lemma.getText());
+            if (lemma.isHaveChildren()) {
+                for (Lemma relationLemma : lemma.getRelationLemmas()) {
+                    if (relationLemma.getProperty().equals(EntityEnum.TIME.toString())) {
+                        smoking.setPd(addPD(relationLemma));
+                    } else if (relationLemma.getProperty().equals(EntityEnum.USAGE.toString())) {
+                        smoking.setUsage(addUsage(relationLemma));
+                    }
+                }
+            }
+            personalLabel.setSmoking(smoking);
+        }
+
+        //饮酒史
+        List<Lemma> drinkingLemmas = createEntityTree(aiOut, EntityEnum.HISTORY_OF_ALCOHOL_INTAKE.toString());
+        for (Lemma lemma :smokingLemmas) {
+            Drinking drinking = new Drinking();
+            drinking.setName(lemma.getText());
+            if (lemma.isHaveChildren()) {
+                for (Lemma relationLemma : lemma.getRelationLemmas()) {
+                    if (relationLemma.getProperty().equals(EntityEnum.TIME.toString())) {
+                        drinking.setPd(addPD(relationLemma));
+                    } else if (relationLemma.getProperty().equals(EntityEnum.USAGE.toString())) {
+                        drinking.setUsage(addUsage(relationLemma));
+                    }
+                }
+            }
+            personalLabel.setDrinking(drinking);
+        }
+        //冶游史
+        List<Lemma> maritalHistoryLemmas = createEntityTree(aiOut, EntityEnum.MARITAL_HISTORY.toString());
+        for (Lemma lemma :maritalHistoryLemmas) {
+            MaritalHistory maritalHistory = new MaritalHistory();
+            maritalHistory.setName(lemma.getText());
+            if (lemma.isHaveChildren()) {
+                maritalHistory.setNegative(findNegative(lemma));
+            }
+            personalLabel.setMaritalHistory(maritalHistory);
+        }
+        return personalLabel;
+    }
+
+    /**
+     * 时间
+     * @param timeLemma
+     * @return
+     */
+    private PD addPD(Lemma timeLemma) {
+        PD pd = new PD();
+        pd.setName(timeLemma.getText());
+        pd.setValue(timeLemma.getText());
+        return pd;
+    }
+
+    /**
+     * 用量
+     * @param usageLemma
+     * @return
+     */
+    private Usage addUsage(Lemma usageLemma) {
+        Usage usage = new Usage();
+        usage.setName(usageLemma.getText());
+        return usage;
+    }
+}

+ 15 - 0
public/src/main/java/com/lantone/qc/pub/model/entity/Contact.java

@@ -0,0 +1,15 @@
+package com.lantone.qc.pub.model.entity;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @ClassName : Contact
+ * @Description : 接触史
+ * @Author : 楼辉荣
+ * @Date: 2020-03-10 19:35
+ */
+@Setter
+@Getter
+public class Contact extends General {
+}

+ 7 - 0
public/src/main/java/com/lantone/qc/pub/model/entity/Drinking.java

@@ -1,10 +1,17 @@
 package com.lantone.qc.pub.model.entity;
 
+import lombok.Getter;
+import lombok.Setter;
+
 /**
  * @ClassName : Drinking
  * @Description : 饮酒史
  * @Author : 楼辉荣
  * @Date: 2020-03-05 19:21
  */
+@Setter
+@Getter
 public class Drinking extends General {
+    private PD pd;  //时间
+    private Usage usage;   //用量
 }

+ 15 - 0
public/src/main/java/com/lantone/qc/pub/model/entity/EpidemicArea.java

@@ -0,0 +1,15 @@
+package com.lantone.qc.pub.model.entity;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @ClassName : EpidemicArea
+ * @Description : 疫区史
+ * @Author : 楼辉荣
+ * @Date: 2020-03-10 19:33
+ */
+@Getter
+@Setter
+public class EpidemicArea extends General {
+}

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

@@ -0,0 +1,16 @@
+package com.lantone.qc.pub.model.entity;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @ClassName : MaritalHistory
+ * @Description : 冶游史
+ * @Author : 楼辉荣
+ * @Date: 2020-03-10 19:38
+ */
+@Getter
+@Setter
+public class MaritalHistory extends General {
+    private Negative negative;
+}

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

@@ -5,7 +5,7 @@ import lombok.Setter;
 
 @Setter
 @Getter
-public class PD {
+public class PD extends General {
     private String value;
     private String unit;
 }

+ 7 - 0
public/src/main/java/com/lantone/qc/pub/model/entity/Smoking.java

@@ -1,10 +1,17 @@
 package com.lantone.qc.pub.model.entity;
 
+import lombok.Getter;
+import lombok.Setter;
+
 /**
  * @ClassName : Smoking
  * @Description :
  * @Author : 楼辉荣
  * @Date: 2020-03-05 19:15
  */
+@Setter
+@Getter
 public class Smoking extends General {
+    private PD pd;  //时间
+    private Usage usage;   //用量
 }

+ 15 - 0
public/src/main/java/com/lantone/qc/pub/model/entity/Usage.java

@@ -0,0 +1,15 @@
+package com.lantone.qc.pub.model.entity;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @ClassName : Usage
+ * @Description :
+ * @Author : 楼辉荣
+ * @Date: 2020-03-10 19:57
+ */
+@Getter
+@Setter
+public class Usage extends General {
+}

+ 8 - 3
public/src/main/java/com/lantone/qc/pub/model/label/PersonalLabel.java

@@ -1,7 +1,6 @@
 package com.lantone.qc.pub.model.label;
 
-import com.lantone.qc.pub.model.entity.Diag;
-import com.lantone.qc.pub.model.entity.General;
+import com.lantone.qc.pub.model.entity.*;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -16,5 +15,11 @@ import java.util.List;
 @Setter
 @Getter
 public class PersonalLabel extends GeneralLabel {
-    private List<Diag> diags;
+    private Address address;    //地点
+    private Occupation occupation;  //职业
+    private EpidemicArea epidemicArea; //疫区史
+    private Contact contact;    //接触史
+    private Smoking smoking;    //吸烟史
+    private Drinking drinking;  //饮酒史
+    private MaritalHistory maritalHistory;  //冶游史
 }