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 : DEAC0109
 * @Description : 死亡病例讨论记录未在患者死亡1周内完成
 * @Author : 胡敬
 * @Date: 2020-03-19 10:45
 */
@Component
public class DEAC0109 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        if (inputInfo.getDeathCaseDiscussDoc() != null && inputInfo.getDeathCaseDiscussDoc().getStructureMap() != null) {
            Map<String, String> deathCaseDiscussStructureMap = inputInfo.getDeathCaseDiscussDoc().getStructureMap();
            String deceaseTime = deathCaseDiscussStructureMap.get("死亡时间");
            String recordTime = deathCaseDiscussStructureMap.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(7 * 24 * 60))) {
                status.set("-1");
            }
        }
    }
}