浏览代码

添加crf依赖

kongwz 5 年之前
父节点
当前提交
d286ccb19e

+ 102 - 1
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/BeHospitalizedAI.java

@@ -1,6 +1,20 @@
 package com.lantone.qc.kernel.structure.ai;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
+import com.lantone.qc.kernel.client.CRFServiceClient;
+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.label.ChiefLabel;
+import com.lantone.qc.pub.model.vo.CRFVo;
+import com.lantone.qc.pub.util.StringUtil;
+
+import java.util.Arrays;
+import java.util.List;
 
 /**
  * @ClassName : InHospitalDoc
@@ -9,8 +23,95 @@ import com.lantone.qc.kernel.catalogue.QCCatalogue;
  * @Date: 2020-03-03 18:58
  */
 public class BeHospitalizedAI extends QCCatalogue {
-    public void medrec(){
+    /**
+     * FirstCourseRecord_cx[病历首程]
+     * PastFamily_cx[既往史家族史]
+     * PersonalHistory_cx[个人史(月经史、婚育史)]
+     * HPIForCX_cx[主诉、现病史、专科检查]
+     * GeneralVital_cx[一般体格检查]
+     * chief_present[邵逸夫医院主诉现病史]
+     */
+    public static List<String> medicalTextType = Arrays.asList("FirstCourseRecord_cx", "PastFamily_cx", "PersonalHistory_cx", "HPIForCX_cx",
+            "GeneralVital_cx", "chief_present");
+    public void medrec(InputInfo inputInfo,CRFServiceClient crfServiceClient){
+        JSONArray crfContent = new JSONArray();
+        BeHospitalizedDoc beHospitalizedDoc = inputInfo.getBeHospitalizedDoc();
+        String chief_text = beHospitalizedDoc.getChiefLabel().getText();
+        String Personal_text = beHospitalizedDoc.getPersonalLabel().getText();
+        String family_text = beHospitalizedDoc.getFamilyLabel().getText();
+        String past_text = beHospitalizedDoc.getPastLabel().getText();
+        String present_text = beHospitalizedDoc.getPresentLabel().getText();
+        //月经史
+        String menstrual_text = beHospitalizedDoc.getMenstrualLabel().getText();
+        //婚育史
+        String marital_text = beHospitalizedDoc.getMaritalLabel().getText();
+        //存放主诉、现病史
+        putContent(crfContent,medicalTextType.get(3), chief_text,Content.chief);
+        putContent(crfContent,medicalTextType.get(3), present_text,Content.present);
+        //存放既往史、家族史
+        putContent(crfContent,medicalTextType.get(3), past_text,Content.past);
+        putContent(crfContent,medicalTextType.get(3), family_text,Content.family);
+        //存放个人史、月经史、婚育史
+        putContent(crfContent,medicalTextType.get(3), Personal_text,Content.personal);
+        putContent(crfContent,medicalTextType.get(3), menstrual_text,Content.menses);
+        putContent(crfContent,medicalTextType.get(3), marital_text,Content.marriage);
+        //存储CRF完整所需结构数据
+        CRFVo crfVo = new CRFVo();
+        crfVo.setData(crfContent);
+        //获取CRF模型返回数据
+        JSONArray data = getAnnotation(crfServiceClient, crfVo).getData();
+        JSONObject midData = getOutputs(data);
+
+
+
+    }
+    public void putContent(JSONArray crfContent, String medicalTextType, String text,String sign){
+        String move_text = this.moveSpecialSymbols(text);
+        if (StringUtil.isEmpty(move_text)) {
+            return;
+        }
+        JSONObject detailContent = new JSONObject();
+        detailContent.put("medical_text_type", medicalTextType);
+        detailContent.put("content", move_text);
+        detailContent.put("detail_title", sign);
+        crfContent.add(detailContent);
+    }
+    private Annotation getAnnotation(CRFServiceClient crfServiceClient, CRFVo crfVo) {
 
+        Annotation annotation = new Annotation();
+        try {
+            String annotation_str = crfServiceClient.getAnnotation(crfVo);
+            annotation = JSON.parseObject(annotation_str, Annotation.class);
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        } finally {
+            return annotation;
+        }
     }
 
+    /**
+     * 获取CRF模型输出并处理
+     *
+     * @param data
+     * @return
+     */
+    public JSONObject getOutputs(JSONArray data) {
+        JSONObject midData = new JSONObject();
+        for (int i = 0; i < data.size(); i++) {
+            JSONObject detailContent = data.getJSONObject(i);
+            String detail_title = detailContent.getString("detail_title");
+            if (StringUtil.isNotEmpty(detail_title) && midData.get(detail_title) == null) {
+                midData.put(detail_title, detailContent);
+            }
+        }
+        return midData;
+    }
+    //文本去除\r\n\t特殊符号
+    public String moveSpecialSymbols(String content){
+        if (StringUtil.isEmpty(content)){
+            return "";
+        }
+        return content.replaceAll("\\r\\n|/r/n", "\r\n")
+                .replaceAll("\\t", "\t").trim();
+    }
 }

+ 126 - 0
public/src/main/java/com/lantone/qc/pub/Content.java

@@ -0,0 +1,126 @@
+/**
+ *	Content.java
+ *	医学病案质控病历内容标签
+ *
+ *	@author Mark Huang
+ *	@since 8/1/2020
+ **/
+package com.lantone.qc.pub;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class Content {
+
+    public static String title = "病历";
+    public static String header = "标题";
+    public static String content_lbl="内容";
+
+    public static String label = "content";
+
+    public static String[] docname = {"病案首页","入院记录","首次病程录","病程","医嘱","出院小结"};
+
+    public static List<String> title_homepage = Arrays.asList("医疗机构","医疗付费方式","健康卡号","住院次数"
+            ,"病案号","姓名","性别","出生日期","年龄","国籍","(年龄不足1周岁的)年龄","新生儿出生体重","新生儿入院体重"
+            ,"出生地","籍贯","民族","身份证号","职业","婚姻","现住址","户口地址","工作单位及地址"
+            ,"联系人姓名","入院途径","入院时间","出院时间","门(急)诊诊断","疾病编码","出院诊断","主要诊断","其他诊断"
+            ,"入院病情","损伤、中毒的外部因素"
+            ,"疾病代码","病理诊断","病理号","药物过敏","过敏药物","死亡患者尸检","血型","Rh","科主任","主任(副主任)医生"
+            ,"主治医师","住院医师","责任护士","进修医师","实习医师","编码员","病案质量","质控医师","质控护士","质控日期"
+            ,"手术操作码","手术操作日期","手术级别","手术及操作名称","手术及操作医师","术者"
+            ,"I助","II助","切口愈合等级","麻醉方式","麻醉医师","离院方式","拟接收医疗机构名称","是否有出院31天内再住院计划"
+            ,"目的","颅脑损伤患者昏迷时间","入院前天","入院后天","住院费用(元) : 总费用"
+            ,"1.综合医疗服务类","2.诊断类","3.治疗类", "4.康复类","5.中医类","6.西药类","7.中药类","8.血液和血液制品类",
+            "9.耗材类","10.其他类","单病种管理","临床路径管理","诊断符合情况","抢救情况","主要诊断治愈好转情况");
+
+    public static List<String> title_admit = Arrays.asList("姓名","性别","年龄","民族",
+            "职业","出生地","婚姻","联系地址","病史陈述者","入院日期","记录日期",
+            "主诉","现病史","既往史","个人史","月经史","婚育史","家族史","体格检查(一)",
+            "体格检查(二)","辅助检查","初步诊断","修正诊断","医师签名","补充诊断");
+
+    public static List<String> admit_basic = Arrays.asList("姓名","性别","年龄","民族",
+            "职业","出生地","婚姻","联系地址","病史陈述者","入院日期","记录日期");
+
+
+    public static List<String> title_progress = Arrays.asList("记录","记录医师");
+
+    public static List<String> title_first_progress = Arrays.asList("首次病程录","一、病例特点","二、初步诊断",
+            "三、诊断依据","四、鉴别诊断","五、诊疗计划","记录医师");
+
+    public static List<String> title_round = Arrays.asList("查房记录","记录医师");
+
+    public static List<String> title_critical_rec = Arrays.asList("危急值记录", "患者临床诊断", "危急值记录内容",
+            "报告部门","报告人姓名","报告时间","接收人姓名","接收时间","病情分析及处理","医生姓名","签名时间","记录医师");
+
+    public static List<String> title_transfusion = Arrays.asList("输血/血制品病程记录","输注原因","输注开始",
+            "输注结束","输注方式","输注种类、血型、数量","输注过程","输注后效果评价","记录医师");
+
+    public static List<String> title_preop_summary = Arrays.asList("术前讨论、术前小结","讨论方式","参加人员","简要病情",
+            "术前诊断","手术指征与禁忌征","可替代方案","拟施手术方式、名称及可能的变更","计划性多次手术","拟施麻醉方式"
+            ,"术前特殊准备","主要术中、术后风险及防范措施","术中、术后注意事项","经治医师签名","主刀医师签名");
+
+    public static List<String> title_operator_record = Arrays.asList("手术记录","手术时间","术前诊断","手术名称","手术中诊断",
+            "手术者","Ⅰ助","Ⅱ助","Ⅲ助","麻醉方式","麻醉人员","手术经过","手术者签字","记录时间");
+
+    public static List<String> title_postop_session = Arrays.asList("术后首次病程及谈话记录","手术时间","麻醉方式",
+            "手术名称","术中诊断","手术简要经过","患者术后情况","术后处理措施","术后可能出现的并发症及预防措施",
+            "术后注意事项","谈话医师签字","患者签名","被授权人/代理人签名");
+
+    public static List<String> title_decease_discuss = Arrays.asList("死亡病例讨论记录","入院时间","死亡时间","入院诊断",
+            "死亡诊断","讨论时间","讨论地点","参加讨论人员","讨论主持人","讨论内容","结论","记录医师");
+
+    public static List<String> title_decease_record = Arrays.asList("死亡记录","姓名","性别","科别","床号"
+            ,"病案号","年龄","入院时间","死亡时间","入院情况","入院诊断","诊疗经过","死亡原因","死亡诊断","记录医师"
+            ,"记录时间");
+
+    public static List<String> title_rescue = Arrays.asList("抢救记录","抢救时间","参加现场抢救的医师及护理人员",
+            "抢救过程","记录医师");
+
+    public static List<String> title_intractable_rec = Arrays.asList("疑难病例讨论记录","入院时间","入院诊断",
+            "讨论时间","讨论地点","讨论目的","主持人","参加讨论者(包括职称及姓名)","讨论内容","结论","记录医师");
+
+    public static List<String> title_phase_summary = Arrays.asList("阶段小结","入院日期","患者","入院情况","入院诊断",
+            "诊疗经过","目前情况","目前诊断","记录医师");
+
+    public static List<String> title_order = Arrays.asList("开始日期","开始时间","医嘱",
+            "结束日期","结束时间","医师签名","护士签名");
+
+    public static List<String> title_consultant = Arrays.asList("会诊记录","记录医师");
+
+    public static List<String> title_discharge = Arrays.asList("姓名","性别","年龄","床号",
+            "入院时间","出院时间","入院诊断","出院诊断","住院天数","入院情况", "诊治经过",
+            "出院情况","出院医嘱","健康教育","随访计划","温馨提示","医师签名","签名时间");
+
+    public static List<String> progress_type = Arrays.asList("查房记录","会诊记录","危急值记录","病重通知记录");
+
+
+    public static final String chief = "主诉";
+    public static final String present = "现病史";
+    public static final String past = "既往史";
+    public static final String personal = "个人史";
+    public static final String marriage = "婚育史";
+    public static final String menses = "月经史";
+    public static final String family = "家族史";
+    public static final String phys_exam = "体格检查(一)";
+    public static final String special_exam = "体格检查(二)";
+
+    public static final String case_feature = "一、病例特点";
+    public static final String pridiag = "二、初步诊断";
+    public static final String diag_basis = "三、诊断依据";
+
+    public static final String name = "姓名";
+    public static final String gender = "性别";
+    public static final String age = "年龄";
+    public static final String idcard_info = "身份证号";
+    public static final String marry = "婚姻";
+    public static final String contact_name = "联系人姓名";
+    public static final String admit_dept = "入院科别";
+    public static final String blood_type="血型";
+    public static final String rh_factor="RH因子";
+    public static final String type = "性";
+
+    public static final String doctor_rank = "医师等级";
+    public static final String round_doctor = "查房医师";
+
+    public static final String timestamp = "timestamp";
+}

+ 18 - 0
public/src/main/java/com/lantone/qc/pub/model/entity/Annotation.java

@@ -0,0 +1,18 @@
+package com.lantone.qc.pub.model.entity;
+
+
+import com.alibaba.fastjson.JSONArray;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:CRF标注内容结构
+ * @time: 13/12/2019
+ */
+
+@Getter
+@Setter
+public class Annotation {
+    private JSONArray data;
+    private boolean status;
+}

+ 4 - 0
public/src/main/java/com/lantone/qc/pub/model/label/ChiefLabel.java

@@ -1,6 +1,8 @@
 package com.lantone.qc.pub.model.label;
 
 import com.lantone.qc.pub.model.entity.Clinical;
+import lombok.Getter;
+import lombok.Setter;
 
 import java.util.List;
 
@@ -10,6 +12,8 @@ import java.util.List;
  * @Author : 楼辉荣
  * @Date: 2020-03-03 18:44
  */
+@Setter
+@Getter
 public class ChiefLabel extends GeneralLabel {
     private List<Clinical> clinicals;
 }

+ 1 - 1
public/src/main/java/com/lantone/qc/pub/model/label/FamilyLabel.java

@@ -6,5 +6,5 @@ package com.lantone.qc.pub.model.label;
  * @Author : 楼辉荣
  * @Date: 2020-03-03 18:49
  */
-public class FamilyLabel {
+public class FamilyLabel extends GeneralLabel {
 }

+ 5 - 0
public/src/main/java/com/lantone/qc/pub/model/label/GeneralLabel.java

@@ -1,11 +1,16 @@
 package com.lantone.qc.pub.model.label;
 
+import lombok.Getter;
+import lombok.Setter;
+
 /**
  * @ClassName : GeneralLabel
  * @Description :
  * @Author : 楼辉荣
  * @Date: 2020-03-04 10:44
  */
+@Setter
+@Getter
 public class GeneralLabel {
     private String text;
 }

+ 1 - 1
public/src/main/java/com/lantone/qc/pub/model/label/MaritalLabel.java

@@ -6,5 +6,5 @@ package com.lantone.qc.pub.model.label;
  * @Author : 楼辉荣
  * @Date: 2020-03-03 18:48
  */
-public class MaritalLabel {
+public class MaritalLabel extends GeneralLabel{
 }

+ 1 - 1
public/src/main/java/com/lantone/qc/pub/model/label/MenstrualLabel.java

@@ -6,5 +6,5 @@ package com.lantone.qc.pub.model.label;
  * @Author : 楼辉荣
  * @Date: 2020-03-03 18:48
  */
-public class MenstrualLabel {
+public class MenstrualLabel extends GeneralLabel{
 }

+ 1 - 1
public/src/main/java/com/lantone/qc/pub/model/label/PastLabel.java

@@ -6,5 +6,5 @@ package com.lantone.qc.pub.model.label;
  * @Author : 楼辉荣
  * @Date: 2020-03-03 18:45
  */
-public class PastLabel {
+public class PastLabel extends GeneralLabel{
 }

+ 1 - 1
public/src/main/java/com/lantone/qc/pub/model/label/PersonalLabel.java

@@ -12,5 +12,5 @@ import lombok.Setter;
  **/
 @Setter
 @Getter
-public class PersonalLabel extends General {
+public class PersonalLabel extends GeneralLabel {
 }

+ 2 - 1
public/src/main/java/com/lantone/qc/pub/model/vo/CRFVo.java

@@ -1,5 +1,6 @@
 package com.lantone.qc.pub.model.vo;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import lombok.Getter;
 import lombok.Setter;
@@ -7,7 +8,7 @@ import lombok.Setter;
 @Getter
 @Setter
 public class CRFVo {
+    private JSONArray data = new JSONArray();
 //    private String medical_text_type;
 //    private String content;
-    private JSONObject data = new JSONObject();
 }