|
@@ -0,0 +1,121 @@
|
|
|
+package com.lantone.qc.kernel.structure.ai.process;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.lantone.qc.kernel.structure.ai.model.CrfOut;
|
|
|
+import com.lantone.qc.kernel.structure.ai.model.EntityEnum;
|
|
|
+import com.lantone.qc.pub.model.entity.Negative;
|
|
|
+import com.lantone.qc.pub.model.entity.Past;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+public class EntityProcessPast extends EntityProcess {
|
|
|
+ public static String allergy_history = "过敏史";
|
|
|
+ public static String disease_history = "疾病史";
|
|
|
+ public static String surgery_history = "手术史";
|
|
|
+ public static String injury_history = "外伤史";
|
|
|
+ public static String blood_history = "输血史";
|
|
|
+ public static String vaccination_history = "预防接种史";
|
|
|
+ public static String infect_history = "传染病史";
|
|
|
+ @Override
|
|
|
+ public void extractEntity(JSONObject outputs, CrfOut outputInfo) {
|
|
|
+ List<Past> pasts = new ArrayList<>();
|
|
|
+ //疾病史
|
|
|
+ addPast(outputs, pasts);
|
|
|
+ //手术史
|
|
|
+ addPast(outputs, pasts, EntityEnum.OPERATION, 1, EntityProcessPast.surgery_history);
|
|
|
+ addPast(outputs, pasts, EntityEnum.OPERATION_KEYWORD, 1, EntityProcessPast.surgery_history);
|
|
|
+
|
|
|
+ //外伤史
|
|
|
+ addPast(outputs, pasts, EntityEnum.INJURY, 2, EntityProcessPast.injury_history);
|
|
|
+
|
|
|
+ //过敏史
|
|
|
+ addPast(outputs, pasts, EntityEnum.ALLERGY, 3, EntityProcessPast.allergy_history);
|
|
|
+ addPast(outputs, pasts, EntityEnum.FOOD_ALLERGY, 3, EntityProcessPast.allergy_history);
|
|
|
+ addPast(outputs, pasts, EntityEnum.DRUG_ALLERGY, 3, EntityProcessPast.allergy_history);
|
|
|
+ addPast(outputs, pasts, EntityEnum.ALLERGY_SYMPTOM, 3, EntityProcessPast.allergy_history);
|
|
|
+
|
|
|
+ //输血史
|
|
|
+ addPast(outputs, pasts, EntityEnum.BLOOD_TRANSFUSION, 4, EntityProcessPast.blood_history);
|
|
|
+
|
|
|
+ //预防接种史
|
|
|
+ addPast(outputs, pasts, EntityEnum.VACCINATION, 5, EntityProcessPast.vaccination_history);
|
|
|
+
|
|
|
+ //传染病史
|
|
|
+ addPast(outputs, pasts, EntityEnum.INFECTIOUS_KEYWORD, 7, EntityProcessPast.infect_history);
|
|
|
+ outputInfo.setPasts(pasts);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ private void addPast(JSONObject outputs, List<Past> pasts) {
|
|
|
+ Past past = null;
|
|
|
+ List<Map<String, String>> pastEntityList = processJson(outputs, EntityEnum.DIEASE.toString());
|
|
|
+ for (Map<String, String> pastEntityMap : pastEntityList) {
|
|
|
+ if (StringUtils.isEmpty(pastEntityMap.get(EntityEnum.DIEASE.toString()))) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ past = new Past();
|
|
|
+ String cureValue = "";
|
|
|
+ for (String key : pastEntityMap.keySet()) {
|
|
|
+ switch (EntityEnum.parseOfValue(key)) {
|
|
|
+ case DIEASE:
|
|
|
+ past.setType(6);
|
|
|
+ past.setTitle(EntityProcessPast.disease_history);
|
|
|
+ past.setValue(pastEntityMap.get(key));
|
|
|
+ break;
|
|
|
+ case CURE:
|
|
|
+ past.setTreat(pastEntityMap.get(key));
|
|
|
+ break;
|
|
|
+ case CURE_AIM:
|
|
|
+ cureValue += "," + pastEntityMap.get(key);
|
|
|
+ break;
|
|
|
+ case TREND:
|
|
|
+ cureValue += "," + pastEntityMap.get(key);
|
|
|
+ break;
|
|
|
+ case TIME:
|
|
|
+ cureValue += "," + pastEntityMap.get(key);
|
|
|
+ break;
|
|
|
+ case FREQUENCY:
|
|
|
+ cureValue += "," + pastEntityMap.get(key);
|
|
|
+ break;
|
|
|
+ case MODIFICATION:
|
|
|
+ cureValue += "," + pastEntityMap.get(key);
|
|
|
+ break;
|
|
|
+ case NEGATIVE:
|
|
|
+ Negative negative = new Negative();
|
|
|
+ negative.setName(StringUtils.isEmpty(pastEntityMap.get(key)) ? "" : pastEntityMap.get(key));
|
|
|
+ past.setNegative(negative);
|
|
|
+ break;
|
|
|
+ //TODO PD
|
|
|
+ }
|
|
|
+ }
|
|
|
+ past.setDescribe(cureValue.startsWith(",") ? cureValue.substring(1, cureValue.length()) : cureValue);
|
|
|
+ pasts.add(past);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void addPast(JSONObject outputs, List<Past> pasts, EntityEnum entityType, int pastType, String pastTypeString) {
|
|
|
+ Past past = null;
|
|
|
+ List<Map<String, String>> pastEntityList = processJson(outputs, entityType.toString());
|
|
|
+ for (Map<String, String> pastEntityMap : pastEntityList) {
|
|
|
+ if (StringUtils.isEmpty(pastEntityMap.get(entityType.toString()))) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ past = new Past();
|
|
|
+ for (String key : pastEntityMap.keySet()) {
|
|
|
+ if (key.equals(entityType.toString())) {
|
|
|
+ past.setType(pastType);
|
|
|
+ past.setTitle(pastTypeString);
|
|
|
+ past.setValue(pastEntityMap.get(key));
|
|
|
+ } else if (key.equals(EntityEnum.NEGATIVE.toString())) {
|
|
|
+ Negative negative = new Negative();
|
|
|
+ negative.setName(StringUtils.isEmpty(pastEntityMap.get(key)) ? "" : pastEntityMap.get(key));
|
|
|
+ past.setNegative(negative);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ pasts.add(past);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|