Browse Source

入院记录字段切割

rengb 5 years ago
parent
commit
3a4a86664e

+ 6 - 0
kernel/pom.xml

@@ -37,6 +37,12 @@
 			<version>1.0</version>
 		</dependency>
 
+		<dependency>
+			<groupId>com.lantone.qc</groupId>
+			<artifactId>trans</artifactId>
+			<version>1.0</version>
+		</dependency>
+
 		<dependency>
 			<groupId>org.springframework.boot</groupId>
 			<artifactId>spring-boot-starter-web</artifactId>

+ 9 - 2
kernel/src/main/java/com/lantone/qc/kernel/analysis/QCAnalysis.java

@@ -1,7 +1,10 @@
 package com.lantone.qc.kernel.analysis;
 
+import com.lantone.qc.pub.model.InputInfo;
+import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.vo.QueryVo;
-import org.apache.commons.beanutils.PropertyUtils;
+import com.lantone.qc.trans.TransDispatch;
+import org.springframework.stereotype.Component;
 
 /**
  * @ClassName : QCAnalysis
@@ -9,7 +12,11 @@ import org.apache.commons.beanutils.PropertyUtils;
  * @Author : 楼辉荣
  * @Date: 2020-03-04 11:48
  */
+@Component
 public class QCAnalysis {
-    public void anlysis(QueryVo queryVo) {
+    public OutputInfo anlysis(QueryVo queryVo) {
+        OutputInfo outputInfo = new OutputInfo();
+        InputInfo inputInfo = TransDispatch.trans(queryVo);
+        return outputInfo;
     }
 }

+ 7 - 0
kernel/src/main/java/com/lantone/qc/kernel/web/controller/QCController.java

@@ -1,9 +1,11 @@
 package com.lantone.qc.kernel.web.controller;
 
+import com.lantone.qc.kernel.analysis.QCAnalysis;
 import com.lantone.qc.pub.model.vo.QueryVo;
 import com.lantone.qc.pub.res.Response;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -22,10 +24,15 @@ import java.util.Map;
 @RequestMapping(value = "analyse")
 public class QCController {
 
+    @Autowired
+    private QCAnalysis qCAnalysis;
+
     @ApiOperation(value = "质控外部接口,需要token信息", notes = "")
     @PostMapping("rec")
     public Response<Map<String, Object>> extract(@RequestBody QueryVo queryVo) {
         Response response = new Response();
+        qCAnalysis.anlysis(queryVo);
         return response;
     }
+    
 }

+ 5 - 0
public/pom.xml

@@ -28,6 +28,11 @@
             <version>2.8.6</version>
             <!--<scope>provided</scope>-->
         </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>18.0</version>
+        </dependency>
     </dependencies>
 
     <build>

+ 1 - 0
public/src/main/java/com/lantone/qc/pub/model/entity/Negative.java

@@ -13,4 +13,5 @@ import lombok.Setter;
 @Setter
 @Getter
 public class Negative extends General {
+
 }

+ 68 - 0
public/src/main/java/com/lantone/qc/pub/model/keys/ModelStandardKeys.java

@@ -0,0 +1,68 @@
+package com.lantone.qc.pub.model.keys;
+
+import com.google.common.collect.Lists;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @author: rengb
+ * @time: 2020/3/5 14:50
+ */
+public class ModelStandardKeys {
+
+    //入院病历的标准key
+    public static final List<String> beHospitalized = Lists.newArrayList(
+            "姓名",
+            "性别",
+            "年龄",
+            "民族",
+            "职业",
+            "出生地",
+            "婚姻",
+            "联系地址",
+            "病史陈述者",
+            "出生日期",
+            "户口地址",
+            "电话",
+            "入院日期",
+            "记录日期",
+            "主诉",
+            "现病史",
+            "既往史",
+            "个人史",
+            "婚育史",
+            "月经史",
+            "家族史",
+            "体格检查(一)",
+            "体格检查(二)",
+            "辅助检查",
+            "初步诊断",
+            "修正诊断",
+            "医师签名",
+            "补充诊断"
+    );
+
+    //出院小结的标准key
+    public static final List<String> leaveHospital = Lists.newArrayList(
+            "姓名",
+            "性别",
+            "年龄",
+            "床号",
+            "入院时间",
+            "出院时间",
+            "入院诊断",
+            "出院诊断",
+            "住院天数",
+            "入院情况",
+            "诊治经过",
+            "出院情况",
+            "出院医嘱",
+            "健康教育",
+            "随访计划",
+            "温馨提示",
+            "医师签名",
+            "签名时间"
+    );
+
+}

+ 4 - 3
public/src/main/java/com/lantone/qc/pub/model/vo/QueryVo.java

@@ -16,8 +16,9 @@ import java.util.List;
 public class QueryVo extends TokenVO {
 
     private List<MedrecVo> medrec;
-    // 调用机构id, 0:ICSS, 1:长兴人民医院, 2:邵逸夫医院, 3:台州市立医院
-    private int cid;
-    // 机构名称
+
+    private String cid;
+
     private String org;
+
 }

+ 5 - 0
trans/pom.xml

@@ -25,6 +25,11 @@
       <version>4.11</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>com.lantone.qc</groupId>
+      <artifactId>public</artifactId>
+      <version>1.0</version>
+    </dependency>
   </dependencies>
 
   <build>

+ 3 - 2
trans/src/main/java/com/lantone/qc/trans/DocTrans.java

@@ -1,6 +1,7 @@
 package com.lantone.qc.trans;
 
-import java.util.Map;
+import com.lantone.qc.pub.model.InputInfo;
+import com.lantone.qc.pub.model.vo.QueryVo;
 
 /**
  * @ClassName : DocTrans
@@ -9,5 +10,5 @@ import java.util.Map;
  * @Date: 2020-03-03 19:47
  */
 public abstract class DocTrans {
-    protected abstract Map<String, String> extract(String classify);
+    protected abstract InputInfo extract(QueryVo queryVo);
 }

+ 28 - 0
trans/src/main/java/com/lantone/qc/trans/TransDispatch.java

@@ -0,0 +1,28 @@
+package com.lantone.qc.trans;
+
+import com.lantone.qc.pub.model.InputInfo;
+import com.lantone.qc.pub.model.vo.QueryVo;
+
+/**
+ * @Description:
+ * @author: rengb
+ * @time: 2020/3/5 19:49
+ */
+public class TransDispatch {
+
+    public static InputInfo trans(QueryVo queryVo) {
+        try {
+            String classPath = "com.lantone.qc.trans."
+                    + queryVo.getCid()
+                    + "."
+                    + queryVo.getCid().substring(0, 1).toUpperCase()
+                    + queryVo.getCid().substring(1)
+                    + "DocTrans";
+            DocTrans docTrans = (DocTrans) Class.forName(classPath).newInstance();
+            return docTrans.extract(queryVo);
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+}

+ 28 - 0
trans/src/main/java/com/lantone/qc/trans/changx/BeHospitalizedDocTrans.java

@@ -0,0 +1,28 @@
+package com.lantone.qc.trans.changx;
+
+import com.lantone.qc.pub.model.doc.BeHospitalizedDoc;
+import com.lantone.qc.pub.model.keys.ModelStandardKeys;
+import com.lantone.qc.pub.model.vo.MedrecVo;
+import com.lantone.qc.pub.model.vo.QueryVo;
+import com.lantone.qc.trans.comsis.Preproc;
+
+import java.util.Map;
+
+/**
+ * @Description:
+ * @author: rengb
+ * @time: 2020/3/5 15:47
+ */
+public class BeHospitalizedDocTrans {
+
+    public BeHospitalizedDoc extract(MedrecVo medrecVo) {
+        BeHospitalizedDoc beHospitalizedDoc = new BeHospitalizedDoc();
+        Preproc preproc = new Preproc();
+        beHospitalizedDoc.setStructureMap(preproc.extract_doc_pub(
+                false,
+                ModelStandardKeys.beHospitalized,
+                medrecVo.getContent().get("content").toString()));
+        return beHospitalizedDoc;
+    }
+
+}

+ 15 - 4
trans/src/main/java/com/lantone/qc/trans/changx/ChangxDocTrans.java

@@ -1,9 +1,10 @@
 package com.lantone.qc.trans.changx;
 
+import com.lantone.qc.pub.model.InputInfo;
+import com.lantone.qc.pub.model.vo.MedrecVo;
+import com.lantone.qc.pub.model.vo.QueryVo;
 import com.lantone.qc.trans.DocTrans;
 
-import java.util.Map;
-
 /**
  * @ClassName : TaiZhouDocTrans
  * @Description :
@@ -11,7 +12,17 @@ import java.util.Map;
  * @Date: 2020-03-03 19:47
  */
 public class ChangxDocTrans extends DocTrans {
-    public Map<String, String> extract(String classify) {
-        return null;
+
+    @Override
+    protected InputInfo extract(QueryVo queryVo) {
+        InputInfo inputInfo = new InputInfo();
+        for (MedrecVo i : queryVo.getMedrec()) {
+            if (i.getTitle().equals("入院记录")) {
+                BeHospitalizedDocTrans beHospitalizedDocTrans = new BeHospitalizedDocTrans();
+                inputInfo.setBeHospitalizedDoc(beHospitalizedDocTrans.extract(i));
+            }
+        }
+        return inputInfo;
     }
+
 }

+ 96 - 0
trans/src/main/java/com/lantone/qc/trans/comsis/Preproc.java

@@ -0,0 +1,96 @@
+package com.lantone.qc.trans.comsis;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import static java.util.Map.Entry.comparingByValue;
+import static java.util.stream.Collectors.toMap;
+
+/**
+ * 字符串切map工具
+ *
+ * @Description:
+ * @author: rengb
+ * @time: 2020/3/5 15:56
+ */
+public class Preproc {
+
+    /**
+     * 将需处理字符串根据key集合,切成map,分病程模块处理和非病程模块处理
+     *
+     * @param isProgress 是否病程模块
+     * @param title      key集合
+     * @param line       需处理字符串
+     * @return
+     */
+    public Map<String, String> extract_doc_pub(boolean isProgress, List<String> title, String line) {
+        line = line.replaceAll("[ *| *| *]*", "");
+        int pos = 0;
+        int ln_pos = 0;
+        String item = "";
+        String newline = "\n";
+        String tab = "\t";
+        int pos_newln, pos_tab;
+        Map<String, String> sections = new HashMap<>();
+        Map<String, Integer> sorted = new HashMap<>();
+
+        for (String key : title) {
+            pos = 0;
+            while (line.indexOf(key, pos) >= 0 && null == sorted.get(key)) {
+                pos = line.indexOf(key, pos);
+
+                if (isProgress) {
+                    pos += key.length();
+                    if (null == sorted.get(key)) {
+                        sorted.put(key, pos);
+                    }
+                } else {
+                    pos_newln = line.substring(0, pos).lastIndexOf(newline);
+                    pos_tab = line.substring(0, pos).lastIndexOf(tab);
+                    ln_pos = (pos_newln < pos_tab) ? pos_tab : pos_newln;
+
+                    if (ln_pos == -1 || line.substring(ln_pos + tab.length(), pos).trim().length() == 0) {
+                        pos += key.length();
+                        sorted.put(key, pos);
+                    } else {
+                        pos += 1;
+                    }
+                }
+            }
+        }
+
+        sorted = sorted
+                .entrySet()
+                .stream()
+                .sorted(comparingByValue())
+                .collect(
+                        toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e2,
+                                LinkedHashMap::new));
+
+        String lbl = "";
+        System.out.println(line);
+        for (String key : sorted.keySet()) {
+            if (lbl.length() > 0 && pos <= sorted.get(key) - key.length()) {
+                item = line.substring(pos, sorted.get(key) - key.length());
+                if (item.indexOf(":") == 0 || item.indexOf(":") == 0) {
+                    item = item.substring(1);
+                }
+
+                sections.put(lbl, item);
+            }
+            lbl = key;
+            pos = sorted.get(key);
+        }
+
+        item = line.substring(pos);
+        if (item.indexOf(":") == 0 || item.indexOf(":") == 0) {
+            item = item.substring(1);
+        }
+        sections.put(lbl, item);
+
+        return sections;
+    }
+
+}

+ 3 - 1
trans/src/main/java/com/lantone/qc/trans/shaoyf/ShaoyfDocTrans.java

@@ -1,5 +1,7 @@
 package com.lantone.qc.trans.shaoyf;
 
+import com.lantone.qc.pub.model.InputInfo;
+import com.lantone.qc.pub.model.vo.QueryVo;
 import com.lantone.qc.trans.DocTrans;
 
 import java.util.Map;
@@ -11,7 +13,7 @@ import java.util.Map;
  * @Date: 2020-03-03 19:47
  */
 public class ShaoyfDocTrans extends DocTrans {
-    public Map<String, String> extract(String classify) {
+    public InputInfo extract(QueryVo queryVo) {
         return null;
     }
 }

+ 3 - 1
trans/src/main/java/com/lantone/qc/trans/taizhou/TaiZhouDocTrans.java

@@ -1,5 +1,7 @@
 package com.lantone.qc.trans.taizhou;
 
+import com.lantone.qc.pub.model.InputInfo;
+import com.lantone.qc.pub.model.vo.QueryVo;
 import com.lantone.qc.trans.DocTrans;
 
 import java.util.Map;
@@ -11,7 +13,7 @@ import java.util.Map;
  * @Date: 2020-03-03 19:47
  */
 public class TaiZhouDocTrans extends DocTrans {
-    public Map<String, String> extract(String classify) {
+    public InputInfo extract(QueryVo queryVo) {
         return null;
     }
 }