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.Drinking;
import com.lantone.qc.pub.model.entity.Usage;
import com.lantone.qc.pub.model.label.PersonalLabel;
import com.lantone.qc.pub.util.StringUtil;
import org.springframework.stereotype.Component;

/**
 * @Description: 饮酒史患者描述不规范
 * @author: rengb
 * @time: 2020/3/10 14:02
 */
@Component
public class BEH0051 extends QCCatalogue {

    @Override
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        if (inputInfo.getBeHospitalizedDoc() == null) {
            status.set("0");
            return;
        }
        PersonalLabel personalLabel = inputInfo.getBeHospitalizedDoc().getPersonalLabel();
        if (personalLabel == null) {
            status.set("0");
            return;
        }
        String pastText = personalLabel.getText();
        if (StringUtil.isNotBlank(pastText) && pastText.contains("饮酒")) {
            status.set("0");
            return;
        }
        Drinking drinking = personalLabel.getDrinking();
        if (drinking == null
                || StringUtil.isBlank(drinking.getName())
                || (drinking.getNegative() != null && StringUtil.isNotBlank(drinking.getNegative().getName()))
                || (drinking.getPd() != null && StringUtil.isNotBlank(drinking.getPd().getName()))
                || (drinking.getUsage() != null && StringUtil.isNotBlank(drinking.getUsage().getName()))) {
            status.set("0");
        }
        //出现用量实体，即认为规范
        Usage usage = inputInfo.getBeHospitalizedDoc().getPersonalLabel().getUsage();
        if (usage != null && StringUtil.isNotEmpty(usage.getName())) {
            status.set("0");
        }
    }

}