Adding category SearchParameter breaks similar SearchParameters until restart #3487
Description
Describe the bug
Adding a SearchParameter for the 'category' on a resource type for which this is not supported by default breaks support of the 'category' SearchParameter for other resource types.
We are adding a SearchParameter for MedicationDispense & MedicationAdministration, which works fine, but after doing so, the SearchParameter of 'category' no longer works for Observation, Consent, Procedure, MedicationRequest, MedicationStatement, and likely others.
After many successful(ly failing) reproductions on my local machine the problem was gone after I restarted my laptop, it appears that restarting the fhir-server also fixes the problem.
FHIR Version?
Stu3
Data provider?
SQL Server
To Reproduce
- Start fresh fhir-server connected to an empty database
- Add 2 Observations and 2 MedicationDispenses, all with different categories example-resources-sparam-category-bug.txt
- Make following GET Request to prove Observation category SearchParameter is initially working, you should get 1 resource back
{{fhirServerUrl}}/Patient/example/Observation?code=http%3A%2F%2Fsnomed.info%2Fsct%7C49581000146104
- Make following GET Request to prove MedicationDispense category SearchParameter is not supported, you should get 2 resources and an operationoutcome indicating the SearchParameter is not supported.
{{fhirServerUrl}}/Patient/example/MedicationDispense?category=http%3A%2F%2Fsnomed.info%2Fsct%7C373784005
- Add new SearchParameter for MedicationDispense-category SearchParameter-Medications-category.txt
- Reindex & wait for reindexing to be done
- Repeat the request from step 4 to prove the MedicationDispense category SearchParameter is now supported, you should get 1 resource back
- Repeat the request from step 3, an OperationOutcome will be returned indicating "The search parameter 'category' is not supported for resource type 'Observation'."
Extra step: Restarting the fhir-server and repeat the requests, now both search parameters are supported
Expected behavior
Adding a category SearchParameter to one ResourceType does not affect existing/default SearchParameters for other ResourceTypes
Actual behavior
After adding a category SearchParameter for MedicationDispense, the default category SearchParameters for other ResourceTypes like Observation/Consent etc. are no longer supported until fhir-server is restarted.