|
@@ -0,0 +1,117 @@
|
|
|
|
+package com.lantone.qc.kernel.structure.ai.process;
|
|
|
|
+
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.lantone.qc.kernel.structure.ai.model.EntityEnum;
|
|
|
|
+import com.lantone.qc.kernel.structure.ai.model.Lemma;
|
|
|
|
+import com.lantone.qc.pub.model.entity.Clinical;
|
|
|
|
+import com.lantone.qc.pub.model.entity.Diag;
|
|
|
|
+import com.lantone.qc.pub.model.entity.Sign;
|
|
|
|
+import com.lantone.qc.pub.model.entity.TreatmentPlan;
|
|
|
|
+import com.lantone.qc.pub.model.label.ThreeLevelWardLabel;
|
|
|
|
+
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @ClassName : EntityProcessThreeLevelWard
|
|
|
|
+ * @Description : 查房记录
|
|
|
|
+ * @Author : 胡敬
|
|
|
|
+ * @Date: 2020-03-20 11:20
|
|
|
|
+ */
|
|
|
|
+public class EntityProcessThreeLevelWard extends EntityProcess {
|
|
|
|
+ public ThreeLevelWardLabel extractEntity(JSONObject aiOut) {
|
|
|
|
+ ThreeLevelWardLabel threeLevelWardLabel = new ThreeLevelWardLabel();
|
|
|
|
+ String content = aiOut.getString("content");
|
|
|
|
+ int titleForDiagBasisIndex = 0, titleForDiffIndex = 0, titleForTreatIndex = 0;
|
|
|
|
+ List<Lemma> diagBasisLemmas = createEntityTree(aiOut, EntityEnum.TITLE_FOR_DIAG_BASIS.toString());
|
|
|
|
+ List<Lemma> diagDiffLemmas = createEntityTree(aiOut, EntityEnum.TITLE_FOR_DIFF.toString());
|
|
|
|
+ List<Lemma> treatLemmas = createEntityTree(aiOut, EntityEnum.TITLE_FOR_TREAT.toString());
|
|
|
|
+ if (diagBasisLemmas.size() > 0) {
|
|
|
|
+ titleForDiagBasisIndex = content.indexOf(diagBasisLemmas.get(0).getText());//诊断依据标题起始位置
|
|
|
|
+ }
|
|
|
|
+ if (diagDiffLemmas.size() > 0) {
|
|
|
|
+ titleForDiffIndex = content.indexOf(diagDiffLemmas.get(0).getText());//鉴别诊断标题起始位置
|
|
|
|
+ }
|
|
|
|
+ if (treatLemmas.size() > 0) {
|
|
|
|
+ titleForTreatIndex = content.indexOf(treatLemmas.get(0).getText());//诊疗计划标题起始位置
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //诊断依据文本
|
|
|
|
+ if (titleForDiagBasisIndex > 0 && titleForDiffIndex > 0) {
|
|
|
|
+ threeLevelWardLabel.setDiagBasisText(content.substring(titleForDiagBasisIndex, titleForDiffIndex));
|
|
|
|
+ }
|
|
|
|
+ //病史(在 诊断依据,鉴别诊断 以外的片段中出现 任一 临床表现)
|
|
|
|
+ if (titleForDiagBasisIndex > 0) {
|
|
|
|
+ List<Lemma> clinicalLemmas = createEntityTree(aiOut, EntityEnum.CLINICAL_FEATURE.toString());
|
|
|
|
+ List<Clinical> clinicals = new ArrayList<>();
|
|
|
|
+ for (Lemma lemma : clinicalLemmas) {
|
|
|
|
+ if (Integer.parseInt(lemma.getPosition()) > titleForDiagBasisIndex) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ Clinical clinical = new Clinical();
|
|
|
|
+ clinical.setName(lemma.getText());
|
|
|
|
+ clinicals.add(clinical);
|
|
|
|
+ }
|
|
|
|
+ threeLevelWardLabel.setClinicals(clinicals);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //查体
|
|
|
|
+ List<Lemma> signLemmas = createEntityTree(aiOut, EntityEnum.PHYSICAL_EXAMINATION.toString());
|
|
|
|
+ List<Sign> signs = new ArrayList<>();
|
|
|
|
+ for (Lemma lemma : signLemmas) {
|
|
|
|
+ Sign sign = new Sign();
|
|
|
|
+ sign.setName(lemma.getText());
|
|
|
|
+ signs.add(sign);
|
|
|
|
+ }
|
|
|
|
+ threeLevelWardLabel.setSigns(signs);
|
|
|
|
+
|
|
|
|
+ //鉴别诊断
|
|
|
|
+ if (titleForDiffIndex > 0) {
|
|
|
|
+ List<Diag> diags = new ArrayList<>();
|
|
|
|
+ List<Lemma> dieaseLemmas = createEntityTree(aiOut, EntityEnum.DIEASE.toString());
|
|
|
|
+ for (Lemma dieaseLemma : dieaseLemmas) {
|
|
|
|
+ if (Integer.parseInt(dieaseLemma.getPosition()) < titleForDiffIndex
|
|
|
|
+ || Integer.parseInt(dieaseLemma.getPosition()) > titleForTreatIndex) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ Diag diag = new Diag();
|
|
|
|
+ diag.setName(dieaseLemma.getText());
|
|
|
|
+ diags.add(diag);
|
|
|
|
+ }
|
|
|
|
+ threeLevelWardLabel.setDiffDiag(diags);
|
|
|
|
+
|
|
|
|
+ for (Lemma lemma : diagDiffLemmas) {
|
|
|
|
+ if (lemma.getText().contains("诊断明确") || lemma.getText().contains("无需鉴别")) {
|
|
|
|
+ threeLevelWardLabel.setDiffDiagText(lemma.getText());
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //补充诊断/初步诊断/修正诊断
|
|
|
|
+ if (titleForDiagBasisIndex > 0 && titleForTreatIndex > 0) {
|
|
|
|
+ List<Lemma> dieaseLemmas = createEntityTree(aiOut, EntityEnum.DIEASE.toString());
|
|
|
|
+ List<Diag> diags = new ArrayList<>();
|
|
|
|
+ for (Lemma dieaseLemma : dieaseLemmas) {
|
|
|
|
+ if (Integer.parseInt(dieaseLemma.getPosition()) < titleForDiagBasisIndex
|
|
|
|
+ || Integer.parseInt(dieaseLemma.getPosition()) > titleForTreatIndex) {
|
|
|
|
+ Diag diag = new Diag();
|
|
|
|
+ diag.setName(dieaseLemma.getText());
|
|
|
|
+ diags.add(diag);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ threeLevelWardLabel.setDiags(diags);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //诊疗计划
|
|
|
|
+ List<Lemma> treatmentPlanLemmas = createEntityTree(aiOut, EntityEnum.TREATMENT_PLAN.toString());
|
|
|
|
+ List<TreatmentPlan> treatmentPlans = new ArrayList<>();
|
|
|
|
+ for (Lemma lemma : treatmentPlanLemmas) {
|
|
|
|
+ TreatmentPlan treatmentPlan = new TreatmentPlan();
|
|
|
|
+ treatmentPlan.setName(lemma.getText());
|
|
|
|
+ treatmentPlans.add(treatmentPlan);
|
|
|
|
+ }
|
|
|
|
+ threeLevelWardLabel.setTreatmentPlans(treatmentPlans);
|
|
|
|
+ return threeLevelWardLabel;
|
|
|
|
+ }
|
|
|
|
+}
|