Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contained resource IDs are getting prepended with "#", causing downstream usage of domainResource.getContained(reference) to fail #6612

Open
mattStorer opened this issue Jan 10, 2025 · 1 comment

Comments

@mattStorer
Copy link

Describe the bug
Java Spring Boot application using spring-boot-starter-parent version 3.4.1, and employing HAPI FHIR libraries at version 7.6.1 on a Windows 11 PC using Java 17.

Testing ability to retrieve a contained resource, but calls to DomainResource.getContained(reference) are failing when they should not.

This screenshot illustrates that mr.getMedicationReference().getReference() is #medication-MBS-Test1-1, and that the contained resource, available at mr.getContained().get(0), also has an id of #medication-MBS-Test1-1. They both are prepended with a #.

image

However, the source JSON that is used to build these objects is not the same. This is a screenshot showing the id element on the contained Medication resource, which as we can see does not include a # prefix:

image

So, somewhere between ingesting the resource and processing it, a # is getting prepended onto the contained resource's id field. At least, that's what appears to be happening.

As such, when logic gets into getContained(reference), that logic in there is not expecting the contained resource's id to have a # prefix already on it, which it dutifully appends to perform a string match. But it really shouldn't do that in this case, and is causing the call to always return null:

image

Finally, here's the state of things after returning from the call to getContained(reference):

image

To Reproduce
Steps to reproduce the behavior:

  1. Import these FHIR resources into a sandbox of your choice:

MBS-Test1-Patient.json
MBS-Test1-MedicationRequestWithContainedMedication.json

  1. Attempt to retrieve the contained Medication from the MedicationRequest resource using medicationRequest.getContained(medicationRequest.getMedicationReference().getReference())

Expected behavior
The call to getContained(reference) should return the referenced resource.

Screenshots
See above

Environment (please complete the following information):

  • HAPI FHIR: Version 7.6.1
  • OS: Windows 11
  • Browser: Firefox 134
  • Java: OpenJDK 17

Additional context
None

@dotasek
Copy link
Contributor

dotasek commented Jan 14, 2025

This is the same issue as #6514

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants