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

import com.lantone.qc.kernel.catalogue.QCCatalogue;
import com.lantone.qc.kernel.util.CatalogueUtil;
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.Date;
import java.util.Map;

/**
 * @ClassName : DEAC0098
 * @Description : 死亡记录未在患者死亡后24小时内完成
 * @Author : 胡敬
 * @Date: 2020-03-19 11:08
 */
@Component
public class DEAC0098 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        if (inputInfo.getDeathRecordDoc() != null && inputInfo.getDeathRecordDoc().getStructureMap() != null) {
            Map<String, String> deathRecordStructureMap = inputInfo.getDeathRecordDoc().getStructureMap();
            String deceaseTime = deathRecordStructureMap.get("死亡时间");
            String recordTime = deathRecordStructureMap.get("记录时间");
            if (CatalogueUtil.isEmpty(deceaseTime) || CatalogueUtil.isEmpty(recordTime)) {
                return;
            }
            Date deceaseDate = StringUtil.parseDateTime(deceaseTime);
            Date recordDate = StringUtil.parseDateTime(recordTime);
            if (deceaseDate.before(recordDate) && CatalogueUtil.compareTime(deceaseDate, recordDate, Long.valueOf(24 * 60))) {
                status.set("-1");
            }
        }
    }
}