public IHttpActionResult GetClientConfig(bool isRef = false)
        {
            var clientConfig = new ClientConfigModel();

            foreach (IGTypeFhirElement fit in IGTypeSection.GetSection().FhirIgTypes)
            {
                ImplementationGuideType igType = this.tdb.ImplementationGuideTypes.SingleOrDefault(y => y.Name.ToLower() == fit.ImplementationGuideTypeName.ToLower());

                if (igType == null)
                {
                    Log.For(this).Warn("Configured FHIR IG Type could not be found in the database: " + fit.ImplementationGuideTypeName);
                    continue;
                }

                var fhirIgType = new ClientConfigModel.FhirIgType()
                {
                    Id      = igType.Id,
                    Name    = igType.Name,
                    Version = fit.Version,
                    BaseUrl = ""
                };

                switch (fhirIgType.Version)
                {
                case "DSTU1":
                    fhirIgType.BaseUrl = "/api/FHIR1/";
                    break;

                case "DSTU2":
                    fhirIgType.BaseUrl = "/api/FHIR2/";
                    break;

                case "STU3":
                    fhirIgType.BaseUrl = "/api/FHIR3/";
                    break;
                }

                clientConfig.FhirIgTypes.Add(fhirIgType);
            }

            if (isRef)
            {
                var clientConfigJson = Newtonsoft.Json.JsonConvert.SerializeObject(clientConfig);
                return(Content <string>(HttpStatusCode.OK, "var trifoliaConfig = " + clientConfigJson + ";", new Formatters.JavaScriptFormatter(), "text/javascript"));
            }

            return(Content <ClientConfigModel>(HttpStatusCode.OK, clientConfig));
        }
        public static IIGTypePlugin GetPlugin(ImplementationGuideType igType)
        {
            IGTypeSection       config        = IGTypeSection.GetSection();
            IGTypePluginElement configElement = config.Plugins[igType.Name];

            if (configElement == null)
            {
                throw new Exception("Plugin not configured for this type of schema!");
            }

            Type type = Type.GetType(configElement.PluginAssembly);

            if (type == null)
            {
                throw new Exception("Plugin not loaded for IG Type: " + configElement.PluginAssembly);
            }

            var pluginInterface = (IIGTypePlugin)Activator.CreateInstance(type);

            return(pluginInterface);
        }
Exemple #3
0
        public static ImplementationGuideType GetImplementationGuideType(IObjectRepository tdb, bool throwError)
        {
            ImplementationGuideType found = null;

            foreach (IGTypeFhirElement configFhirIgType in IGTypeSection.GetSection().FhirIgTypes)
            {
                if (configFhirIgType.Version == VERSION_NAME)
                {
                    found = tdb.ImplementationGuideTypes.SingleOrDefault(y => y.Name.ToLower() == configFhirIgType.ImplementationGuideTypeName.ToLower());
                    break;
                }
            }

            if (found == null && throwError)
            {
                string errorMsg = "No STU3 FHIR IG Type is defined/configured";
                Log.For(typeof(STU3Helper)).Error(errorMsg);
                throw new Exception(errorMsg);
            }

            return(found);
        }