I'm converting my code to FHIR STU3 and I'm trying to get the Organization Resource referenced by a List.entry[x].item.reference by calling getItemTarget() on the ListEntryComponent, but it always returns NULL although the resource is there (see if (organizations.get(i).getItemTarget())
). What can be wrong?
Here is part of the code I'm using:
if (entries0.get(e).getReference().equals("List/g1")) {
//get the organizations list
var organizations = entries0.get(e).getResource().getEntry();
for (var i = 0; i < organizations.size(); i++) {
var orgReference = organizations.get(i).getItem();
if (orgReference.hasReference()) {
//if the reference resolves, Organization.type must be present
if (organizations.get(i).getItemTarget() &&
organizations.get(i).getItemTarget().getResourceType() == fhirPackageStruct.ResourceType.Organization) {
list1OrgTypeSystem = organizations.get(i).getItemTarget().getTypeFirstRep().getCodingFirstRep().getSystem().equals("http://spms.min-saude.pt/pds/codings/nn_organization_types");
throwIfTrue(!list1OrgTypeSystem,'Composition.section[0].entry['+e+'].entry['+i+'].item ' + orgReference.getReference(), "INVALID Organization.type.system. Expected: http://spms.min-saude.pt/pds/codings/nn_organization_types");
}
else {
throw 'srcTransf validateNNDocumentProfile: não foi encontrado o recurso referenciado por ' + orgReference.getReference() + ' da lista de instituições de seguimento da grávida.';
}
orgReference = orgReference.getReference().toLowerCase();
}
if (orgReference.equals("organization/hospital")) {
section0HospMotive = organizations.get(i).getItemTarget().getExtension().isEmpty();
throwIfTrue(section0HospMotive,'Composition.section[0].entry['+e+'].entry['+i+'].item (Organization/Hospital)', "MISSING FOLLOWUP MOTIVE EXTENSION");
}
}
}
Can you please help me? Thank you!!
The getFOOTarget()
methods are a bit confusing, they aren't actually used and will probably be removed.
You need to replace getItemTarget()
with getItem().getResource()