Stream: dotnet
Topic: Navigate to reference elements
Santosh Jami (Sep 19 2017 at 19:56):
I have DiagnosticReport, and Observations are added as ResourceReferences and Patient is added as reference in the Subject. If I need to load the Observations, should I navigate to Observation element which is stored in DB as 'Observation/spark156', substring for the logical id and do a SearchById for the Observation? Is there a better way? I am using Spark server DSTU2.
Thanks
Santosh Jami
Yunwei Wang (Sep 19 2017 at 20:02):
Are you using .NET FhirClient?
Santosh Jami (Sep 19 2017 at 20:26):
Yes, using .NET FhirCLient
Yunwei Wang (Sep 19 2017 at 21:02):
var obs = client.Read<Observation>("Observation/spark156");
Santosh Jami (Sep 19 2017 at 21:17):
Thanks - that works for me.
Here was my code:
foreach (ResourceReference observationReference in fhirDiagnosticReport.Result)
{
SearchParams qObs = new SearchParams();
qObs.Add("uri", observationReference.ReferenceElement.ToString());
qObs.Add("_sort:desc", "_lastUpdated");
var searchResult1 = fhirClient.Search<Observation>(qObs);//http://localhost:8091/spark/fhir/Observation/spark156
var searchResult2 = fhirClient.Read<Observation>(qObs);
var searchResult3= fhirClient.Read<Observation>("Observation/spark156");
}
searchResult2 and searchResult3 got me the expected output.
searchResult1 put me off - it gave me the searchBundle with few different entries including the 1 I got as part of searchResult2 and searchResult3. And those entries didn't have anything common with "Observation/spark156". May be I am overlooking something.
But, I am able to read my Observation resource using Read operation as suggested by @Yunwei
Last updated: Apr 12 2022 at 19:14 UTC