Kaynağa Gözat

日常病程记录

chengyao 4 yıl önce
ebeveyn
işleme
e3722a3383

+ 37 - 8
structure-center/src/main/java/com/lantone/structure/ai/FirstCourseRecordAI.java

@@ -3,21 +3,18 @@ package com.lantone.structure.ai;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.google.common.collect.Lists;
+import com.lantone.common.util.ListUtil;
+import com.lantone.structure.ai.process.*;
 import com.lantone.structure.client.CRFServiceClient;
 import com.lantone.structure.client.SimilarityServiceClient;
-import com.lantone.structure.ai.process.EntityProcessClinic;
-import com.lantone.structure.ai.process.EntityProcessDiag;
-import com.lantone.structure.ai.process.EntityProcessDrug;
-import com.lantone.structure.ai.process.EntityProcessTreatPlan;
 import com.lantone.common.util.CatalogueUtil;
 import com.lantone.structure.model.Content;
 import com.lantone.structure.model.InputInfo;
+import com.lantone.structure.model.doc.DailyCourseRecordDoc;
 import com.lantone.structure.model.doc.FirstCourseRecordDoc;
 import com.lantone.structure.model.entity.Diag;
 import com.lantone.structure.model.entity.Drug;
-import com.lantone.structure.model.label.DrugLabel;
-import com.lantone.structure.model.label.PresentLabel;
-import com.lantone.structure.model.label.TreatPlanLabel;
+import com.lantone.structure.model.label.*;
 import com.lantone.common.util.StringUtil;
 import org.apache.commons.lang3.StringUtils;
 
@@ -36,7 +33,7 @@ public class FirstCourseRecordAI extends ModelAI {
      *
      */
     public static List<String> medicalTextType = Arrays.asList("FirstCoursera_cx", "Diagnoses_cx"
-            , "FirstCourseTreatment_cx", "CourseRecordSRR");
+            , "FirstCourseTreatment_cx", "CourseRecordSRR","Taizhou_before_surgery");
     public static String entityRelationObject = "entity_relation_object";
     public static String outputs = "outputs";
     public static String content = "content";
