package com.lantone.qc.kernel.catalogue.clinicalblood;

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.doc.ClinicalBloodDoc;
import com.lantone.qc.pub.util.ListUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @ClassName : CLI0307
 * @Description : 输血记录中无血液制品种类及量
 * @Author : 楼辉荣
 * @Date: 2020-03-06 17:28
 */
@Component
public class CLI0307 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {

        List<ClinicalBloodDoc> clinicalBloodDocs = inputInfo.getClinicalBloodDocs();
        if (ListUtil.isEmpty(clinicalBloodDocs)) {
            status.set("0");
            return;
        }
        if (clinicalBloodDocs != null && clinicalBloodDocs.size() > 0) {
            int matchSum = 0;
            for (ClinicalBloodDoc cliB : clinicalBloodDocs) {
                Map<String, String> cliBStructureMap = cliB.getStructureMap();
                //台州
                if (StringUtils.isNotEmpty(cliBStructureMap.get("输血计划"))) {
                    matchSum++;
                    continue;
                }

                if (StringUtils.isNotEmpty(cliBStructureMap.get("输血成分及数量"))) {
                    matchSum++;
                }
            }
            if (matchSum == clinicalBloodDocs.size()) {
                status.set("0");
            }
        }

    }
}