Pārlūkot izejas kodu

身份证号与性别不符合规则新增

wangsy 3 gadi atpakaļ
vecāks
revīzija
be51620c00

+ 50 - 0
kernel/src/main/java/com/lantone/qc/kernel/catalogue/firstpagerecord/FIRP03229.java

@@ -0,0 +1,50 @@
+package com.lantone.qc.kernel.catalogue.firstpagerecord;
+
+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.util.StringUtil;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+
+/**
+ * @ClassName : FIRP03229
+ * @Description : 身份证号与性别不符合
+ * @Author : wsy
+ * @Date: 2022-04-12 16:13
+ */
+@Component
+public class FIRP03229 extends QCCatalogue {
+    /**
+     * 1.获取病案首页的患者性别和身份证号,若任一不存在则通过
+     * 2.根据18位数的身份证号码的第十七位(倒数第二位)判断性别,如果为奇数则为男性,偶数则为女性
+     * 3.校验首页填写的性别是否和身份证性别一致
+     */
+
+    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
+        status.set("0");
+        if (inputInfo.getFirstPageRecordDoc() == null) {
+            return;
+        }
+        if (inputInfo.getFirstPageRecordDoc().getStructureMap() != null) {
+            Map<String, String> firstPageStructureMap = inputInfo.getFirstPageRecordDoc().getStructureMap();
+            String idNumber = firstPageStructureMap.get(Content.idNumber);//身份证号
+            String gender = firstPageStructureMap.get(Content.gender);//性别
+            if (StringUtil.isBlank(idNumber) || StringUtil.isBlank(gender)) {
+                return;
+            }
+            if (idNumber.length() > 17) {
+                int num = Integer.parseInt(idNumber.substring(16, 17));
+                //奇数表示男性,偶数表示女性;
+                if (gender.contains("男") && num % 2 == 0) {
+                    status.set("-1");
+                }
+                if (gender.contains("女") && num % 2 == 1) {
+                    status.set("-1");
+                }
+            }
+        }
+    }
+}