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

import com.lantone.qc.kernel.catalogue.QCCatalogue;
import com.lantone.qc.pub.model.InputInfo;
import com.lantone.qc.pub.model.OutputInfo;
import com.lantone.qc.pub.model.entity.EpidemicArea;
import com.lantone.qc.pub.model.label.PersonalLabel;
import com.lantone.qc.pub.util.StringUtil;
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 BEH0044 extends QCCatalogue {

    @Override
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        if (inputInfo.getBeHospitalizedDoc() == null) {
            status.set("0");
            return;
        }
        //台州结构化
        Map<String, String> structureMap_beh = inputInfo.getBeHospitalizedDoc().getStructureMap();
        if (StringUtils.isNotEmpty(structureMap_beh.get("疫区居留史"))) {
            status.set("0");
            return;
        }
        PersonalLabel personalLabel = inputInfo.getBeHospitalizedDoc().getPersonalLabel();
        if (personalLabel == null || StringUtil.isBlank(personalLabel.getText())) {
            status.set("0");
            return;
        }
        String personalText = personalLabel.getText();
        if (personalText.contains("详见病历")) {
            status.set("0");
            return;
        }
        //北仑硬匹配
        if (personalText.contains("否认疫水疫源接触史") || personalText.contains("否认疫区、疫情、疫水接触史")
                || personalText.contains("否认其他疫区、疫情、疫水接触史") || personalText.contains("否认发病前14天内曾接触过来自武汉")) {
            status.set("0");
            return;
        }
        EpidemicArea epidemicArea = personalLabel.getEpidemicArea();
        if (epidemicArea != null && StringUtil.isNotBlank(epidemicArea.getName())) {
            status.set("0");
        }
    }

}