public ServerFhirResponse Search(string type)
        {
            int start        = FhirHttpUtil.GetIntParameter(HttpContext.Request, FhirParameter.SNAPSHOT_INDEX) ?? 0;
            var searchparams = HttpHeaderUtil.GetSearchParams(HttpContext.Request);

            return(fhirService.Search(type, searchparams, start));
        }
        public ServerFhirResponse Update(string type, Resource resource, string id = null)
        {
            string versionid = FhirHttpUtil.IfMatchVersionId(HttpContext.Request);
            Key    key       = Key.Create(type, id, versionid);

            if (key.HasResourceId())
            {
                return(fhirService.Update(key, resource));
            }
            else
            {
                SearchParams searchparams = SearchParams.FromUriParamList(HttpHeaderUtil.TupledParameters(HttpContext.Request));
                return(fhirService.ConditionalUpdate(key, resource, searchparams));
            }
        }
        public ServerFhirResponse Create(string type, Resource resource)
        {
            Key key = Key.Create(type, resource?.Id);

            if (HttpHeaderUtil.Exists(Request.Headers, FhirHttpHeaders.IfNoneExist))
            {
                NameValueCollection searchQueryString =
                    HttpUtility.ParseQueryString(
                        Request.Headers.First(h => h.Key == FhirHttpHeaders.IfNoneExist).Value.Single());

                IEnumerable <Tuple <string, string> > searchValues =
                    searchQueryString.Keys.Cast <string>()
                    .Select(k => new Tuple <string, string>(k, searchQueryString[k]));


                return(fhirService.ConditionalCreate(key, resource, SearchParams.FromUriParamList(searchValues)));
            }

            return(fhirService.Create(key, resource));
        }
        public ServerFhirResponse ConditionalDelete(string type)
        {
            Key key = Key.Create(type);

            return(fhirService.ConditionalDelete(key, HttpHeaderUtil.TupledParameters(Request)));
        }