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.StringUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @ClassName : CLI0565
 * @Description : 输血记录输血结束时间填写不规范
 * @Author : 楼辉荣
 * @Date: 2020-03-06 17:28
 */
@Component
public class CLI0565 extends QCCatalogue {
    public static String FORMAT_LONC_CN_MI = "yyyy/MM/dd HH:mm";
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        List<ClinicalBloodDoc> clinicalBloodDocs = inputInfo.getClinicalBloodDocs();
        if(clinicalBloodDocs != null && clinicalBloodDocs.size()>0){
            for (ClinicalBloodDoc cliB:clinicalBloodDocs) {
                Map<String, String> cliBStructureMap = cliB.getStructureMap();
                if(cliBStructureMap.containsKey("输注结束")){
                    if(!StringUtils.isEmpty(cliBStructureMap.get("输注结束"))){
                        try {
                            //Date date_in = new SimpleDateFormat(FORMAT_LONC_CN_MI).parse(cliBStructureMap.get("输注结束"));
                            Date date_in = StringUtil.parseDateTime(cliBStructureMap.get("输注结束"));
                        } catch (Exception e) {
                            status.set("-1");
                            break;
                        }
                    }
                }

            }
        }

    }
}