private Uri BuildSnapshotPageLink(Uri baseurl, string snapshotId, int snapshotIndex) { return baseurl .AddParam(FhirParameter.SNAPSHOT_ID, snapshotId) .AddParam(FhirParameter.SNAPSHOT_INDEX, snapshotIndex.ToString()); }
public Snapshot CreateSnapshot(Uri selflink, IEnumerable<string> keys, SearchParams searchCommand) { string sort = GetFirstSort(searchCommand); int? count = null; if (searchCommand.Count.HasValue) { count = Math.Min(searchCommand.Count.Value, MAX_PAGE_SIZE); selflink = selflink.AddParam(SearchParams.SEARCH_PARAM_COUNT, new string[] {count.ToString()}); } if (string.IsNullOrEmpty(sort) == false) { selflink = selflink.AddParam(SearchParams.SEARCH_PARAM_SORT, new string[] {sort }); } if (searchCommand.Include.Any()) { selflink = selflink.AddParam(SearchParams.SEARCH_PARAM_INCLUDE, searchCommand.Include.ToArray()); } return CreateSnapshot(Bundle.BundleType.Searchset, selflink, keys, sort, count, searchCommand.Include); }
// Given a set of version id's, go fetch a subset of them from the store and build a Bundle /*private Bundle createBundle(Snapshot snapshot, int start, int count) { var entryVersionIds = snapshot.Keys.Skip(start).Take(count).ToList(); var pageContents = store.Get(entryVersionIds, snapshot.SortBy).ToList(); var bundle = BundleEntryFactory.CreateBundleWithEntries(snapshot.FeedTitle, new Uri(snapshot.FeedSelfLink), "Spark MatchBox Search Engine", null, pageContents); if (snapshot.Count != Snapshot.NOCOUNT) bundle.TotalResults = snapshot.Count; else bundle.TotalResults = null; var total = snapshot.Keys.Count(); // If we need paging, add the paging links if (total > count) buildLinks(bundle, snapshot, start, count); return bundle; } */ private static void buildLinks(Bundle bundle, Snapshot snapshot, int start, int count) { var lastPage = snapshot.Count / count; // http://spark.furore.com/fhir/_snapshot/ Uri baseurl = new Uri(Settings.Endpoint.ToString() + "/" + FhirRestOp.SNAPSHOT); bundle.Links.SelfLink = baseurl .AddParam(FhirParameter.SNAPSHOT_ID, snapshot.Id) .AddParam(FhirParameter.SNAPSHOT_INDEX, start.ToString()) .AddParam(FhirParameter.COUNT, count.ToString()); // First bundle.Links.FirstLink = baseurl .AddParam(FhirParameter.SNAPSHOT_ID, snapshot.Id) .AddParam(FhirParameter.SNAPSHOT_INDEX, "0"); // Last bundle.Links.LastLink = baseurl .AddParam(FhirParameter.SNAPSHOT_ID, snapshot.Id) .AddParam(FhirParameter.SNAPSHOT_INDEX, (lastPage * count).ToString()); // Only do a Previous if we can go back if (start > 0) { int prevIndex = start - count; if (prevIndex < 0) prevIndex = 0; bundle.Links.PreviousLink = baseurl .AddParam(FhirParameter.SNAPSHOT_ID, snapshot.Id) .AddParam(FhirParameter.SNAPSHOT_INDEX, prevIndex.ToString()); } // Only do a Next if we can go forward if (start + count < snapshot.Count) { int nextIndex = start + count; bundle.Links.NextLink = baseurl .AddParam(FhirParameter.SNAPSHOT_ID, snapshot.Id) .AddParam(FhirParameter.SNAPSHOT_INDEX, nextIndex.ToString()); } }
void BuildLinks(Bundle bundle, Snapshot snapshot, int start, int count) { var lastPage = snapshot.Count / count; Uri baseurl = new Uri(localhost.Base.ToString() + "/" + FhirRestOp.SNAPSHOT); bundle.SelfLink = baseurl .AddParam(FhirParameter.SNAPSHOT_ID, snapshot.Id) .AddParam(FhirParameter.SNAPSHOT_INDEX, start.ToString()) .AddParam(FhirParameter.COUNT, count.ToString()); // First bundle.FirstLink = baseurl .AddParam(FhirParameter.SNAPSHOT_ID, snapshot.Id) .AddParam(FhirParameter.SNAPSHOT_INDEX, "0"); // Last bundle.LastLink = baseurl .AddParam(FhirParameter.SNAPSHOT_ID, snapshot.Id) .AddParam(FhirParameter.SNAPSHOT_INDEX, (lastPage * count).ToString()); // Only do a Previous if we can go back if (start > 0) { int prevIndex = start - count; if (prevIndex < 0) prevIndex = 0; bundle.PreviousLink = baseurl .AddParam(FhirParameter.SNAPSHOT_ID, snapshot.Id) .AddParam(FhirParameter.SNAPSHOT_INDEX, prevIndex.ToString()); } // Only do a Next if we can go forward if (start + count < snapshot.Count) { int nextIndex = start + count; bundle.NextLink = baseurl .AddParam(FhirParameter.SNAPSHOT_ID, snapshot.Id) .AddParam(FhirParameter.SNAPSHOT_INDEX, nextIndex.ToString()); } }
private static void buildLinks(Bundle bundle, string snapshotId, int index, int pageSize, int count) { var lastPage = count / pageSize; // http://spark.furore.com/fhir/_snapshot/ Uri baseurl = new Uri(Settings.Endpoint.ToString() + "/" + FhirRestOp.SNAPSHOT); bundle.Links.SelfLink = baseurl .AddParam(FhirParameter.SNAPSHOT_ID, snapshotId) .AddParam(FhirParameter.SNAPSHOT_INDEX, index.ToString()) .AddParam(FhirParameter.COUNT, pageSize.ToString()); // First bundle.Links.FirstLink = baseurl .AddParam(FhirParameter.SNAPSHOT_ID, snapshotId) .AddParam(FhirParameter.SNAPSHOT_INDEX, "0"); // Last bundle.Links.LastLink = baseurl .AddParam(FhirParameter.SNAPSHOT_ID, snapshotId) .AddParam(FhirParameter.SNAPSHOT_INDEX, (lastPage * pageSize).ToString()); // Only do a Previous if we can go back if (index > 0) { int prevIndex = index - pageSize; if (prevIndex < 0) prevIndex = 0; bundle.Links.PreviousLink = baseurl .AddParam(FhirParameter.SNAPSHOT_ID, snapshotId) .AddParam(FhirParameter.SNAPSHOT_INDEX, prevIndex.ToString()); } // Only do a Next if we can go forward if (index + pageSize < count) { int nextIndex = index + pageSize; bundle.Links.NextLink = baseurl .AddParam(FhirParameter.SNAPSHOT_ID, snapshotId) .AddParam(FhirParameter.SNAPSHOT_INDEX, nextIndex.ToString()); } }