package com.lantone.qc.kernel.catalogue.beilun.majorInspection;

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

import java.util.Map;

/**
 * @ClassName : FIRP03110
 * @Description : 病案首页未在患者出院院24小时内完成
 * @Author : zhanghang
 * @Date: 2021-03-31 11:12
 */
@Component
public class FIRP03110 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        if (inputInfo.getFirstPageRecordDoc() != null && inputInfo.getFirstPageRecordDoc().getStructureMap() != null) {
            Map<String, String> firstPageRecordMap = inputInfo.getFirstPageRecordDoc().getStructureMap();
            String admisDate = firstPageRecordMap.get(Content.dischargeTime);
            String recordTime = firstPageRecordMap.get("创建时间");
            if (CatalogueUtil.isEmpty(admisDate) || CatalogueUtil.isEmpty(recordTime)) {
                return;
            }
            if(!CatalogueUtil.compareTime(
                    StringUtil.parseDateTime(admisDate),
                    StringUtil.parseDateTime(DateUtil.nowString()),
                    Long.valueOf(24 * 60))){//如果出院还未过24小时规则不判断
                return;
            }

            if (CatalogueUtil.compareTime(
                    StringUtil.parseDateTime(admisDate),
                    StringUtil.parseDateTime(recordTime),
                    Long.valueOf(24 * 60))) {
                status.set("-1");
            }
        }
    }

}
