Selaa lähdekoodia

入院记录预产期规则修正

wangsy 3 vuotta sitten
vanhempi
commit
d5d7a23be3

+ 23 - 28
kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH03330.java

@@ -1,22 +1,15 @@
 package com.lantone.qc.kernel.catalogue.behospitalized;
 
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
-import com.lantone.qc.pub.Content;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
-import com.lantone.qc.pub.model.doc.BeHospitalizedDoc;
-import com.lantone.qc.pub.model.entity.Diag;
-import com.lantone.qc.pub.model.label.DiagLabel;
-import com.lantone.qc.pub.model.label.PastLabel;
-import com.lantone.qc.pub.util.DateUtil;
-import com.lantone.qc.pub.util.ListUtil;
+import com.lantone.qc.pub.model.doc.BeHospitalizedDoc;;
 import com.lantone.qc.pub.util.StringUtil;
 import org.springframework.stereotype.Component;
 
-import java.util.ArrayList;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
 import java.util.Date;
-import java.util.List;
-
 
 /**
  * @ClassName : BEH03330
@@ -30,9 +23,9 @@ public class BEH03330 extends QCCatalogue {
     @Override
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
         /**
-         * 1.查证【入院记录】,是否有“预产期”和“末次月经”两个字段,任一不存在则直接返回。
-         * 2.查证【入院记录】>>【末次月经月份】字段内容,字段内容:月+9(月+9大于12则月-3)记为:A【末次月经日】字段内容:日+7(日+7大于30则返回月份,月改记为:A+1,日:日+7-30)记为:B
-         * 3.查证【入院记录】>>【预产期】中的内容与A(月)B(日)对比,内容一致则通过,否则提示
+         * 1.查证【首次病程录】>>是否有“预产期”和“末次月经”两个字段,任一不存在则直接返回。
+         * 2.查证【首次病程录】>>【末次月经】字段内容,加280天计算出数值为“预产期”。
+         * 3.查证【首次病程录】>>【预产期】中的内容与计算出的“预产期”转换相同格式后时间一致或大于3天或小于1天则通过,否则提示。
          * */
         status.set("0");
         //获取入院记录
@@ -53,22 +46,24 @@ public class BEH03330 extends QCCatalogue {
             return;
         }
         try {
-            //预产期月份
-            int eDOCMonth = DateUtil.getMonth(eDOCDate);
-            //预产期日
-            int eDOCDay = DateUtil.getDay(eDOCDate);
-            //末次月经月份
-            int lastMPMonth = DateUtil.getMonth(lastMPDate);
-            //末次月经日
-            int lastMPDay = DateUtil.getDay(lastMPDate);
+            SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");//定义格式
+            Calendar c = Calendar.getInstance();
 
-            int lastMPMonthNum = lastMPMonth + 9 > 12 ? lastMPMonth - 3 : lastMPMonth + 9;
-            int lastMPDayNum = lastMPDay + 7;
-            if (lastMPDayNum > 30) {
-                lastMPMonthNum = lastMPMonthNum + 1;
-                lastMPDayNum = lastMPDayNum - 30;
-            }
-            if (eDOCMonth != lastMPMonthNum || eDOCDay != lastMPDayNum) {
+            //添加末次月经时间
+            c.setTime(lastMPDate);
+            c.add(Calendar.DATE, 277); //给末次月经时间加277天
+            String after = sdf.format(c.getTime());
+            Date afterDate = StringUtil.parseDateTime(after);//日期转成Date格式
+
+            c.setTime(lastMPDate);
+            c.add(Calendar.DATE,281);//给末次月经时间加281天
+            String before =sdf.format(c.getTime());
+            Date beforeDate = StringUtil.parseDateTime(before);
+
+            //判断预产期是否在正确的区间里
+            if (eDOCDate.after(afterDate) && eDOCDate.before(beforeDate) ){
+                return;
+            }else {
                 status.set("-1");
                 return;
             }