Search code examples
hl7-fhir

Can I have two modifiers in the same request parameter?


We are trying to create a @Search method in a FHIR Server to look for all the observations from a Patient. I have seen that the parameter can be subject or patient. We want that you could look for a Patient by Identifier, so the request should be something like this:

GET [base]/Observation?subject:identifier=http://acme.org/fhir/identifier/mrn|123456

or

GET [base]/Observation?patient:identifier=http://acme.org/fhir/identifier/mrn|123456

Our problem is that we only have Patient Identifiers with type. In order to look for a Patient by Identifier with type, you have to add the modifier :of-type. My question is, is correct to have a request with two modifiers? Just like the example below

GET [base]/Observation?patient:identifier:of-type=http://terminology.hl7.org/CodeSystem/v2-0203|MR|446053


Solution

  • Modifiers modify the default search behaviour, not the filter that you want to put on the resource type. You can only use modifier specified by FHIR. They are listed on this page: http://hl7.org/fhir/search.html.

    Your first two searches above are not valid. In order to search Observations based on a patient's identifier, you would have to do a chained search:

    GET [base]/Observation?patient.identifier=http://acme.org/fhir/identifier/mrn|123456

    This is a shortcut for 'subject' with a resource type modifier:

    GET [base]/Observation?subject:Patient.identifier=http://acme.org/fhir/identifier/mrn|123456

    If you need to incorporate the 'of-type' modifier, the search could look like this:

    GET [base]/Observation?patient.identifier:of-type=[codesystem_for_type]|MR|123456

    I prefer to use the 'patient' parameter whenever applicable, but it would also be valid to do subject:Patient.identifier:oftype. Edit to add: for now it is valid, but see Lloyd's answer for future FHIR versions.