package com.lantone.qc.kernel.catalogue.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.label.MenstrualLabel;
import com.lantone.qc.pub.util.StringUtil;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @ClassName : BEH0068
 * @Description : 月经史未描述白带情况
 * @Author : 胡敬
 * @Date: 2020-03-11 14:49
 */
@Component
public class BEH0068 extends QCCatalogue {
    @Override
    protected void start(InputInfo inputInfo, OutputInfo outputInfo) {
        if (inputInfo.getBeHospitalizedDoc() == null) {
            status.set("0");
            return;
        }
        if (inputInfo.getBeHospitalizedDoc().getStructureMap().get("性别") == null
                || inputInfo.getBeHospitalizedDoc().getStructureMap().get("性别").contains("男")) {
            status.set("0"); //如果性别是男,就不报错
        } else if (inputInfo.getBeHospitalizedDoc().getMenstrualLabel() == null
                || inputInfo.getBeHospitalizedDoc().getMenstrualLabel().getText().contains("null")) {
            status.set("0");
        } else {
            Map<String, String> structureMap = inputInfo.getBeHospitalizedDoc().getStructureMap();
            if (StringUtil.isNotBlank(structureMap.get("白带"))) {
                status.set("0");
                return;
            }
            if (inputInfo.getBeHospitalizedDoc().getMenstrualLabel() != null) {
                MenstrualLabel menstrualLabel = inputInfo.getBeHospitalizedDoc().getMenstrualLabel();
                String text = menstrualLabel.getText();
                if (StringUtil.isNotBlank(text) && (text.contains("未行经") || text.contains("未来潮") || text.contains("绝经"))) {
                    status.set("0");
                    return;
                }
                if (menstrualLabel.getLeukorrheas() == null) {
                    return;
                }
                if (menstrualLabel.getLeukorrheas().size() > 0) {
                    status.set("0");
                }
            }
        }
    }
}