private async Task <FhirResponse> HandleOperation( ResourceManipulationOperation operation, IInteractionHandler interactionHandler, Mapper <string, IKey> mapper = null) { IList <Entry> interactions = operation.GetEntries().ToList(); if (mapper != null) { await _transfer.Internalize(interactions, mapper).ConfigureAwait(false); } FhirResponse response = null; foreach (var interaction in interactions) { response = MergeFhirResponse( response, await interactionHandler.HandleInteraction(interaction).ConfigureAwait(false)); if (!response.IsValid) { throw new Exception(); } interaction.Resource = response.Resource; } _transfer.Externalize(interactions); return(response); }
public FhirResponse HandleOperation(ResourceManipulationOperation operation, IInteractionHandler interactionHandler, Mapper <string, IKey> mapper = null) { IList <Entry> interactions = operation.GetEntries().ToList(); if (mapper != null) { transfer.Internalize(interactions, mapper); } FhirResponse response = null; foreach (Entry interaction in interactions) { response = MergeFhirResponse(response, interactionHandler.HandleInteraction(interaction)); if (!response.IsValid) { throw new Exception(); } interaction.Resource = response.Resource; } transfer.Externalize(interactions); return(response); }
public Entry Get(IKey key) { var entry = fhirStore.Get(key); if (entry != null) { transfer.Externalize(entry); } return(entry); }
public async Task <Entry> Get(IKey key) { var entry = await _fhirStore.Get(key).ConfigureAwait(false); if (entry != null) { _transfer.Externalize(entry); } return(entry); }
private async Task <Bundle> CreateBundleAsync(int?start = null) { var bundle = new Bundle { Type = _snapshot.Type, Total = _snapshot.Count, Id = Guid.NewGuid().ToString() }; var keys = _snapshotPaginationCalculator.GetKeysForPage(_snapshot, start).ToList(); var entries = (await _fhirStore.Get(keys).ConfigureAwait(false)).ToList(); if (_snapshot.SortBy != null) { entries = entries.Select(e => new { Entry = e, Index = keys.IndexOf(e.Key) }) .OrderBy(e => e.Index) .Select(e => e.Entry) .ToList(); } var included = await GetIncludesRecursiveForAsync(entries, _snapshot.Includes).ConfigureAwait(false); entries.Append(included); _transfer.Externalize(entries); bundle.Append(entries); BuildLinks(bundle, start); return(bundle); }
private Bundle CreateBundle(int?start = null) { Bundle bundle = new Bundle(); bundle.Type = snapshot.Type; bundle.Total = snapshot.Count; bundle.Id = UriHelper.CreateUuid().ToString(); List <IKey> keys = _snapshotPaginationCalculator.GetKeysForPage(snapshot, start).ToList(); IList <Entry> entries = fhirStore.Get(keys).ToList(); if (snapshot.SortBy != null) { entries = entries.Select(e => new { Entry = e, Index = keys.IndexOf(e.Key) }) .OrderBy(e => e.Index) .Select(e => e.Entry).ToList(); } IList <Entry> included = GetIncludesRecursiveFor(entries, snapshot.Includes); entries.Append(included); transfer.Externalize(entries); bundle.Append(entries); BuildLinks(bundle, start); return(bundle); }