|
@@ -2,18 +2,25 @@ package com.lantone.qc.kernel.structure.ai;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.google.common.collect.Lists;
|
|
import com.lantone.qc.kernel.client.CRFServiceClient;
|
|
import com.lantone.qc.kernel.client.CRFServiceClient;
|
|
|
|
+import com.lantone.qc.kernel.structure.ai.process.EntityProcessDrug;
|
|
import com.lantone.qc.kernel.structure.ai.process.EntityProcessOperationDiscussion;
|
|
import com.lantone.qc.kernel.structure.ai.process.EntityProcessOperationDiscussion;
|
|
import com.lantone.qc.kernel.util.CatalogueUtil;
|
|
import com.lantone.qc.kernel.util.CatalogueUtil;
|
|
import com.lantone.qc.pub.Content;
|
|
import com.lantone.qc.pub.Content;
|
|
import com.lantone.qc.pub.model.InputInfo;
|
|
import com.lantone.qc.pub.model.InputInfo;
|
|
import com.lantone.qc.pub.model.doc.operation.OperationDiscussionDoc;
|
|
import com.lantone.qc.pub.model.doc.operation.OperationDiscussionDoc;
|
|
import com.lantone.qc.pub.model.doc.operation.OperationDoc;
|
|
import com.lantone.qc.pub.model.doc.operation.OperationDoc;
|
|
|
|
+import com.lantone.qc.pub.model.doc.operation.OperationRecordDoc;
|
|
|
|
+import com.lantone.qc.pub.model.entity.Drug;
|
|
import com.lantone.qc.pub.model.label.OperationDiscussionLabel;
|
|
import com.lantone.qc.pub.model.label.OperationDiscussionLabel;
|
|
|
|
+import com.lantone.qc.pub.model.label.OperationRecordLabel;
|
|
import com.lantone.qc.pub.util.StringUtil;
|
|
import com.lantone.qc.pub.util.StringUtil;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @ClassName : OperationAI
|
|
* @ClassName : OperationAI
|
|
@@ -25,29 +32,59 @@ public class OperationAI extends ModelAI {
|
|
/**
|
|
/**
|
|
*
|
|
*
|
|
*/
|
|
*/
|
|
- public static List<String> medicalTextType = Arrays.asList("CourseAfterOperation_cx");
|
|
|
|
|
|
+ public static List<String> medicalTextType = Arrays.asList("CourseAfterOperation_cx", "CourseRecordSRR");
|
|
public static String entityRelationObject = "entity_relation_object";
|
|
public static String entityRelationObject = "entity_relation_object";
|
|
public static String outputs = "outputs";
|
|
public static String outputs = "outputs";
|
|
public static String content = "content";
|
|
public static String content = "content";
|
|
|
|
+ public static List<String> discussionKey = Lists.newArrayList("术前诊断", "术中诊断", "手术名称", "麻醉方式"
|
|
|
|
+ , "手术经过", "目前情况", "术后注意事项");
|
|
|
|
|
|
public void medrec(InputInfo inputInfo, CRFServiceClient crfServiceClient) {
|
|
public void medrec(InputInfo inputInfo, CRFServiceClient crfServiceClient) {
|
|
JSONArray crfContent = new JSONArray();
|
|
JSONArray crfContent = new JSONArray();
|
|
List<OperationDoc> operationDocs = inputInfo.getOperationDocs();
|
|
List<OperationDoc> operationDocs = inputInfo.getOperationDocs();
|
|
for (int i = 0; i < operationDocs.size(); i++) {
|
|
for (int i = 0; i < operationDocs.size(); i++) {
|
|
- if (operationDocs.get(i).getOperationDiscussionDoc() == null) {
|
|
|
|
- continue;
|
|
|
|
|
|
+ if (operationDocs.get(i).getOperationRecordDoc() != null) {
|
|
|
|
+ OperationRecordDoc operationRecordDoc = operationDocs.get(i).getOperationRecordDoc();
|
|
|
|
+ Map<String, String> structureMap = operationRecordDoc.getStructureMap();
|
|
|
|
+ //存放抓取的药品
|
|
|
|
+ String content = CatalogueUtil.structureMapJoin(structureMap, Lists.newArrayList("手术经过"));
|
|
|
|
+ putContent(crfContent, medicalTextType.get(1), content, "手术记录" + i + "药物");
|
|
|
|
+ }
|
|
|
|
+ if (operationDocs.get(i).getOperationDiscussionDoc() != null) {
|
|
|
|
+ OperationDiscussionDoc operationDiscussionDoc = operationDocs.get(i).getOperationDiscussionDoc();
|
|
|
|
+ Map<String, String> structureMap = operationDiscussionDoc.getStructureMap();
|
|
|
|
+ String discussionText = CatalogueUtil.structureMapJoin(structureMap, discussionKey);
|
|
|
|
+ putContent(crfContent, medicalTextType.get(0), discussionText, Content.operation_Discussion + i);
|
|
|
|
+ //存放抓取的药品
|
|
|
|
+ String content = CatalogueUtil.structureMapJoin(structureMap, Lists.newArrayList("治疗计划和措施"));
|
|
|
|
+ putContent(crfContent, medicalTextType.get(1), content, Content.operation_Discussion + i + "药物");
|
|
}
|
|
}
|
|
- OperationDiscussionDoc operationDiscussionDoc = operationDocs.get(i).getOperationDiscussionDoc();
|
|
|
|
- putContent(crfContent, medicalTextType.get(0), operationDiscussionDoc.getText(), Content.operation_Discussion + i);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
JSONObject midData = loadAI(inputInfo.isUseCrfCache(), inputInfo.getMedicalRecordInfoDoc().getStructureMap().get("behospitalCode"), crfContent, crfServiceClient);//crf返回数据
|
|
JSONObject midData = loadAI(inputInfo.isUseCrfCache(), inputInfo.getMedicalRecordInfoDoc().getStructureMap().get("behospitalCode"), crfContent, crfServiceClient);//crf返回数据
|
|
|
|
|
|
for (int i = 0; i < operationDocs.size(); i++) {
|
|
for (int i = 0; i < operationDocs.size(); i++) {
|
|
- if (midData.get(Content.operation_Discussion + i) == null) {
|
|
|
|
- continue;
|
|
|
|
|
|
+ if (midData.get("手术记录" + i + "药物") != null) {
|
|
|
|
+ OperationRecordDoc operationRecordDoc = operationDocs.get(i).getOperationRecordDoc();
|
|
|
|
+ //手术记录药品
|
|
|
|
+ OperationRecordLabel operationRecordLabel = new OperationRecordLabel();
|
|
|
|
+ operationRecordLabel.setDrugs(putDrugCrfData(midData.getJSONObject("手术记录" + i + "药物")));
|
|
|
|
+ }
|
|
|
|
+ if (midData.get(Content.operation_Discussion + i) != null) {
|
|
|
|
+ OperationDiscussionDoc discussionDoc = operationDocs.get(i).getOperationDiscussionDoc();
|
|
|
|
+ OperationDiscussionLabel discussionLabel = putOperationDiscussionCrfData(midData.getJSONObject(Content.operation_Discussion + i));
|
|
|
|
+ if (discussionLabel != null) {
|
|
|
|
+ discussionDoc.setOperationDiscussionLabel(discussionLabel);
|
|
|
|
+ }
|
|
|
|
+ //术后首程药品
|
|
|
|
+ if (midData.get(Content.operation_Discussion + i + "药物") != null) {
|
|
|
|
+ discussionLabel = operationDocs.get(i).getOperationDiscussionDoc().getOperationDiscussionLabel();
|
|
|
|
+ if (discussionLabel == null) {
|
|
|
|
+ discussionLabel = new OperationDiscussionLabel();
|
|
|
|
+ }
|
|
|
|
+ discussionLabel.setDrugs(putDrugCrfData(midData.getJSONObject(Content.operation_Discussion + i + "药物")));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- putOperationDiscussionCrfData(midData.getJSONObject(Content.operation_Discussion + i), inputInfo);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -55,32 +92,30 @@ public class OperationAI extends ModelAI {
|
|
* 处理手术记录
|
|
* 处理手术记录
|
|
*
|
|
*
|
|
* @param jsonObject
|
|
* @param jsonObject
|
|
- * @param inputInfo
|
|
|
|
*/
|
|
*/
|
|
- public void putOperationDiscussionCrfData(JSONObject jsonObject, InputInfo inputInfo) {
|
|
|
|
|
|
+ public OperationDiscussionLabel putOperationDiscussionCrfData(JSONObject jsonObject) {
|
|
JSONObject aiOut = loadEntity(jsonObject, entityRelationObject, outputs, content);
|
|
JSONObject aiOut = loadEntity(jsonObject, entityRelationObject, outputs, content);
|
|
if (aiOut == null) {
|
|
if (aiOut == null) {
|
|
- return;
|
|
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
String originalText = jsonObject.getString("originalText");
|
|
String originalText = jsonObject.getString("originalText");
|
|
- //使用现病史结构来处理病历特点
|
|
|
|
EntityProcessOperationDiscussion entityProcessOperationDiscussion = new EntityProcessOperationDiscussion();
|
|
EntityProcessOperationDiscussion entityProcessOperationDiscussion = new EntityProcessOperationDiscussion();
|
|
- OperationDiscussionLabel operationDiscussionLabel = entityProcessOperationDiscussion.extractEntity(aiOut);
|
|
|
|
- List<OperationDoc> operationDocs = inputInfo.getOperationDocs();
|
|
|
|
- for (OperationDoc operationDoc : operationDocs) {
|
|
|
|
- OperationDiscussionDoc operationDiscussionDoc = null;
|
|
|
|
- String text = null;
|
|
|
|
- if(operationDoc.getOperationDiscussionDoc() != null){
|
|
|
|
- operationDiscussionDoc = operationDoc.getOperationDiscussionDoc();
|
|
|
|
- if(StringUtil.isNotBlank(operationDiscussionDoc.getText())){
|
|
|
|
- text = operationDiscussionDoc.getText();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (StringUtil.isNotBlank(text) && StringUtil.isNotBlank(originalText) && text.equals(originalText)) {
|
|
|
|
- operationDiscussionDoc.setOperationDiscussionLabel(operationDiscussionLabel);
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+ return entityProcessOperationDiscussion.extractEntity(aiOut);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 存放抓取的药品
|
|
|
|
+ *
|
|
|
|
+ * @param jsonObject
|
|
|
|
+ */
|
|
|
|
+ public List<Drug> putDrugCrfData(JSONObject jsonObject) {
|
|
|
|
+ JSONObject aiOut = loadEntity(jsonObject, entityRelationObject, outputs, content);
|
|
|
|
+ if (aiOut == null) {
|
|
|
|
+ return new ArrayList<>();
|
|
}
|
|
}
|
|
|
|
+ EntityProcessDrug entityProcessDrug = new EntityProcessDrug();
|
|
|
|
+ List<Drug> drugs = entityProcessDrug.extractEntity(aiOut);
|
|
|
|
+ return drugs;
|
|
}
|
|
}
|
|
|
|
|
|
protected void putContent(JSONArray crfContent, String medicalTextType, String text, String sign) {
|
|
protected void putContent(JSONArray crfContent, String medicalTextType, String text, String sign) {
|