package com.lantone.qc.kernel.catalogue.beilun.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.ClinicBloodEffectDoc;
import com.lantone.qc.pub.model.doc.ClinicalBloodDoc;
import com.lantone.qc.pub.util.DateUtil;
import com.lantone.qc.pub.util.ListUtil;
import com.lantone.qc.pub.util.StringUtil;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @ClassName : CLI0309
 * @Description : 无输血或使用血液制品后效果评价
 * @Author : 楼辉荣
 * @Date: 2020-03-06 17:28
 */
@Component
public class CLI0309 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        List<ClinicalBloodDoc> clinicalBloodDocs = inputInfo.getClinicalBloodDocs();//输血记录
        List<ClinicBloodEffectDoc> clinicBloodEffectDocs = inputInfo.getClinicBloodEffectDocs();//输血效果评价
        if (ListUtil.isEmpty(clinicalBloodDocs)) {
            return;
        }
        List<Date> clinicalBloodDate = new ArrayList<>();
        for (ClinicalBloodDoc clinicalBloodDoc : clinicalBloodDocs) {
            Map<String, String> structureMap = clinicalBloodDoc.getStructureMap();
            if (StringUtil.isNotBlank(structureMap.get("记录时间"))) {
                Date date = DateUtil.dateZeroClear(StringUtil.parseDateTime(structureMap.get("记录时间")));
                if (!clinicalBloodDate.contains(date)) {
                    clinicalBloodDate.add(date);
                }
            }
        }

        if (clinicalBloodDate.size() > clinicBloodEffectDocs.size()) {
            status.set("-1");
            info.set("部分输血记录未找到对应输血后效果评价");
        }
        /*
        if (clinicalBloodDocs != null && clinicalBloodDocs.size() > 0) {
            for (ClinicBloodEffectDoc cliB : clinicBloodEffectDocs) {
                Map<String, String> cliBStructureMap = cliB.getStructureMap();
                if (StringUtils.isEmpty(cliBStructureMap.get("输注后效果评价"))) {
                    status.set("-1");
                    break;
                }
            }
        }

         */
    }
}