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;
import java.util.stream.Collectors;

/**
 * @ClassName : CLI0564
 * @Description : 输血记录输血结束时间未填写
 * @Author : 楼辉荣
 * @Date: 2020-03-06 17:28
 */
@Component
public class CLI0564 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        List<ClinicalBloodDoc> clinicalBloodDocs = inputInfo.getClinicalBloodDocs();
        if(ListUtil.isEmpty(clinicalBloodDocs)){
            return;
        }

        if (clinicalBloodDocs != null && clinicalBloodDocs.size() > 0) {
//            List<ClinicalBloodDoc> bloodDocs = clinicalBloodDocs.stream().filter(bloodDoc -> bloodDoc.getStructureMap().get("输血后效果评价") == null).collect(Collectors.toList());
            for (ClinicalBloodDoc cliB : clinicalBloodDocs) {
                Map<String, String> cliBStructureMap = cliB.getStructureMap();
                if (cliBStructureMap.containsKey("输注结束")) {
                    if (StringUtils.isEmpty(cliBStructureMap.get("输注结束"))) {
                        status.set("-1");
                        break;
                    }
                } else {
                    status.set("-1");
                    break;
                }

            }
        }

    }
}