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.OuterCourtyard;
import com.lantone.qc.pub.model.entity.Pacs;
import com.lantone.qc.pub.util.StringUtil;
import org.springframework.stereotype.Component;

/**
 * @ClassName : BEH0082
 * @Description : 外院医疗机构检查记录不规范
 * @Author : 胡敬
 * @Date: 2020-03-12 16:29
 */
@Component
public class BEH0082 extends QCCatalogue {
    @Override
    protected void start(InputInfo inputInfo, OutputInfo outputInfo) {
        if (inputInfo.getBeHospitalizedDoc() == null) {
            status.set("0");
            return;
        }
        if (inputInfo.getBeHospitalizedDoc().getPacsLabel() == null) {
            status.set("0");
            return;
        }
        if (inputInfo.getBeHospitalizedDoc().getPacsLabel().getPacses() == null) {
            status.set("0");
            return;
        }
        int outerCourtyardObjNum = 0;
        for (Pacs pacs : inputInfo.getBeHospitalizedDoc().getPacsLabel().getPacses()) {
            if (pacs.getOuterCourtyard() == null) {
                outerCourtyardObjNum++;
            } else {
                OuterCourtyard outerCourtyard = pacs.getOuterCourtyard();
                if (outerCourtyard.getPd().size() > 0 && StringUtil.isNotBlank(outerCourtyard.getPacsValue().getName())) {
                    status.set("0");
                    break;
                }
            }
        }
        if (outerCourtyardObjNum == inputInfo.getBeHospitalizedDoc().getPacsLabel().getPacses().size()) {
            status.set("0");
        }
    }
}