package com.lantone.qc.kernel.util;

import com.lantone.qc.dbanaly.util.KernelConstants;
import com.lantone.qc.dbanaly.util.SpecialStorageUtil;
import com.lantone.qc.pub.model.entity.Diag;
import com.lantone.qc.pub.util.SpringContextUtil;
import com.lantone.qc.pub.util.StringUtil;

import java.util.Map;

/**
 * @Description:
 * @author: rengb
 * @time: 2020/3/12 18:03
 */
public class DiagEnhancer {

    public static Diag create(String hospitalDiagName) {
        Diag diag = new Diag();
        diag.setHospitalDiagName(hospitalDiagName);
        SpecialStorageUtil specialStorageUtil = SpringContextUtil.getBean("specialStorageUtil");
        Map<String, Map<String, String>> hospitalDiagHuazMap = specialStorageUtil.getJsonStringValue(KernelConstants.HOSPITAL_DIAG_HUAZ_MAP);
        Map<String, Map<String, String>> lantoneDiagHuazMap = specialStorageUtil.getJsonStringValue(KernelConstants.LANTONE_DIAG_HUAZ_MAP);
        if (hospitalDiagHuazMap != null && lantoneDiagHuazMap != null) {
            Map<String, String> huazDiagMap = hospitalDiagHuazMap.get(hospitalDiagName);
            if (huazDiagMap != null) {
                String huazDiagName = huazDiagMap.get("name");
                if (StringUtil.isNotBlank(huazDiagName)) {
                    Map<String, String> lantoneDiagMap = lantoneDiagHuazMap.get(huazDiagName);
                    if (lantoneDiagMap != null) {
                        diag.setName(lantoneDiagMap.get("name"));
                    }
                }
            }
        }
        return diag;
    }

}