Esempio n. 1
0
        public HttpResponseMessage GetHistory(string resource, string id, string vid)
        {
            HttpResponseMessage response;
            var respval = "";
            var item    = storage.HistoryStore.GetResourceHistoryItem(resource, id, vid);

            if (item != null)
            {
                var retVal = (Resource)jsonparser.Parse(item, FhirHelper.ResourceTypeFromString(resource));
                if (retVal != null)
                {
                    respval = SerializeResponse(retVal);
                }
                response = Request.CreateResponse(HttpStatusCode.OK);
                response.Headers.TryAddWithoutValidation("Accept", CurrentAcceptType);
                response.Headers.Add("ETag", "W/\"" + retVal.Meta.VersionId + "\"");
                response.Content = new StringContent(respval, Encoding.UTF8);
                response.Content.Headers.LastModified = retVal.Meta.LastUpdated;
            }
            else
            {
                response         = Request.CreateResponse(HttpStatusCode.NotFound);
                response.Content = new StringContent("", Encoding.UTF8);
            }

            response.Content.Headers.TryAddWithoutValidation("Content-Type",
                                                             IsAccceptTypeJson ? Fhircontenttypejson : Fhircontenttypexml);
            return(response);
        }
Esempio n. 2
0
        public HttpResponseMessage GetHistoryComplete(string resource, string id)
        {
            string respval = "";
            IEnumerable <string> history = storage.HistoryStore.GetResourceHistory(resource, id);
            //Create Return Bundle
            Bundle results = new Bundle();

            results.Id    = Guid.NewGuid().ToString();
            results.Type  = Bundle.BundleType.History;
            results.Total = history.Count();
            results.Link  = new System.Collections.Generic.List <Bundle.LinkComponent>();
            results.Link.Add(new Bundle.LinkComponent()
            {
                Url = Request.RequestUri.AbsoluteUri, Relation = "self"
            });
            results.Entry = new System.Collections.Generic.List <Bundle.EntryComponent>();
            //Add History Items to Bundle
            foreach (string h in history)
            {
                var r = (Resource)jsonparser.Parse(h, FhirHelper.ResourceTypeFromString(resource));
                results.Entry.Add(new Bundle.EntryComponent()
                {
                    Resource = r
                });
            }


            //Serialize and Return Bundle
            respval = SerializeResponse(results);
            var response = this.Request.CreateResponse(HttpStatusCode.OK);

            response.Content = new StringContent(respval, Encoding.UTF8, CurrentAcceptType);
            return(response);
        }
Esempio n. 3
0
        /// <inheritdoc />
        public async Task <ResourceQueryResult> QueryFhirResourceAsync(string query, string resourceType, int count = 100,
                                                                       string continuationToken = null, long querytotal = -1)
        {
            var retVal = new List <Resource>();

            await CreateDocumentCollectionIfNotExistsAsync(DbName, resourceType).ConfigureAwait(false);

            var options = new FeedOptions
            {
                MaxItemCount        = count,
                RequestContinuation = FhirHelper.UrlBase64Decode(continuationToken)
            };
            var collectionId = UriFactory.CreateDocumentCollectionUri(DbName, resourceType);
            var docq         = client.CreateDocumentQuery <Document>(collectionId, query, options).AsDocumentQuery();
            var rslt         = await docq.ExecuteNextAsync <Document>().ConfigureAwait(false);

            //Get Totalcount first
            if (querytotal < 0)
            {
                querytotal = rslt.Count;
            }
            foreach (var doc in rslt)
            {
                retVal.Add(ConvertDocument(doc));
            }
            return(new ResourceQueryResult(retVal, querytotal, FhirHelper.UrlBase64Encode(rslt.ResponseContinuation)));
        }
