|
@@ -12,8 +12,7 @@ import com.lantone.structure.model.label.PastLabel;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 恩泽过敏史、输血史、手术史、预防接种史、疾病史(含外伤)、传染病史
|
|
@@ -24,7 +23,6 @@ public class EntityProcessEZaAll extends EntityProcess {
|
|
|
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<>();//疾病史
|
|
@@ -34,15 +32,15 @@ public class EntityProcessEZaAll extends EntityProcess {
|
|
|
|
|
|
try {
|
|
|
//输血史-
|
|
|
- List<Lemma> bloods = createEntityTree(aiOut, EntityEnum.BLOOD_TRANSFUSION.toString());
|
|
|
+ List<Lemma> bloods = createEntityTree(aiOut, EntityEnum.NEGATIVE.toString());
|
|
|
for (Lemma lemma : bloods) {
|
|
|
BloodTransfusion bloodTransfusionFir = new BloodTransfusion();
|
|
|
String text = lemma.getText();
|
|
|
if (lemma.isHaveChildren()) {
|
|
|
for (Lemma relationLemmaRec : lemma.getRelationLemmas()) {
|
|
|
BloodTransfusion bloodTransfusionSec = new BloodTransfusion();
|
|
|
- if (relationLemmaRec.getProperty().equals(EntityEnum.NEGATIVE.toString())) {
|
|
|
- text = relationLemmaRec.getText()+text;
|
|
|
+ if (relationLemmaRec.getProperty().equals(EntityEnum.BLOOD_TRANSFUSION.toString())) {
|
|
|
+ text = text+relationLemmaRec.getText();
|
|
|
bloodTransfusionSec.setName(text);
|
|
|
bloodTransfusions.add(bloodTransfusionSec);
|
|
|
}
|
|
@@ -73,25 +71,29 @@ public class EntityProcessEZaAll extends EntityProcess {
|
|
|
}
|
|
|
|
|
|
|
|
|
- //疾病史
|
|
|
- List<Lemma> diagList = createEntityTree(aiOut, EntityEnum.DIEASE.toString());
|
|
|
+ //疾病史 NEGATIVE-TIME DIEASE
|
|
|
+ //否定
|
|
|
+ Set<String> diagSet = new HashSet<>();
|
|
|
+ Set<String> diagRetSet = new HashSet<>();
|
|
|
+ List<Lemma> diagList = createEntityTree(aiOut, EntityEnum.NEGATIVE.toString());
|
|
|
+ if( ListUtil.isEmpty(diagList)){
|
|
|
+ //时间
|
|
|
+ diagList = createEntityTree(aiOut, EntityEnum.TIME.toString());
|
|
|
+ }
|
|
|
for (Lemma lemma : diagList) {
|
|
|
Diag diagFir = new Diag();
|
|
|
String text = lemma.getText();
|
|
|
if (lemma.isHaveChildren()) {
|
|
|
for (Lemma relationLemmaRec : lemma.getRelationLemmas()) {
|
|
|
Diag diagSec = new Diag();
|
|
|
- if (relationLemmaRec.getProperty().equals(EntityEnum.NEGATIVE.toString())) {
|
|
|
- text = relationLemmaRec.getText()+text;
|
|
|
- diagSec.setName(text);
|
|
|
- diags.add(diagSec);
|
|
|
- }
|
|
|
- if (relationLemmaRec.getProperty().equals(EntityEnum.TIME.toString())) {
|
|
|
- text = relationLemmaRec.getText()+text;
|
|
|
- diagSec.setName(text);
|
|
|
+ //疾病名称
|
|
|
+ if (relationLemmaRec.getProperty().equals(EntityEnum.DIEASE.toString())||
|
|
|
+ relationLemmaRec.getProperty().equals(EntityEnum.INJURY.toString())) {
|
|
|
+ diagSet.add(relationLemmaRec.getText());
|
|
|
+ String flagText = text+relationLemmaRec.getText();
|
|
|
+ diagSec.setName(flagText);
|
|
|
diags.add(diagSec);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}else{
|
|
|
diagFir.setName(text);
|
|
@@ -99,57 +101,71 @@ public class EntityProcessEZaAll extends EntityProcess {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //外伤史-
|
|
|
- List<Lemma> woundList = createEntityTree(aiOut, EntityEnum.INJURY.toString());
|
|
|
- for (Lemma lemma : woundList) {
|
|
|
- Diag diagFir = new Diag();
|
|
|
- String text = lemma.getText();
|
|
|
- if (lemma.isHaveChildren()) {
|
|
|
- for (Lemma relationLemmaRec : lemma.getRelationLemmas()) {
|
|
|
- Diag diagSec = new Diag();
|
|
|
- if (relationLemmaRec.getProperty().equals(EntityEnum.NEGATIVE.toString())) {
|
|
|
- text = relationLemmaRec.getText()+text;
|
|
|
- diagSec.setName(text);
|
|
|
- diags.add(diagSec);
|
|
|
- }
|
|
|
+ //肯定
|
|
|
+ List<Lemma> diaList = createEntityTree(aiOut, EntityEnum.DIEASE.toString());
|
|
|
+ for (Lemma lemma : diaList) {
|
|
|
+ if(!diagSet.contains(lemma.getText())){
|
|
|
+ diagRetSet.add(lemma.getText());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(null != diagRetSet){
|
|
|
+ for (String str : diagRetSet) {
|
|
|
+ Diag diagSec = new Diag();
|
|
|
+ diagSec.setName(str);
|
|
|
+ diags.add(diagSec);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ List<Lemma> diaListss = createEntityTree(aiOut, EntityEnum.INJURY.toString());
|
|
|
+ for (Lemma lemma : diaListss) {
|
|
|
+ for (String str : diagSet) {
|
|
|
+ if(!lemma.getText().contains(str)){
|
|
|
+ diagRetSet.add(lemma.getText());
|
|
|
}
|
|
|
- }else{
|
|
|
- diagFir.setName(text);
|
|
|
- diags.add(diagFir);
|
|
|
}
|
|
|
}
|
|
|
+ if(null != diagRetSet){
|
|
|
+ for (String str : diagRetSet) {
|
|
|
+ Diag diagSec = new Diag();
|
|
|
+ diagSec.setName(str);
|
|
|
+ diags.add(diagSec);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
//过敏史-药物过敏原表现为使用后皮疹
|
|
|
- //过敏表现
|
|
|
- StringBuffer sb = new StringBuffer();
|
|
|
- List<Lemma> allergieList = createEntityTree(aiOut, EntityEnum.ALLERGY_SYMPTOM.toString());
|
|
|
+ //否定 NEGATIVE 过敏 ALLERGY 食物过敏原 FOOD_ALLERGY 药物过敏原 DRUG_ALLERGY
|
|
|
+ List<Lemma> allergieList = createEntityTree(aiOut, EntityEnum.NEGATIVE.toString());
|
|
|
for (Lemma lemma : allergieList) {
|
|
|
Allergy allergyFir = new Allergy();
|
|
|
String text = lemma.getText();
|
|
|
if (lemma.isHaveChildren()) {
|
|
|
for (Lemma relationLemma : lemma.getRelationLemmas()) {
|
|
|
Allergy allergySec= new Allergy();
|
|
|
- //药物过敏原-食物过敏原
|
|
|
- if (relationLemma.getProperty().equals(EntityEnum.DRUG_ALLERGY.toString())|| relationLemma.getProperty().equals(EntityEnum.FOOD_ALLERGY.toString()) ) {
|
|
|
- String secText = relationLemma.getText();
|
|
|
- if( relationLemma.getRelationLemmas() == null){
|
|
|
+ //过敏
|
|
|
+ if (relationLemma.getProperty().equals(EntityEnum.ALLERGY.toString())) {
|
|
|
+ text = text +relationLemma.getText();
|
|
|
allergySec.setName(text);
|
|
|
allergies.add(allergySec);
|
|
|
- break;
|
|
|
- }
|
|
|
for (Lemma relationLemmaRe : relationLemma.getRelationLemmas()) {
|
|
|
+ allergies.remove(0);
|
|
|
Allergy allergyThr= new Allergy();
|
|
|
- //过敏
|
|
|
- if (relationLemmaRe.getProperty().equals(EntityEnum.ALLERGY.toString())) {
|
|
|
- text = secText+relationLemmaRe.getText()+text;
|
|
|
+ //食物过敏原 - 药物过敏原-情况不详
|
|
|
+ if (relationLemmaRe.getProperty().equals(EntityEnum.FOOD_ALLERGY.toString()) ||
|
|
|
+ relationLemmaRe.getProperty().equals(EntityEnum.DRUG_ALLERGY.toString())||
|
|
|
+ relationLemmaRe.getProperty().equals(EntityEnum.UNKNOWN.toString())) {
|
|
|
+ text = text+relationLemmaRe.getText();
|
|
|
+ allergyThr.setName(text);
|
|
|
+ allergies.add(allergyThr);
|
|
|
for (Lemma relationLemmaRec : relationLemmaRe.getRelationLemmas()) {
|
|
|
- Allergy allergy = new Allergy();
|
|
|
- //否定
|
|
|
- if (relationLemmaRec.getProperty().equals(EntityEnum.NEGATIVE.toString())) {
|
|
|
- text = relationLemmaRec.getText()+text;
|
|
|
- allergyThr.setName(text);
|
|
|
- allergies.add(allergyThr);
|
|
|
+ allergies.remove(0);
|
|
|
+ Allergy allergyFor = new Allergy();
|
|
|
+ //过敏表现
|
|
|
+ if (relationLemmaRec.getProperty().equals(EntityEnum.ALLERGY_SYMPTOM.toString())) {
|
|
|
+ text = text+relationLemmaRec.getText();
|
|
|
+ allergyFor.setName(text);
|
|
|
+ allergies.add(allergyFor);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -161,7 +177,7 @@ public class EntityProcessEZaAll extends EntityProcess {
|
|
|
allergies.add(allergyFir);
|
|
|
}
|
|
|
}
|
|
|
- if(ListUtil.isEmpty(allergieList)){
|
|
|
+ /* if(ListUtil.isEmpty(allergieList)){
|
|
|
//情况不详
|
|
|
allergieList = createEntityTree(aiOut, EntityEnum.UNKNOWN.toString());
|
|
|
for (Lemma lemma : allergieList) {
|
|
@@ -173,7 +189,7 @@ public class EntityProcessEZaAll extends EntityProcess {
|
|
|
//过敏
|
|
|
if (relationLemmaRe.getProperty().equals(EntityEnum.ALLERGY.toString())) {
|
|
|
text = relationLemmaRe.getText()+text;
|
|
|
- if( relationLemmaRe.getRelationLemmas() == null){
|
|
|
+ if( ListUtil.isEmpty( relationLemmaRe.getRelationLemmas())){
|
|
|
allergySec.setName(text);
|
|
|
allergies.add(allergySec);
|
|
|
break;
|
|
@@ -194,14 +210,11 @@ public class EntityProcessEZaAll extends EntityProcess {
|
|
|
allergies.add(allergyFir);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
//手术史
|
|
|
- //时间
|
|
|
- List<Lemma> operationList = createEntityTree(aiOut, EntityEnum.TIME.toString());
|
|
|
- if(ListUtil.isEmpty(operationList)){
|
|
|
- operationList = createEntityTree(aiOut, EntityEnum.UNKNOWN.toString());
|
|
|
- }
|
|
|
+ //否定 NEGATIVE 时间 TIME 手术名称 OPERATION 药物过敏原 DRUG_ALLERGY
|
|
|
+ List<Lemma> operationList = createEntityTree(aiOut, EntityEnum.NEGATIVE.toString());
|
|
|
for (Lemma lemma : operationList) {
|
|
|
Operation operationFir = new Operation();
|
|
|
String text = lemma.getText();
|
|
@@ -211,18 +224,38 @@ public class EntityProcessEZaAll extends EntityProcess {
|
|
|
//手术史
|
|
|
if (relationLemmaRec.getProperty().equals(EntityEnum.OPERATION_KEYWORD.toString())) {
|
|
|
text = text+relationLemmaRec.getText();
|
|
|
- if( relationLemmaRec.getRelationLemmas() == null){
|
|
|
operationSec.setName(text);
|
|
|
operations.add(operationSec);
|
|
|
- break;
|
|
|
- }
|
|
|
for (Lemma relationLemmaThr : relationLemmaRec.getRelationLemmas()) {
|
|
|
+ operations.remove(0);
|
|
|
Operation operationThr = new Operation();
|
|
|
- //否定
|
|
|
- if (relationLemmaThr.getProperty().equals(EntityEnum.NEGATIVE.toString())) {
|
|
|
- text = relationLemmaThr.getText()+text;
|
|
|
- operationThr.setName(text);
|
|
|
- operations.add(operationThr);
|
|
|
+ //时间-情况不详
|
|
|
+ if (relationLemmaThr.getProperty().equals(EntityEnum.TIME.toString()) ||
|
|
|
+ relationLemmaThr.getProperty().equals(EntityEnum.UNKNOWN.toString())) {
|
|
|
+ text =text+ relationLemmaThr.getText();
|
|
|
+ operationThr.setName(text);
|
|
|
+ operations.add(operationThr);
|
|
|
+ for (Lemma relationLemmaFor : relationLemmaThr.getRelationLemmas()) {
|
|
|
+ operations.remove(0);
|
|
|
+ Operation allergyFor = new Operation();
|
|
|
+ //手术名称
|
|
|
+ if (relationLemmaFor.getProperty().equals(EntityEnum.OPERATION.toString())) {
|
|
|
+ text = text+relationLemmaFor.getText();
|
|
|
+ allergyFor.setName(text);
|
|
|
+ operations.add(allergyFor);
|
|
|
+ for (Lemma relationLemmaFiv : relationLemmaFor.getRelationLemmas()) {
|
|
|
+ operations.remove(0);
|
|
|
+ Operation allergyFiv = new Operation();
|
|
|
+ //手术结果-情况不详
|
|
|
+ if (relationLemmaFiv.getProperty().equals(EntityEnum.OPERATION_RESULT.toString())||
|
|
|
+ relationLemmaFiv.getProperty().equals(EntityEnum.UNKNOWN.toString())) {
|
|
|
+ text = text+relationLemmaFiv.getText();
|
|
|
+ allergyFiv.setName(text);
|
|
|
+ operations.add(allergyFiv);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -233,59 +266,57 @@ public class EntityProcessEZaAll extends EntityProcess {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(ListUtil.isEmpty(operationList)){
|
|
|
- //手术结果
|
|
|
- operationList = createEntityTree(aiOut, EntityEnum.OPERATION_RESULT.toString());
|
|
|
- //情况不详
|
|
|
- if(ListUtil.isEmpty(operationList)){
|
|
|
- operationList = createEntityTree(aiOut, EntityEnum.UNKNOWN.toString());
|
|
|
- }
|
|
|
- for (Lemma lemma : operationList) {
|
|
|
+ //手术名称
|
|
|
+ List<Lemma> operationsList = createEntityTree(aiOut, EntityEnum.OPERATION.toString());
|
|
|
+ if(ListUtil.isEmpty(operationList) && ListUtil.isNotEmpty(operationsList)) {
|
|
|
+ }
|
|
|
+ for (Lemma lemma : operationsList) {
|
|
|
Operation operationFir = new Operation();
|
|
|
String text = lemma.getText();
|
|
|
+ if (!lemma.isHaveChildren()) {
|
|
|
+ operationFir.setName(text);
|
|
|
+ operations.add(operationFir);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(ListUtil.isEmpty(operationList)) {
|
|
|
+ operationList = createEntityTree(aiOut, EntityEnum.OPERATION_KEYWORD.toString());
|
|
|
+ }
|
|
|
+ for (Lemma lemma : operationList) {
|
|
|
+ Operation operationFir = new Operation();
|
|
|
+ String text = lemma.getText();
|
|
|
+ if (lemma.isHaveChildren()) {
|
|
|
if (lemma.isHaveChildren()) {
|
|
|
for (Lemma relationLemmaRec : lemma.getRelationLemmas()) {
|
|
|
Operation operationSec = new Operation();
|
|
|
//手术名称
|
|
|
- if (relationLemmaRec.getProperty().equals(EntityEnum.OPERATION.toString())) {
|
|
|
+ if (relationLemmaRec.getProperty().equals(EntityEnum.NEGATIVE.toString())) {
|
|
|
text = relationLemmaRec.getText()+text;
|
|
|
- if( relationLemmaRec.getRelationLemmas() == null){
|
|
|
- operationSec.setName(text);
|
|
|
- operations.add(operationSec);
|
|
|
- break;
|
|
|
- }
|
|
|
- for (Lemma relationLemmaThr : relationLemmaRec.getRelationLemmas()) {
|
|
|
- Operation operation = new Operation();
|
|
|
- //时间
|
|
|
- if (relationLemmaThr.getProperty().equals(EntityEnum.TIME.toString())) {
|
|
|
- text = relationLemmaThr.getText()+text;
|
|
|
- operation.setName(text);
|
|
|
- operations.add(operation);
|
|
|
- }
|
|
|
- }
|
|
|
+ operationSec.setName(text);
|
|
|
+ operations.add(operationSec);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
}else{
|
|
|
- operationFir.setName(text);
|
|
|
- operations.add(operationFir);
|
|
|
+ operationFir.setName(text);
|
|
|
+ operations.add(operationFir);
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
//传染病史
|
|
|
- List<Lemma> diagInfectiouList = createEntityTree(aiOut, EntityEnum.INFECTIOUS_KEYWORD.toString());
|
|
|
+ // 否定 NEGATIVE 传染病史 INFECTIOUS_KEYWORD
|
|
|
+ List<Lemma> diagInfectiouList = createEntityTree(aiOut, EntityEnum.NEGATIVE.toString());
|
|
|
for (Lemma lemma : diagInfectiouList) {
|
|
|
DiagInfectious diagInfectiousFir = new DiagInfectious();
|
|
|
String text = lemma.getText();
|
|
|
if (lemma.isHaveChildren()) {
|
|
|
for (Lemma relationLemmaRec : lemma.getRelationLemmas()) {
|
|
|
DiagInfectious diagInfectiousSec = new DiagInfectious();
|
|
|
- if (relationLemmaRec.getProperty().equals(EntityEnum.NEGATIVE.toString())) {
|
|
|
- text = relationLemmaRec.getText()+text;
|
|
|
+ //传染病史
|
|
|
+ if (relationLemmaRec.getProperty().equals(EntityEnum.INFECTIOUS_KEYWORD.toString())) {
|
|
|
+ text = text+relationLemmaRec.getText();
|
|
|
diagInfectiousSec.setName(text);
|
|
|
diagInfectiouses.add(diagInfectiousSec);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
} else{
|
|
|
diagInfectiousFir.setName(text);
|