zhoutg hace 5 años
padre
commit
4d57234b6e

+ 62 - 1
public/src/main/java/com/lantone/qc/pub/util/DateUtil.java

@@ -683,5 +683,66 @@ public class DateUtil {
         int year = toYear  -  fromYear;
         return year;
     }
-    
+
+
+    /**
+     * 通过日期计算年龄
+     *
+     * @param birthDay
+     * @return
+     */
+    public static int getAge(Date birthDay){
+        Calendar cal = Calendar.getInstance();
+        if (cal.before(birthDay)) { //出生日期晚于当前时间,无法计算
+            return 0;
+//            throw new IllegalArgumentException(
+//                    "The birthDay is before Now.It's unbelievable!");
+        }
+        int yearNow = cal.get(Calendar.YEAR);  //当前年份
+        int monthNow = cal.get(Calendar.MONTH);  //当前月份
+        int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH); //当前日期
+        cal.setTime(birthDay);
+        int yearBirth = cal.get(Calendar.YEAR);
+        int monthBirth = cal.get(Calendar.MONTH);
+        int dayOfMonthBirth = cal.get(Calendar.DAY_OF_MONTH);
+        int age = yearNow - yearBirth;   //计算整岁数
+        if (monthNow <= monthBirth) {
+            if (monthNow == monthBirth) {
+                if (dayOfMonthNow < dayOfMonthBirth) age--;//当前日期在生日之前,年龄减一
+            }else{
+                age--;//当前月份在生日之前,年龄减一
+            }
+        }
+        if (age < 0) {
+            return 0;
+        }
+        return age;
+    }
+
+
+    /**
+     * 通过日期字符串计算年龄
+     *
+     * @param birthDayStr
+     * @return
+     */
+    public static int getAge(String birthDayStr) {
+        try {
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            Date birthDay = sdf.parse(birthDayStr);
+            return getAge(birthDay);
+        } catch (Exception e) {
+            return 0;
+        }
+    }
+
+
+    public static void main(String[] args) {
+        try {
+            int age = getAge("2019-04-05");           //由出生日期获得年龄***
+            System.out.println("age:"+age);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
 }

+ 8 - 0
public/src/main/java/com/lantone/qc/pub/util/MapUtil.java

@@ -142,4 +142,12 @@ public class MapUtil {
         }
     }
 
+    public static void console(Map<String, String> map) {
+        System.out.println("***************打印map内容开始******************");
+        for (String key : map.keySet()) {
+            System.out.println(key + "=" + map.get(key));
+        }
+        System.out.println("***************打印map内容结束******************");
+    }
+
 }

+ 135 - 12
trans/src/main/java/com/lantone/qc/trans/taizhou/TaiZhouBeHospitalizedDocTrans.java

@@ -1,8 +1,22 @@
 package com.lantone.qc.trans.taizhou;
 
 import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
 import com.lantone.qc.pub.model.doc.BeHospitalizedDoc;
+import com.lantone.qc.pub.model.label.ChiefLabel;
+import com.lantone.qc.pub.model.label.DiagLabel;
+import com.lantone.qc.pub.model.label.FamilyLabel;
+import com.lantone.qc.pub.model.label.MaritalLabel;
+import com.lantone.qc.pub.model.label.MenstrualLabel;
+import com.lantone.qc.pub.model.label.PacsLabel;
+import com.lantone.qc.pub.model.label.PastLabel;
+import com.lantone.qc.pub.model.label.PersonalLabel;
+import com.lantone.qc.pub.model.label.PresentLabel;
+import com.lantone.qc.pub.model.label.VitalLabel;
+import com.lantone.qc.pub.model.label.VitalLabelSpecial;
 import com.lantone.qc.pub.model.vo.MedrecVo;
+import com.lantone.qc.pub.util.DateUtil;
+import com.lantone.qc.pub.util.StringUtil;
 import com.lantone.qc.trans.ModelDocTrans;
 import com.lantone.qc.trans.comsis.OrdinaryAssistant;
 import com.lantone.qc.trans.taizhou.util.TzXmlUtil;
