Stream: implementers
Topic: Read Observations on a Patient
Chris Meeusen (May 01 2017 at 17:43):
Not sure how to use this API to get all observations on a given patient. Tried this:
var loc = new Uri(FhirClient.Endpoint + string.Format("/Observation?patient={0}", patId)); var obs = FhirClient.Read<Observation>(loc);
and i've tried this:
var obs = FhirClient.Read<Observation>(string.Format("patient={0}",patId));
both return this:
<ExceptionMessage>
Must be a FHIR REST url containing the resource type in its path Parameter name: location
</ExceptionMessage>
<ExceptionType>System.ArgumentException</ExceptionType>
<StackTrace>
at Hl7.Fhir.Rest.FhirClient.verifyResourceIdentity(Uri location, Boolean needId, Boolean needVid) at Hl7.Fhir.Rest.FhirClient.Read
can someone point me in the right direction?
Chris Meeusen (May 01 2017 at 17:54):
getting this Additional information: Must be a FHIR REST url containing the resource type in its path
when i change the code to this:
var obs = FhirClient.Read<Observation>("Observation");
I'm just trying to get a list of observations for a given patient.
Thanks
Yunwei Wang (May 01 2017 at 18:11):
You should use FhirClient.Search<Observation>(string.Format("patient={0}",patId));
Chris Meeusen (May 01 2017 at 18:17):
Just to be clear I have this query i can run in postman and it pulls back what i want:
https://api.hspconsortium.org/mysandboxidhere/data/Observation?patient=SMART-1288992
And all I'm trying to do is execute that with this api.
var obs =FhirClient.Search<Observation>(new string[] { string.Format("Observation?patient={0}",patId) });
returns this error message:
Operation was unsuccessful, and returned status NotAcceptable. OperationOutcome: Overall result: FAILURE (1 errors and 0 warnings) [ERROR] (no details)(further diagnostics: Endpoint returned a body with contentType 'text/html', while a valid FHIR xml/json body type was expected. Is this a FHIR endpoint?)
Yunwei Wang (May 01 2017 at 18:48):
Have you got authentication in your query? When I access that link directly, I got error: Full authentication is required to access this resourceunauthorized
Chris Meeusen (May 01 2017 at 18:50):
You're correct I had a flaw in my code, I wasn't setting the access_token.
var obs =FhirClient.Search<Observation>(new string[] { string.Format("patient={0}",patId) });
seems to work, thanks!
Last updated: Apr 12 2022 at 19:14 UTC