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.Map;

/**
 * @ClassName : FIRP0225
 * @Description : 出院时间与出院记录时间不一致,具体到天
 * @Author : 胡敬
 * @Date: 2020-03-14 17:10
 */
@Component
public class FIRP0225 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        if (inputInfo.getFirstPageRecordDoc() != null && inputInfo.getFirstPageRecordDoc().getStructureMap() != null
                && inputInfo.getLeaveHospitalDoc() != null && inputInfo.getLeaveHospitalDoc().getStructureMap() != null) {
            Map<String, String> firstpageStructureMap = inputInfo.getFirstPageRecordDoc().getStructureMap();
            Map<String, String> leaveHospitalStructureMap = inputInfo.getLeaveHospitalDoc().getStructureMap();
            String firstDischargeTime = firstpageStructureMap.get(Content.dischargeTime);//病案首页出院时间
            String dischargeTime = leaveHospitalStructureMap.get(Content.dischargeTime);//出院小结出院时间
            if (StringUtil.isBlank(firstDischargeTime) || StringUtil.isBlank(dischargeTime)){
                return;
            }
            if (!CatalogueUtil.equalsDate(firstDischargeTime, dischargeTime, "yyyy-MM-dd")) {
                status.set("-1");
            }
        }
    }
}