Stream: implementers
Topic: Search Location using partOf
Reham Muzzamil (Jul 26 2021 at 07:53):
Hi, I have few queries regarding the Location search API:
1) I want to get all root locations having partOf as empty or null. But when I query using partOf as null, it treats it as a string and does not bring out any records. I understand that partOf should be a valid Location reference or we could also pass an empty string.
2) When I pass an empty partOf param, it throws an error that an id part can not be null. I was wondering how this can be handled to get those records having an empty or null partOf params.
3) I also think the inability to query on a null value sounds like a general limitation for any resource. Can anyone please confirm this?
Thanks!
Lloyd McKenzie (Jul 26 2021 at 14:35):
You can't have empty or null partOf (or anything) in FHIR. If you don't have a value for an element, you omit the element entirely. You can query for missing elements using the :missing
qualifier. E.g. Location?partof:missing=true
should work.
Reham Muzzamil (Jul 27 2021 at 11:56):
Thanks for your prompt response.
I have tested using Location?partof:missing=true it throws an exception of "The validated expression is false" since it fails the validation of Validate.isTrue(id.hasIdPart());
I am not sure, may be I am missing something.
Lloyd McKenzie (Jul 27 2021 at 13:04):
Are you saying the instance fails validation or the profile fails validation?
Reham Muzzamil (Jul 28 2021 at 07:28):
Thanks, Lloyd.
I am not actually running a validator standalone/or via code. Rather I just hit the end-point of Search Location with the :missing
qualifier. And the API throws an exception The validated expression is false
. On debugging I have figured out that there is a validation written inside the class IdHelperService
that checks if id has a valid idPart, if not it throws an exception. I believe the logic is centralized for all the resource providers as it will be called when creating a predicate. Since partOf
is of Reference dataType it verifies that the id part can not be null.
Mirjam Baltus (Jul 28 2021 at 13:08):
It sounds like your endpoint does not support the :missing
modifier. Maybe you can reach out to the #hapi stream to get guidance on how to implement that.
Lloyd McKenzie (Jul 28 2021 at 13:41):
partOf can't be empty
Lloyd McKenzie (Jul 28 2021 at 13:42):
It can be omitted entirely. :missing will check that it's been omitted entirely.
Reham Muzzamil (Jul 29 2021 at 07:36):
Sure, Thanks!
Last updated: Apr 12 2022 at 19:14 UTC