package com.lantone.structure.util;

import com.lantone.common.util.StringUtil;
import com.lantone.structure.model.entity.Diag;

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;
    }

}