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

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 com.lantone.qc.pub.util.ListUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @Description: 慢病史未填写
 * @author: rengb
 * @time: 2020/3/10 14:02
 */
@Component
public class BEH0031 extends QCCatalogue {

    @Override
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        if(inputInfo.getBeHospitalizedDoc() == null){
            status.set("0");
            return;
        }
        Map<String, String> structureMap = inputInfo.getBeHospitalizedDoc().getStructureMap();
        if (StringUtils.isNotEmpty(structureMap.get("高血压"))) {
            status.set("0");
            return;
        }

        if (ListUtil.isNotEmpty(
                CatalogueUtil.filterDiagsByNature(
                        inputInfo.getBeHospitalizedDoc().getPastLabel().getDiags(),
                        "chronic",
                        "1"
                )
        )) {
            status.set("0");
        }
        //硬规则匹配
        String text = inputInfo.getBeHospitalizedDoc().getPastLabel().getText();
        if (StringUtils.isNotEmpty(text)) {
            if (text.contains("心脑血管") || text.contains("肺肝")
                    || text.contains("内分泌") || text.contains("高血压") || text.contains("糖尿病")) {
                status.set("0");
            }
        }
    }

}