Esempio n. 4
0
        public void CreateanAppointmentInXDaysTimeForPatientAndOrganizationCodeWithserviceCategoryandserviceTypeinRequest(int days, string patient, string code)
        {
            _patientSteps.GetThePatientForPatientValue(patient);
            _patientSteps.StoreThePatient();

            _searchForFreeSlotsSteps.GetAvailableFreeSlotsSearchingXDaysInFuture(days);
            _searchForFreeSlotsSteps.StoreTheFreeSlotsBundle();

            _httpSteps.ConfigureRequest(GpConnectInteraction.AppointmentCreate);
            Organization changed = FhirHelper.GetDefaultOrganization();

            changed.Identifier.First().Value = GlobalContext.OdsCodeMap[code];
            _httpSteps.jwtHelper.RequestingOrganization = changed.ToFhirJson();

            CreateAnAppointmentFromTheStoredPatientAndStoredSchedule();

            //Add two new elements into request
            //add ServiceCategory
            _fhirResourceRepository.Appointment.ServiceCategory      = new CodeableConcept();
            _fhirResourceRepository.Appointment.ServiceCategory.Text = "Test-ServiceCategory";

            //add ServiceType
            _fhirResourceRepository.Appointment.ServiceType = new List <CodeableConcept>();
            var st = new CodeableConcept();

            st.Text = "Test-ServiceType";
            _fhirResourceRepository.Appointment.ServiceType.Add(st);

            _httpSteps.MakeRequest(GpConnectInteraction.AppointmentCreate);
        }
Esempio n. 5
0
        public void CreateanAppointmentInXDaysTimeforPatientAndOrganizationCodeRemovingServiceCategoryandServiceTypefromCreatedAppointment(int days, string patient, string code)
        {
            _patientSteps.GetThePatientForPatientValue(patient);
            _patientSteps.StoreThePatient();

            _searchForFreeSlotsSteps.GetAvailableFreeSlotsSearchingXDaysInFuture(days);

            _searchForFreeSlotsSteps.StoreTheFreeSlotsBundle();

            _httpSteps.ConfigureRequest(GpConnectInteraction.AppointmentCreate);
            Organization changed = FhirHelper.GetDefaultOrganization();

            changed.Identifier.First().Value = GlobalContext.OdsCodeMap[code];
            _httpSteps.jwtHelper.RequestingOrganization = changed.ToFhirJson();

            CreateAnAppointmentFromTheStoredPatientAndStoredSchedule();

            if (_fhirResourceRepository.Appointment.ServiceCategory != null)
            {
                _fhirResourceRepository.Appointment.ServiceCategory = null;
            }

            if (_fhirResourceRepository.Appointment.ServiceType != null)
            {
                _fhirResourceRepository.Appointment.ServiceType = null;
            }

            _httpSteps.MakeRequest(GpConnectInteraction.AppointmentCreate);
        }
        public void SetTheJwtRequestingOrganizationWithMissingIdentifier()
        {
            var organization = FhirHelper.GetDefaultOrganization();

            organization.Identifier.Clear();

            _jwtHelper.RequestingOrganization = organization.ToFhirJson();
        }
        public void SetTheJwtRequestingPractitionerWithMissingIdentifier()
        {
            var practitioner = FhirHelper.GetDefaultPractitioner();

            practitioner.Identifier.Clear();

            _jwtHelper.SetRequestingPractitioner("1", practitioner.ToFhirJson());
        }
        public void SetTheJwtRequestingPractitionerWithMissingName()
        {
            var practitioner = FhirHelper.GetDefaultPractitioner();

            practitioner.Name = null;

            _jwtHelper.SetRequestingPractitioner("1", practitioner.ToFhirJson());
        }
        public void SetJWTRequestingOrganizationToOldURL()
        {
            var organization = FhirHelper.GetDefaultOrganization();

            organization.Identifier[0].System = FhirConst.IdentifierSystems.kOdsOrgzCodeBackwardCom;

            _jwtHelper.RequestingOrganization = organization.ToFhirJson();
        }
