|
@@ -13,6 +13,7 @@ import org.diagbot.nlp.relation.module.cell.*;
|
|
|
import org.diagbot.nlp.relation.util.LemmaUtil;
|
|
|
import org.diagbot.nlp.relation.util.OutputInfo;
|
|
|
import org.diagbot.nlp.util.Constants;
|
|
|
+import org.omg.Messaging.SYNC_WITH_TRANSPORT;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
@@ -33,8 +34,10 @@ public class StructureAnalyze {
|
|
|
private List<OutputInfo> outputInfos = new ArrayList<>();
|
|
|
private static boolean updated = false;
|
|
|
private static Object current = null;
|
|
|
+ private static Object current_treat = null;
|
|
|
private static String num = "";
|
|
|
private static List<String> diag_con = Arrays.asList("门诊","诊断");
|
|
|
+ private static List<String> past_con = Arrays.asList("既往");
|
|
|
|
|
|
/**
|
|
|
* 分词,提取词性,封装
|
|
@@ -101,6 +104,7 @@ public class StructureAnalyze {
|
|
|
Pacs pacs = null;
|
|
|
Vital vital = null;
|
|
|
Treat treat = null;
|
|
|
+ Past past = null;
|
|
|
PD pd1 = null;
|
|
|
|
|
|
try {
|
|
@@ -118,6 +122,18 @@ public class StructureAnalyze {
|
|
|
current = updateClinicalInfo(outputInfo, lexeme.getText(), lexeme.getProperty());
|
|
|
updated = true;
|
|
|
break;
|
|
|
+ case Constants.word_property_vital_value:
|
|
|
+ if (current instanceof Vital) {
|
|
|
+ vital = (Vital) current;
|
|
|
+ if (vital.getPd() == null) {
|
|
|
+ vital.setPd(new PD());
|
|
|
+ }
|
|
|
+ pd1 = vital.getPd();
|
|
|
+ pd1.setValue(lexeme.getText());
|
|
|
+ pd1.setUnit("");
|
|
|
+ updated = true;
|
|
|
+ }
|
|
|
+ break;
|
|
|
case Constants.word_property_LIS:
|
|
|
case Constants.word_property_LIS_Detail:
|
|
|
lis = new Lis();
|
|
@@ -162,6 +178,16 @@ public class StructureAnalyze {
|
|
|
((Pacs) current).setBodypart(((Pacs)current).getBodypart()+lexeme.getText() + ", ");
|
|
|
updated = true;
|
|
|
}
|
|
|
+ else if (current instanceof Symptom) {
|
|
|
+ PD pd = new PD();
|
|
|
+ pd.setValue(lexeme.getText());
|
|
|
+ pd.setUnit("");
|
|
|
+ if (((Symptom)current).getPds() == null) {
|
|
|
+ ((Symptom)current).setPds(new ArrayList<>());
|
|
|
+ }
|
|
|
+ ((Symptom)current).getPds().add(pd);
|
|
|
+ updated = true;
|
|
|
+ }
|
|
|
break;
|
|
|
case Constants.word_property_neg:
|
|
|
Negative negative = new Negative();
|
|
@@ -221,6 +247,14 @@ public class StructureAnalyze {
|
|
|
lis.setPd(new PD());
|
|
|
}
|
|
|
pd1 = lis.getPd();
|
|
|
+ } else if (current instanceof Past) {
|
|
|
+ past = (Past)current;
|
|
|
+ if (past.getPds() == null) {
|
|
|
+ List<PD> pds1 = new ArrayList<>();
|
|
|
+ pds1.add(new PD());
|
|
|
+ past.setPds(pds1);
|
|
|
+ }
|
|
|
+ pd1 = past.getPds().get(0);
|
|
|
}
|
|
|
}
|
|
|
pd1.setValue(num);
|
|
@@ -244,39 +278,18 @@ public class StructureAnalyze {
|
|
|
}
|
|
|
break;
|
|
|
case Constants.word_property_diagnose:
|
|
|
- current = updateClinicalInfo(outputInfo, lexeme.getText(), lexeme.getProperty());
|
|
|
- updated = true;
|
|
|
- break;
|
|
|
case Constants.word_property_med:
|
|
|
- if (!(current instanceof Treat)) {
|
|
|
- current = updateClinicalInfo(outputInfo, "", Constants.word_property_diagnose);
|
|
|
- }
|
|
|
- treat = (Treat) current;
|
|
|
-
|
|
|
- if (treat.getTreatName() == null || treat.getTreatName().trim().length() == 0) {
|
|
|
- treat.setTreatName(lexeme.getText());
|
|
|
- }
|
|
|
- else {
|
|
|
- treat.setTreatName(treat.getTreatName() + "," + lexeme.getText());
|
|
|
- }
|
|
|
- updated = true;
|
|
|
- break;
|
|
|
case Constants.word_property_treat:
|
|
|
- if (current instanceof Treat) {
|
|
|
- treat = (Treat)current;
|
|
|
- if (treat.getValue() == null || treat.getValue().trim().length() == 0) {
|
|
|
- treat.setValue(lexeme.getText());
|
|
|
- }
|
|
|
- else {
|
|
|
- treat.setValue(treat.getValue() + "," + lexeme.getText());
|
|
|
- }
|
|
|
- updated = true;
|
|
|
- }
|
|
|
+ current = updateClinicalInfo(outputInfo, lexeme.getText(), lexeme.getProperty());
|
|
|
+ updated = true;
|
|
|
break;
|
|
|
case Constants.word_property_other:
|
|
|
if (diag_con.indexOf(lexeme.getText()) >= 0) {
|
|
|
current = new Treat();
|
|
|
}
|
|
|
+ else if (past_con.indexOf(lexeme.getText()) >= 0) {
|
|
|
+ current = new Past();
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -294,6 +307,8 @@ public class StructureAnalyze {
|
|
|
|
|
|
outputInfo.setVitals(new ArrayList<>());
|
|
|
|
|
|
+ outputInfo.setPasts(new ArrayList<>());
|
|
|
+
|
|
|
outputInfo.setLises(new ArrayList<>());
|
|
|
|
|
|
outputInfo.setPacses(new ArrayList<>());
|
|
@@ -304,8 +319,9 @@ public class StructureAnalyze {
|
|
|
}
|
|
|
|
|
|
public int getPropsize(OutputInfo outputInfo) {
|
|
|
- int size = outputInfo.getSymptoms().size() + outputInfo.getLises().size() + outputInfo.getTreats().size()
|
|
|
- + outputInfo.getVitals().size() + outputInfo.getPacses().size();
|
|
|
+ int size = outputInfo.getSymptoms().size() + outputInfo.getVitals().size() +
|
|
|
+ outputInfo.getPasts().size() + outputInfo.getLises().size() +
|
|
|
+ outputInfo.getPacses().size() + outputInfo.getTreats().size();
|
|
|
|
|
|
return size;
|
|
|
}
|
|
@@ -315,6 +331,8 @@ public class StructureAnalyze {
|
|
|
|
|
|
Object obj = null;
|
|
|
Symptom symptom = null;
|
|
|
+ Treat treat = null;
|
|
|
+ Past past = null;
|
|
|
|
|
|
switch (type) {
|
|
|
case Constants.word_property_symptom:
|
|
@@ -347,19 +365,34 @@ public class StructureAnalyze {
|
|
|
obj = vital;
|
|
|
break;
|
|
|
case Constants.word_property_diagnose:
|
|
|
- if (outputInfo.getTreats().size() == 0) {
|
|
|
- outputInfo.getTreats().add(new Treat());
|
|
|
- }
|
|
|
-
|
|
|
- Treat treat = outputInfo.getTreats().get(outputInfo.getTreats().size()-1);
|
|
|
+ if (current instanceof Past) {
|
|
|
+ past = (Past)current;
|
|
|
|
|
|
- if (treat.getDiagnose() == null || treat.getDiagnose().trim().length() == 0) {
|
|
|
- treat.setDiagnose(name);
|
|
|
+ if (past.getDiagnose() == null || past.getDiagnose().trim().length() == 0) {
|
|
|
+ past.setDiagnose(name);
|
|
|
+ } else {
|
|
|
+ past.setDiagnose(past.getDiagnose() + "," + name);
|
|
|
+ }
|
|
|
+ outputInfo.getPasts().add(past);
|
|
|
+ obj = past;
|
|
|
+ current_treat = past;
|
|
|
}
|
|
|
else {
|
|
|
- treat.setDiagnose(treat.getDiagnose() + "," + name);
|
|
|
+ if (current instanceof Treat) {
|
|
|
+ treat = (Treat) current;
|
|
|
+ } else if (outputInfo.getTreats().size() == 0) {
|
|
|
+ outputInfo.getTreats().add(new Treat());
|
|
|
+ treat = outputInfo.getTreats().get(outputInfo.getTreats().size() - 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (treat.getDiagnose() == null || treat.getDiagnose().trim().length() == 0) {
|
|
|
+ treat.setDiagnose(name);
|
|
|
+ } else {
|
|
|
+ treat.setDiagnose(treat.getDiagnose() + "," + name);
|
|
|
+ }
|
|
|
+ obj = treat;
|
|
|
+ current_treat = treat;
|
|
|
}
|
|
|
- obj = treat;
|
|
|
break;
|
|
|
case Constants.word_property_cause:
|
|
|
Cause cause = new Cause();
|
|
@@ -425,6 +458,60 @@ public class StructureAnalyze {
|
|
|
symptom.setProperty(property);
|
|
|
obj = symptom;
|
|
|
break;
|
|
|
+ case Constants.word_property_treat:
|
|
|
+ if (current instanceof Treat) {
|
|
|
+ treat = (Treat)current;
|
|
|
+ if (treat.getValue() == null || treat.getValue().trim().length() == 0) {
|
|
|
+ treat.setValue(name);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ treat.setValue(treat.getValue() + "," + name);
|
|
|
+ }
|
|
|
+ current_treat = treat;
|
|
|
+ obj = treat;
|
|
|
+ }
|
|
|
+ else if (current_treat instanceof Past) {
|
|
|
+ past = (Past)current_treat;
|
|
|
+ if (past.getValue() == null || past.getValue().trim().length() == 0) {
|
|
|
+ past.setValue(name);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ past.setValue(past.getValue() + "," + name);
|
|
|
+ }
|
|
|
+
|
|
|
+ obj = past;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case Constants.word_property_med:
|
|
|
+ if (current_treat instanceof Past) {
|
|
|
+ past = (Past)current_treat;
|
|
|
+
|
|
|
+ if (past.getTreatName() == null || past.getTreatName().trim().length() == 0) {
|
|
|
+ past.setTreatName(name);
|
|
|
+ } else {
|
|
|
+ past.setTreatName(past.getTreatName() + "," + name);
|
|
|
+ }
|
|
|
+
|
|
|
+ obj = past;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (!(current instanceof Treat)) {
|
|
|
+ if (current_treat != null && current_treat instanceof Treat) {
|
|
|
+ current = current_treat;
|
|
|
+ } else {
|
|
|
+ current = updateClinicalInfo(outputInfo, "", Constants.word_property_diagnose);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ treat = (Treat) current;
|
|
|
+
|
|
|
+ if (treat.getTreatName() == null || treat.getTreatName().trim().length() == 0) {
|
|
|
+ treat.setTreatName(name);
|
|
|
+ } else {
|
|
|
+ treat.setTreatName(treat.getTreatName() + "," + name);
|
|
|
+ }
|
|
|
+ obj = treat;
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
return obj;
|