microsoft / microsoft/fhir-server
Adding category SearchParameter breaks similar SearchParameters until restart
Nobody has claimed this yet.
- Dominant language
- TSQL
- Stars
- 1.4k
- Forks
- 592
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 41
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**
1. Start fresh fhir-server connected to an empty database
2. Add 2 Observations and 2 MedicationDispenses, all with different categories [example-resources-sparam-category-bug.txt](https://github.com/microsoft/fhir-server/files/12377662/example-resources-sparam-category-bug.txt)
3. 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`
5. 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`
6. Add new SearchParameter for MedicationDispense-category [SearchParameter-Medications-category.txt](https://github.com/microsoft/fhir-server/files/12377719/SearchParameter-Medications-category.txt)
7. Reindex & wait for reindexing to be done
8. Repeat the request from step 4 to prove the MedicationDispense category SearchParameter is now supported, you should get 1 resource back
9. 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the request sequence against a fresh FHIR server with SQL Server, using example-resources-sparam-category-bug.txt and SearchParameter-Medications-category.txt. Compare category searches before and after adding the MedicationDispense parameter and reindexing; done means existing category parameters remain supported without restarting the server.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- sql
- Domain
- api, backend, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100