Exemplo n.º 1
0
        public ServerFhirResponse GetFhirResponse(IList <Entry> interactions, Bundle.BundleType bundleType)
        {
            //Bundle bundle = localhost.CreateBundle(bundleType).Append(interactions);
            Bundle bundle = new Bundle().Append(interactions);

            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));
        }
Exemplo n.º 3
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.º 4
0
        public FhirResponse GetFhirResponse(IEnumerable <Tuple <Entry, FhirResponse> > responses, Bundle.BundleType bundleType)
        {
            Bundle bundle = localhost.CreateBundle(bundleType);

            foreach (Tuple <Entry, FhirResponse> response in responses)
            {
                bundle.Append(response.Item1, response.Item2);
            }

            return(Respond.WithBundle(bundle));
        }
Exemplo n.º 5
0
        public FhirResponse History(HistoryParameters parameters)
        {
            var since = parameters.Since ?? DateTimeOffset.MinValue;
            Uri link  = localhost.Uri(RestOperation.HISTORY);

            IEnumerable <string> keys = fhirStore.History(since);
            var    snapshot           = pager.CreateSnapshot(Bundle.BundleType.History, link, keys, parameters.SortBy, parameters.Count, null);
            Bundle bundle             = pager.GetFirstPage(snapshot);

            // DSTU2: export
            // exporter.Externalize(bundle);
            return(Respond.WithBundle(bundle));
        }
Exemplo n.º 6
0
        public FhirResponse Transaction(Bundle bundle)
        {
            var interactions = localhost.GetEntries(bundle);

            transfer.Internalize(interactions);

            fhirStore.Add(interactions);
            fhirIndex.Process(interactions);
            transfer.Externalize(interactions);

            bundle = localhost.CreateBundle(Bundle.BundleType.TransactionResponse).Append(interactions);

            return(Respond.WithBundle(bundle));
        }
Exemplo n.º 7
0
        public ServerFhirResponse GetFhirResponse(IEnumerable <Tuple <Entry, ServerFhirResponse> > responses, Bundle.BundleType bundleType)
        {
            //Bundle bundle = localhost.CreateBundle(bundleType);
            Bundle bundle = new Bundle()
            {
                Type = bundleType
            };

            foreach (Tuple <Entry, ServerFhirResponse> response in responses)
            {
                bundle.Append(response.Item1, response.Item2);
            }

            return(Respond.WithBundle(bundle));
        }
Exemplo n.º 8
0
        public FhirResponse GetFhirResponse(
            IEnumerable <Tuple <Entry, FhirResponse> > responses,
            Bundle.BundleType bundleType)
        {
            var bundle = new Bundle {
                Type = bundleType
            };

            foreach (var response in responses)
            {
                bundle.Append(response.Item1, response.Item2);
            }

            return(Respond.WithBundle(bundle));
        }
Exemplo n.º 9
0
        public FhirResponse Search([FromUri] string type)
        {
            var cursor = _cursorManager.AcquireCursor(type, Request.GetQueryNameValuePairs());

            try
            {
                var pageSize = Request.GetParameterAsIntWithDefault("_count", _defaultPageSize);
                var bundle   = cursor.GetNextPage(pageSize);
                return(Respond.WithBundle(bundle));
            }
            finally
            {
                _cursorManager.ReleaseCursor(cursor);
            }
        }
Exemplo n.º 10
0
        public FhirResponse History(DateTimeOffset?since, string sortby)
        {
            if (since == null)
            {
                since = DateTimeOffset.MinValue;
            }
            Uri link = localhost.Uri(RestOperation.HISTORY);

            IEnumerable <string> keys = store.History(since);
            var    snapshot           = pager.CreateSnapshot(Bundle.BundleType.History, link, keys, sortby);
            Bundle bundle             = pager.GetFirstPage(snapshot);

            // DSTU2: export
            // exporter.Externalize(bundle);
            return(Respond.WithBundle(bundle, localhost.Base));
        }
Exemplo n.º 11
0
        // These should eventually be Interaction! = FhirRequests. Not Entries.
        public FhirResponse Transaction(IList <Entry> interactions)
        {
            transfer.Internalize(interactions);

            var resources = new List <Resource>();

            foreach (Entry interaction in interactions)
            {
                FhirResponse response = HandleInteraction(interaction);

                if (!response.IsValid)
                {
                    return(response);
                }
                resources.Add(response.Resource);
            }

            transfer.Externalize(interactions);

            Bundle bundle = localhost.CreateBundle(Bundle.BundleType.TransactionResponse).Append(interactions);

            return(Respond.WithBundle(bundle));
        }
Exemplo n.º 12
0
        public FhirResponse Search(string type, IEnumerable <Tuple <string, string> > parameters, int pageSize, string sortby)
        {
            Validate.TypeName(type);
            Uri link = localhost.Uri(type);

            IEnumerable <string> keys = store.List(type);
            var    snapshot           = pager.CreateSnapshot(Bundle.BundleType.Searchset, link, keys, sortby);
            Bundle bundle             = pager.GetFirstPage(snapshot);

            return(Respond.WithBundle(bundle, localhost.Base));
            // DSTU2: search

            /*
             * Query query = FhirParser.ParseQueryFromUriParameters(collection, parameters);
             * ICollection<string> includes = query.Includes;
             *
             * SearchResults results = index.Search(query);
             *
             * if (results.HasErrors)
             * {
             *  throw new SparkException(HttpStatusCode.BadRequest, results.Outcome);
             * }
             *
             * Uri link = localhost.Uri(type).AddPath(results.UsedParameters);
             *
             * Bundle bundle = pager.GetFirstPage(link, keys, sortby);
             *
             * /*
             * if (results.HasIssues)
             * {
             *  var outcomeEntry = BundleEntryFactory.CreateFromResource(results.Outcome, new Uri("outcome/1", UriKind.Relative), DateTimeOffset.Now);
             *  outcomeEntry.SelfLink = outcomeEntry.Id;
             *  bundle.Entries.Add(outcomeEntry);
             * }
             * return Respond.WithBundle(bundle);
             */
        }
Exemplo n.º 13
0
 public ServerFhirResponse GetFhirResponse(Bundle bundle)
 {
     return(Respond.WithBundle(bundle));
 }
Exemplo n.º 14
0
 public FhirResponse GetFhirResponse(Bundle bundle) => Respond.WithBundle(bundle);
Exemplo n.º 15
0
        public FhirResponse GetPage(string snapshotkey, int index)
        {
            Bundle bundle = pager.GetPage(snapshotkey, index);

            return(Respond.WithBundle(bundle));
        }
Exemplo n.º 16
0
        public FhirResponse GetPage(string snapshotkey, int index, int count)
        {
            Bundle bundle = pager.GetPage(snapshotkey, index, count);

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