Esempio n. 10
0
        public HttpResponseMessage GetHistoryComplete(string resource, string id)
        {
            try
            {
                string respval               = "";
                string validResource         = FhirHelper.ValidateResourceType(resource);
                IEnumerable <string> history = storage.HistoryStore.GetResourceHistory(validResource, id);
                //Create Return Bundle
                Bundle results = new Bundle();
                results.Id    = Guid.NewGuid().ToString();
                results.Type  = Bundle.BundleType.History;
                results.Total = history.Count();
                results.Link  = new System.Collections.Generic.List <Bundle.LinkComponent>();
                results.Link.Add(new Bundle.LinkComponent()
                {
                    Url = Request.RequestUri.GetLeftPart(UriPartial.Authority), Relation = "self"
                });
                results.Entry = new System.Collections.Generic.List <Bundle.EntryComponent>();
                //Add History Items to Bundle
                foreach (string h in history)
                {
                    //todo
                    var r = (Resource)jsonparser.Parse(h, FhirHelper.ResourceTypeFromString(validResource));
                    results.Entry.Add(new Bundle.EntryComponent()
                    {
                        Resource = r, FullUrl = FhirHelper.GetFullURL(Request, r)
                    });
                }


                //Serialize and Return Bundle
                respval = SerializeResponse(results);
                var response = this.Request.CreateResponse(HttpStatusCode.OK);
                response.Headers.TryAddWithoutValidation("Accept", CurrentAcceptType);

                response.Content = new StringContent(respval, Encoding.UTF8);
                response.Content.Headers.TryAddWithoutValidation("Content-Type", IsAccceptTypeJSON ? FHIRCONTENTTYPEJSON : FHIRCONTENTTYPEXML);
                return(response);
            }
            catch (Exception e)
            {
                OperationOutcome oo = new OperationOutcome();
                oo.Issue = new System.Collections.Generic.List <OperationOutcome.IssueComponent>();
                OperationOutcome.IssueComponent ic = new OperationOutcome.IssueComponent();
                ic.Severity    = OperationOutcome.IssueSeverity.Error;
                ic.Code        = OperationOutcome.IssueType.Exception;
                ic.Diagnostics = e.Message;
                oo.Issue.Add(ic);
                var response = this.Request.CreateResponse(HttpStatusCode.BadRequest);
                response.Headers.TryAddWithoutValidation("Accept", CurrentAcceptType);
                response.Content = new StringContent(SerializeResponse(oo), Encoding.UTF8);
                response.Content.Headers.TryAddWithoutValidation("Content-Type", IsAccceptTypeJSON ? FHIRCONTENTTYPEJSON : FHIRCONTENTTYPEXML);
                response.Content.Headers.LastModified = DateTimeOffset.Now;
                return(response);
            }
        }
        public void SetTheJwtRequestingOrganizationIdentifierWithMissingOdsCode()
        {
            var organization = FhirHelper.GetDefaultOrganization();

            organization.Identifier.Clear();

            var identifier = new Identifier("http://fhir.nhs.net/Id/someOtherCodingSystem", "NoOdsCode");

            organization.Identifier.Add(identifier);

            _jwtHelper.RequestingOrganization = organization.ToFhirJson();
        }
        public void SetTheJwtRequestingPractitionerWithMissingSdsId()
        {
            var practitioner = FhirHelper.GetDefaultPractitioner();

            practitioner.Identifier.Clear();

            var identifier = new Identifier("http://IdentifierServer/RandomId", "ABC123");

            practitioner.Identifier.Add(identifier);

            _jwtHelper.SetRequestingPractitioner("1", practitioner.ToFhirJson());
        }
Esempio n. 13
0
        public async Task <HttpResponseMessage> Get(string resource, string id)
        {
            try
            {
                if (Request.Method == HttpMethod.Post)
                {
                    return(await Upsert(resource));
                }
                if (Request.Method == HttpMethod.Put)
                {
                    return(await Upsert(resource));
                }

                HttpResponseMessage response = null;
                string respval       = "";
                string validResource = FhirHelper.ValidateResourceType(resource);
                var    retVal        = await storage.LoadFHIRResource(id, validResource);

                if (retVal != null)
                {
                    respval  = SerializeResponse(retVal);
                    response = this.Request.CreateResponse(HttpStatusCode.OK);
                    response.Headers.TryAddWithoutValidation("Accept", CurrentAcceptType);
                    response.Content = new StringContent(respval, Encoding.UTF8);
                    response.Content.Headers.LastModified = retVal.Meta.LastUpdated;
                    response.Headers.Add("ETag", "W/\"" + retVal.Meta.VersionId + "\"");
                }
                else
                {
                    response         = this.Request.CreateResponse(HttpStatusCode.NotFound);
                    response.Content = new StringContent("", Encoding.UTF8);
                }
                response.Content.Headers.TryAddWithoutValidation("Content-Type", IsAccceptTypeJSON ? FHIRCONTENTTYPEJSON : FHIRCONTENTTYPEXML);
                return(response);
            } catch (Exception e)
            {
                OperationOutcome oo = new OperationOutcome();
                oo.Issue = new System.Collections.Generic.List <OperationOutcome.IssueComponent>();
                OperationOutcome.IssueComponent ic = new OperationOutcome.IssueComponent();
                ic.Severity    = OperationOutcome.IssueSeverity.Error;
                ic.Code        = OperationOutcome.IssueType.Exception;
                ic.Diagnostics = e.Message;
                oo.Issue.Add(ic);
                var response = this.Request.CreateResponse(HttpStatusCode.BadRequest);
                response.Headers.TryAddWithoutValidation("Accept", CurrentAcceptType);
                response.Content = new StringContent(SerializeResponse(oo), Encoding.UTF8);
                response.Content.Headers.TryAddWithoutValidation("Content-Type", IsAccceptTypeJSON? FHIRCONTENTTYPEJSON : FHIRCONTENTTYPEXML);
                response.Content.Headers.LastModified = DateTimeOffset.Now;
                return(response);
            }
        }
