Search code examples
fhir-server-for-azurehl7-fhir

How to search a Claim using extension field


I have a Claim payload, in which I have added an extension block: (not sure how where the url came from)

"extension" : [{
   "url" : "http://hl7.org/fhir/StructureDefinition/iso-21090-EN-use",
   "valueString" : "MAPD"
}],

I want search this claim record using the extension but don't know how to do it.
I tried using GET request to https://<azure_fhir_server>/Claim?extension=MAPD but it says

 {
     "severity": "warning",
     "code": "not-supported",
     "diagnostics": "The search parameter 'extension' is not supported for resource type 'Claim'."
 }

===================== EDIT:
As suggested by @Nik Klassen, I posted the following payload to /SearchParameter

{
    "resourceType" : "SearchParameter",
    "id": "b072f860-7ecd-4d73-a490-74acd673f8d2",
    "name": "extensionValueString",
    "status": "active",
    "url" : "http://hl7.org/fhir/SearchParameter/extension-valuestring",
    "description": "Returns a Claim with extension.valueString matching the specified one in request.",
    "code" : "lob",
    "base" : [
        "Claim"
    ],
    "type" : "string",
    "expression" : "Claim.extension.where(url ='http://hl7.org/fhir/SearchParameter/extension-valuestring').extension.value.string"
}

Also, did the $reindex on Claim, but the couldnt find the column lob($reindex response is below):

{
    "resourceType": "Parameters",
    "id": "ee8786d2-616a-4b81-8f6a-8089591b1225",
    "meta": {
        "versionId": "1"
    },
    "parameter": [
        {
            "name": "_id",
            "valueString": "28e808d6-e420-4a33-bb0b-7cd325c8c169"
        },
        {
            "name": "status",
            "valueString": "http://hl7.org/fhir/fm-status|active"
        },
        {
            "name": "priority",
            "valueString": "http://terminology.hl7.org/CodeSystem/processpriority|normal"
        },
        {
            "name": "facility",
            "valueString": "Location/Location"
        },
        {
            "name": "patient",
            "valueString": "Patient/f8d8477c-1ef4-4878-abed-51e514bfd91f"
        },
        {
            "name": "encounter",
            "valueString": "Encounter/67062d00-2531-3ebd-8558-1de2fd3e5aab"
        },
        {
            "name": "use",
            "valueString": "http://hl7.org/fhir/claim-use|claim"
        },
        {
            "name": "identifier",
            "valueString": "TEST"
        },
        {
            "name": "_lastUpdated",
            "valueString": "2021-08-25T07:39:15.3050000+00:00"
        },
        {
            "name": "created",
            "valueString": "1957-04-12T21:23:35+05:30"
        }
    ]
}

I read somewhere I need to create StructureDefinition, but don't know how to do that.
Basically I want to add a field "LOB" as an extension to all my resources, and search them using: GET: https://fhir_server/{resource}?lob=<value>


Solution

  • By default you can only search on fields that are part of the FHIR spec. These are listed in a "Search Parameters" section on the page for each resource type, i.e. https://hl7.org/fhir/claim.html#search. To search on extensions you will need to create a custom SearchParameter https://learn.microsoft.com/en-us/azure/healthcare-apis/fhir/how-to-do-custom-search, i.e.

    POST {{FHIR_URL}}/SearchParameter
    
    {
      "resourceType" : "SearchParameter",
      "id" : "iso-21090-EN-use",
      "url" : "ttp://hl7.org/fhir/SearchParameter/iso-21090-EN-use",
      ... some required fields ...
      "code" : "iso-use",
      "base" : [
        "Claim"
      ],
      "type" : "token",
      "expression" : "Claim.extension.where(url = 'http://hl7.org/fhir/StructureDefinition/iso-21090-EN-use').value.string"
    }