@@ -44,6 +41,20 @@ public class FirstCourseRecordAI extends ModelAI {
     public void medrec(InputInfo inputInfo, CRFServiceClient crfServiceClient, SimilarityServiceClient similarityServiceClient) {
         JSONArray crfContent = new JSONArray();
         JSONArray similarContent = new JSONArray();
+        List<DailyCourseRecordDoc> dailyCourseRecordDocs  = inputInfo.getDailyCourseRecordDocs();
+        if (ListUtil.isNotEmpty(dailyCourseRecordDocs)) {
+            DailyCourseRecordDoc dailyCourseRecordDoc = dailyCourseRecordDocs.get(0);
+            if (dailyCourseRecordDoc != null) {
+                String text = dailyCourseRecordDoc.getText();
+                if(text.contains("医嘱")){
+                    //title记得改!!!!Taizhou_before_surgery
+                    text = text.substring(text.indexOf("医嘱"),text.lastIndexOf(""));
+                    putContent(crfContent, medicalTextType.get(4), text, Content.doctorAdviceRecord);
+                    JSONObject midData = loadAI(crfContent, crfServiceClient);//crf返回数据
+                    dailyCourseRecordCrfData(midData.getJSONObject(Content.doctorAdviceRecord), inputInfo);
+                }
+            }
+        }
         FirstCourseRecordDoc firstCourseRecordDoc = inputInfo.getFirstCourseRecordDoc();
         if (firstCourseRecordDoc != null) {
             Map<String, String> structureMap = firstCourseRecordDoc.getStructureMap();
@@ -187,6 +198,24 @@ public class FirstCourseRecordAI extends ModelAI {
         inputInfo.getFirstCourseRecordDoc().getInitialDiagLabel().setDiags(diags);
     }
 
+    /**
+     * 处理日常病程记录
+     *
+     * @param jsonObject
+     */
+    public void dailyCourseRecordCrfData(JSONObject jsonObject, InputInfo inputInfo) {
+        if (jsonObject == null) {
+            return;
+        }
+        JSONObject aiOut = jsonObject.getJSONObject(entityRelationObject).getJSONObject(BeHospitalizedAI.outputs);
+        if (aiOut == null) {
+            return;
+        }
+        EntityDailyCourseRecord entityDailyCourseRecord = new EntityDailyCourseRecord();
+        DailyCourseRecordLabel dailyCourseRecordLabel = entityDailyCourseRecord.extractEntity(aiOut);
+        inputInfo.getDailyCourseRecordDocs().get(0).setDailyCourseRecordLabel(dailyCourseRecordLabel);
+    }
+
     /**
      * 诊断依据
      *

+ 1 - 2
structure-center/src/main/java/com/lantone/structure/ai/model/EntityEnum.java

@@ -41,8 +41,7 @@ public enum EntityEnum {
     CORD_AROUND_BODY("脐带绕身"), UTERINE_WALL_SUTURE("子宫壁缝合情况"), UC_AGENT("宫缩剂名称"), UC_CONSUMPTION("宫缩剂用量"), UC_USAGE_WARD_ROUND("宫缩剂用法"),
     UTERINE_CAVITY_ABNORMITY("宫腔探查异常情况描述"), UTERINE_CAVITY_DISPOSE("宫腔探查处理情况"), PUERPERA_CONDITION("手术时产妇情况"), HEMORRHAGE("术中出血"),
     FLUID_INFUSION("补液"),BLOOD_PRESSURE("血压情况"), NEWBORN("新生儿"), APGAR_SCORE("Apgar评分"), SCORE("分数"), CAPUT_SUCCEDANEUM("产瘤"),
-    CAPUT_SUCCEDANEUM_PART("产瘤部位"), OPE_DRUG("手术用药名称"), OPE_CONSUMPTION("手术用药量"), OPE_USAGE_WARD_ROUND("手术用药方法"), TRANSFUSION("输血成分"), DOCTORADVICE_RECORD("医嘱内容"), ASSESSMENTPLAN("诊疗计划"),ALLERGYRECORD("过敏史"),OPCONTRAINDICATION("手术禁忌"),OPBOTTOMNAME("手术目标部位");
-
+    CAPUT_SUCCEDANEUM_PART("产瘤部位"), OPE_DRUG("手术用药名称"), OPE_CONSUMPTION("手术用药量"), OPE_USAGE_WARD_ROUND("手术用药方法"), TRANSFUSION("输血成分"), DOCTORADVICE_RECORD("医嘱内容"), ASSESSMENTPLAN("诊疗计划"),ALLERGYRECORD("过敏史"),OPCONTRAINDICATION("手术禁忌"),OPBOTTOMNAME("手术目标部位"),DOCTORADVICERECORD("医嘱信息");
 
 
     private String value;

+ 42 - 0
structure-center/src/main/java/com/lantone/structure/ai/process/EntityDailyCourseRecord.java

@@ -0,0 +1,42 @@
+package com.lantone.structure.ai.process;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.lantone.structure.ai.model.EntityEnum;
+import com.lantone.structure.ai.model.Lemma;
+import com.lantone.structure.model.label.DailyCourseRecordLabel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+/**
+ * 处理日常病程记录
+ */
+public class EntityDailyCourseRecord extends EntityProcess {
+    private Logger logger = LoggerFactory.getLogger(EntityDailyCourseRecord.class);
+
+    public DailyCourseRecordLabel extractEntity(JSONObject aiOut) {
+        DailyCourseRecordLabel dailyCourseRecordLabel= new DailyCourseRecordLabel();
+        try {
+
+            //医嘱信息
+            StringBuffer sb = new StringBuffer();
+            int doctorAdvice = 0;
+            List<Lemma> doctorAdviceRecord = createEntityTree(aiOut, EntityEnum.DOCTORADVICERECORD.toString());
+            for (Lemma lemma : doctorAdviceRecord) {
+                doctorAdvice++;
+                if(doctorAdviceRecord.size()>1){
+                    sb.append(doctorAdvice+lemma.getText()+" ");
+                }else{
+                    sb.append(lemma.getText());
+                }
+            }
+            dailyCourseRecordLabel.setDoctorAdviceRecord(sb.toString());
+        } catch (Exception e) {
+            e.printStackTrace();
+            logger.error(e.getMessage(), e);
+        }
+        return dailyCourseRecordLabel;
+    }
+}

+ 3 - 0
structure-center/src/main/java/com/lantone/structure/facade/StructureFacade.java

@@ -98,6 +98,9 @@ public class StructureFacade {
             case "术后首次病程记录":
                 targetTran = new OperationDiscussionTran();
                 break;
+            case "日常病程记录":
+                targetTran = new DailyCourseRecordTran();
+                break;
             default:
                 break;
         }

+ 97 - 0
structure-center/src/main/java/com/lantone/structure/facade/tran/DailyCourseRecordTran.java

@@ -0,0 +1,97 @@
+package com.lantone.structure.facade.tran;
+
+import com.lantone.common.util.StringUtil;
+import com.lantone.structure.model.doc.DailyCourseRecordDoc;
+import com.lantone.structure.model.label.DailyCourseRecordLabel;
+import lombok.extern.slf4j.Slf4j;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @Description:日常病程记录
+ * @author: cy
+ * @time: 2021/3/16 17:23
+ */
+@Slf4j
+public class DailyCourseRecordTran extends TargetTran {
+
+    @Override
+    public Map<String, String> convert(String text) {
+        List<DailyCourseRecordDoc> dailyCourseRecordDocs = new ArrayList<>();
+        DailyCourseRecordDoc dailyCourseRecordDoc  = new DailyCourseRecordDoc();
+        dailyCourseRecordDoc.setText(text);
+        dailyCourseRecordDocs.add(dailyCourseRecordDoc);
+        inputInfo.setDailyCourseRecordDocs(dailyCourseRecordDocs);
+        Map<String, String> structureMap = new HashMap<String, String>();
+        dailyCourseContrast(inputInfo.getDailyCourseRecordDocs(), structureMap);
+        dailyCourseRecordDoc.setStructureMap(structureMap);
+        aiProcess();
+        lastSovle(inputInfo.getDailyCourseRecordDocs(),structureMap);
+        return structureMap;
+    }
+
+    public void dailyCourseContrast(List<DailyCourseRecordDoc> dailyCourseRecordDocs,Map<String, String> retMap) {
+        String text = dailyCourseRecordDocs.get(0).getText();
+        String file = text;
+        retMap.put("住院病程",file);
+        String signDate = "签名日期";
+        if(file.contains("签字日期")){
+            signDate = "签字日期";
+        }
+        if(file.contains(signDate)){
+            String date = file.substring(file.lastIndexOf(signDate));
+            date = extractDate(date);
+            if(StringUtil.isNotEmpty(date)){
+                retMap.put("签名日期时间",date);
+            }
+        }
+        String signName= parseString(file);
+        if(StringUtil.isNotEmpty(signName)){
+            retMap.put("医师签名",signName);
+        }
+
+    }
+
+    public static void lastSovle(List<DailyCourseRecordDoc> dailyCourseRecordDocs , Map<String,String> rep) {
+        if(!dailyCourseRecordDocs.isEmpty() && dailyCourseRecordDocs.get(0)!=null && dailyCourseRecordDocs.get(0)
+                .getDailyCourseRecordLabel()!=null){
+            DailyCourseRecordLabel dailyCourseRecordLabel = dailyCourseRecordDocs.get(0).getDailyCourseRecordLabel();
+            String doctorAdviceRecord = dailyCourseRecordLabel.getDoctorAdviceRecord();
+            if(StringUtil.isNotEmpty(doctorAdviceRecord)){
+                rep.put("医嘱内容",doctorAdviceRecord);
+            }
+        }
+    }
+
+
+    /**
+     * 抽取文本中的第一个时间
+     *
+     * @param top
+     * @return
+     */
+    public static String extractDate (String top){
+        Pattern pattern = Pattern.compile("[0-9]{4}[-][0-9]{1,2}[-][0-9]{1,2}");
+        Matcher matcher = pattern.matcher(top);
+        if (matcher.find()) {
+            return matcher.group(0);
+        } else {
+            Pattern p1 = Pattern.compile("[0-9]{4}年[0-9]+月[0-9]+日");
+            Matcher m1 = p1.matcher(top);
+            if (m1.find()) {
+                return m1.group(0);
+            }
+        }
+        return null;
+    }
+
+    // 取/后
+    public static String parseString(String text){
+        if(text.contains("/")){
+            text = text.substring(text.lastIndexOf("/")+1);
+            text= parseString(text);
+        }
+        return text;
+    }
+}

+ 20 - 1
structure-center/src/main/java/com/lantone/structure/facade/tran/OperationDiscussionTran.java

@@ -6,7 +6,6 @@ import com.lantone.common.util.StringUtil;
 import com.lantone.structure.facade.tran.util.CommonAnalysisUtil;
 import com.lantone.structure.model.doc.operation.OperationDiscussionDoc;
 import com.lantone.structure.model.doc.operation.OperationDoc;
-import com.lantone.structure.model.doc.operation.PreoperativeDiscussionDoc;
 import com.lantone.structure.util.MapUtil;
 import lombok.extern.slf4j.Slf4j;
 
@@ -86,6 +85,17 @@ public class OperationDiscussionTran extends TargetTran {
             }
             retMap.put("术后诊断名称",sureStr);
         }
+        if(text.contains("注意观察")){
+            String sureStr = text.substring(text.indexOf("注意观察") + "注意观察".length());
+            if(sureStr.contains("。")){
+                sureStr = sureStr.split("。")[0];
+            }
+            retMap.put("注意事项",sureStr);
+        }
+        String signName= parseString(text);
+        if(StringUtil.isNotEmpty(signName)){
+            retMap.put("医师签名",signName);
+        }
 
     }
 
@@ -136,4 +146,13 @@ public class OperationDiscussionTran extends TargetTran {
         }
         return null;
     }
