package com.lantone.qc.kernel.catalogue.firstpagerecord;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.lantone.qc.kernel.catalogue.QCCatalogue;
import com.lantone.qc.kernel.util.CatalogueUtil;
import com.lantone.qc.pub.model.InputInfo;
import com.lantone.qc.pub.model.OutputInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @ClassName : FIRP02842
 * @Description : 出院诊断疾病编码未填写
 * @Author : kwz
 * @Date: 2020-07-15 17:45
 */
@Component
public class FIRP02842 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        if (inputInfo.getFirstPageRecordDoc() == null) {
            return;
        }
        if (inputInfo.getFirstPageRecordDoc().getStructureMap() != null) {
            Map<String, Object> firstpageStructureMap = inputInfo.getFirstPageRecordDoc().getStructureExtMap();
            JSONArray out_diag = (JSONArray)firstpageStructureMap.get("出院诊断");
            if (out_diag.size() > 0) {
                for (int i=0;i<out_diag.size();i++) {
                    JSONObject jsonObject = out_diag.getJSONObject(i);
                    String diag_code = (String)jsonObject.get("诊断编码");
                    if(StringUtils.isBlank(diag_code)){
                        status.set("-1");
                        return;
                    }

                }

            }
        }
    }
}