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

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.Date;
import java.util.Map;

/**
 * @ClassName : FIRP0220
 * @Description : 入院时间与入院记录时间不一致
 * @Author : 胡敬
 * @Date: 2020-03-14 17:10
 */
@Component
public class FIRP0220 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        if (inputInfo.getFirstPageRecordDoc() == null || inputInfo.getBeHospitalizedDoc() == null) {
            status.set("0");
            return;
        }
        Map<String, String> firstpageStructureMap = inputInfo.getFirstPageRecordDoc().getStructureMap();
        Map<String, String> beHospitalStructureMap = inputInfo.getBeHospitalizedDoc().getStructureMap();
        String firstAdmissionDate = firstpageStructureMap.get(Content.admisTime);
        String admissionDate = beHospitalStructureMap.get(Content.admisDate);
        if (StringUtil.isEmpty(firstAdmissionDate) || StringUtil.isEmpty(admissionDate)) {
            status.set("0");
            return;
        }
        Date firstDate = StringUtil.parseDateTime(firstAdmissionDate);
        Date admisDate = StringUtil.parseDateTime(admissionDate);
        if (firstDate != null && admisDate != null) {
            if (firstDate.getYear() == admisDate.getYear() &&
                    firstDate.getMonth() == admisDate.getMonth() &&
                    firstDate.getDay() == admisDate.getDay()) {
                status.set("0");
            }
        }
    }
}