Validating references and referential integrity
When a resource is written to the repository (create/update/etc), local resource references that are indexed by at least one SearchParameter can be checked to ensure that the target of the reference is valid.
References that are not indexed by at least one SearchParameter are never checked for target existence. Non-local references (that is, references where the base URL of the reference target refers to a different FHIR server) are never checked for target existence.
Reference validation
If the config Enforce Referential Integrity on Write (enforce_referential_integrity_on_write) is enabled, reference targets are checked.
For example, if a patient contains a reference to managing organization Organization/HealthOrg but HealthOrg is not a valid ID for an organization on the server, the operation is blocked unless this property has been disabled.
This property can cause confusing results for clients of the server since searches, includes, and other FHIR features may not behave as expected when referential integrity is not preserved. In particular, resource references to target resources that do not exist at the time that the source resource is created will not be indexed, even if the target resource is created later. Disable with caution.
Referential integrity
If the config Enforce Referential Integrity on Delete (enforce_referential_integrity_on_delete) is enabled on HDR FHIR Server, resources can only be deleted if there are no other resources with indexed references to the candidate resource for deletion.
Parent topic: Creating data