package com.lantone.qc.kernel.catalogue.ywzxyy.behospitalized;

import com.lantone.qc.kernel.catalogue.QCCatalogue;
import com.lantone.qc.pub.Content;
import com.lantone.qc.pub.model.InputInfo;
import com.lantone.qc.pub.model.OutputInfo;
import org.springframework.stereotype.Component;

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

/**
 * @author wangfeng
 * @Description: 入院时间错误（具体到分）
 * @date 2020-06-29 11:44
 */
@Component
public class BEH03002 extends QCCatalogue {
    @Override
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        if (inputInfo.getBeHospitalizedDoc() == null) {
            return;
        }
        Map<String, String> structureMap = inputInfo.getBeHospitalizedDoc().getStructureMap();
        if (structureMap != null) {
            String dateStr = structureMap.get(Content.admisDate);
            if (dateStr!=null&&!dateStr.isEmpty()) {
                SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                try {
                    String replace = dateStr.replace('/', '-');
                    Date d = formatter.parse(replace);
                    status.set("0");
                } catch (Exception e) {
                    status.set("-1");
                    return;
                }
            }
        }
    }
}
