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

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.springframework.stereotype.Component;

import java.util.Map;

/**
 * @ClassName : DEAR0339
 * @Description : 死亡记录无主诉
 * @Author : 胡敬
 * @Date: 2020-03-18 19:44
 */
@Component
public class DEAR0339 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        if (inputInfo.getDeathRecordDoc() != null && inputInfo.getDeathRecordDoc().getStructureMap() != null
                && inputInfo.getBeHospitalizedDoc() != null && inputInfo.getBeHospitalizedDoc().getChiefLabel() != null) {
            Map<String, String> deathRecordStructureMap = inputInfo.getDeathRecordDoc().getStructureMap();
            String deathChief = deathRecordStructureMap.get("主诉");
            if (StringUtil.isNotBlank(deathChief)) {
                return;
            }
            String chiefText = inputInfo.getBeHospitalizedDoc().getChiefLabel().getText();
            String admissionStatus = deathRecordStructureMap.get("入院情况");
            if (admissionStatus == null || CatalogueUtil.isEmpty(chiefText)) {
                return;
            }
            chiefText = CatalogueUtil.removeSpecialChar(chiefText).replace("。", "");
            admissionStatus = CatalogueUtil.removeSpecialChar(admissionStatus).replace("。", "");
            if (!admissionStatus.contains(chiefText)) {
                status.set("-1");
            }
        }
    }
}