Esempio n. 14
0
        private Resource ConvertDocument(Document doc)
        {
            var obj = (JObject)(dynamic)doc;

            obj.Remove("_rid");
            obj.Remove("_self");
            obj.Remove("_etag");
            obj.Remove("_attachments");
            obj.Remove("_ts");
            var rt = (string)obj["resourceType"];
            var t  = (Resource)parser.Parse(obj.ToString(Formatting.None), FhirHelper.ResourceTypeFromString(rt));

            return(t);
        }
Esempio n. 15
0
 public HttpResponseMessage GetHistory(string resource, string id, string vid)
 {
     try
     {
         HttpResponseMessage response = null;
         string respval       = "";
         string validResource = FhirHelper.ValidateResourceType(resource);
         string item          = storage.HistoryStore.GetResourceHistoryItem(validResource, id, vid);
         if (item != null)
         {
             Resource retVal = (Resource)jsonparser.Parse(item, FhirHelper.ResourceTypeFromString(validResource));
             if (retVal != null)
             {
                 respval = SerializeResponse(retVal);
             }
             response = this.Request.CreateResponse(HttpStatusCode.OK);
             response.Headers.TryAddWithoutValidation("Accept", CurrentAcceptType);
             response.Headers.Add("ETag", "W/\"" + retVal.Meta.VersionId + "\"");
             response.Content = new StringContent(respval, Encoding.UTF8);
             response.Content.Headers.LastModified = retVal.Meta.LastUpdated;
         }
         else
         {
             response         = this.Request.CreateResponse(HttpStatusCode.NotFound);
             response.Content = new StringContent("", Encoding.UTF8);
         }
         response.Content.Headers.TryAddWithoutValidation("Content-Type", IsAccceptTypeJSON ? FHIRCONTENTTYPEJSON : FHIRCONTENTTYPEXML);
         return(response);
     } catch (Exception e)
     {
         OperationOutcome oo = new OperationOutcome();
         oo.Issue = new System.Collections.Generic.List <OperationOutcome.IssueComponent>();
         OperationOutcome.IssueComponent ic = new OperationOutcome.IssueComponent();
         ic.Severity    = OperationOutcome.IssueSeverity.Error;
         ic.Code        = OperationOutcome.IssueType.Exception;
         ic.Diagnostics = e.Message;
         oo.Issue.Add(ic);
         var response = this.Request.CreateResponse(HttpStatusCode.BadRequest);
         response.Headers.TryAddWithoutValidation("Accept", CurrentAcceptType);
         response.Content = new StringContent(SerializeResponse(oo), Encoding.UTF8);
         response.Content.Headers.TryAddWithoutValidation("Content-Type", IsAccceptTypeJSON? FHIRCONTENTTYPEJSON : FHIRCONTENTTYPEXML);
         response.Content.Headers.LastModified = DateTimeOffset.Now;
         return(response);
     }
 }
        public void CreateAnAppointmentForPatientAndOrganizationCode(string patient, string code)
        {
            _patientSteps.GetThePatientForPatientValue(patient);
            _patientSteps.StoreThePatient();

            _searchForFreeSlotsSteps.GetAvailableFreeSlots();
            _searchForFreeSlotsSteps.StoreTheFreeSlotsBundle();

            _httpSteps.ConfigureRequest(GpConnectInteraction.AppointmentCreate);
            Organization changed = FhirHelper.GetDefaultOrganization();

            changed.Identifier.First().Value = GlobalContext.OdsCodeMap[code];
            _httpSteps.jwtHelper.RequestingOrganization = changed.ToFhirJson();

            CreateAnAppointmentFromTheStoredPatientAndStoredSchedule();

            _httpSteps.MakeRequest(GpConnectInteraction.AppointmentCreate);
        }
