|
@@ -0,0 +1,104 @@
|
|
|
+package com.lantone.structure.ai.process;
|
|
|
+
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.lantone.structure.ai.model.EntityEnum;
|
|
|
+import com.lantone.structure.ai.model.Lemma;
|
|
|
+import com.lantone.structure.model.entity.*;
|
|
|
+import com.lantone.structure.model.label.ClinicalBloodLabel;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 输血记录处理
|
|
|
+ */
|
|
|
+public class EntityProcessBlood extends EntityProcess {
|
|
|
+ private Logger logger = LoggerFactory.getLogger(EntityProcessBlood.class);
|
|
|
+
|
|
|
+ public ClinicalBloodLabel extractEntity(JSONObject aiOut) {
|
|
|
+ ClinicalBloodLabel clinicalBloodLabel = new ClinicalBloodLabel();
|
|
|
+ try {
|
|
|
+ Blood blood = new Blood();
|
|
|
+ List<Blood> bloodList = new ArrayList<>();
|
|
|
+ //输血指征
|
|
|
+ List<Lemma> indicationBlood = createEntityTree(aiOut, EntityEnum.INDICA_BLOOD.toString());
|
|
|
+ for (Lemma lemma : indicationBlood) {
|
|
|
+ Indication indication = new Indication();
|
|
|
+ indication.setName(lemma.getText());
|
|
|
+ blood.setIndication(indication);
|
|
|
+ }
|
|
|
+
|
|
|
+ //输血类型
|
|
|
+ List<Lemma> typeBlood = createEntityTree(aiOut, EntityEnum.TYPE_BLOOD.toString());
|
|
|
+ for (Lemma lemma : typeBlood) {
|
|
|
+ Type type = new Type();
|
|
|
+ type.setName(lemma.getText());
|
|
|
+ Amount amount = new Amount();
|
|
|
+ if (lemma.isHaveChildren()) {
|
|
|
+ for (Lemma relationLemma : lemma.getRelationLemmas()) {
|
|
|
+ if (relationLemma.getProperty().equals(EntityEnum.AMOUNT_BLOOD.toString())) {
|
|
|
+ amount.setName(relationLemma.getText());
|
|
|
+ MeasurementUnit measurementUnit = new MeasurementUnit();
|
|
|
+ for (Lemma measureLemma : relationLemma.getRelationLemmas()) {
|
|
|
+ if (measureLemma.getProperty().equals(EntityEnum.MEASURE_BLOOD.toString())) {
|
|
|
+ measurementUnit.setName(measureLemma.getText());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ amount.setMeasurementUnit(measurementUnit);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ type.setAmount(amount);
|
|
|
+ blood.setType(type);
|
|
|
+ }
|
|
|
+ //输血原因
|
|
|
+ List<Lemma> reasonBlood = createEntityTree(aiOut, EntityEnum.REASON_BLOOD.toString());
|
|
|
+ for (Lemma lemma : reasonBlood) {
|
|
|
+ Reason reason = new Reason();
|
|
|
+ reason.setName(lemma.getText());
|
|
|
+ blood.setReason(reason);
|
|
|
+ }
|
|
|
+ //输血开始时间
|
|
|
+ List<Lemma> startTimeBlood = createEntityTree(aiOut, EntityEnum.START_TIME_BLOOD.toString());
|
|
|
+ for (Lemma lemma : startTimeBlood) {
|
|
|
+ StartTime startTime = new StartTime();
|
|
|
+ startTime.setName(lemma.getText());
|
|
|
+ blood.setStartTime(startTime);
|
|
|
+ }
|
|
|
+ //输血结束时间
|
|
|
+ List<Lemma> endTimeBlood = createEntityTree(aiOut, EntityEnum.END_TIME_BLOOD.toString());
|
|
|
+ for (Lemma lemma : endTimeBlood) {
|
|
|
+ EndTime endTime = new EndTime();
|
|
|
+ endTime.setName(lemma.getText());
|
|
|
+ blood.setEndTime(endTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ //输血反应类型
|
|
|
+ List<Lemma> responseTypeBlood = createEntityTree(aiOut, EntityEnum.RESPONSE_TYPE_BLOOD.toString());
|
|
|
+ List<ResponseType> responseTypeList = new ArrayList<>();
|
|
|
+ for (Lemma lemma : responseTypeBlood) {
|
|
|
+ ResponseType responseType = new ResponseType();
|
|
|
+ responseType.setName(lemma.getText());
|
|
|
+ responseType.setNegative(findT(lemma, new Negative(), EntityEnum.NEGATIVE_BLOOD.toString()));
|
|
|
+ responseTypeList.add(responseType);
|
|
|
+ }
|
|
|
+ blood.setResponseType(responseTypeList);
|
|
|
+ //输血次数
|
|
|
+ List<Lemma> frequencyBlood = createEntityTree(aiOut, EntityEnum.FREQUENCY_BLOOD.toString());
|
|
|
+ for (Lemma lemma : frequencyBlood) {
|
|
|
+ Frequency frequency = new Frequency();
|
|
|
+ frequency.setName(lemma.getText());
|
|
|
+ blood.setFrequency(frequency);
|
|
|
+ }
|
|
|
+ bloodList.add(blood);
|
|
|
+ clinicalBloodLabel.setBlood(bloodList);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
+ }
|
|
|
+ return clinicalBloodLabel;
|
|
|
+ }
|
|
|
+}
|