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); }
public BundleModel GetHistoryBundleModel(IList <ResourceStore> ResourceStoreList) { //Construct the History Bundle var BundleModel = new BundleModel(BundleType.History) { Total = ResourceStoreList.Count }; BundleModel.Entry = new List <BundleModel.EntryComponent>(); foreach (var ResourceStore in ResourceStoreList) { var entry = new BundleModel.EntryComponent(); BundleModel.Entry.Add(entry); if (ResourceStore.ResourceBlob is object) { entry.Resource = IFhirResourceParseJsonService.ParseJson(ResourceStore.FhirVersionId, IGZipper.Decompress(ResourceStore.ResourceBlob)); } string RequestUrl = ResourceStore.ResourceTypeId.GetCode(); if (ResourceStore.MethodId == HttpVerb.PUT || ResourceStore.MethodId == HttpVerb.DELETE) { RequestUrl = $"{RequestUrl}/{ResourceStore.ResourceId}"; } entry.Request = new BundleModel.RequestComponent(ResourceStore.MethodId, RequestUrl); entry.Response = new BundleModel.ResponseComponent($"{ResourceStore.HttpStatusCode.Code.ToString()} - {((int)ResourceStore.HttpStatusCode.Number).ToString()}") { LastModified = IServerDateTimeSupport.ZuluToServerTimeZone(ResourceStore.LastUpdated) }; } return(BundleModel); }