microsoft/fhir-server

Help with defining custom search parameter

liamwilson-kainos opened this issue · 4 comments

Hi there,

Reaching out to see if anyone could help me with defining a search parameter against my version 4 FHIR instance. I have HealthcareService resources which have notAvailable information specified such as

             "notAvailable": [
                    {
                        "extension": [
                            {
                                "url": "https://ommitted/fhir/StructureDefinition/Extension-HealthcareServiceExceptionReason",
                                "valueCoding": {
                                    "system": "https://ommitted.ca/fhir/CodeSystem/HealthcareServiceExceptionType",
                                    "code": "04",
                                    "display": "Unscheduled - Paramedic"
                                }
                            }
                        ],
                        "description": "Upcoming closure",
                        "during": {
                            "start": "2024-02-14T14:00:00+00:00",
                            "end": "2024-02-15T15:00:00+00:00"
                        }
                    }
                ]

https://hl7.org/fhir/R4/healthcareservice-definitions.html#HealthcareService.notAvailable

I want to be able to be do one of the following -

  1. Search for HealthcareServices where the notAvailable array has one or more value
  2. Find HealthcareService resources with a notAvailable.during.start of a given value

I have tried this POST request to create a new search param

{
    "resourceType": "SearchParameter",
    "id": "not-available-start",
    "meta": {
        "versionId": "1",
        "lastUpdated": "2023-12-18T14:34:26.358+00:00"
    },
    "url": "https://nshealth.ca/fhir/SearchParameter/NotAvailableStart",
    "name": "not-available-start",
    "status": "active",
    "date": "2023-08-09",
    "publisher": "omitted",
    "contact": [
        {
            "name": "omitted"
        }
    ],
    "description": "Closure start date",
    "code": "not-available-start",
    "base": [
        "HealthcareService"
    ],
    "type": "string",
    "expression": "HealthcareService.notAvailable.during.start"
}

and get back

{
    "resourceType": "OperationOutcome",
    "id": "3ad5587093a41f9445b486a575959268",
    "meta": {
        "lastUpdated": "2024-03-11T14:12:39.6571265+00:00"
    },
    "issue": [
        {
            "severity": "error",
            "code": "not-supported",
            "diagnostics": "The search parameter with definition URL 'https://nshealth.ca/fhir/SearchParameter/NotAvailableStart' is not supported."
        },
        {
            "severity": "error",
            "code": "exception",
            "diagnostics": "An error occurred creating the custom search parameter.  The issue must be resolved and the parameter resubmitted to become functional."
        }
    ]
}

Any help appreciated please!

I have also tried

{fhirHost}/HealthcareService?notAvailable:missing=true

but i get back

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

Hi @liamwilson-kainos
For the not-available-start search parameter you need to change the type from string to date as that is the data type of the field.

Also @liamwilson-kainos , please look into the expression value "HealthcareService.notAvailable.during.start". The notAvailable value does not exist in the searchparameter definition.

Thanks @LTA-Thinking - that works! Silly mistake :)