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

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.DateUtil;
import org.springframework.stereotype.Component;

import java.util.Map;


/**
 * @ClassName : BEH0439
 * @Description : 入院记录个人出生日期填写错误
 * @Author : 楼辉荣
 * @Date: 2020-03-06 17:28
 */
@Component
public class BEH0439 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        if (inputInfo.getBeHospitalizedDoc() == null || inputInfo.getFirstPageRecordDoc() == null) {
            return;
        }
        Map<String, String> bhMap = inputInfo.getBeHospitalizedDoc().getStructureMap();
        Map<String, String> fprMap = inputInfo.getFirstPageRecordDoc().getStructureMap();
        if (bhMap != null && fprMap != null) {
            String birthDate_bh = bhMap.get("出生日期");
            String birthDate_fpr = fprMap.get("出生日期");
            if (birthDate_bh != null && birthDate_fpr != null) {
                if (!CatalogueUtil.isEmpty(birthDate_bh) && !CatalogueUtil.isEmpty(birthDate_fpr)) {
                    if (!DateUtil.format(DateUtil.parseDate(birthDate_bh), DateUtil.DATE_FORMAT).equals(DateUtil.format(DateUtil.parseDate(birthDate_fpr), DateUtil.DATE_FORMAT))) {
                        status.set("-1");
                    }
                }
            }
        }

    }
}