zhoutg 5 anos atrás
pai
commit
e987f9dbeb

+ 83 - 57
kernel/src/main/java/com/lantone/qc/kernel/catalogue/firstpagerecord/FIRP0256.java

@@ -5,16 +5,10 @@ import com.lantone.qc.kernel.util.CatalogueUtil;
 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.ThreeLevelWardDoc;
-import com.lantone.qc.pub.model.entity.BetterFinding;
-import com.lantone.qc.pub.model.entity.OutcomeCure;
-import com.lantone.qc.pub.model.entity.OutcomeToBetter;
-import com.lantone.qc.pub.model.entity.PositiveFinding;
-import com.lantone.qc.pub.model.label.LeaveHospitalLabel;
-import com.lantone.qc.pub.model.label.ThreeLevelWardLabel;
+import com.lantone.qc.pub.util.ListUtil;
+import com.lantone.qc.pub.util.StringUtil;
 import org.springframework.stereotype.Component;
 
-import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -27,69 +21,101 @@ import java.util.Map;
 @Component
 public class FIRP0256 extends QCCatalogue {
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
+        /**
+         * 1、转归情况“死亡”与死亡记录不匹配
+         * 2、病案首页【转归情况】与病案首页诊断信息第一个诊断的“入院情况”进行比对,如果不相同,报错
+         */
         status.set("0");
-        if (inputInfo.getFirstPageRecordDoc() != null && inputInfo.getFirstPageRecordDoc().getStructureMap() != null
-                && inputInfo.getThreeLevelWardDocs().size() > 0
-                && inputInfo.getLeaveHospitalDoc() != null && inputInfo.getLeaveHospitalDoc().getLeaveHospitalLabel() != null
-                && inputInfo.getLeaveHospitalDoc().getLeaveHospitalLabel() != null) {
+        if (inputInfo.getFirstPageRecordDoc() != null && inputInfo.getFirstPageRecordDoc().getStructureMap() != null) {
             Map<String, String> firstpageStructureMap = inputInfo.getFirstPageRecordDoc().getStructureMap();
             String outcome = firstpageStructureMap.get(Content.outcome);    //病案首页转归情况
             if (CatalogueUtil.isEmpty(outcome)) {
                 return;
             }
-
-            List<ThreeLevelWardDoc> threeLevelWardDocs = inputInfo.getThreeLevelWardDocs();
-            //最后一次主任查房记录、出院小结转归情况
-            List<BetterFinding> betterFindings = new ArrayList<>();//好转表现
-            List<OutcomeToBetter> outcomeToBetters = new ArrayList<>();//转归情况-好转
-            List<OutcomeCure> outcomeCures = new ArrayList<>();//转归情况-治愈
-            List<PositiveFinding> positiveFindings = new ArrayList<>();//阳性表现
-            for (ThreeLevelWardDoc threeLevelWardDoc : threeLevelWardDocs) {
-                if (threeLevelWardDoc.getThreeLevelWardLabel() == null) {
-                    List<ThreeLevelWardLabel> threeLevelWardLabels = threeLevelWardDoc.getThreeLevelWardLabel();
-                    for (ThreeLevelWardLabel threeLevelWardLabel : threeLevelWardLabels) {
-                        if (!threeLevelWardLabel.getTitle().contains("最后一次")) {
-                            continue;
-                        }
-                        betterFindings = threeLevelWardLabel.getBetterFindings();
-                        outcomeToBetters = threeLevelWardLabel.getOutcomeToBetters();
-                        outcomeCures = threeLevelWardLabel.getOutcomeCures();
-                        positiveFindings = threeLevelWardLabel.getPositiveFindings();
-                    }
-                }
-            }
-
-            //出院小结转归情况
-            LeaveHospitalLabel leaveHospitalLabel = inputInfo.getLeaveHospitalDoc().getLeaveHospitalLabel();
-            betterFindings.addAll(leaveHospitalLabel.getBetterFindings());
-            outcomeToBetters.addAll(leaveHospitalLabel.getOutcomeToBetters());
-            outcomeCures.addAll(leaveHospitalLabel.getOutcomeCures());
-            positiveFindings.addAll(leaveHospitalLabel.getPositiveFindings());
-
             //若出现死亡记录或死亡医嘱,则 转归情况 必须为 死亡。若未出现死亡记录或死亡医嘱,则 转归情况 必不为 死亡。
             if (inputInfo.getDeathRecordDoc() != null && !"死亡".equals(outcome)
                     || inputInfo.getDeathRecordDoc() == null && "死亡".equals(outcome)) {
                 status.set("-1");
                 return;
             }
-            //若出院小结或末次病程中明确记录转归情况 实体(转归情况-好转,转归情况-治愈,转归情况-未愈),则首页必须与其保持一致。
-            if (outcomeToBetters.size() > 0 && !"好转".equals(outcome)
-                    || outcomeCures.size() > 0 && !"治愈".equals(outcome)) {
-                status.set("-1");
-                return;
+            Map<String, Object> firstpageStructureMapExt = inputInfo.getFirstPageRecordDoc().getStructureExtMap();
+            List<Map<String, String>> dischargeDiag = (List) firstpageStructureMapExt.get(Content.dischargeDiag);
+            if (ListUtil.isEmpty(dischargeDiag)) {
+                return ;
+            }
+            // 取第一个诊断的出院情况
+            String firstDisInfo = dischargeDiag.get(0).get("出院情况");
+            if (StringUtil.isEmpty(firstDisInfo)) {
+                return ;
             }
-            //若出院小结或末次病程中没有明确记录转归情况
-            if (outcomeToBetters.size() == 0 && outcomeCures.size() == 0) {
-                //若末次病程中发现任一 阳性表现 实体,则转归情况必不为 治愈。
-                if (positiveFindings.size() > 0 && "治愈".equals(outcome)) {
-                    status.set("-1");
-                    return;
-                }
-                //若末次病程中没有发现 阳性表现 实体,且发现任一 好转表现,则转归情况必不为 未愈。
-                if (positiveFindings.size() == 0 && betterFindings.size() > 0 && "未愈".equals(outcome)) {
-                    status.set("-1");
-                }
+            if (!outcome.equals(firstDisInfo)) {
+                status.set("-1");
+                return ;
             }
         }
+
+        // if (inputInfo.getFirstPageRecordDoc() != null && inputInfo.getFirstPageRecordDoc().getStructureMap() != null
+        //         && inputInfo.getThreeLevelWardDocs().size() > 0
+        //         && inputInfo.getLeaveHospitalDoc() != null && inputInfo.getLeaveHospitalDoc().getLeaveHospitalLabel() != null
+        //         && inputInfo.getLeaveHospitalDoc().getLeaveHospitalLabel() != null) {
+        //     Map<String, String> firstpageStructureMap = inputInfo.getFirstPageRecordDoc().getStructureMap();
+        //     String outcome = firstpageStructureMap.get(Content.outcome);    //病案首页转归情况
+        //     if (CatalogueUtil.isEmpty(outcome)) {
+        //         return;
+        //     }
+        //
+        //     List<ThreeLevelWardDoc> threeLevelWardDocs = inputInfo.getThreeLevelWardDocs();
+        //     //最后一次主任查房记录、出院小结转归情况
+        //     List<BetterFinding> betterFindings = new ArrayList<>();//好转表现
+        //     List<OutcomeToBetter> outcomeToBetters = new ArrayList<>();//转归情况-好转
+        //     List<OutcomeCure> outcomeCures = new ArrayList<>();//转归情况-治愈
+        //     List<PositiveFinding> positiveFindings = new ArrayList<>();//阳性表现
+        //     for (ThreeLevelWardDoc threeLevelWardDoc : threeLevelWardDocs) {
+        //         if (threeLevelWardDoc.getThreeLevelWardLabel() == null) {
+        //             List<ThreeLevelWardLabel> threeLevelWardLabels = threeLevelWardDoc.getThreeLevelWardLabel();
+        //             for (ThreeLevelWardLabel threeLevelWardLabel : threeLevelWardLabels) {
+        //                 if (!threeLevelWardLabel.getTitle().contains("最后一次")) {
+        //                     continue;
+        //                 }
+        //                 betterFindings = threeLevelWardLabel.getBetterFindings();
+        //                 outcomeToBetters = threeLevelWardLabel.getOutcomeToBetters();
+        //                 outcomeCures = threeLevelWardLabel.getOutcomeCures();
+        //                 positiveFindings = threeLevelWardLabel.getPositiveFindings();
+        //             }
+        //         }
+        //     }
+        //
+        //     //出院小结转归情况
+        //     LeaveHospitalLabel leaveHospitalLabel = inputInfo.getLeaveHospitalDoc().getLeaveHospitalLabel();
+        //     betterFindings.addAll(leaveHospitalLabel.getBetterFindings());
+        //     outcomeToBetters.addAll(leaveHospitalLabel.getOutcomeToBetters());
+        //     outcomeCures.addAll(leaveHospitalLabel.getOutcomeCures());
+        //     positiveFindings.addAll(leaveHospitalLabel.getPositiveFindings());
+        //
+        //     //若出现死亡记录或死亡医嘱,则 转归情况 必须为 死亡。若未出现死亡记录或死亡医嘱,则 转归情况 必不为 死亡。
+        //     if (inputInfo.getDeathRecordDoc() != null && !"死亡".equals(outcome)
+        //             || inputInfo.getDeathRecordDoc() == null && "死亡".equals(outcome)) {
+        //         status.set("-1");
+        //         return;
+        //     }
+        //     //若出院小结或末次病程中明确记录转归情况 实体(转归情况-好转,转归情况-治愈,转归情况-未愈),则首页必须与其保持一致。
+        //     if (outcomeToBetters.size() > 0 && !"好转".equals(outcome)
+        //             || outcomeCures.size() > 0 && !"治愈".equals(outcome)) {
+        //         status.set("-1");
+        //         return;
+        //     }
+        //     //若出院小结或末次病程中没有明确记录转归情况
+        //     if (outcomeToBetters.size() == 0 && outcomeCures.size() == 0) {
+        //         //若末次病程中发现任一 阳性表现 实体,则转归情况必不为 治愈。
+        //         if (positiveFindings.size() > 0 && "治愈".equals(outcome)) {
+        //             status.set("-1");
+        //             return;
+        //         }
+        //         //若末次病程中没有发现 阳性表现 实体,且发现任一 好转表现,则转归情况必不为 未愈。
+        //         if (positiveFindings.size() == 0 && betterFindings.size() > 0 && "未愈".equals(outcome)) {
+        //             status.set("-1");
+        //         }
+        //     }
+        // }
     }
 }