GetFirstPage() public method

public GetFirstPage ( Spark.Core.Snapshot snapshot ) : Hl7.Fhir.Model.Bundle
snapshot Spark.Core.Snapshot
return Hl7.Fhir.Model.Bundle
Exemplo n.º 1
0
        public FhirResponse Search(string type, SearchParams searchCommand)
        {
            _log.ServiceMethodCalled("search");

            Validate.TypeName(type);
            SearchResults results = fhirIndex.Search(type, searchCommand);

            if (results.HasErrors)
            {
                throw new SparkException(HttpStatusCode.BadRequest, results.Outcome);
            }

            UriBuilder builder = new UriBuilder(localhost.Uri(type));

            builder.Query = results.UsedParameters;
            Uri link = builder.Uri;

            var    snapshot = pager.CreateSnapshot(link, results, searchCommand);
            Bundle bundle   = pager.GetFirstPage(snapshot);

            if (results.HasIssues)
            {
                bundle.AddResourceEntry(results.Outcome, new Uri("outcome/1", UriKind.Relative).ToString());
            }

            return(Respond.WithBundle(bundle));
        }
Exemplo n.º 2
0
        public FhirResponse Search(string type, SearchParams searchCommand)
        {
            Validate.TypeName(type);
            SearchResults results = index.Search(type, searchCommand);

            if (results.HasErrors)
            {
                throw new SparkException(HttpStatusCode.BadRequest, results.Outcome);
            }

            Uri link = new RestUrl(localhost.Uri(type)).AddPath(results.UsedParameters).Uri;


            string firstSort = null;

            if (searchCommand.Sort != null && searchCommand.Sort.Count() > 0)
            {
                firstSort = searchCommand.Sort[0].Item1; //TODO: Support sortorder and multiple sort arguments.
            }


            var    snapshot = pager.CreateSnapshot(Bundle.BundleType.Searchset, link, results, firstSort);
            Bundle bundle   = pager.GetFirstPage(snapshot);

            return(Respond.WithBundle(bundle, localhost.Base));
        }