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.PresentLabel;
import com.lantone.qc.pub.util.ListUtil;
import com.lantone.qc.pub.util.StringUtil;
import org.springframework.stereotype.Component;

import java.util.List;


/**
 * @ClassName : BEH0017
 * @Description :  现病史症状缺少时间描述
 * @Author : 楼辉荣
 * @Date: 2020-03-06 17:28
 */
@Component
public class BEH0017 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        if (inputInfo.getBeHospitalizedDoc() == null) {
            status.set("0");
            return;
        }
        PresentLabel presentLabel = inputInfo.getBeHospitalizedDoc().getPresentLabel();
        if (presentLabel == null) {
            status.set("0");
            return;
        }
        String presentText = presentLabel.getText();
        if (StringUtil.isNotBlank(presentText) && presentText.contains("复查")) {
            status.set("0");
            return;
        }
        List<Clinical> clinicals = presentLabel.getClinicals();
        if (clinicals.size() > 0) {
            for (Clinical clinical : clinicals) {
                List<PD> timestamp = clinical.getTimestamp();
                if (ListUtil.isNotEmpty(timestamp)) {
                    status.set("0");
                    return;
                }
            }
            //现病史取第一个症状
            //            Clinical clinical = clinicals.get(0);
            //            List<PD> timestamp = clinical.getTimestamp();
            //            if (timestamp == null) {
            //                info.set(clinical.getName());
            //            } else {
            //                status.set("0");
            //            }
        } else {
            status.set("0");
        }
        if (presentLabel.getPds().size() > 0) {
            status.set("0");
        }
    }
}