package com.lantone.qc.kernel.catalogue.threelevelward;

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

import java.util.Map;

/**
 * @ClassName : THR0122
 * @Description : 首次病程未在患者入院8小时内完成
 * @Author : 楼辉荣
 * @Date: 2020-03-06 17:28
 */
@Component
public class THR0122 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        if (inputInfo.getBeHospitalizedDoc() != null && inputInfo.getBeHospitalizedDoc().getStructureMap() != null
                && inputInfo.getFirstCourseRecordDoc() != null && inputInfo.getFirstCourseRecordDoc().getStructureMap() != null) {
            Map<String, String> beHospitalStructureMap = inputInfo.getBeHospitalizedDoc().getStructureMap();
            String admisDate = beHospitalStructureMap.get(Content.admisDate);
            Map<String, String> firstCourseRecordStructureMap = inputInfo.getFirstCourseRecordDoc().getStructureMap();
            String recordTime = firstCourseRecordStructureMap.get("记录时间");
            if (CatalogueUtil.isEmpty(admisDate) || CatalogueUtil.isEmpty(recordTime)) {
                return;
            }
            if (CatalogueUtil.compareTime(
                    StringUtil.parseDateTime(admisDate),
                    StringUtil.parseDateTime(recordTime),
                    Long.valueOf(8 * 60))) {
                status.set("-1");
            }

        }
    }
}