Esempio n. 17
0
        public async Task <HttpResponseMessage> Get(string resource)
        {
            string respval = null;

            if (Request.RequestUri.AbsolutePath.ToLower().EndsWith("metadata"))
            {
                respval = SerializeResponse(FhirHelper.GenerateCapabilityStatement());
            }
            else
            {
                NameValueCollection nvc = HttpUtility.ParseQueryString(Request.RequestUri.Query);
                string query            = FhirParmMapper.Instance.GenerateQuery(storage, resource, nvc);
                var    retVal           = await storage.QueryFHIRResource(query, resource);

                Bundle results = new Bundle();
                results.Id    = Guid.NewGuid().ToString();
                results.Type  = Bundle.BundleType.Searchset;
                results.Total = retVal.Count();
                results.Link  = new System.Collections.Generic.List <Bundle.LinkComponent>();
                results.Link.Add(new Bundle.LinkComponent()
                {
                    Url = Request.RequestUri.AbsoluteUri, Relation = "self"
                });
                results.Entry = new System.Collections.Generic.List <Bundle.EntryComponent>();
                foreach (Resource p in retVal)
                {
                    results.Entry.Add(new Bundle.EntryComponent()
                    {
                        Resource = p
                    });
                }

                if (retVal != null)
                {
                    respval = SerializeResponse(results);
                }
            }
            var response = this.Request.CreateResponse(HttpStatusCode.OK);

            response.Content = new StringContent(respval, Encoding.UTF8, CurrentAcceptType);
            return(response);
        }
Esempio n. 18
0
        public HttpResponseMessage GetHistoryComplete(string resource, string id)
        {
            var history = storage.HistoryStore.GetResourceHistory(resource, id);
            //Create Return Bundle
            var results = new Bundle
            {
                Id    = Guid.NewGuid().ToString(),
                Type  = Bundle.BundleType.History,
                Total = history.Count(),
                Link  = new List <Bundle.LinkComponent>
                {
                    new Bundle.LinkComponent
                    {
                        Url      = Request.RequestUri.GetLeftPart(UriPartial.Authority),
                        Relation = "self"
                    }
                },
                Entry = new List <Bundle.EntryComponent>()
            };

            //Add History Items to Bundle
            foreach (var h in history)
            {
                //todo
                var r = (Resource)jsonparser.Parse(h, FhirHelper.ResourceTypeFromString(resource));
                results.Entry.Add(new Bundle.EntryComponent {
                    Resource = r, FullUrl = FhirHelper.GetFullUrl(Request, r)
                });
            }


            //Serialize and Return Bundle
            var respval  = SerializeResponse(results);
            var response = Request.CreateResponse(HttpStatusCode.OK);

            response.Headers.TryAddWithoutValidation("Accept", CurrentAcceptType);

            response.Content = new StringContent(respval, Encoding.UTF8);
            response.Content.Headers.TryAddWithoutValidation("Content-Type",
                                                             IsAccceptTypeJson ? Fhircontenttypejson : Fhircontenttypexml);
            return(response);
        }