+
+    // 取/后
+    public static String parseString(String text){
+        if(text.contains("/")){
+            text = text.substring(text.lastIndexOf("/")+1);
+            text= parseString(text);
+        }
+        return text;
+    }
 }

+ 1 - 0
structure-center/src/main/java/com/lantone/structure/model/Content.java

@@ -252,6 +252,7 @@ public class Content {
     public static final String timestamp = "timestamp";
     public static final String  preoperativeDiscussion = "过敏、禁忌症";
     public static final String  surgicalSite = "手术目标部位";
+    public static final String  doctorAdviceRecord = "医嘱内容";
     public static final String bloodRecord = "输血记录";
     public static final String stagesSummary = "阶段小结";
     public static final String rescue = "抢救记录";

+ 2 - 0
structure-center/src/main/java/com/lantone/structure/model/doc/DailyCourseRecordDoc.java

@@ -1,5 +1,6 @@
 package com.lantone.structure.model.doc;
 
+import com.lantone.structure.model.label.DailyCourseRecordLabel;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -12,4 +13,5 @@ import lombok.Setter;
 @Setter
 @Getter
 public class DailyCourseRecordDoc extends ModelDoc {
+    DailyCourseRecordLabel dailyCourseRecordLabel;
 }

+ 16 - 0
structure-center/src/main/java/com/lantone/structure/model/label/DailyCourseRecordLabel.java

@@ -0,0 +1,16 @@
+package com.lantone.structure.model.label;
+import lombok.Getter;
+import lombok.Setter;
+
+
+/**
+ * @ClassName :
+ * @Description :
+ * @Author :
+ * @Date:
+ */
+@Getter
+@Setter
+public class DailyCourseRecordLabel extends GeneralLabel {
+   private String doctorAdviceRecord;//医嘱信息
+}