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

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.StringUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @ClassName : DEAC0099
 * @Description : 死亡病例讨论记录中无主诉
 * @Author : 胡敬
 * @Date: 2020-03-19 09:35
 */
@Component
public class DEAC0099 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        if (inputInfo.getDeathCaseDiscussDoc() != null
                && inputInfo.getBeHospitalizedDoc() != null && inputInfo.getBeHospitalizedDoc().getChiefLabel() != null) {
            Map<String, String> deathCaseDiscussStructureMap = inputInfo.getDeathCaseDiscussDoc().getStructureMap();
            String deathCaseDiscussChief = deathCaseDiscussStructureMap.get("主诉");
            if (StringUtil.isNotBlank(deathCaseDiscussChief)) {
                return;
            }

            String chiefText = inputInfo.getBeHospitalizedDoc().getChiefLabel().getText();
            String admissionStatus = deathCaseDiscussStructureMap.get("入院情况");
            if (CatalogueUtil.isEmpty(admissionStatus) || CatalogueUtil.isEmpty(chiefText)) {
                return;
            }
            chiefText = CatalogueUtil.removeSpecialChar(chiefText).replace("。", "");
            if (StringUtils.isNotEmpty(chiefText)) {
                return;
            }
            admissionStatus = CatalogueUtil.removeSpecialChar(admissionStatus).replace("。", "");
            if (!admissionStatus.contains(chiefText)) {
                status.set("-1");
            }
            //处理台州的
            if (admissionStatus.contains("患者因")) {
                status.set("0");
            }
        }
    }
}