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

import com.lantone.qc.kernel.catalogue.QCCatalogue;
import com.lantone.qc.dbanaly.util.KernelConstants;
import com.lantone.qc.dbanaly.util.SpecialStorageUtil;
import com.lantone.qc.pub.model.InputInfo;
import com.lantone.qc.pub.model.OutputInfo;
import com.lantone.qc.pub.model.doc.FirstCourseRecordDoc;
import com.lantone.qc.pub.util.SpringContextUtil;
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();
        // 如果记录医师未填，则不判断
        if (sign.length()==0) {
            status.set("0");
            return;
        }


        SpecialStorageUtil specialStorageUtil = SpringContextUtil.getBean("specialStorageUtil");
        Map<String, Object> surgeon = specialStorageUtil.getJsonStringValue(KernelConstants.HOSPITAL_DOCTOR_MAP);
        if (surgeon == null) {
            status.set("0");
            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");
            }
        }
    }
}