LinuxForHealth / FHIR

The LinuxForHealth FHIR® Server and related projects
https://linuxforhealth.github.io/FHIR
Apache License 2.0
330 stars 157 forks source link

Add capability to configure compartment search via searchParameterCombinations config property #1778

Open michaelwschroeder opened 3 years ago

michaelwschroeder commented 3 years ago

Is your feature request related to a problem? Please describe. If a compartment inclusion criteria search parameter is specified in the fhirServer/resources/<resourceType>/searchParameterCombinations list to limit search scope (i.e. patient or performer), then that parameter must be specified on a compartment search even though the compartment search already scopes the query to that search parameter. In addition, the search parameter will be specified twice in the generated SQL.

Example:

  1. fhir-server-config.json specifies the patient search parameter in its fhirServer/resources/<resourceType>/searchParameterCombinations list for the Procedure resource type:

        "resources": {
          "Procedure": {
            "searchParameterCombinations": ["patient","patient+date","patient+status","patient+code"]
          }
        },
  2. The following compartment search is performed:

        Patient/17575/Procedure

    It will fail because the patient search parameter was not specified, even though the compartment search already scopes the search to a single Patient.

  3. The following compartment search is performed:

        Patient/17575/Procedure?patient=Patient/17575

    It will correctly return the Patient's Procedure resources, but the patient search parameter has to be unnecessarily specified, and the generated SQL will contain functionally duplicate WHERE clauses to scope the results to a single Patient.

Describe the solution you'd like Provide a way for the user to configure valid search parameter combinations for compartment searches in the fhirServer/resources/<resourceType>/searchParameterCombinations config property using a custom format. One suggested format is the following:

    <compartmentType>/<searchParameter1>+<searchParameter2>+...

For example, if a user wanted to allow Procedure searches on the Patient compartment where the code and status search parameters were valid for the Procedure search, they could specify the following in the fhir-server-config.json file:

        "resources": {
          "Procedure": {
            "searchParameterCombinations": ["Patient/code+status"]
          }
        },

This would allow the following search request:

    Patient/12345/Procedure?code=1028-5&status=completed

Describe alternatives you've considered See issue #1707 for possible alternatives considered.

Acceptance Criteria At least one acceptance criteria is included.

  1. GIVEN a compartment search parameter combination is configured for a particular compartment WHEN a compartment search is executed with that parameter combination THEN all valid resources are returned

  2. GIVEN no compartment search parameter combination is configured for a particular compartment WHEN a compartment search is executed for that compartment THEN the search request fails

  3. GIVEN a compartment search parameter combination is configured for a particular compartment WHEN a compartment search is executed for that compartment, but with the wrong parameter combination THEN the search request fails

Additional context Add any other context or screenshots about the feature request here.

lmsurpre commented 3 years ago

stretch goal for sprint 22