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.entity.Clinical;
import com.lantone.qc.pub.model.entity.Menses;
import com.lantone.qc.pub.model.label.MenstrualLabel;
import com.lantone.qc.pub.util.ListUtil;
import com.lantone.qc.pub.util.StringUtil;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @ClassName : BEH0066
 * @Description : 月经史未描述月经血块情况
 * @Author : 胡敬
 * @Date: 2020-03-11 14:48
 */
@Component
public class BEH0066 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) {
            MenstrualLabel menstrualLabel = inputInfo.getBeHospitalizedDoc().getMenstrualLabel();
            String text = menstrualLabel.getText();
            if (StringUtil.isNotBlank(text) && text.contains("未行经")){
                status.set("0");
                return;
            }
            List<Menses> mensesList = menstrualLabel.getMensesList();
            if (ListUtil.isEmpty(mensesList)) {
                return;
            }
            for (Menses menses : mensesList) {
                if (menses.getClinicals() == null) {
                    continue;
                }
                List<Clinical> clinicals = menses.getClinicals();
                for (Clinical clinical : clinicals) {
                    if (clinical.getName().contains("血块")) {
                        status.set("0");
                        return;
                    }
                }
            }
        }
    }
}