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

import com.lantone.qc.kernel.catalogue.QCCatalogue;
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.model.doc.FirstPageRecordDoc;
import com.lantone.qc.pub.model.doc.MedicalRecordInfoDoc;
import com.lantone.qc.pub.model.doc.transferrecord.TransferRecordDoc;
import com.lantone.qc.pub.util.StringUtil;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @ClassName : FIRP0222
 * @Description : 入院科别填写错误
 * @Author : 楼辉荣
 * @Date: 2020-03-06 17:28ss
 */
@Component
public class FIRP0222 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        FirstPageRecordDoc firstPageRecordDoc = inputInfo.getFirstPageRecordDoc();
        MedicalRecordInfoDoc medicalRecordInfoDoc = inputInfo.getMedicalRecordInfoDoc();
        TransferRecordDoc transferRecordDocs = inputInfo.getTransferRecordDocs();
        /* 如果有转入转出科室记录，则不判断 */
        if (transferRecordDocs != null) {
            return;
        }
        if (firstPageRecordDoc == null || medicalRecordInfoDoc == null) {
            return;
        }
        Map<String, String> firpStructureMap = firstPageRecordDoc.getStructureMap();
        Map<String, String> medStructureMap = medicalRecordInfoDoc.getStructureMap();
        String admitDept = firpStructureMap.get(Content.admitDept);
        String behDeptId = medStructureMap.get("behDeptName");
        if (StringUtil.isNotBlank(admitDept) && StringUtil.isNotBlank(behDeptId) && !admitDept.equals(behDeptId)) {
            status.set("-1");
        }
    }
}