Summary
After a successful PUT on a Consent resource, Spark does not update the search index for custom SearchParameters. Subsequent searches return stale results — the resource is still returned even though the indexed field has been changed to a non-matching value.
This affects both single-provision and multi-provision Consent resources.
Environment
- Spark version:
sparkfhir/spark:r4-latest (Docker image)
- FHIR version: R4
- Backend: MongoDB 7.0
- Test tool: Newman 6.2.2
Steps to reproduce
1. Register a custom SearchParameter
{
"resourceType": "SearchParameter",
"id": "mii-sp-consent-provisioncodetype",
"url": "https://www.medizininformatik-initiative.de/fhir/modul-consent/SearchParameter/mii-sp-consent-provisioncodetype",
"status": "active",
"code": "mii-provision-provision-code-type",
"base": ["Consent"],
"type": "composite",
"expression": "Consent.provision.provision",
"component": [
{
"definition": "https://www.medizininformatik-initiative.de/fhir/modul-consent/SearchParameter/mii-sp-consent-provisioncode",
"expression": "code"
},
{
"definition": "https://www.medizininformatik-initiative.de/fhir/modul-consent/SearchParameter/mii-sp-consent-provisiontype",
"expression": "type"
}
]
}
(The component SPs are available here: https://github.com/oeme-github/consent-test-suite/tree/main/infrastructure/searchparameters)
2. Create a Consent with a nested provision (type=permit, code=.3.7)
PUT /fhir/Consent/test-consent-001
{
"resourceType": "Consent",
"id": "test-consent-001",
"status": "active",
"scope": { "coding": [{ "system": "http://terminology.hl7.org/CodeSystem/consentscope", "code": "research" }] },
"category": [{ "coding": [{ "system": "http://loinc.org", "code": "57016-8" }] }],
"patient": { "reference": "Patient/test-patient-001" },
"policy": [{ "uri": "urn:oid:2.16.840.1.113883.3.1937.777.24.2.1791" }],
"provision": {
"type": "deny",
"provision": [
{
"type": "permit",
"code": [{ "coding": [{ "system": "urn:oid:2.16.840.1.113883.3.1937.777.24.5.3", "code": "urn:oid:2.16.840.1.113883.3.1937.777.24.5.3.7" }] }]
}
]
}
}
3. Verify the resource is found
GET /fhir/Consent?patient=Patient/test-patient-001&mii-provision-provision-code-type=urn:oid:2.16.840.1.113883.3.1937.777.24.5.3|urn:oid:2.16.840.1.113883.3.1937.777.24.5.3.7$permit
→ Returns total: 1 ✅
4. Update the Consent — change provision type from permit to deny
PUT /fhir/Consent/test-consent-001
(same body as above, but with "type": "deny" on the nested provision)
→ 200 OK ✅
5. Search again — expect 0 results
GET /fhir/Consent?patient=Patient/test-patient-001&mii-provision-provision-code-type=urn:oid:2.16.840.1.113883.3.1937.777.24.5.3|urn:oid:2.16.840.1.113883.3.1937.777.24.5.3.7$permit
→ Returns total: 1 ❌ (expected: total: 0)
The resource is still returned even though the indexed field now has type: deny.
Observed behaviour
The search index is not updated after PUT. The stale value persists indefinitely — no subsequent search reflects the change. This also affects _refresh=true (no effect).
Expected behaviour
After a successful PUT, the search index must reflect the new resource state. Searches must not return resources that no longer match the search criteria.
Comparison with other servers
We tested the same scenario against HAPI FHIR v7.4.0 and Blaze 1.9.0:
| Server |
Single-Provision PUT |
Notes |
| HAPI v7.4.0 |
✅ |
Stale index only for multi-provision Consents |
| Blaze 1.9.0 |
✅ |
Correctly reindexed |
| Spark r4-latest |
❌ |
Stale even for single-provision Consents |
Test suite
This issue was discovered while running the MII Consent Test Suite, specifically test case TC-UPDATE-001. The full test collection is available for reproduction.
Related upstream reports:
Summary
After a successful
PUTon aConsentresource, Spark does not update the search index for custom SearchParameters. Subsequent searches return stale results — the resource is still returned even though the indexed field has been changed to a non-matching value.This affects both single-provision and multi-provision Consent resources.
Environment
sparkfhir/spark:r4-latest(Docker image)Steps to reproduce
1. Register a custom SearchParameter
{ "resourceType": "SearchParameter", "id": "mii-sp-consent-provisioncodetype", "url": "https://www.medizininformatik-initiative.de/fhir/modul-consent/SearchParameter/mii-sp-consent-provisioncodetype", "status": "active", "code": "mii-provision-provision-code-type", "base": ["Consent"], "type": "composite", "expression": "Consent.provision.provision", "component": [ { "definition": "https://www.medizininformatik-initiative.de/fhir/modul-consent/SearchParameter/mii-sp-consent-provisioncode", "expression": "code" }, { "definition": "https://www.medizininformatik-initiative.de/fhir/modul-consent/SearchParameter/mii-sp-consent-provisiontype", "expression": "type" } ] }(The component SPs are available here: https://github.com/oeme-github/consent-test-suite/tree/main/infrastructure/searchparameters)
2. Create a Consent with a nested provision (type=permit, code=.3.7)
{ "resourceType": "Consent", "id": "test-consent-001", "status": "active", "scope": { "coding": [{ "system": "http://terminology.hl7.org/CodeSystem/consentscope", "code": "research" }] }, "category": [{ "coding": [{ "system": "http://loinc.org", "code": "57016-8" }] }], "patient": { "reference": "Patient/test-patient-001" }, "policy": [{ "uri": "urn:oid:2.16.840.1.113883.3.1937.777.24.2.1791" }], "provision": { "type": "deny", "provision": [ { "type": "permit", "code": [{ "coding": [{ "system": "urn:oid:2.16.840.1.113883.3.1937.777.24.5.3", "code": "urn:oid:2.16.840.1.113883.3.1937.777.24.5.3.7" }] }] } ] } }3. Verify the resource is found
→ Returns
total: 1✅4. Update the Consent — change provision type from
permittodeny(same body as above, but with
"type": "deny"on the nested provision)→
200 OK✅5. Search again — expect 0 results
→ Returns
total: 1❌ (expected:total: 0)The resource is still returned even though the indexed field now has
type: deny.Observed behaviour
The search index is not updated after
PUT. The stale value persists indefinitely — no subsequent search reflects the change. This also affects_refresh=true(no effect).Expected behaviour
After a successful
PUT, the search index must reflect the new resource state. Searches must not return resources that no longer match the search criteria.Comparison with other servers
We tested the same scenario against HAPI FHIR v7.4.0 and Blaze 1.9.0:
Test suite
This issue was discovered while running the MII Consent Test Suite, specifically test case
TC-UPDATE-001. The full test collection is available for reproduction.Related upstream reports: