Repository navigation
Fix Patient $purge Purging Resources of Other Patients - #4605
Open
alexanderkiel wants to merge 1 commit into
Open
alexanderkiel wants to merge 1 commit into
alexanderkiel wants to merge 1 commit into
Conversation
alexanderkiel
force-pushed
the
claude/4596-purge-graph-definition
branch
2 times, most recently
from
November 7, 2026 12:29
781ba35 to
331aa9b
Compare
alexanderkiel
force-pushed
the
claude/4596-purge-graph-definition
branch
21 times, most recently
from
November 9, 2026 07:07
d3524d4 to
8de23fa
Compare
Closes: #4596 Signed-off-by: Alexander Kiel <alexanderkiel@gmx.net>
alexanderkiel
force-pushed
the
claude/4596-purge-graph-definition
branch
from
November 9, 2026 20:02
8de23fa to
1003da3
Compare
This branch has not been deployed
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: #4596
Changes
ig: new FSH instancePatientPurge(input/fsh/patient-purge.fsh). It produces the GraphDefinitionhttps://blaze-server.org/fhir/GraphDefinition/PatientPurge|1, using R5 cross-version extensions. The IG validator passes with 0 errors.graph-definition: new pure functiongd/rev-links. It takes a compiled graph and returns its[type code]tuples. It returns anincorrectanomaly if the graph is outside the restricted subset:Patient<code>={ref}Patientnodedb:[:patient-purge id graph]/ tx-cmd key:graph(url|version, optional).expand "patient-purge"resolves the GraphDefinition indb-beforebyurl,versionand_security=…AccessControl|internal. It pulls it and runsgd/compileandgd/rev-links. It checks that every code is areferencesearch param of its type that targetsPatient. The resulting tuples feed the existingrev-includeloop. Without:graph, it keeps the compartment-based expansion.and othersif there are more. Before, it named one.operation-patient-purge:GraphDefinition-PatientPurge.jsonfrom the IG, like the job modules do.url,versionand_security, usingp/internal. On install it adds theinternalsecurity label (current system only) and theread-onlytag (both systems).url|versionwith the purge command.:parsing-context,:clockand:rng-fn.blaze.ednis updated.Link decisions (please review)
The links are in
modules/ig/input/fsh/patient-purge.fsh. Each uses the param for the patient the resource is about, e.g. Observationsubject, Coveragebeneficiary, CareTeamsubject, ResearchSubjectindividual.These types get no link, because the element can hold several patients: Account (
subject0..*), Appointment, AuditEvent, Group, Patient, Person, Schedule.Provenance is linked via
patient, althoughtargetcan hold several patients. The Synthea test data has one Provenance per patient, targeting that patient. Without the link, nearly every purge in the integration test would fail on referential integrity.API Behaviour
These changes are visible to clients:
$purgeno longer erases resources that reference the patient in a non-focal role.docs/api/operation/patient-purge.mdhas a "Selected Resources" section, badged since 1.14.0, with a table of the compartment and GraphDefinition search params per type.docs/implementation/database.mddocuments thegraphproperty and the expansion.Tests
gd/rev-links: valid tuples, plus one anomaly per restricted-subset violation.prepare-opand tx-cmd spec tests..github/scripts/patient-purge.sh):$graphwith the purge GraphDefinition lists the selected resources$graphis now also enabled for thepatient-purgefeature run inbuild.ymlcheck-resource-totals*.shignore GraphDefinition and StructureDefinition, andcheck-total-number-of-resources.shignores GraphDefinitions.Rolling upgrades of the distributed variant are out of scope, as stated in the issue.