|
@@ -3,7 +3,6 @@ package com.lantone.qc.kernel.structure.ai;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.lantone.qc.kernel.catalogue.QCCatalogue;
|
|
|
import com.lantone.qc.kernel.client.CRFServiceClient;
|
|
|
import com.lantone.qc.kernel.structure.ai.model.CrfOut;
|
|
|
import com.lantone.qc.kernel.structure.ai.process.*;
|
|
@@ -13,13 +12,11 @@ import com.lantone.qc.pub.model.doc.BeHospitalizedDoc;
|
|
|
import com.lantone.qc.pub.model.entity.Annotation;
|
|
|
import com.lantone.qc.pub.model.entity.Clinical;
|
|
|
import com.lantone.qc.pub.model.entity.Diag;
|
|
|
-import com.lantone.qc.pub.model.entity.Lis;
|
|
|
import com.lantone.qc.pub.model.label.ChiefLabel;
|
|
|
import com.lantone.qc.pub.model.vo.CRFVo;
|
|
|
import com.lantone.qc.pub.util.StringUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
-import java.math.BigInteger;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
@@ -60,18 +57,23 @@ public class BeHospitalizedAI {
|
|
|
String vital_text = beHospitalizedDoc.getVitalLabel().getText();
|
|
|
//专科体格检查
|
|
|
String vitalSpecial_text = beHospitalizedDoc.getVitalLabelSpecial().getText();
|
|
|
- //存放主诉、现病史、专科查体(体格检查(二))
|
|
|
+ //主诉
|
|
|
putContent(crfContent,medicalTextType.get(3), chief_text,Content.chief);
|
|
|
+ //现病史
|
|
|
putContent(crfContent,medicalTextType.get(3), present_text,Content.present);
|
|
|
+ //专科检查
|
|
|
putContent(crfContent,medicalTextType.get(3), vitalSpecial_text,Content.special_exam);
|
|
|
- //存放既往史、家族史
|
|
|
+ //既往史
|
|
|
putContent(crfContent,medicalTextType.get(3), past_text,Content.past);
|
|
|
+ //家族史
|
|
|
putContent(crfContent,medicalTextType.get(3), family_text,Content.family);
|
|
|
//存放一般查体
|
|
|
putContent(crfContent,medicalTextType.get(3), vital_text,Content.phys_exam);
|
|
|
- //存放个人史、月经史、婚育史
|
|
|
+ //个人史
|
|
|
putContent(crfContent,medicalTextType.get(3), Personal_text,Content.personal);
|
|
|
+ //月经史
|
|
|
putContent(crfContent,medicalTextType.get(3), menstrual_text,Content.menses);
|
|
|
+ //婚育史
|
|
|
putContent(crfContent,medicalTextType.get(3), marital_text,Content.marriage);
|
|
|
//存储CRF完整所需结构数据
|
|
|
CRFVo crfVo = new CRFVo();
|
|
@@ -79,8 +81,7 @@ public class BeHospitalizedAI {
|
|
|
//获取CRF模型返回数据
|
|
|
JSONArray data = getAnnotation(crfServiceClient, crfVo).getData();
|
|
|
JSONObject midData = getOutputs(data);
|
|
|
- EntityProcessMethod entityProcessMethod = new EntityProcessMethod();
|
|
|
- putChiefCrfData(midData.getJSONObject(Content.chief),inputInfo,entityProcessMethod);
|
|
|
+ putChiefCrfData(midData.getJSONObject(Content.chief), inputInfo);
|
|
|
//处理主诉
|
|
|
// putAllCrfData(midData.getJSONObject(Content.chief),crfOut);
|
|
|
// putAllCrfData(midData.getJSONObject(Content.present), crfOut);
|
|
@@ -101,59 +102,41 @@ public class BeHospitalizedAI {
|
|
|
// putAllCrfData(midData.getJSONObject(Content.diag_basis), crfOut);
|
|
|
// return crfOut;
|
|
|
}
|
|
|
- public void putChiefCrfData(JSONObject jsonObject,InputInfo inputInfo,EntityProcessMethod entityProcessMethod){
|
|
|
+ public void putChiefCrfData(JSONObject jsonObject, InputInfo inputInfo){
|
|
|
if (jsonObject == null) {
|
|
|
return;
|
|
|
}
|
|
|
- JSONObject outputs = jsonObject.getJSONObject(entityRelationObject).getJSONObject(BeHospitalizedAI.outputs);
|
|
|
- List<Clinical> clinicals = entityProcessMethod.extractClinicalEntity(outputs);
|
|
|
- List<Diag> diags = entityProcessMethod.extractDiagEntity(outputs);
|
|
|
+ JSONObject aiOut = jsonObject.getJSONObject(entityRelationObject).getJSONObject(BeHospitalizedAI.outputs);
|
|
|
+ //放置入inputinfo
|
|
|
ChiefLabel chiefLabel = inputInfo.getBeHospitalizedDoc().getChiefLabel();
|
|
|
- chiefLabel.setClinicals(clinicals);
|
|
|
- chiefLabel.setDiags(diags);
|
|
|
+ chiefLabel.setClinicals(loadClinicals(aiOut));
|
|
|
+ chiefLabel.setDiags(loadDiags(aiOut));
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 关系抽取临床表现信息
|
|
|
+ * @param aiOut
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<Clinical> loadClinicals(JSONObject aiOut) {
|
|
|
+ //主诉
|
|
|
+ EntityProcessClinic entityProcessClinic = new EntityProcessClinic();
|
|
|
+ List<Clinical> clinicals = entityProcessClinic.extractEntity(aiOut);
|
|
|
+ return clinicals;
|
|
|
}
|
|
|
- public Map<String,CrfOut> medrec_new(InputInfo inputInfo,CRFServiceClient crfServiceClient) {
|
|
|
- Map<String, CrfOut> crfOut = new HashMap<>();//主诉-->
|
|
|
- JSONArray crfContent = new JSONArray();
|
|
|
- BeHospitalizedDoc beHospitalizedDoc = inputInfo.getBeHospitalizedDoc();
|
|
|
- String chief_text = beHospitalizedDoc.getChiefLabel().getText();
|
|
|
- String Personal_text = beHospitalizedDoc.getPersonalLabel().getText();
|
|
|
- String family_text = beHospitalizedDoc.getFamilyLabel().getText();
|
|
|
- String past_text = beHospitalizedDoc.getPastLabel().getText();
|
|
|
- String present_text = beHospitalizedDoc.getPresentLabel().getText();
|
|
|
- //月经史
|
|
|
- String menstrual_text = beHospitalizedDoc.getMenstrualLabel().getText();
|
|
|
- //婚育史
|
|
|
- String marital_text = beHospitalizedDoc.getMaritalLabel().getText();
|
|
|
- //一般体格检查
|
|
|
- String vital_text = beHospitalizedDoc.getVitalLabel().getText();
|
|
|
- //专科体格检查
|
|
|
- String vitalSpecial_text = beHospitalizedDoc.getVitalLabelSpecial().getText();
|
|
|
- //存放主诉、现病史、专科查体(体格检查(二))
|
|
|
- putContent(crfContent,medicalTextType.get(3), chief_text,Content.chief);
|
|
|
- putContent(crfContent,medicalTextType.get(3), present_text,Content.present);
|
|
|
- putContent(crfContent,medicalTextType.get(3), vitalSpecial_text,Content.special_exam);
|
|
|
- //存放既往史、家族史
|
|
|
- putContent(crfContent,medicalTextType.get(3), past_text,Content.past);
|
|
|
- putContent(crfContent,medicalTextType.get(3), family_text,Content.family);
|
|
|
- //存放一般查体
|
|
|
- putContent(crfContent,medicalTextType.get(3), vital_text,Content.phys_exam);
|
|
|
- //存放个人史、月经史、婚育史
|
|
|
- putContent(crfContent,medicalTextType.get(3), Personal_text,Content.personal);
|
|
|
- putContent(crfContent,medicalTextType.get(3), menstrual_text,Content.menses);
|
|
|
- putContent(crfContent,medicalTextType.get(3), marital_text,Content.marriage);
|
|
|
- //存储CRF完整所需结构数据
|
|
|
- CRFVo crfVo = new CRFVo();
|
|
|
- crfVo.setData(crfContent);
|
|
|
- //获取CRF模型返回数据
|
|
|
- JSONArray data = getAnnotation(crfServiceClient, crfVo).getData();
|
|
|
- JSONObject midData = getOutputs(data);
|
|
|
- //处理主诉
|
|
|
- putAllCrfData_new(midData.getJSONObject(Content.chief),crfOut);
|
|
|
- putAllCrfData_new(midData.getJSONObject(Content.present),crfOut);
|
|
|
- return crfOut;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 关系抽取疾病信息
|
|
|
+ * @param aiOut
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<Diag> loadDiags(JSONObject aiOut) {
|
|
|
+ //诊断信息
|
|
|
+ EntityProcessDiag entityProcessDiag = new EntityProcessDiag();
|
|
|
+ List<Diag> diags = entityProcessDiag.extractEntity(aiOut);
|
|
|
+ return diags;
|
|
|
}
|
|
|
+
|
|
|
public void putAllCrfData_new(JSONObject jsonObject,Map<String,CrfOut> crfOut){
|
|
|
if (jsonObject == null) {
|
|
|
return;
|
|
@@ -182,13 +165,13 @@ public class BeHospitalizedAI {
|
|
|
Map<String, Map<String, String>> stringMapMap = annsiys_tr(outputs);
|
|
|
List<CrfOut> medOut = new ArrayList<>();
|
|
|
CrfOut outputInfo = new CrfOut();
|
|
|
- add2Output(new EntityProcessSymptom(), outputs, outputInfo);//临床表现
|
|
|
- add2Output(new EntityProcessGenerals(), outputs, outputInfo);//一般情况描述
|
|
|
- add2Output(new EntityProcessVital(), outputs, outputInfo);//体征
|
|
|
- add2Output(new EntityProcessLis(), outputs, outputInfo);//化验
|
|
|
- add2Output(new EntityProcessPacs(), outputs, outputInfo);//辅检
|
|
|
- add2Output(new EntityProcessDiag(), outputs, outputInfo);//诊断
|
|
|
- add2Output(new EntityProcessPast(), outputs, outputInfo);
|
|
|
+// add2Output(new EntityProcessClinic(), outputs, outputInfo);//临床表现
|
|
|
+// add2Output(new EntityProcessGenerals(), outputs, outputInfo);//一般情况描述
|
|
|
+// add2Output(new EntityProcessVital(), outputs, outputInfo);//体征
|
|
|
+// add2Output(new EntityProcessLis(), outputs, outputInfo);//化验
|
|
|
+// add2Output(new EntityProcessPacs(), outputs, outputInfo);//辅检
|
|
|
+// add2Output(new EntityProcessDiag(), outputs, outputInfo);//诊断
|
|
|
+// add2Output(new EntityProcessPast(), outputs, outputInfo);
|
|
|
|
|
|
medOut.add(outputInfo);
|
|
|
crfOut.put(jsonObject.getString("detail_title"),medOut);
|
|
@@ -259,9 +242,7 @@ public class BeHospitalizedAI {
|
|
|
}
|
|
|
return result_map;
|
|
|
}
|
|
|
- public void add2Output(EntityProcess entityProcess, JSONObject outputs, CrfOut outputInfo){
|
|
|
- entityProcess.extractEntity(outputs, outputInfo);
|
|
|
- }
|
|
|
+
|
|
|
public void putContent(JSONArray crfContent, String medicalTextType, String text,String sign){
|
|
|
String move_text = this.moveSpecialSymbols(text);
|
|
|
if (StringUtil.isEmpty(move_text)) {
|