hapifhir / hapi-fhir

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

Support for searching for Observation?subject:identifier #2916

Open bmilius-nmdp opened 3 years ago

bmilius-nmdp commented 3 years ago

According to https://www.hl7.org/fhir/search.html#reference I should be able to search for Observations with a subject where the reference is only an identifier, e.g.,

"subject": {
    "identifer": {
        "system": "http://acme.org/fhir/identifier/mrn",
        "value": "123456"
    }
}

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

"The modifier :identifier allows for searching by the identifier rather than the literal reference"

As far as I can tell, this is not supported in HAPI.

We could really use this capability.

tadgh commented 3 years ago

Just checking, does this search work for you? Wondering if chaining resolves this issue or not.

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

Maybe this can hold you over if it does work, until the :identifier qualifier is implemented.

bmilius-nmdp commented 3 years ago

Thanks, but no. The Patient resource doesn't exist so nothing is returned. We prefer to use the subject.identifier in the Observation so the sender doesn't have to know the reference id when sending us data.

tadgh commented 3 years ago

Understood. Could you do me a favour and provide me some sample observations or other resources you would like to work with which contain this identifier-only reference, in full? This may not be too painful to implement.

bmilius-nmdp commented 3 years ago
{
    "resourceType": "Observation",
    "status": "final",
    "category": [
        {
            "coding": [
                {
                    "system": "http://terminology.hl7.org/CodeSystem/observation-category",
                    "code": "vital-signs",
                    "display": "Vital Signs"
                }
            ],
            "text": "Vital Signs"
        }
    ],
    "code": {
        "coding": [
            {
                "system": "http://loinc.org",
                "code": "9279-1",
                "display": "Respiratory rate"
            }
        ],
        "text": "Respiratory rate"
    },
    "subject": {
        "identifier": {
            "system": "http://example.org/identifier",
            "value": "1234567"
        }
    },
    "effectiveDateTime": "1999-07-02",
    "valueQuantity": {
        "value": 26,
        "unit": "breaths/minute",
        "system": "http://unitsofmeasure.org",
        "code": "/min"
    }
}
tadgh commented 3 years ago

Thanks! I've actually never seen anybody just put a sole identifier in a reference field. TIL this was possible

bmilius-nmdp commented 3 years ago

btw, there's a thread about this on chat.fhir.org https://chat.fhir.org/#narrow/stream/179167-hapi/topic/searching.20for.20subject.3Aidentifier

tadgh commented 3 years ago

This isn't exactly what you are after, but something that may hold you over is using the Auto Create placeholder references by Identifier feature. An example usage is detailed here: https://smilecdr.com/docs/fhir_repository/creating_data.html#auto-create-placeholder-reference-targets-with-identifier. (Sorry for the smile link, it was just the first one i could find). HAPI FHIR supports these settings.

While it won't let you execute your subject:identifier search, what it would do is create a placholder patient with that MRN id, and point the subject to that reference. Then you could search using a chain as normal. Obviously this is non-optimal, but may hold you over until this gets implemented.

bmilius-nmdp commented 3 years ago

Thanks. I'll take a look at it.

bmilius-nmdp commented 3 years ago

Is there an open test HAPI server that has implemented the auto create placeholder? I'd like to play with it without spinning up a test server.

tadgh commented 3 years ago

I have DMed you on zulip with credentials to a box that has this enabled.