Browse Source

现病史提取查体内容

zhoutg 4 years ago
parent
commit
bb093f1162

+ 19 - 0
src/main/java/com/diagbot/facade/CommonFacade.java

@@ -104,6 +104,9 @@ public class CommonFacade {
 
         // 处理现病史中的化验和辅检,放入结构化
         processPresentLisPacs(wordCrfDTO);
+
+        // 现病史中体征内容放入体征标签
+        processPresentVital(wordCrfDTO);
         return wordCrfDTO;
     }
 
@@ -354,6 +357,22 @@ public class CommonFacade {
         return pushVO;
     }
 
+    /**
+     * 将现病史中提取的体征内容放入体征标签中
+     *
+     * @param wordCrfDTO
+     */
+    public void processPresentVital(WordCrfDTO wordCrfDTO){
+        PresentLabel presentLabel = wordCrfDTO.getPresentLabel();
+        VitalLabel vitalLabel = wordCrfDTO.getVitalLabel();
+        if (ListUtil.isNotEmpty(presentLabel.getVitals())) {
+            vitalLabel.getVitals().addAll(presentLabel.getVitals());
+        }
+        if (ListUtil.isNotEmpty(presentLabel.getClinicals())) {
+            vitalLabel.getClinicals().addAll(presentLabel.getClinicals());
+        }
+    }
+
     public void processPresentLisPacs(WordCrfDTO wordCrfDTO){
         PresentLabel presentLabel = wordCrfDTO.getPresentLabel();
         List<com.diagbot.model.entity.Lis> lises = presentLabel.getLises();

+ 22 - 1
src/main/java/com/diagbot/model/ai/process/EntityProcessClinic.java

@@ -4,7 +4,24 @@ package com.diagbot.model.ai.process;
 import com.alibaba.fastjson.JSONObject;
 import com.diagbot.model.ai.model.EntityEnum;
 import com.diagbot.model.ai.model.Lemma;
-import com.diagbot.model.entity.*;
+import com.diagbot.model.entity.Aggravate;
+import com.diagbot.model.entity.BeHospitalizedWay;
+import com.diagbot.model.entity.BodyPart;
+import com.diagbot.model.entity.Cause;
+import com.diagbot.model.entity.Clinical;
+import com.diagbot.model.entity.Degree;
+import com.diagbot.model.entity.Diag;
+import com.diagbot.model.entity.General;
+import com.diagbot.model.entity.GeneralDesc;
+import com.diagbot.model.entity.Medicine;
+import com.diagbot.model.entity.Modification;
+import com.diagbot.model.entity.Operation;
+import com.diagbot.model.entity.PD;
+import com.diagbot.model.entity.Property;
+import com.diagbot.model.entity.Relief;
+import com.diagbot.model.entity.Treat;
+import com.diagbot.model.entity.Trend;
+import com.diagbot.model.entity.Vital;
 import com.diagbot.model.label.PresentLabel;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -157,6 +174,10 @@ public class EntityProcessClinic extends EntityProcess {
             }
             presentLabel.setPds(pds);
 
+            EntityProcessVital vital = new EntityProcessVital();
+            List<Vital> vitals = vital.extractEntityClinic(aiOut);
+            presentLabel.setVitals(vitals);
+
         } catch (Exception e) {
             e.printStackTrace();
             logger.error(e.getMessage(), e);

+ 96 - 0
src/main/java/com/diagbot/model/ai/process/EntityProcessVital.java

@@ -12,6 +12,8 @@ import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 public class EntityProcessVital extends EntityProcess {
     public VitalLabel extractEntity(JSONObject outputs) {
@@ -108,4 +110,98 @@ public class EntityProcessVital extends EntityProcess {
         }
         return vitalLabel;
     }
+
+
+    /**
+     * 只获取体征内容
+     * @param outputs
+     * @return
+     */
+    public List<Vital> extractEntityClinic(JSONObject outputs) {
+        List<Vital> vitals = new ArrayList<>();
+        Vital vital =null;
+        List<Map<String, String>> vitalEntityList = processJson(outputs, EntityEnum.SIGN.toString());
+        for (Map<String, String> vitalEntityMap : vitalEntityList) {
+            if (StringUtils.isEmpty(vitalEntityMap.get(EntityEnum.SIGN.toString()))) {
+                continue;
+            }
+            vital = new Vital();
+            for (String key:vitalEntityMap.keySet()) {
+                String entity = vitalEntityMap.get(key);
+                switch (EntityEnum.parseOfValue(key)) {
+                    case SIGN:
+                        vital.setName(entity);
+                        vital.setStandName(entity);
+                        break;
+                    case NEGATIVE:
+                        Negative negative = new Negative();
+                        negative.setName(entity);
+                        vital.setNegative(negative);
+                        break;
+                    case BODY:
+                        BodyPart bodyPart = new BodyPart();
+                        bodyPart.setName(entity);
+                        vital.setBodyPart(bodyPart);
+                        break;
+                    case INDEX_VALUE:
+                        PD pd = new PD();
+                        String[] val_unit = new String[2];
+                        if (StringUtil.isNotBlank(entity)) {
+                            val_unit = extract_digit_new(entity);
+                            pd.setValue(val_unit[0]);
+                            pd.setUnit(val_unit[1]);
+                        }
+                        pd.setName(entity);
+                        vital.setPd(pd);
+                        break;
+                    case MODIFICATION:
+                        if(entity.contains("度")){
+                            Degree degree = new Degree();
+                            degree.setName(entity);
+                            vital.setDegree(degree);
+                        }
+                        break;
+                }
+            }
+            vitals.add(vital);
+        }
+
+        // 生命体征特殊处理
+        for (Vital vi : vitals) {
+            if ("T".equals(vi.getName().toUpperCase())) {
+                vi.setStandName("体温");
+            } else if ("P".equals(vi.getName().toUpperCase())) {
+                vi.setStandName("脉搏");
+            } else if ("R".equals(vi.getName().toUpperCase())) {
+                vi.setStandName("呼吸");
+            } else if ("血压".equals(vi.getName()) || "BP".equals(vi.getName().toUpperCase())) {
+                String bpName = vi.getPd().getName();
+                Pattern pattern = Pattern.compile("\\d+/\\d+"); // 示例:血压80/44mmHg
+                Matcher matcher = pattern.matcher(bpName);
+
+                if (matcher.find()) {
+                    String val = matcher.group();
+                    vi.getPd().setValue(val);  // 重新赋值血压的数值
+                    vi.getPd().setUnit(bpName.substring(bpName.indexOf(val) + 1));   // 重新赋值血压的单位
+
+                    String[] bp = val.split("/");
+
+                    List<Usual> usualList = new ArrayList<>();
+                    Usual usualSbp = new Usual();
+                    usualSbp.setName(vi.getName());
+                    usualSbp.setStandName("收缩压");
+                    usualSbp.setValue(bp[0]);
+                    usualList.add(usualSbp);
+                    vi.setUsualList(usualList);
+
+                    Usual usualDbp = new Usual();
+                    usualDbp.setName(vi.getName());
+                    usualDbp.setStandName("舒张压");
+                    usualDbp.setValue(bp[1]);
+                    usualList.add(usualDbp);
+                }
+            }
+        }
+        return vitals;
+    }
 }

+ 2 - 0
src/main/java/com/diagbot/model/label/PresentLabel.java

@@ -42,6 +42,8 @@ public class PresentLabel extends GeneralLabel {
     private List<PD> pds = new ArrayList<>();
     //现病史一般情况之后的服用药品
     List<Medicine> takeMedicine = new ArrayList<>();
+    //体征内容
+    private List<Vital> vitals = new ArrayList<>();
 
     public <T> void add(List<T> list, T obj) {
         list.add(obj);

+ 2 - 0
src/main/java/com/diagbot/util/CoreUtil.java

@@ -329,6 +329,7 @@ public class CoreUtil {
                 if (nodeNeoDTO.getName().contains(clinical.getStandName())) {
                     map.put("msg", clinical.getName());
                     flag = true;
+                    break;
                 }
             }
         } else {
@@ -340,6 +341,7 @@ public class CoreUtil {
                     flag = compareNum(nodeNeoDTO, Double.parseDouble(vital.getPd().getValue()));
                     if (flag) {
                         map.put("msg", vital.getName() + subZeroAndDot(String.valueOf(vital.getPd().getValue())));
+                        break;
                     }
                 } else if (ListUtil.isNotEmpty(usualList)) {
                     for (Usual usual : usualList) {