Esempio n. 19
0
        public HttpResponseMessage GetHistory(string resource, string id, string vid)
        {
            HttpResponseMessage response = null;
            string respval = "";
            string item    = storage.HistoryStore.GetResourceHistoryItem(resource, id, vid);

            if (item != null)
            {
                Resource retVal = (Resource)jsonparser.Parse(item, FhirHelper.ResourceTypeFromString(resource));
                if (retVal != null)
                {
                    respval = SerializeResponse(retVal);
                }
                response         = this.Request.CreateResponse(HttpStatusCode.OK);
                response.Content = new StringContent(respval, Encoding.UTF8, CurrentAcceptType);
            }
            else
            {
                response = this.Request.CreateResponse(HttpStatusCode.NotFound);
            }
            return(response);
        }
 public void SetTheJwtRequestingDeviceAsAnInvalidDevice()
 {
     _jwtHelper.RequestingDevice = FhirHelper.AddInvalidFieldToResourceJson(FhirHelper.GetDefaultDevice().ToFhirJson());
 }
        public void GivenISetAMedicationsTimeAParameterStartDateToAndEndDateTo(string startDate, string endDate)
        {
            IEnumerable <Tuple <string, Base> > tuples = new Tuple <string, Base>[] {
                Tuple.Create(FhirConst.GetStructuredRecordParams.kPrescriptionIssues, (Base) new FhirBoolean(false)),
                Tuple.Create(FhirConst.GetStructuredRecordParams.kMedicationDatePeriod, (Base)FhirHelper.GetTimePeriod(startDate, endDate))
            };

            _httpContext.HttpRequestConfiguration.BodyParameters.Add(FhirConst.GetStructuredRecordParams.kMedication, tuples);
        }
 public void SetTheJwtRequestingPractitionerResourceTypeAsAnInvalidResourceType()
 {
     _jwtHelper.SetRequestingPractitioner(_jwtHelper.RequestingIdentityId, FhirHelper.ChangeResourceTypeString(_jwtHelper.RequestingIdentity, FhirConst.Resources.kInvalidResourceType));
 }
 public void SetTheJwtRequestingPractitionerWithUserIdNotMatching()
 {
     _jwtHelper.SetRequestingPractitioner("2", FhirHelper.GetDefaultPractitioner().ToFhirJson());
 }
Esempio n. 24
0
        public async Task <HttpResponseMessage> Get(string resource)
        {
            string respval;

            if (Request.RequestUri.AbsolutePath.ToLower().EndsWith("metadata"))
            {
                respval = SerializeResponse(FhirHelper.GenerateCapabilityStatement(Request.RequestUri.AbsoluteUri));
            }
            else
            {
                var nvc        = HttpUtility.ParseQueryString(Request.RequestUri.Query);
                var id         = nvc["_id"];
                var nextpage   = nvc["_nextpage"];
                var count      = nvc["_count"] ?? "100";
                var querytotal = nvc["_querytotal"] ?? "-1";
                IEnumerable <Resource> retVal;
                ResourceQueryResult    searchrslt = null;
                int iqueryTotal;
                if (string.IsNullOrEmpty(id))
                {
                    var query = FhirParmMapper.Instance.GenerateQuery(storage, resource, nvc);
                    searchrslt =
                        await storage.QueryFhirResourceAsync(query, resource, int.Parse(count), nextpage, long.Parse(querytotal)).
                        ConfigureAwait(false);

                    retVal      = searchrslt.Resources;
                    iqueryTotal = (int)searchrslt.Total;
                }
                else
                {
                    retVal = new List <Resource>();
                    var r = await storage.LoadFhirResourceAsync(id, resource).ConfigureAwait(false);

                    if (r != null)
                    {
                        ((List <Resource>)retVal).Add(r);
                    }
                    iqueryTotal = retVal.Count();
                }

                var baseurl = Request.RequestUri.Scheme + "://" + Request.RequestUri.Authority + "/" + resource;
                var results = new Bundle
                {
                    Id    = Guid.NewGuid().ToString(),
                    Type  = Bundle.BundleType.Searchset,
                    Total = iqueryTotal,
                    Link  = new List <Bundle.LinkComponent>()
                };
                var qscoll = Request.RequestUri.ParseQueryString();
                qscoll.Remove("_count");
                qscoll.Remove("_querytotal");
                qscoll.Add("_querytotal", searchrslt.Total.ToString());
                qscoll.Add("_count", count);

                results.Link.Add(new Bundle.LinkComponent {
                    Url = baseurl + "?" + qscoll, Relation = "self"
                });

                if (searchrslt.ContinuationToken != null)
                {
                    qscoll.Remove("_nextpage");
                    qscoll.Add("_nextpage", searchrslt.ContinuationToken);
                    results.Link.Add(new Bundle.LinkComponent {
                        Url = baseurl + "?" + qscoll, Relation = "next"
                    });
                }

                results.Entry = new List <Bundle.EntryComponent>();
                var match = new Bundle.SearchComponent {
                    Mode = Bundle.SearchEntryMode.Match
                };
                var include = new Bundle.SearchComponent {
                    Mode = Bundle.SearchEntryMode.Include
                };
                foreach (var p in retVal)
                {
                    results.Entry.Add(new Bundle.EntryComponent
                    {
                        Resource = p,
                        FullUrl  = FhirHelper.GetFullUrl(Request, p),
                        Search   = match
                    });
                    var includes = await FhirHelper.ProcessIncludesAsync(p, nvc, storage).ConfigureAwait(false);

                    foreach (var r in includes)
                    {
                        results.Entry.Add(new Bundle.EntryComponent
                        {
                            Resource = r,
                            FullUrl  = FhirHelper.GetFullUrl(Request, r),
                            Search   = include
                        });
                    }
                }

                respval = SerializeResponse(results);
            }

            var response = Request.CreateResponse(HttpStatusCode.OK);

            response.Headers.TryAddWithoutValidation("Accept", CurrentAcceptType);

            response.Content = new StringContent(respval, Encoding.UTF8);
            response.Content.Headers.TryAddWithoutValidation("Content-Type",
                                                             IsAccceptTypeJson ? Fhircontenttypejson : Fhircontenttypexml);
            return(response);
        }
 public void SetTheJwtRequestingPractitionerAsAnInvalidPractitioner()
 {
     _jwtHelper.SetRequestingPractitioner("1", FhirHelper.AddInvalidFieldToResourceJson(FhirHelper.GetDefaultPractitioner().ToFhirJson()));
 }
 public void SetTheJwtRequestingOrganizationResourceTypeAsAnInvalidResourceType()
 {
     _jwtHelper.RequestingOrganization = FhirHelper.ChangeResourceTypeString(_jwtHelper.RequestingOrganization, FhirConst.Resources.kInvalidResourceType);
 }
