Пример #1
0
        public async Task <IServiceBaseUrl> GetPrimaryAsync(Bug.Common.Enums.FhirVersion fhirVersion)
        {
            byte[]? data = await IDistributedCache.GetAsync(GetPrimaryKey(fhirVersion));

            if (data is object)
            {
                return(JsonSerializer.Deserialize <ServiceBaseUrl>(data));
            }
            else
            {
                IServiceBaseUrl?ServiceBaseUrl = await IServiceBaseUrlRepository.GetPrimary(fhirVersion);

                if (ServiceBaseUrl is object)
                {
                    await this.SetPrimaryAsync(ServiceBaseUrl);

                    return(ServiceBaseUrl);
                }
                else
                {
                    ServiceBaseUrl = await IServiceBaseUrlRepository.AddAsync(fhirVersion, StringSupport.StripHttp(IServiceBaseUrlConfig.Url(fhirVersion).OriginalString), true);

                    await this.SetPrimaryAsync(ServiceBaseUrl);

                    return(ServiceBaseUrl);
                }
            }
        }
Пример #2
0
        public async Task <IServiceBaseUrl?> GetAsync(Bug.Common.Enums.FhirVersion fhirVersion, string url)
        {
            byte[]? data = await IDistributedCache.GetAsync(GetKey(fhirVersion, url));

            if (data is object)
            {
                return(JsonSerializer.Deserialize <ServiceBaseUrl>(data));
            }
            else
            {
                IServiceBaseUrl?ServiceBaseUrl = await IServiceBaseUrlRepository.GetBy(fhirVersion, url);

                if (ServiceBaseUrl is object && ServiceBaseUrl is IServiceBaseUrl IServiceBaseUrl)
                {
                    await this.SetAsync(IServiceBaseUrl);

                    return(IServiceBaseUrl);
                }
                return(null);
            }
        }
Пример #3
0
 private string GetKey(Bug.Common.Enums.FhirVersion fhirVersion, string url)
 {
     return($"table:serviceBaseUrl:fVer:{((int)fhirVersion).ToString()}:url:{url}");
 }
Пример #4
0
 private string GetPrimaryKey(Bug.Common.Enums.FhirVersion fhirVersion)
 {
     return($"table:serviceBaseUrl:fVer:{((int)fhirVersion).ToString()}:isPrimary:true");
 }
Пример #5
0
        public async Task RemovePrimaryAsync(Bug.Common.Enums.FhirVersion fhirVersion, string url)
        {
            await IDistributedCache.RemoveAsync(GetPrimaryKey(fhirVersion));

            await RemoveAsync(fhirVersion, url);
        }
Пример #6
0
 public FhirResourceSupport(IResourceNameToTypeMap IResourceNameToTypeMap)
 {
     this.IResourceNameToTypeMap = IResourceNameToTypeMap;
     this.FhirVersion            = Common.Enums.FhirVersion.R4;
 }
Пример #7
0
        public async Task <BundleModel> GetSearchBundleModel(IList <ResourceStore> ResourceStoreList, Bug.Common.Enums.FhirVersion fhirVersion)
        {
            var IServiceBaseUrl = await IServiceBaseUrlCache.GetPrimaryAsync(fhirVersion);

            //Construct the History Bundle
            var BundleModel = new BundleModel(BundleType.Searchset)
            {
                Total = ResourceStoreList.Count
            };

            BundleModel.Entry = new List <BundleModel.EntryComponent>();
            foreach (var ResourceStore in ResourceStoreList)
            {
                var entry = new BundleModel.EntryComponent
                {
                    FullUrl = new Uri($"{IServiceBaseUrl.Url}/{ResourceStore.ResourceId}")
                };
                BundleModel.Entry.Add(entry);
                if (ResourceStore.ResourceBlob is object)
                {
                    entry.Resource = IFhirResourceParseJsonService.ParseJson(ResourceStore.FhirVersionId, IGZipper.Decompress(ResourceStore.ResourceBlob));
                }
            }
            return(BundleModel);
        }