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.PD;
import com.lantone.qc.pub.model.label.ChiefLabel;
import com.lantone.qc.pub.util.StringUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.util.List;


/**
 * @ClassName : BEH0001
 * @Description : 症状缺少时间描述
 * @Author : 楼辉荣
 * @Date: 2020-03-06 17:28
 */
@Component
public class BEH0001 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {

        status.set("0");
        if (inputInfo.getBeHospitalizedDoc() == null) {
            return;
        }
        ChiefLabel chiefLabel = inputInfo.getBeHospitalizedDoc().getChiefLabel();
        if (chiefLabel == null) {
            return;
        }
        String chiefText = chiefLabel.getText();
        if (StringUtil.isNotBlank(chiefText) && (chiefText.contains("检查") || chiefText.contains("术后") || chiefText.contains("药物"))) {
            status.set("0");
            return;
        } else {
            List<Clinical> clinicals = inputInfo.getBeHospitalizedDoc().getChiefLabel().getClinicals();
            if (clinicals.size() > 0) {
                for (Clinical clinical : clinicals) {
                    String clinicalName = clinical.getName();
                    List<PD> timestamp = clinical.getTimestamp();
                    if (timestamp == null) {
                        if (StringUtils.isEmpty(info.get())) {
                            info.set(clinicalName);
                        } else {
                            info.set(info.get() + "," + clinicalName);
                        }
                    }
                }
            }
        }
        if (StringUtils.isNotEmpty(info.get())) {
            status.set("-1");
        }
    }
}