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.Smoking;
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 BEH0050 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 personalText = personalLabel.getText();
        if (StringUtil.isNotBlank(personalText) && personalText.contains("偶有")){
            status.set("0");
            return;
        }
        Smoking smoking = personalLabel.getSmoking();
        if (smoking == null
                || StringUtil.isBlank(smoking.getName())
                || (smoking.getNegative() != null && StringUtil.isNotBlank(smoking.getNegative().getName()))
                || (smoking.getPd() != null && StringUtil.isNotBlank(smoking.getPd().getName()))
                || (smoking.getUsage() != null && StringUtil.isNotBlank(smoking.getUsage().getName()))) {
            status.set("0");
        }
        //出现用量实体，即认为规范
        Usage usage = inputInfo.getBeHospitalizedDoc().getPersonalLabel().getUsage();
        if (usage != null && StringUtil.isNotEmpty(usage.getName())) {
            status.set("0");
        }
    }

}