|
@@ -0,0 +1,160 @@
|
|
|
+package com.lantone.structure.ai.process;
|
|
|
+
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.lantone.common.util.ListUtil;
|
|
|
+import com.lantone.structure.ai.model.EntityEnum;
|
|
|
+import com.lantone.structure.ai.model.Lemma;
|
|
|
+import com.lantone.structure.model.doc.BeHospitalizedDoc;
|
|
|
+import com.lantone.structure.model.entity.*;
|
|
|
+import com.lantone.structure.model.label.FamilyLabel;
|
|
|
+import com.lantone.structure.model.label.PastLabel;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 恩泽过敏史、输血史、手术史、预防接种史、疾病史(含外伤)、传染病史
|
|
|
+ */
|
|
|
+public class EntityProcessEZaAll extends EntityProcess {
|
|
|
+ private Logger logger = LoggerFactory.getLogger(EntityProcessEZaAll.class);
|
|
|
+
|
|
|
+ public BeHospitalizedDoc extractEntity(JSONObject aiOut) {
|
|
|
+ BeHospitalizedDoc beHospitalizedDoc = new BeHospitalizedDoc();
|
|
|
+ PastLabel pastLabel= new PastLabel();
|
|
|
+ FamilyLabel familyLabel = new FamilyLabel();
|
|
|
+ List<BloodTransfusion> bloodTransfusions = new ArrayList<>();//输血史
|
|
|
+ List<Vaccinate> vaccinates = new ArrayList<>();//预防接种史
|
|
|
+ List<Diag> diags = new ArrayList<>();//疾病史
|
|
|
+ List<Allergy> allergies = new ArrayList<>();//过敏史
|
|
|
+ List<Operation> operations = new ArrayList<>();//手术史
|
|
|
+ List<DiagInfectious> diagInfectiouses = new ArrayList<>();//传染病史
|
|
|
+
|
|
|
+ try {
|
|
|
+ //输血史-
|
|
|
+ List<Lemma> bloods = createEntityTree(aiOut, EntityEnum.BLOOD_TRANSFUSION.toString());
|
|
|
+ for (Lemma lemma : bloods) {
|
|
|
+ BloodTransfusion bloodTransfusion = new BloodTransfusion();
|
|
|
+ String text = lemma.getText();
|
|
|
+ if(ListUtil.isNotEmpty(lemma.getRelationLemmas())){
|
|
|
+ List<Lemma> relationLemmas = lemma.getRelationLemmas();
|
|
|
+ if(relationLemmas.size()==1){
|
|
|
+ String property = relationLemmas.get(0).getProperty();
|
|
|
+ text= property+text;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ bloodTransfusion.setName(text);
|
|
|
+ bloodTransfusions.add(bloodTransfusion);
|
|
|
+ }
|
|
|
+ //预防接种史-
|
|
|
+ List<Lemma> vaccinateList = createEntityTree(aiOut, EntityEnum.VACCINATION.toString());
|
|
|
+ for (Lemma lemma : vaccinateList) {
|
|
|
+ Vaccinate vaccinate = new Vaccinate();
|
|
|
+ String text = lemma.getText();
|
|
|
+ if(ListUtil.isNotEmpty(lemma.getRelationLemmas())){
|
|
|
+ List<Lemma> relationLemmas = lemma.getRelationLemmas();
|
|
|
+ if(relationLemmas.size()==1){
|
|
|
+ String property = relationLemmas.get(0).getProperty();
|
|
|
+ text= property+text;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ vaccinate.setName(text);
|
|
|
+ vaccinates.add(vaccinate);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //疾病史
|
|
|
+ List<Lemma> diagList = createEntityTree(aiOut, EntityEnum.DISEASE_KEYWORD.toString());
|
|
|
+ for (Lemma lemma : diagList) {
|
|
|
+ Diag diag = new Diag();
|
|
|
+ String text = lemma.getText();
|
|
|
+ if(ListUtil.isNotEmpty(lemma.getRelationLemmas())){
|
|
|
+ List<Lemma> relationLemmas = lemma.getRelationLemmas();
|
|
|
+ if(relationLemmas.size()==1){
|
|
|
+ String property = relationLemmas.get(0).getProperty();
|
|
|
+ text= property+text;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ diag.setName(text);
|
|
|
+ diags.add(diag);
|
|
|
+ }
|
|
|
+ //外伤史-
|
|
|
+ List<Lemma> woundList = createEntityTree(aiOut, EntityEnum.INJURY.toString());
|
|
|
+ for (Lemma lemma : woundList) {
|
|
|
+ Diag diag = new Diag();
|
|
|
+ String text = lemma.getText();
|
|
|
+ if(ListUtil.isNotEmpty(lemma.getRelationLemmas())){
|
|
|
+ List<Lemma> relationLemmas = lemma.getRelationLemmas();
|
|
|
+ if(relationLemmas.size()==1){
|
|
|
+ String property = relationLemmas.get(0).getProperty();
|
|
|
+ text= property+text;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ diag.setName(text);
|
|
|
+ diags.add(diag);
|
|
|
+ }
|
|
|
+
|
|
|
+ //过敏史-药物过敏原表现为使用后皮疹
|
|
|
+ List<Lemma> allergieList = createEntityTree(aiOut, EntityEnum.ALLERGY_SYMPTOM.toString());
|
|
|
+ for (Lemma lemma : allergieList) {
|
|
|
+ Allergy allergy = new Allergy();
|
|
|
+ String text = lemma.getText();
|
|
|
+ if(ListUtil.isNotEmpty(lemma.getRelationLemmas())){
|
|
|
+ List<Lemma> relationLemmas = lemma.getRelationLemmas();
|
|
|
+ if(relationLemmas.size()==1){
|
|
|
+ String property = relationLemmas.get(0).getProperty();
|
|
|
+ System.out.println("property = " + property);
|
|
|
+ text= property+text;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ allergy.setName(text);
|
|
|
+ allergies.add(allergy);
|
|
|
+ }
|
|
|
+
|
|
|
+ //手术史
|
|
|
+ List<Lemma> operationList = createEntityTree(aiOut, EntityEnum.OPERATION.toString());
|
|
|
+ for (Lemma lemma : operationList) {
|
|
|
+ Operation operation = new Operation();
|
|
|
+ String text = lemma.getText();
|
|
|
+ if(ListUtil.isNotEmpty(lemma.getRelationLemmas())){
|
|
|
+ List<Lemma> relationLemmas = lemma.getRelationLemmas();
|
|
|
+ if(relationLemmas.size()==1){
|
|
|
+ String property = relationLemmas.get(0).getProperty();
|
|
|
+ text= property+text;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ operation.setName(text);
|
|
|
+ operations.add(operation);
|
|
|
+ }
|
|
|
+
|
|
|
+ //传染病史
|
|
|
+ List<Lemma> diagInfectiouList = createEntityTree(aiOut, EntityEnum.INFECTIOUS_KEYWORD.toString());
|
|
|
+ for (Lemma lemma : diagInfectiouList) {
|
|
|
+ DiagInfectious diagInfectious = new DiagInfectious();
|
|
|
+ String text = lemma.getText();
|
|
|
+ if(ListUtil.isNotEmpty(lemma.getRelationLemmas())){
|
|
|
+ List<Lemma> relationLemmas = lemma.getRelationLemmas();
|
|
|
+ if(relationLemmas.size()==1){
|
|
|
+ String property = relationLemmas.get(0).getProperty();
|
|
|
+ text= property+text;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ diagInfectious.setName(text);
|
|
|
+ diagInfectiouses.add(diagInfectious);
|
|
|
+ }
|
|
|
+ pastLabel.setBloodTransfusions(bloodTransfusions);
|
|
|
+ pastLabel.setVaccinates(vaccinates);
|
|
|
+ pastLabel.setDiags(diags);
|
|
|
+ pastLabel.setOperations(operations);
|
|
|
+ pastLabel.setAllergies(allergies);
|
|
|
+ pastLabel.setDiagInfectiouses(diagInfectiouses);
|
|
|
+ beHospitalizedDoc.setPastLabel(pastLabel);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
+ }
|
|
|
+ return beHospitalizedDoc;
|
|
|
+ }
|
|
|
+}
|