LinuxForHealth / FHIR

The LinuxForHealth FHIR® Server and related projects
https://linuxforhealth.github.io/FHIR
Apache License 2.0
330 stars 157 forks source link

Fingerprint resources with profile configuration at ingestion #2961

Open punktilious opened 2 years ago

punktilious commented 2 years ago

Is your feature request related to a problem? Please describe. With the implicit profile feature described at #2887, resources can be validated against profiles defined in the server configuration. If this configuration changes, then resources which had previously been validated may no longer be valid in relation to the new implicit profile configuration.

Describe the solution you'd like If a resource is validated using an implicit profile, then this relationship should be recorded in the database. This could take the form of a signature using a hash including the relevant configuration, or perhaps explicitly using a new table logical_resource_profile_refs which records references to the profiles used at the time of ingestion.

Such information could be useful if a scan is needed (similar to reindex) to reassert validation when profiles are updated.

Describe alternatives you've considered Don't track, and a scan would have to reassert everything whenever the configuration was changed.

Acceptance Criteria

  1. GIVEN resource not asserting a profile AND the fhir-server-config defines an implicit profile for the resource WHEN the resource is ingested THEN the relationship between the resource and the implicit profile used for validation during ingestion is recorded in the database.

lmsurpre commented 2 years ago

I think even without the implicit-profile feature described at #2887, this feature could be useful for resources which use versionless canonicals in their Resource.meta.profile list. At least if the config supported 'defaultVersions' for the profile in question.

However, in cases where there is no defaultVersions configured, it might still be nice to know which versions of which profiles we validated against...I wonder if there's an alternative design that could accomodate that?

lmsurpre commented 2 years ago

decision: rather than fingerprinting the profile config, we should only fingerprint the DECISION of the config (i.e. which profiles we actually validated against -- url AND version)

proposal: only capture the TOP-LEVEL profiles that we validate against. it is possible that the url and version of that profile stays the same but that the generated constraints for it change, but we chose to draw the line at this top level.

comment from lee: it would be nice if we could query this data back out (probably directly from the DB). then we could answer questions like "which profiles was this resource validated against when we ingested it".