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); }
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); }
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); }
//TODO: I've commented this. Do we still need it? //public IList<string> List(string resource, DateTimeOffset? since = null) //{ // var clauses = new List<FilterDefinition<BsonDocument>>(); // clauses.Add(Builders<BsonDocument>.Filter.Eq(Field.TYPENAME, resource)); // if (since != null) // { // clauses.Add(Builders<BsonDocument>.Filter.GT(Field.WHEN, BsonDateTime.Create(since))); // } // clauses.Add(Builders<BsonDocument>.Filter.Eq(Field.STATE, Value.CURRENT)); // return FetchPrimaryKeys(clauses); //} public bool Exists(IKey key) { // PERF: efficiency Entry existing = _mongoFhirStoreOther.Get(key); return(existing != null); }
//TODO: I've commented this. Do we still need it? //public IList<string> List(string resource, DateTimeOffset? since = null) //{ // var clauses = new List<FilterDefinition<BsonDocument>>(); // clauses.Add(Builders<BsonDocument>.Filter.Eq(Field.TYPENAME, resource)); // if (since != null) // { // clauses.Add(Builders<BsonDocument>.Filter.GT(Field.WHEN, BsonDateTime.Create(since))); // } // clauses.Add(Builders<BsonDocument>.Filter.Eq(Field.STATE, Value.CURRENT)); // return FetchPrimaryKeys(clauses); //} public async Task <bool> Exists(IKey key) { // PERF: efficiency var existing = await _mongoFhirStoreOther.Get(key).ConfigureAwait(false); return(existing != null); }
public Bundle CreateBundle(Snapshot snapshot, int?start = null) { Bundle bundle = new Bundle(); bundle.Type = snapshot.Type; bundle.Total = snapshot.Count; bundle.Id = UriHelper.CreateUuid().ToString(); IEnumerable <string> keysInBundle = snapshot.Keys; if (start.HasValue) { keysInBundle = keysInBundle.Skip(start.Value); } IList <string> keys = keysInBundle.Take(snapshot.CountParam ?? DEFAULT_PAGE_SIZE).ToList(); IList <Interaction> interactions = fhirStore.Get(keys, snapshot.SortBy).ToList(); IList <Interaction> included = GetIncludesRecursiveFor(interactions, snapshot.Includes); interactions.Append(included); transfer.Externalize(interactions); bundle.Append(interactions); BuildLinks(bundle, snapshot, start); return(bundle); }
public FhirResponse GetFhirResponse(Key key, IEnumerable <object> parameters = null) { Entry entry = fhirStore.Get(key); if (entry == null) { return(Respond.NotFound(key)); } return(GetFhirResponse(entry, parameters)); }
public FhirResponse GetFhirResponse(Key key, IEnumerable <object> parameters = null) { Interaction interaction = fhirStore.Get(key); if (interaction == null) { return(Respond.NotFound(key)); } return(GetFhirResponse(interaction, parameters)); }
public Bundle CreateBundle(Snapshot snapshot, int start, int count) { Bundle bundle = new Bundle(); bundle.Title = snapshot.FeedTitle; bundle.TotalResults = snapshot.Count; bundle.Id = Key.NewUuid(); bundle.AuthorName = "Furore Spark FHIR server"; bundle.AuthorUri = "http://fhir.furore.com"; bundle.Links = new UriLinkList(); bundle.Links.SelfLink = new Uri(snapshot.FeedSelfLink); bundle.LastUpdated = snapshot.WhenCreated; IEnumerable <Uri> keys = snapshot.Keys.Skip(start).Take(count); bundle.Entries = store.Get(keys, snapshot.SortBy).ToList(); Include(bundle, snapshot.Includes); buildLinks(bundle, snapshot, start, count); exporter.Externalize(bundle); return(bundle); }
public FhirResponse ReadMeta(Key key) { _log.ServiceMethodCalled("readmeta"); ValidateKey(key); Entry entry = fhirStore.Get(key); if (entry == null) { return(Respond.NotFound(key)); } else if (entry.IsDeleted()) { return(Respond.Gone(entry)); } return(Respond.WithMeta(entry)); }
public FhirResponse ReadMeta(Key key) { _log.ServiceMethodCalled("readmeta"); ValidateKey(key); Interaction interaction = fhirStore.Get(key); if (interaction == null) { return(Respond.NotFound(key)); } else if (interaction.IsDeleted()) { return(Respond.Gone(interaction)); } return(Respond.WithMeta(interaction)); }
public Bundle CreateBundle(Snapshot snapshot, int start, int count) { Bundle bundle = new Bundle(); bundle.Type = snapshot.Type; bundle.Total = snapshot.Count; bundle.Id = UriHelper.CreateUuid().ToString(); IList <string> keys = snapshot.Keys.Skip(start).Take(count).ToList(); IList <Interaction> interactions = store.Get(keys, snapshot.SortBy).ToList(); transfer.Externalize(interactions); bundle.Append(interactions); Include(bundle, snapshot.Includes); BuildLinks(bundle, snapshot, start, count); return(bundle); }
public FhirResponse Read(Key key) { Validate.HasTypeName(key); Validate.HasResourceId(key); Validate.HasNoVersion(key); Validate.Key(key); var interaction = store.Get(key); if (interaction == null) { return(Respond.NotFound(key)); } else if (interaction.IsDeleted()) { transfer.Externalize(interaction); return(Respond.Gone(interaction)); } else { transfer.Externalize(interaction); return(Respond.WithResource(interaction)); } }
/// <summary> /// Retrieves the current contents of a resource. /// </summary> /// <param name="collection">The resource type, in lowercase</param> /// <param name="id">The id part of a Resource id</param> /// <returns>A Result containing the resource, or an Issue</returns> /// <remarks> /// Note: Unknown resources and deleted resources are treated differently on a read: /// * A deleted resource returns a 410 status code /// * an unknown resource returns 404. /// </remarks> public ResourceEntry Read(string collection, string id) { Uri key = BuildKey(collection, id); BundleEntry entry = store.Get(key); if (entry == null) { throwNotFound("Cannot read resource", collection, id); } else if (entry is DeletedEntry) { var deletedentry = (entry as DeletedEntry); var message = String.Format("A {0} resource with id {1} existed, but was deleted on {2} (version {3}).", collection, id, deletedentry.When, new ResourceIdentity(deletedentry.Links.SelfLink).VersionId); throw new SparkException(HttpStatusCode.Gone, message); } ResourceEntry result = (ResourceEntry)entry; exporter.Externalize(result); return(result); }