hapifhir / hapi-fhir

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

`_list` parameter ignored in the search #3761

Closed oxabz closed 9 months ago

oxabz commented 2 years ago

The bug The FHIR RESTfull API returns resources that are not contained in the List/Group specified in the _list field. From what I've read, even if the _list search parameter isn't in the doc, it was added on the 5.4.0 release.

To Reproduce Steps to reproduce the behavior:

  1. Create a List containing some resouces
  2. Search the resources with _list

Expected behavior Expected the API to respond with a bundle containing exclusively resources member of list

Environment (please complete the following information):

tevariou commented 2 years ago

Related pr: https://github.com/hapifhir/hapi-fhir/pull/2421/files/3b60034a080ce7a4f05c8141264295273075274a#diff-522de37509c439428e5f5a5215a5a160b27f63f028e7b51581d2fef2b573b302

Using ?_has:List:item:_id=<list_id> seems to work fine though

sidharthramesh commented 1 year ago

Can confirm that this issue also exists in v6.0.1

flowrider3000 commented 1 year ago

Search requests containing "_list" are still broken on "HAPI FHIR Server (see https://hapi.fhir.org/baseR4)" in version "6.9.3-SNAPSHOT/c8dc410d98/2023-08-17".

Is there any roadmap for the fix?

jkiddo commented 10 months ago

It's still an issue. I've added a test case here: https://github.com/hapifhir/hapi-fhir-jpaserver-starter/compare/master...jkiddo:hapi-fhir-jpaserver-starter:bug/missing-list-evaluation

It should have been evaluated here: https://github.com/hapifhir/hapi-fhir/blob/a491c30aed514bef8ff39895cd8b715a534f7976/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java#L1966 but it is never reached as e.g. the resourceprovider here https://hapifhir.io/hapi-fhir/apidocs/hapi-fhir-jpaserver-base/src-html/ca/uhn/fhir/jpa/rp/r4/OrganizationResourceProvider.html#line-29 does not parse the ca.uhn.fhir.rest.api.Constants.PARAM_LIST. If that is added to the search provider the _list is parsed but then you will encounter a ConcurrentModificationException on https://github.com/hapifhir/hapi-fhir/blob/a491c30aed514bef8ff39895cd8b715a534f7976/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java#L1971 due to the way the values are accessed https://stackoverflow.com/questions/16180568/concurrentmodificationexception-with-linkedhashmap