Skip to content

Implement CRMI $validate operation#1023

Draft
Chris0296 wants to merge 6 commits into
mainfrom
cor-validate-operation
Draft

Implement CRMI $validate operation#1023
Chris0296 wants to merge 6 commits into
mainfrom
cor-validate-operation

Conversation

@Chris0296
Copy link
Copy Markdown
Collaborator

@Chris0296 Chris0296 commented May 1, 2026

Added $validate operation processors
Added the operation to the R4 CR config
Added FhirValidatorRegistry, which stores version specific validators, configured with an Npm Loaded ValidationSupportChain. This prevents running the expensive validator configuration process for each incoming request.

Tests to follow

Issue tracking operation migration process: DBCG/aphl-vsm#604

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 1, 2026

Formatting check succeeded!

@c-schuler c-schuler self-requested a review May 4, 2026 19:24
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

@c-schuler c-schuler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some concerns with the collision with HAPI's built-in $validate operation. I have been discussing with the committer through other channels. Despite that, the code looks pretty good - just a few suggested changes.


public FhirValidatorRegistry(DaoRegistry daoRegistry) {
this.daoRegistry = daoRegistry;
packagesToLoad.add(new String[] {"hl7.fhir.us.ecr", "2.1.2"});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. This should be configurable or moved into an ecr-specific package instead of the generic cqf-fhir-cr-hapi module. Take the package list (or CrSettings) as a constructor / Spring property so consumers can supply their own.

var vsmIG = new NpmPackageValidationSupport(ctx);
var chain = new ValidationSupportChain(
npm,
vsmIG,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm and vsmIG aren't doing anything, right? They are created, but nothing is ever loaded into them... The loadPrePopulatedValidationSupport method is actually loading the eCR profiles. Maybe I am misreading this?

}

@Test
void validate_verify_operation() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would like to see this test actually assert behavior - e.g. inspect the returned operation outcome. I would also like to see tests for the FhirValidatorRegistry.

public IBaseOperationOutcome validate(IBaseBundle resource, String mode, String profile) {
var processor = validateProcessor != null
? validateProcessor
: new ValidateProcessor(FhirContext.forVersion(fhirVersion));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use repository.fhirContext() instead of a fresh context per call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants