瀏覽代碼

代码提交

SGTY 4 月之前
父節點
當前提交
711c6cd35e

+ 49 - 41
kernel/src/main/java/com/lantone/qc/kernel/catalogue/hospital/yiwu/firstpagerecord/FIRP0200.java

@@ -8,6 +8,7 @@ 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 lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
 
 import java.util.List;
@@ -20,34 +21,54 @@ import java.util.Map;
  * @Date: 2020-03-14 16:28
  */
 @Component
+@Slf4j
 public class FIRP0200 extends QCCatalogue {
     private List<String> icdCodeList = Lists.newArrayList("Z37.0", "Z37.2", "Z37.3", "Z37.5", "Z37.6");
 
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
         status.set("0");
+
+        boolean matched = false;
         if (inputInfo.getFirstPageRecordDoc() != null && inputInfo.getFirstPageRecordDoc().getStructureMap() != null) {
             Map<String, String> firstpageStructureMap = inputInfo.getFirstPageRecordDoc().getStructureMap();
+
             String newbornWeightStr = firstpageStructureMap.get(Content.newbornWeight);
-/*            if (CatalogueUtil.isEmpty(newbornWeightStr) || !CatalogueUtil.numbersOnly(newbornWeightStr)) {
+
+            if (CatalogueUtil.isEmpty(newbornWeightStr) || !newbornWeightStr.matches(".*\\d.*")) {
+                log.info("无新生儿出生体重");
                 return;
             }
-            double newbornWeight = Double.parseDouble(newbornWeightStr);
-            if (newbornWeight / 1000 >= 1) {
-                newbornWeight = newbornWeight / 1000;
+
+            String newbornDaye = firstpageStructureMap.get("新生儿出生天数");
+            if (StringUtil.isNotEmpty(newbornDaye) && Long.valueOf(newbornDaye) <= 28) {
+               matched = true;
+            }else{
+                String hospitalDiagnosis = firstpageStructureMap.get("出院诊断");
+                if (StringUtil.isNotEmpty(hospitalDiagnosis)) {
+                    List<Map<String, String>> diagnosisMapList = (List<Map<String, String>>) JSONArray.parse(hospitalDiagnosis);
+                    for (Map<String, String> diagnosisMap : diagnosisMapList) {
+                        String diagnosisIcd = diagnosisMap.get("诊断编码");
+                        if (StringUtil.isNotEmpty(diagnosisIcd)) {
+                            for (String icdCode : icdCodeList) {
+                                if (diagnosisIcd.startsWith(icdCode)) {
+                                    matched = true;
+                                    break;
+                                }
+                            }
+                        }
+                    }
+                }
             }
-            if (newbornWeight <= 1 || newbornWeight >= 10) {
-                status.set("-1");
-                Map<String, Object> structureExtMap = inputInfo.getFirstPageRecordDoc().getStructureExtMap();
-                String xmlId = CatalogueUtil.getXmlId(structureExtMap, Content.newbornWeight);
-                id.set(xmlId);
-            }*/
-            if (CatalogueUtil.isEmpty(newbornWeightStr)) {
+
+            if(!matched){
+                log.info("不满足前提条件");
                 return;
             }
+
             //为阿拉伯数字情况下,比较体重范围
             if (CatalogueUtil.numbersOnly(newbornWeightStr)) {
                 double newbornWeight = Double.parseDouble(newbornWeightStr);
-                if (newbornWeight <= 100 || newbornWeight >= 9999) {
+                if (newbornWeight <= 100 || newbornWeight >= 9999 || !newbornWeightStr.endsWith("0")) {
                     status.set("-1");
                     Map<String, Object> structureExtMap = inputInfo.getFirstPageRecordDoc().getStructureExtMap();
                     String xmlId = CatalogueUtil.getXmlId(structureExtMap, Content.newbornWeight);
@@ -55,37 +76,24 @@ public class FIRP0200 extends QCCatalogue {
                     return;
                 }
             }
-            String newbornDaye = firstpageStructureMap.get("新生儿出生天数");
-            if (StringUtil.isNotEmpty(newbornDaye) && Long.valueOf(newbornDaye) <= 28) {
-                if (newbornWeightStr.equals("-")) {
-                    status.set("-1");
-                    Map<String, Object> structureExtMap = inputInfo.getFirstPageRecordDoc().getStructureExtMap();
-                    String xmlId = CatalogueUtil.getXmlId(structureExtMap, Content.newbornWeight);
-                    id.set(xmlId);
-                    return;
-                }
+
+            if(!newbornWeightStr.replaceAll("\\d", "").trim().toLowerCase().equals("g")){
+                status.set("-1");
+                Map<String, Object> structureExtMap = inputInfo.getFirstPageRecordDoc().getStructureExtMap();
+                String xmlId = CatalogueUtil.getXmlId(structureExtMap, Content.newbornWeight);
+                id.set(xmlId);
+                return;
             }
-            String hospitalDiagnosis = firstpageStructureMap.get("出院诊断");
-            if (StringUtil.isNotEmpty(hospitalDiagnosis)) {
-                List<Map<String, String>> diagnosisMapList = (List<Map<String, String>>) JSONArray.parse(hospitalDiagnosis);
-                for (Map<String, String> diagnosisMap : diagnosisMapList) {
-                    String diagnosisIcd = diagnosisMap.get("诊断编码");
-                    if (StringUtil.isNotEmpty(diagnosisIcd)) {
-                        for (String icdCode : icdCodeList) {
-                            if (diagnosisIcd.startsWith(icdCode)) {
-                                if (newbornWeightStr.equals("-")) {
-                                    status.set("-1");
-                                    Map<String, Object> structureExtMap = inputInfo.getFirstPageRecordDoc().getStructureExtMap();
-                                    String xmlId = CatalogueUtil.getXmlId(structureExtMap, Content.newbornWeight);
-                                    id.set(xmlId);
-                                    return;
-                                }
-                            }
-                        }
-                    }
-                }
+
+            newbornWeightStr = newbornWeightStr.replaceAll("[^\\d.]", "").trim();
+            double newbornWeight = Double.parseDouble(newbornWeightStr);
+            if (newbornWeight <= 100 || newbornWeight >= 9999 || !newbornWeightStr.endsWith("0")) {
+                status.set("-1");
+                Map<String, Object> structureExtMap = inputInfo.getFirstPageRecordDoc().getStructureExtMap();
+                String xmlId = CatalogueUtil.getXmlId(structureExtMap, Content.newbornWeight);
+                id.set(xmlId);
+                return;
             }
-            return;
         }
     }
 }