Esempio n. 27
0
        public async Task <Hl7.Fhir.Model.Resource> LoadFHIRResource(string identity, string resourceType)
        {
            if (!_initTask.IsCompleted)
            {
                await _initTask;
            }
            await CreateDocumentCollectionIfNotExists(DBName, resourceType);

            var result = await LoadFHIRResourceObject(DBName, resourceType, identity);

            if (result == null)
            {
                return(null);
            }

            var retVal = (JObject)(dynamic)result;
            var t      = parser.Parse(retVal.ToString(Newtonsoft.Json.Formatting.None), FhirHelper.ResourceTypeFromString(resourceType));

            return((Hl7.Fhir.Model.Resource)t);
        }
Esempio n. 28
0
        public async Task <IEnumerable <Hl7.Fhir.Model.Resource> > QueryFHIRResource(string query, string resourceType)
        {
            if (!_initTask.IsCompleted)
            {
                await _initTask;
            }
            List <Hl7.Fhir.Model.Resource> retVal = new List <Hl7.Fhir.Model.Resource>();

            try
            {
                await CreateDocumentCollectionIfNotExists(DBName, resourceType);

                var found = client.CreateDocumentQuery <JObject>(UriFactory.CreateDocumentCollectionUri(DBName, resourceType),
                                                                 query).AsEnumerable();

                foreach (JObject obj in found)
                {
                    retVal.Add((Hl7.Fhir.Model.Resource)parser.Parse(obj.ToString(Newtonsoft.Json.Formatting.None), FhirHelper.ResourceTypeFromString(resourceType)));
                }
                return(retVal);
            }
            catch (Exception de)
            {
                Trace.TraceError("Error querying resource type: {0} Query: {1} Message: {2}", resourceType, query, de.Message);
                throw;
            }
        }
 public void SetTheJwtRequestingOrganizationAsAnInvalidOrganization()
 {
     _jwtHelper.RequestingOrganization = FhirHelper.AddInvalidFieldToResourceJson(FhirHelper.GetDefaultOrganization().ToFhirJson());
 }
 public void SetTheJwtRequestingDeviceResourceTypeAsAnInvalidResourceType()
 {
     _jwtHelper.RequestingDevice = FhirHelper.ChangeResourceTypeString(_jwtHelper.RequestingDevice, FhirConst.Resources.kInvalidResourceType);
 }