|
@@ -9,10 +9,9 @@ import com.lantone.qc.kernel.structure.ai.process.*;
|
|
|
import com.lantone.qc.pub.Content;
|
|
|
import com.lantone.qc.pub.model.InputInfo;
|
|
|
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.*;
|
|
|
import com.lantone.qc.pub.model.label.ChiefLabel;
|
|
|
+import com.lantone.qc.pub.model.label.PresentLabel;
|
|
|
import com.lantone.qc.pub.model.vo.CRFVo;
|
|
|
import com.lantone.qc.pub.util.StringUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -81,12 +80,11 @@ public class BeHospitalizedAI {
|
|
|
//获取CRF模型返回数据
|
|
|
JSONArray data = getAnnotation(crfServiceClient, crfVo).getData();
|
|
|
JSONObject midData = getOutputs(data);
|
|
|
- putChiefCrfData(midData.getJSONObject(Content.chief), inputInfo);
|
|
|
//处理主诉
|
|
|
-// putAllCrfData(midData.getJSONObject(Content.chief),crfOut);
|
|
|
-// putAllCrfData(midData.getJSONObject(Content.present), crfOut);
|
|
|
-// putAllCrfData(midData.getJSONObject(Content.special_exam), crfOut);
|
|
|
-//
|
|
|
+ putChiefCrfData(midData.getJSONObject(Content.chief), inputInfo);
|
|
|
+ //处理现病史
|
|
|
+ putPresentCrfData(midData.getJSONObject(Content.present), inputInfo);
|
|
|
+
|
|
|
// //存放CRF模型既往史、家族史返回数据
|
|
|
// putAllCrfData(midData.getJSONObject(Content.past), crfOut);
|
|
|
// putAllCrfData(midData.getJSONObject(Content.family), crfOut);
|
|
@@ -112,7 +110,17 @@ public class BeHospitalizedAI {
|
|
|
chiefLabel.setClinicals(loadClinicals(aiOut));
|
|
|
chiefLabel.setDiags(loadDiags(aiOut));
|
|
|
}
|
|
|
-
|
|
|
+ public void putPresentCrfData(JSONObject jsonObject, InputInfo inputInfo){
|
|
|
+ if (jsonObject == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONObject aiOut = jsonObject.getJSONObject(entityRelationObject).getJSONObject(BeHospitalizedAI.outputs);
|
|
|
+ //放置入inputinfo
|
|
|
+ PresentLabel presentLabel = inputInfo.getBeHospitalizedDoc().getPresentLabel();
|
|
|
+ presentLabel.setClinicals(loadClinicals(aiOut));
|
|
|
+ presentLabel.setGenerals(loadGeneralDes(aiOut));
|
|
|
+ presentLabel.setPacses(loadpacses(aiOut));
|
|
|
+ }
|
|
|
/**
|
|
|
* 关系抽取临床表现信息
|
|
|
* @param aiOut
|
|
@@ -136,111 +144,49 @@ public class BeHospitalizedAI {
|
|
|
List<Diag> diags = entityProcessDiag.extractEntity(aiOut);
|
|
|
return diags;
|
|
|
}
|
|
|
-
|
|
|
- public void putAllCrfData_new(JSONObject jsonObject,Map<String,CrfOut> crfOut){
|
|
|
- if (jsonObject == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- JSONObject outputs = jsonObject.getJSONObject(entityRelationObject).getJSONObject(BeHospitalizedAI.outputs);
|
|
|
- Map<String, Map<String, String>> chiefMap = annsiys_tr(outputs);
|
|
|
- System.out.println();
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 关系抽取化验信息
|
|
|
+ * @param aiOut
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<Lis> loadLises(JSONObject aiOut) {
|
|
|
+ //化验信息
|
|
|
+ EntityProcessLis entityProcessLis = new EntityProcessLis();
|
|
|
+ List<Lis> lises = entityProcessLis.extractEntity(aiOut);
|
|
|
+ return lises;
|
|
|
}
|
|
|
- public void packageData(Map<String, Map<String, String>> chiefMap){
|
|
|
- if(chiefMap.size()>0){
|
|
|
- for (Map.Entry<String, Map<String, String>> data:chiefMap.entrySet()) {
|
|
|
- String key = data.getKey();
|
|
|
- Map<String, String> value = data.getValue();
|
|
|
- if(value.size()>0){
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 关系抽取辅检信息
|
|
|
+ * @param aiOut
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<Pacs> loadpacses(JSONObject aiOut) {
|
|
|
+ //辅检信息
|
|
|
+ EntityProcessPacs entityProcessLis = new EntityProcessPacs();
|
|
|
+ List<Pacs> pacses = entityProcessLis.extractEntity(aiOut);
|
|
|
+ return pacses;
|
|
|
}
|
|
|
- public void putAllCrfData(JSONObject jsonObject,Map<String,List<CrfOut>> crfOut){
|
|
|
- if (jsonObject == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- JSONObject outputs = jsonObject.getJSONObject(entityRelationObject).getJSONObject(BeHospitalizedAI.outputs);
|
|
|
- Map<String, Map<String, String>> stringMapMap = annsiys_tr(outputs);
|
|
|
- List<CrfOut> medOut = new ArrayList<>();
|
|
|
- CrfOut outputInfo = new CrfOut();
|
|
|
-// 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);
|
|
|
+ /**
|
|
|
+ * 关系抽取体格检查
|
|
|
+ * @param aiOut
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<Vital> loadvital(JSONObject aiOut) {
|
|
|
+ //一般情况描述信息
|
|
|
+ EntityProcessVital entityProcessVital = new EntityProcessVital();
|
|
|
+ List<Vital> vitals = entityProcessVital.extractEntity(aiOut);
|
|
|
+ return vitals;
|
|
|
}
|
|
|
- public Map<String,Map<String,String>> annsiys_tr(JSONObject outputs){
|
|
|
- Map<String,Map<String,String>> result_map = new HashMap<>();
|
|
|
- Map<Integer,List<Integer>> id_map = new HashMap<>();
|
|
|
- JSONObject annotation = outputs.getJSONObject("annotation");
|
|
|
- JSONArray entitys = annotation.getJSONArray("T");
|
|
|
- JSONArray relations = annotation.getJSONArray("R");
|
|
|
- if(relations.size()>0){
|
|
|
- for(int i = 0;i<relations.size();i++){
|
|
|
- if (StringUtils.isEmpty(relations.get(i).toString())) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- JSONObject jsonObject = relations.getJSONObject(i);
|
|
|
- if(!jsonObject.isEmpty()){
|
|
|
- Integer from_id = jsonObject.getInteger("from");
|
|
|
- Integer to_id = jsonObject.getInteger("to");
|
|
|
- if(id_map.containsKey(from_id)){
|
|
|
- List<Integer> integers = id_map.get(from_id);
|
|
|
- integers.add(to_id);
|
|
|
- id_map.put(from_id,integers);
|
|
|
- }else {
|
|
|
- List<Integer> ids = new ArrayList<>();
|
|
|
- ids.add(to_id);
|
|
|
- id_map.put(from_id,ids);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if(id_map.size()>0 && entitys.size()>0){
|
|
|
- for(int i = 0;i<entitys.size();i++){
|
|
|
- if (StringUtils.isEmpty(entitys.get(i).toString())) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- JSONObject jsonObject = entitys.getJSONObject(i);
|
|
|
- if(!jsonObject.isEmpty()){
|
|
|
- String name = jsonObject.getString("name");
|
|
|
- Integer id = jsonObject.getInteger("id");
|
|
|
- String value = jsonObject.getString("value");
|
|
|
- if(id_map.keySet().contains(id)){
|
|
|
- Map<String,String> rMap = new HashMap<>();
|
|
|
- rMap.put("type",name);
|
|
|
- List<Integer> ids = id_map.get(id);
|
|
|
- if(ids.size()>0){
|
|
|
- for (Integer id_n:ids) {
|
|
|
- if(entitys.size()>0){
|
|
|
- for(int h = 0;h<entitys.size();h++){
|
|
|
- if (StringUtils.isEmpty(entitys.get(h).toString())) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- JSONObject jsonObject_h = entitys.getJSONObject(h);
|
|
|
- if(!jsonObject_h.isEmpty()){
|
|
|
- Integer id1 = jsonObject_h.getInteger("id");
|
|
|
- if(id_n.equals(id1)){
|
|
|
- rMap.put(jsonObject_h.getString("name"),jsonObject_h.getString("value"));
|
|
|
- result_map.put(value,rMap);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return result_map;
|
|
|
+ /**
|
|
|
+ * 关系抽取一般情况描述信息
|
|
|
+ * @param aiOut
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<GeneralDesc> loadGeneralDes(JSONObject aiOut) {
|
|
|
+ //一般情况描述信息
|
|
|
+ EntityProcessGenerals entityProcessGeneral = new EntityProcessGenerals();
|
|
|
+ List<GeneralDesc> generals = entityProcessGeneral.extractEntity(aiOut);
|
|
|
+ return generals;
|
|
|
}
|
|
|
|
|
|
public void putContent(JSONArray crfContent, String medicalTextType, String text,String sign){
|