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

import com.lantone.qc.kernel.catalogue.QCCatalogue;
import com.lantone.qc.kernel.util.KernelConstants;
import com.lantone.qc.kernel.util.RedisUtil;
import com.lantone.qc.kernel.util.SpringContextUtil;
import com.lantone.qc.pub.model.InputInfo;
import com.lantone.qc.pub.model.OutputInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName : BEH0494
 * @Description :  入院记录由非执业医师填写
 * @Author : Mark
 * @Date: 2020-04-07 10:36
 */
@Component
public class BEH0494 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        if (inputInfo.getBeHospitalizedDoc() == null) {
            status.set("0");
            return;
        }
        String doctorName = "";
        if (inputInfo.getBeHospitalizedDoc().getStructureMap() != null) {
            doctorName = inputInfo.getBeHospitalizedDoc().getStructureMap().get("签名");
        }
        if (StringUtils.isNotEmpty(doctorName)) {
            RedisUtil redisUtil = SpringContextUtil.getBean("redisUtil");
            Map<String, Object> surgeon = redisUtil.getJsonStringValue(KernelConstants.HOSPITAL_DOCTOR_MAP);
            if (surgeon == null) {
                return;
            }
            Map<String, String> doctor = (Map) surgeon.get(doctorName);
            String occup = doctor.get("occup");
            if (StringUtils.isNotEmpty(occup) && "1".equals(occup)) {
                status.set("0");
                return;
            }
        } else {
            status.set("0");
        }
    }
}