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

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 com.lantone.qc.pub.model.doc.FirstCourseRecordDoc;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @ClassName : THR0094
 * @Description :  首次病程由非执业医师填写
 * @Author : Mark
 * @Date: 2020-04-07 17:06
 */
@Component
public class THR0094 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        FirstCourseRecordDoc firstCourseRecordDoc = inputInfo.getFirstCourseRecordDoc();
        if (firstCourseRecordDoc == null) {
            status.set("0");
            return;
        }

        String sign = inputInfo.getFirstCourseRecordDoc().getStructureMap().get("记录医师");
        sign = (null == sign) ? "" : sign.trim();

        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(sign);
        if (doctor != null) {
            String occup = doctor.get("occup");
            if (StringUtils.isNotEmpty(occup) && "1".equals(occup)) {
                status.set("0");
            }
        }
    }
}