package com.lantone.qc.kernel.catalogue.ninghaiyiyi.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.Pacs;
import com.lantone.qc.pub.model.label.PacsLabel;
import com.lantone.qc.pub.util.StringUtil;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @ClassName : BEH02903
 * @Description : 辅助检查未注明时间
 * @Author : 胡敬
 * @Date: 2020-05-28 09:56
 */
@Component
public class BEH02903 extends QCCatalogue {
    @Override
    protected void start(InputInfo inputInfo, OutputInfo outputInfo) {
        if (inputInfo.getBeHospitalizedDoc() == null) {
            status.set("0");
            return;
        }

        String pacsText = inputInfo.getBeHospitalizedDoc().getStructureMap().get("辅助检查");
        if (StringUtil.isBlank(pacsText)) {
            status.set("0");
            return;
        }

        if (StringUtil.isNotBlank(pacsText) && (pacsText.contains("暂缺") || pacsText.contains("暂无"))) {
            status.set("0");
            return;
        }

        PacsLabel pacsLabel = inputInfo.getBeHospitalizedDoc().getPacsLabel();
        if (pacsLabel == null) {
            status.set("0");
            return;
        }

        List<Pacs> pacses = pacsLabel.getPacses();
        if (pacses != null && pacses.size() > 0) {
            for (Pacs pacs : pacses) {
                if (pacs.getPd() != null && pacs.getPd().getName() != null) {
                    status.set("0");
                    return;
                }
            }
        }
    }
}