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

import com.lantone.qc.kernel.catalogue.QCCatalogue;
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.util.StringUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @ClassName : FIRP0187
 * @Description :患者尸检填写错误
 * @Author : 胡敬
 * @Date: 2020-03-17 17:04
 */
@Component
public class FIRP0187 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        if (inputInfo.getFirstPageRecordDoc() == null) {
            status.set("0");
            return;
        }
        Map<String, String> firstpageStructureMap = inputInfo.getFirstPageRecordDoc().getStructureMap();
        String outWay = firstpageStructureMap.get(Content.outWay);
        String deadAutopsy = firstpageStructureMap.get(Content.deadAutopsy);
        if(CatalogueUtil.isSpecialChar(deadAutopsy)){
            status.set("0");
            return;
        }
        if (StringUtils.isEmpty(outWay) || StringUtils.isEmpty(deadAutopsy)) {
            status.set("0");
            return;
        }
        if (StringUtil.isNotEmpty(outWay) && outWay.contains("死亡") && StringUtil.isNotEmpty(deadAutopsy)) {
            status.set("0");
        }
    }
}