@@ -17,14 +31,28 @@ import java.util.Map;
  */
 public class TaiZhouBeHospitalizedDocTrans extends ModelDocTrans {
 
+    /**
+     * CRF规则:主诉、现病史
+     *
+     * @param medrecVo
+     * @return
+     */
     @Override
     public BeHospitalizedDoc extract(MedrecVo medrecVo) {
         String content = ((List<String>) medrecVo.getContent().get("content")).get(0);
 
-        Map<String, String> structureMap = OrdinaryAssistant.mapKeyContrast(TzXmlUtil.getXmlToMapForTZ(content), keyContrasts);
-        BeHospitalizedDoc beHospitalizedDoc = new BeHospitalizedDoc();
-        beHospitalizedDoc.setStructureMap(structureMap);
-
+        Map<String, String> sourceMap = TzXmlUtil.getXmlToMapForTZ(content); // xml原始数据给华卓
+        Map<String, String> sourceMapCopy = Maps.newHashMap();
+        sourceMapCopy.putAll(sourceMap);
+        // 年龄从生日转换
+        if (StringUtil.isBlank(sourceMapCopy.get("年龄")) && StringUtil.isNotBlank(sourceMapCopy.get("生日"))) {
+            int age = DateUtil.getAge(sourceMapCopy.get("生日"));
+            sourceMapCopy.put("年龄", String.valueOf(age));
+        }
+        Map<String, String> structureMap = OrdinaryAssistant.mapKeyContrast(sourceMapCopy, keyContrasts);
+        BeHospitalizedDoc beHospitalizedDoc = beHospitalizedDocGen(structureMap); // 不走共用
+        beHospitalizedDoc.setText(content);
+        beHospitalizedDoc.setPageData((Map)sourceMap);
         return beHospitalizedDoc;
     }
 
@@ -43,7 +71,7 @@ public class TaiZhouBeHospitalizedDocTrans extends ModelDocTrans {
             "肾触及=",
             "鼻体检=",
             "神志水平=",
-            "地址=",
+            "地址=联系地址",
             "角膜=",
             "肝边缘肋下=",
             "心脏浊音界(右3肋间)=",
@@ -55,10 +83,10 @@ public class TaiZhouBeHospitalizedDocTrans extends ModelDocTrans {
             "腋下=",
             "深反射=",
             "药物食物中毒史=",
-            "本人姓名=",
+            "本人姓名=姓名",
             "治疗=",
             "周围血管征=",
-            "出生地址=",
+            "出生地址=出生地",
             "脉搏=",
             "腹式呼吸=",
             "预防接种史=",
@@ -133,7 +161,7 @@ public class TaiZhouBeHospitalizedDocTrans extends ModelDocTrans {
             "经期天数=",
             "心尖搏动位置=",
             "定向力=",
-            "生日=",
+            "生日=出生日期",
             "心脏浊音界(左4肋间)=",
             "四肢红肿=",
             "耳体检=",
@@ -157,7 +185,7 @@ public class TaiZhouBeHospitalizedDocTrans extends ModelDocTrans {
             "肝大小=",
             "生命体征=",
             "运动=",
-            "本人电话=",
+            "本人电话=电话",
             "桡动脉脉率=",
             "肝边缘剑突下=",
             "皮疹部位=",
@@ -228,7 +256,7 @@ public class TaiZhouBeHospitalizedDocTrans extends ModelDocTrans {
             "浅感觉=",
             "营养会诊=",
             "肛门直肠=",
-            "辅助检查结果=",
+            "辅助检查结果=辅助检查",
             "脾质地=",
             "绝经年龄=",
             "肝脏疾病=",
@@ -253,7 +281,7 @@ public class TaiZhouBeHospitalizedDocTrans extends ModelDocTrans {
             "乳房对称度=",
             "传染病史=",
             "表情=",
-            "医生=",
+            "医生=医师签名",
             "月经初潮年龄=",
             "口腔体检=",
             "Babinski征=",
@@ -362,7 +390,102 @@ public class TaiZhouBeHospitalizedDocTrans extends ModelDocTrans {
             "视力粗测左=",
             "运动系统:共济失调=",
             "齿龈=",
-            "心脏浊音界(右4肋间)="
+            "心脏浊音界(右4肋间)=",
+            "入院日期=",
+            "病史陈述者=",
+            "婚育史=",
+            "月经史="
     );
 
+
+    /**
+     * 入院记录不走CRF
+     *
+     * @param structureMap
+     * @return
+     */
+    public static BeHospitalizedDoc beHospitalizedDocGen(Map<String, String> structureMap) {
+        BeHospitalizedDoc beHospitalizedDoc = new BeHospitalizedDoc();
+
+        ChiefLabel chiefLabel = new ChiefLabel();
+        chiefLabel.setText(structureMap.get("主诉"));
+        beHospitalizedDoc.setChiefLabel(chiefLabel);
+        structureMap.remove("主诉");
+
+        PresentLabel presentLabel = new PresentLabel();
+        presentLabel.setText(structureMap.get("现病史"));
+        beHospitalizedDoc.setPresentLabel(presentLabel);
+        structureMap.remove("现病史");
+
+        PastLabel pastLabel = new PastLabel();
+        pastLabel.setCrfLabel(false);
+        pastLabel.setText(structureMap.get("既往史"));
+        beHospitalizedDoc.setPastLabel(pastLabel);
+//        structureMap.remove("既往史");
+
+        PersonalLabel personalLabel = new PersonalLabel();
+        personalLabel.setCrfLabel(false);
+        personalLabel.setText(structureMap.get("个人史"));
+        beHospitalizedDoc.setPersonalLabel(personalLabel);
+//        structureMap.remove("个人史");
+
+        MaritalLabel maritalLabel = new MaritalLabel();
+        maritalLabel.setCrfLabel(false);
+        maritalLabel.setText("婚育史: " + structureMap.get("婚育史"));
+        beHospitalizedDoc.setMaritalLabel(maritalLabel);
+//        structureMap.remove("婚育史");
+
+        MenstrualLabel menstrualLabel = new MenstrualLabel();
+        menstrualLabel.setCrfLabel(false);
+        menstrualLabel.setText("月经史:" + structureMap.get("月经史"));
+        beHospitalizedDoc.setMenstrualLabel(menstrualLabel);
+//        structureMap.remove("月经史");
+
+        FamilyLabel familyLabel = new FamilyLabel();
+        familyLabel.setCrfLabel(false);
+        familyLabel.setText(structureMap.get("家族史"));
+        beHospitalizedDoc.setFamilyLabel(familyLabel);
+//        structureMap.remove("家族史");
+
+        VitalLabel vitalLabel = new VitalLabel();
+        vitalLabel.setCrfLabel(false);
+        vitalLabel.setText(structureMap.get("体格检查"));
+        beHospitalizedDoc.setVitalLabel(vitalLabel);
+//        structureMap.remove("体格检查");
+
+        VitalLabelSpecial vitalLabelSpecial = new VitalLabelSpecial();
+        vitalLabelSpecial.setCrfLabel(false);
+        vitalLabelSpecial.setText(structureMap.get("专科体格检查"));
+        beHospitalizedDoc.setVitalLabelSpecial(vitalLabelSpecial);
+//        structureMap.remove("专科体格检查");
+
+        PacsLabel pacsLabel = new PacsLabel();
+        pacsLabel.setCrfLabel(false);
+        pacsLabel.setText(structureMap.get("辅助检查"));
+        beHospitalizedDoc.setPacsLabel(pacsLabel);
+//        structureMap.remove("辅助检查");
+
+        DiagLabel initialDiagLabel = new DiagLabel();
+        initialDiagLabel.setCrfLabel(false);
+        initialDiagLabel.setText(structureMap.get("初步诊断"));
+        beHospitalizedDoc.setInitialDiagLabel(initialDiagLabel);
+//        structureMap.remove("初步诊断");
+
+        DiagLabel revisedDiagLabel = new DiagLabel();
+        revisedDiagLabel.setCrfLabel(false);
+        revisedDiagLabel.setText(structureMap.get("修正诊断"));
+        beHospitalizedDoc.setRevisedDiagLabel(revisedDiagLabel);
+//        structureMap.remove("修正诊断");
+
+        DiagLabel suppleDiagLabel = new DiagLabel();
+        suppleDiagLabel.setCrfLabel(false);
+        suppleDiagLabel.setText(structureMap.get("补充诊断"));
+        beHospitalizedDoc.setSuppleDiagLabel(suppleDiagLabel);
+//        structureMap.remove("补充诊断");
+
+        beHospitalizedDoc.setStructureMap(structureMap);
+
+        return beHospitalizedDoc;
+    }
+
 }