Stream: implementers
Topic: Get referenced resource
Patricia Alves (May 17 2017 at 11:38):
Hi, sorry for my noob question, but I can't understand, in the new STU3 API, how to get a Resource referenced by the elements in the List<Reference> returned by Composition.SectionComponent.getEntry() .
(see http://hapifhir.io/apidocs-dstu3/org/hl7/fhir/dstu3/model/Composition.SectionComponent.html).
Thanks in advance!
Lloyd McKenzie (May 17 2017 at 15:34):
Can you explain your question further? Are you trying to retrive them with a query? Use one of the reference implementations?
Patricia Alves (May 17 2017 at 15:54):
I'm using HAPI FHIR STU3 and I'm trying to build the code to get a Resource referenced by the elements in the List<Reference> returned by Composition.SectionComponent.getEntry(). For example:
Suppose I have this code:
. . .
var composition = docBundle.getEntryFirstRep().getResource(); var sections = composition.getSection(); var entries0 = sections.get(0).getEntry(); //entries in composition section 0 for (var e = 0; e < entries0.size(); e++) { if (entries0.get(e).getReference().equals("List/g1")) { var organizations = entries0.get(e).getResource().getEntry(); } }
. . .
"List/g1" is a ListResource that has 5 items in the entry array that reference an Organization.
I want to get the content of the referenced Organization resources. I tried this, but it returns"null":
. . .
organizations.get(i).getItemTarget();
. . .
UPDATE: can I send you an attachment with the message and code I'm trying to validate?
Lloyd McKenzie (May 17 2017 at 16:36):
@James Agnew ?
James Agnew (May 18 2017 at 10:07):
The getFooTarget()
methods don't do anything in HAPI. @Grahame Grieve do you use these at all? If not, we should remove them because they tend to confuse people. There is a corresponding field in Reference so I believe they are ust a duplicate.
Patricia, I'm still not totaly clear what you're trying to do. overall.. but assuming you have fetched a composition from a server and now want to discover what resources are in a list in that composition, you want to be calling getItem()
instead of getItemTarget()
and using the methods on that.
Patricia Alves (May 18 2017 at 10:17):
Thank you James! So I can call getItem().getResource() to the get the referenced Resource. getItemTarget() really confused me. Thanks for your help! Please ignore the other topic I posted (ListResource.ListEntryComponent.getItemTarget() not working), I can't delete it.
Grahame Grieve (May 18 2017 at 10:19):
@James Agnew they're not quite just a duplicate because the one in reference is not typed. I had originally used the one in the reference, but moved it out to a sibling to get typed references where appropriate
Grahame Grieve (May 18 2017 at 10:20):
but I don't think I use them much - could use the one on reference.... just have to type cast more
Last updated: Apr 12 2022 at 19:14 UTC