|
@@ -0,0 +1,124 @@
|
|
|
|
+package com.lantone.qc.kernel.structure.ai;
|
|
|
|
+
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.lantone.qc.kernel.client.CRFServiceClient;
|
|
|
|
+import com.lantone.qc.kernel.structure.ai.process.EntityProcessClinic;
|
|
|
|
+import com.lantone.qc.kernel.structure.ai.process.EntityProcessDiag;
|
|
|
|
+import com.lantone.qc.kernel.structure.ai.process.EntityProcessTreatPlan;
|
|
|
|
+import com.lantone.qc.pub.Content;
|
|
|
|
+import com.lantone.qc.pub.model.InputInfo;
|
|
|
|
+import com.lantone.qc.pub.model.doc.FirstCourseRecordDoc;
|
|
|
|
+import com.lantone.qc.pub.model.entity.Diag;
|
|
|
|
+import com.lantone.qc.pub.model.label.*;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+
|
|
|
|
+import java.util.Arrays;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @ClassName : FirstCourseRecordAI
|
|
|
|
+ * @Description :
|
|
|
|
+ * @Author : 楼辉荣
|
|
|
|
+ * @Date: 2020-03-19 14:52
|
|
|
|
+ */
|
|
|
|
+public class FirstCourseRecordAI extends ModelAI {
|
|
|
|
+ /**
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ public static List<String> medicalTextType = Arrays.asList("FirstCoursera_cx", "Diagnoses_cx");
|
|
|
|
+ public static String entityRelationObject = "entity_relation_object";
|
|
|
|
+ public static String outputs = "outputs";
|
|
|
|
+
|
|
|
|
+ public void medrec(InputInfo inputInfo, CRFServiceClient crfServiceClient) {
|
|
|
|
+ JSONArray crfContent = new JSONArray();
|
|
|
|
+ FirstCourseRecordDoc firstCourseRecordDoc = inputInfo.getFirstCourseRecordDoc();
|
|
|
|
+ if (firstCourseRecordDoc != null && StringUtils.isNotEmpty(firstCourseRecordDoc.getText())) {
|
|
|
|
+ //病历特点
|
|
|
|
+ putContent(crfContent, medicalTextType.get(0), firstCourseRecordDoc.getCaseCharacteristicLabel().getText(), Content.case_feature);
|
|
|
|
+ //初步诊断
|
|
|
|
+ putContent(crfContent, medicalTextType.get(1), firstCourseRecordDoc.getInitialDiagLabel().getText(), Content.initial_diag);
|
|
|
|
+ //诊断依据
|
|
|
|
+ putContent(crfContent, medicalTextType.get(0), firstCourseRecordDoc.getDiagnosisLabel().getText(), Content.diag_basis);
|
|
|
|
+ //鉴别诊断
|
|
|
|
+ putContent(crfContent, medicalTextType.get(1), firstCourseRecordDoc.getDifferentialDiagLabel().getText(), Content.differential_diag_basis);
|
|
|
|
+ //诊疗计划
|
|
|
|
+ putContent(crfContent, medicalTextType.get(0), firstCourseRecordDoc.getTreatPlanLabel().getText(), Content.treat_plan);
|
|
|
|
+
|
|
|
|
+ JSONObject midData = loadAI(crfContent, crfServiceClient);//crf返回数据
|
|
|
|
+ putCaseCharacteristicCrfData(midData.getJSONObject(Content.case_feature), inputInfo);//处理病历特点
|
|
|
|
+ putInitialDiagCrfData(midData.getJSONObject(Content.initial_diag), inputInfo);//处理初步诊断
|
|
|
|
+ putDiagnosisCrfData(midData.getJSONObject(Content.diag_basis), inputInfo);//处理诊断依据
|
|
|
|
+ putDifferentialDiagCrfData(midData.getJSONObject(Content.differential_diag_basis), inputInfo);//处理鉴别诊断
|
|
|
|
+ putTreatPlanCrfData(midData.getJSONObject(Content.treat_plan), inputInfo);//处理诊疗计划
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 病历特点
|
|
|
|
+ * @param jsonObject
|
|
|
|
+ * @param inputInfo
|
|
|
|
+ */
|
|
|
|
+ public void putCaseCharacteristicCrfData(JSONObject jsonObject, InputInfo inputInfo) {
|
|
|
|
+ JSONObject aiOut = loadEntity(jsonObject, entityRelationObject, outputs);
|
|
|
|
+ //使用现病史结构来处理病历特点
|
|
|
|
+ EntityProcessClinic entityProcessClinic = new EntityProcessClinic();
|
|
|
|
+ PresentLabel presentLabel = entityProcessClinic.extractEntity(aiOut);
|
|
|
|
+ //临床表现
|
|
|
|
+ inputInfo.getFirstCourseRecordDoc().getCaseCharacteristicLabel().setClinicals(presentLabel.getClinicals());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 初步诊断
|
|
|
|
+ * @param jsonObject
|
|
|
|
+ * @param inputInfo
|
|
|
|
+ */
|
|
|
|
+ public void putInitialDiagCrfData(JSONObject jsonObject, InputInfo inputInfo) {
|
|
|
|
+ JSONObject aiOut = loadEntity(jsonObject, entityRelationObject, outputs);
|
|
|
|
+ //诊断信息
|
|
|
|
+ EntityProcessDiag entityProcessDiag = new EntityProcessDiag();
|
|
|
|
+ List<Diag> diags = entityProcessDiag.extractEntity(aiOut);
|
|
|
|
+ inputInfo.getFirstCourseRecordDoc().getInitialDiagLabel().setDiags(diags);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 诊断依据
|
|
|
|
+ * @param jsonObject
|
|
|
|
+ * @param inputInfo
|
|
|
|
+ */
|
|
|
|
+ public void putDiagnosisCrfData(JSONObject jsonObject, InputInfo inputInfo) {
|
|
|
|
+ JSONObject aiOut = loadEntity(jsonObject, entityRelationObject, outputs);
|
|
|
|
+ //使用现病史结构来处理诊断依据
|
|
|
|
+ EntityProcessClinic entityProcessClinic = new EntityProcessClinic();
|
|
|
|
+ PresentLabel presentLabel = entityProcessClinic.extractEntity(aiOut);
|
|
|
|
+ //临床表现
|
|
|
|
+ inputInfo.getFirstCourseRecordDoc().getDiagnosisLabel().setClinicals(presentLabel.getClinicals());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 鉴别诊断
|
|
|
|
+ * @param jsonObject
|
|
|
|
+ * @param inputInfo
|
|
|
|
+ */
|
|
|
|
+ public void putDifferentialDiagCrfData(JSONObject jsonObject, InputInfo inputInfo) {
|
|
|
|
+ JSONObject aiOut = loadEntity(jsonObject, entityRelationObject, outputs);
|
|
|
|
+ //诊断信息
|
|
|
|
+ EntityProcessDiag entityProcessDiag = new EntityProcessDiag();
|
|
|
|
+ List<Diag> diags = entityProcessDiag.extractEntity(aiOut);
|
|
|
|
+ inputInfo.getFirstCourseRecordDoc().getDifferentialDiagLabel().setDiags(diags);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 诊疗计划
|
|
|
|
+ * @param jsonObject
|
|
|
|
+ * @param inputInfo
|
|
|
|
+ */
|
|
|
|
+ public void putTreatPlanCrfData(JSONObject jsonObject, InputInfo inputInfo) {
|
|
|
|
+ JSONObject aiOut = loadEntity(jsonObject, entityRelationObject, outputs);
|
|
|
|
+ //诊疗计划
|
|
|
|
+ EntityProcessTreatPlan entityProcessTreatPlan = new EntityProcessTreatPlan();
|
|
|
|
+ TreatPlanLabel treatPlanLabel = entityProcessTreatPlan.extractEntity(aiOut);
|
|
|
|
+ treatPlanLabel.setText(inputInfo.getFirstCourseRecordDoc().getTreatPlanLabel().getText());
|
|
|
|
+ inputInfo.getFirstCourseRecordDoc().setTreatPlanLabel(treatPlanLabel);
|
|
|
|
+ }
|
|
|
|
+}
|