Search code examples
azurehl7-fhirazure-health-data-services

How to write expression in custom search parameter for retrieving claim resource based on diagnosis code?


I am using Azure Health Data Services - FHIR service

In FHIR Claim resource, we have diagnosis property. Inside the diagnosis property --> diagnosisCodeableConcept --> code.

Now I want to create a custom search parameter to retrieve claim resources based on Code value inside diagnosis property.

What should be the value in expression property of custom search parameter?

Can you please provide the Custom search parameter for the above?

I gave the following expression value: Claim.diagnosisCodeableConcept.code. But I am getting 424 Failed dependency. What is the reason for this?


Solution

  • If you check the R4 specification for Claim you'll note that the correct path to the diagnosis is:

    Claim.diagnosis.trace('d').diagnosis
    

    :test_tube: Test with FHIRPath-Lab

    I hope you've defined the search parameter as a token type, which creates indexes on CodeableConcept types. You likely don't need to cast down to the type as the search engine will handle that anyway.

    You don't also drill into the coding.code as the search indexer knows how to process the type, and it also permits the usage of the codesystem prefix on the search too

    e.g.

    Claim?diagnosis=http://hl7.org/fhir/sid/icd-10|G89.4
    

    Edit: Try this search parameter

    {
        "resourceType": "SearchParameter",
        "id": "claim-diagnosis",
        "url": "http://example.org/SearchParameter/claim-diagnosis",
        "version": "0.1",
        "name": "ClaimDiagnosis",
        "status": "active",
        "date": "2023-09-10",
        "publisher": "Brian Postlethwaite",
        "description": "Claim diagnosis",
        "code": "diagnosis",
        "base": [
            "Claim"
        ],
        "type": "token",
        "expression": "diagnosis.diagnosis.ofType(CodeableConcept)",
        "xpathUsage": "normal",
        "multipleOr": true,
        "multipleAnd": true
    }