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

import com.google.common.collect.Lists;
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.model.label.MaritalLabel;
import com.lantone.qc.pub.util.StringUtil;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;


/**
 * @ClassName : BEH0407
 * @Description : 入院记录婚姻未填写
 * @Author : 楼辉荣
 * @Date: 2020-03-06 17:28
 */
@Component
public class BEH0407 extends QCCatalogue {
    List<String> words = Lists.newArrayList("已婚", "离异", "离婚", "丧偶", "未婚", "结婚");

    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        if (inputInfo.getBeHospitalizedDoc() == null) {
            return;
        }
        Map<String, String> structureMap = inputInfo.getBeHospitalizedDoc().getStructureMap();
        if (structureMap != null) {
            String name = structureMap.get("婚姻");
            if (StringUtil.isBlank(name)) {
                name = structureMap.get("婚姻状况");
            }
            if (CatalogueUtil.isEmpty(name)) {
                status.set("-1");
            }
        }
        MaritalLabel maritalLabel = inputInfo.getBeHospitalizedDoc().getMaritalLabel();
        if (maritalLabel != null) {
            String maritalText = maritalLabel.getText();
            if (StringUtil.isNotBlank(maritalText)) {
                for (String word : words) {
                    if (maritalText.contains(word)) {
                        status.set("0");
                        return;
                    }
                }
            }
        }
    }
}