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

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

/**
 * @ClassName : CLI0562
 * @Description : 输血记录开始输血时间未填写
 * @Author : 楼辉荣
 * @Date: 2020-03-06 17:28
 */
@Component
public class CLI0562 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) {
            for (ClinicalBloodDoc cliB : clinicalBloodDocs) {
                Map<String, String> cliBStructureMap = cliB.getStructureMap();
                String start = cliBStructureMap.get("输注开始");
                String record = cliBStructureMap.get("病情记录");
                if(StringUtil.isNotBlank(start) || StringUtil.isNotBlank(cliBStructureMap.get("输血开始日期"))) break;
                if (StringUtil.isBlank(start) && !record.contains("开始输")) {
                    status.set("-1");
                    break;
                }
            }
        }
    }
}