Skip to content

[XDS-MHD conversion] cannot retrieve contained resources #334

@jalbadri

Description

@jalbadri

Using HAPI-FHIR and Husky, I am creating FHIR bundles with contained resources.

Contained resources now seems to be referenced with "#" character prepended :

FHIR Contained References
Example
HAPI FHIR Contained References

This disrupts the usage of the "findResource" function which only compares the ids of the contained resources and the reference of that resource.

    /**
     * search a referenced resource from a list of (contained) resources.
     *
     * @param ref       the desired reference
     * @param contained the list of resources
     * @return the resource corresponding to the reference if available
     */
    @Nullable
    public static Resource findResource(final Reference ref,
                                        final List<Resource> contained) {
        return contained.stream()
                .filter(r -> r.getId().equals(ref.getReference()))
                .findFirst()
                .orElse(null);
    }

An example of this is a reference with "#Medication123" compared to "Medication123". As we can see, although the reference seems to point at the right contained resource, the wanted resource is not retrieved.

The function is located here : husky-communication -> husky-xds-mhd-conversion -> utils -> ConverterUtils -> findResource

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions