hapifhir / hapi-fhir

🔥 HAPI FHIR - Java API for HL7 FHIR Clients and Servers
http://hapifhir.io
Apache License 2.0
2k stars 1.31k forks source link

Recursive revincludes don't work #2640

Open jarimayenburg opened 3 years ago

jarimayenburg commented 3 years ago

Describe the bug When searching for resource A, _include-ing a reference in resource A to resource B and _revinclude-ing a reference from resource C to resource B (with recurse, so _revinclude:recurse=C:b), no resource C is included in the result.

To Reproduce Steps to reproduce the behavior:

  1. For example, run GET http://hapi.fhir.org/baseDstu3/Observation?_id=2808483&_include=Observation:context&_revinclude:recurse=MedicationRequest:context.
  2. Observe that no MedicationRequest is included in the response.
  3. Run GET http://hapi.fhir.org/baseDstu3/MedicationRequest?context=Encounter/2780427 and observe that a MedicationRequest does exist with a reference to an Encounter included in the first request.

Expected behavior We would expect the MedicationRequest to be included in the first response.

Environment (please complete the following information):

Additional context Add any other context about the problem here.

jarimayenburg commented 3 years ago

Related conversation: https://groups.google.com/g/hapi-fhir/c/evjXFFNkzfE/m/ob9ztFgbCAAJ.

As suggested in this conversation, I have tried to add the :recurse to the first _include, but that doesn't fix it.

smilenannan commented 2 years ago

@jarimayenburg I am having the same issue for HAPI FHIR Version: 5.7.0. Did you already fix this issue?

jarimayenburg commented 2 years ago

@smilenannan Not yet, I'm afraid this one is a bit above my pay grade in terms of HAPI knowledge.

For now, we worked around the issue with a separate search on the other expected resource type. Performance isn't great though.

tadgh commented 2 years ago

Hey all, I'm happy to have a look into this, if you could provide me with the 3 sample resources mentioned in the original bug (the obs, the context, and the medication request) I can write a test to replicate it.

jarimayenburg commented 2 years ago

He @tadgh, that would be great! You can request the sample resources from the public HAPI FHIR test server here: http://hapi.fhir.org/baseDstu3/Observation/2808483 http://hapi.fhir.org/baseDstu3/Encounter/2780427 http://hapi.fhir.org/baseDstu3/MedicationRequest/2780433

mkaehlershs commented 2 months ago

In HAPI v6.8.3 (and properbly also in earlier versions) you can use '_revinclude:iterate= ' . This works recursively. But I noticed, '_revinclude:recurse=' also works. So I think the bug could be closed.