Support the FHIR PATCH interaction (FHIRPath Patch)#553
Open
schwzr wants to merge 1 commit into
Open
Conversation
Implements the FHIR PATCH interaction using the FHIRPath Patch format (Parameters resource), both as a direct REST interaction (PATCH [type]/[id] and conditional PATCH [type]?[criteria]) and inside transaction and batch bundles. - new FhirPathPatchService applies add/insert/delete/replace/move on the HAPI R4 runtime model without an additional dependency (no hapi-fhir-storage), using the FHIRPath engine already on the classpath - patch reuses the existing update code path, so authorization (reasonUpdateAllowed), validation, optimistic locking (If-Match), versioning and the Prefer header behave identically to an update - new PatchCommand plus PATCH dispatch in CommandFactoryImpl for bundle processing, patch branch added to the audit log - 'patch' interaction added to the CapabilityStatement - FhirWebserviceClient patch(...) and patchConditionaly(...) - unit tests for the patch engine, integration tests for REST, conditional and bundle patch including not-found and bad-request handling Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #552
Summary
Adds support for the FHIR PATCH interaction using the FHIRPath Patch format (a
Parametersresource, https://www.hl7.org/fhir/R4/fhirpatch.html):PATCH [type]/[id]and conditionalPATCH [type]?[criteria]Bundle.entry.request.method = PATCH)interactionin the CapabilityStatementA patch is applied to a copy of the current resource and then written through the existing update code path, so authorization (
reasonUpdateAllowed(old, patched)), validation, optimistic locking (If-Match), versioning and thePreferheader behave exactly as for an update. PATCH maps to the existingUPDATErole — no new permission is required.Implementation
FhirPathPatchService— new engine applying add / insert / delete / replace / move on the HAPI R4 runtime model (FhirContext/IFhirPath). No new runtime dependency — deliberately avoidshapi-fhir-storage(which would pull in hapi-fhir-server, JPA/Hibernate, Quartz, Spring-tx).@PATCHJAX-RS annotation (JAX-RS ships none),patch(...)onBasicResourceServiceand the abstract jaxrs / secure / impl layers. The patch service is provided through the already-injectedParameterConvertersingleton to avoid threading a new constructor argument through all ~28 resource services.PatchCommand(resolves the target DAO from the request URL likeDeleteCommand, transaction priority 3 like update) plus aPATCHbranch inCommandFactoryImpland the audit log.FhirWebserviceClient.patch(...)/patchConditionaly(...).Scope
In scope: FHIRPath Patch (add / insert / delete / replace / move), REST (standard + conditional), transaction + batch bundles, client support, tests.
Out of scope (for now):
application/json-patch+json) and XML Patch — omitted to keep the dependency footprint minimal; FHIRPath Patch is also the format FHIR recommends for FHIR resources. Can be added later.urn:uuid:) references contained inside patch values when processed within a bundle.Testing
FhirPathPatchServiceImplTest: 12/12 (all five operation types incl. list mutation and error handling).PatchIntegrationTest: 5/5 (REST, conditional, transaction bundle, 404 not-found, 400 bad-request) against a real server + PostgreSQL (Testcontainers).ParallelCreateIntegrationTest#testCreateDuplicateStructureDefinitionsParallelDirect(a parallel race test): it passes ondevelopand passes/fails intermittently on this branch (~50%), and this change touches no create / DAO / unique-constraint code.🤖 Generated with Claude Code