Fix IG/$data-requirements key ValueSet binding discovery#1032
Merged
Conversation
Make IG/$data-requirements emit the same key ValueSet bindings the IG-publisher shows in its "Key Elements Table". For several IGs like hl7.fhir.uv.cql the operation previously surfaced zero ValueSets in the relatedArtifact list and zero entries with crmi-dependencyRole=key even though the IG-publisher's published key elements analysis identifies several per profile.
|
Formatting check succeeded! |
|
barhodes
approved these changes
May 13, 2026
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.


Summary
Make
IG/$data-requirementsemit the same key ValueSet bindings the IG-publisher shows in its "Key Elements Table". For abstract-framework IGs likehl7.fhir.uv.cqlthe operation previously surfaced zero ValueSets inrelatedArtifact[]and zero entries withcrmi-dependencyRole=keyeven though the IG-publisher's published key-elements analysis identifies several per profile. End-to-end verification againsthl7.fhir.uv.cql 2.0.0: all 27 expected key ValueSets across 8 profiles (publication-status,library-type,mimetypes,structure-definition-kind,defined-types,related-artifact-type, etc.) now surface withcrmi-dependencyRole=key.Five independent gaps, each fixed independently:
Canonicals.getResourceTypeself-referential URL bug - usedString.replace()(global) and mangled URLs likehttp://hl7.org/fhir/StructureDefinition/StructureDefinitionto return"fhir". Switched tosubstring(0, lastIndexOf("/")). Without this, search-class lookup mis-routed FHIR meta-types toCodeSystemand the visitor never recursed into base FHIR profiles.NpmRepository.search()lazy-load - onlyread()was wired to lazy-load NPM packages on miss;search()fell through to the in-memory store and returned empty for unloaded resources.SearchHelper.searchRepositoryByCanonicalWithPagingtherefore failed to resolve, the visitor'stryResolveDependencyReadOnlygotnull, and recursion into base FHIR profiles was skipped. Added asearch()override: on a miss with aurlparam, look up the URL in a new id index, callread()to warm the cache, then re-run the in-memory search.DependencyRoleClassifier.isTransitiveKeyDependencyversion-asymmetric matching - stripped the version pin from the dependency reference on lookup but compared against a key set whose entries kept whatever pin the binding URL carried (FHIR core is inconsistent -publication-status|4.0.1is pinned,library-typeisn't). Added symmetric stripping (fast path for already-stripped entries, fallback scan otherwise) so set membership is URL-only and matches in either direction.DataRequirementsVisitor.synthesizeMissingKeyDependencies- some key bindings live on slices of complex element types (e.g.Library.relatedArtifact:dependency.type->related-artifact-type, where the binding is on the FHIR coreRelatedArtifactcomplex type). The differential walk inStructureDefinitionAdapter.getDependencies()doesn't followtype.codeinto element types, so these never surfaced as deps.KeyElementAnalyzercorrectly identifies them via the snapshot. Added a synthesizer step after the dep walk: anytransitiveKeyCanonicalsentry not already in the relatedArtifact list becomes a synthetic depends-on entry withrole=key, populatingcqf-resourceTypeandpackage-sourcefrom the conformance resolver.enrichReferencestub-CodeSystem version pin - once fix 2 madesearch()actually resolve stub CodeSystems (CodeSystem.content = not-present), external systems like SNOMED and LOINC picked up the stub's package-version field as a bogus pin (http://snomed.info/sct|3.2.1). Re-use the existing stub-detection signal (URL is in the resource-type index but excluded from the version index) at the enrichment point to return the bare URL for stubs and preserve the unversioned external-CodeSystem references the operation produced previously.Test plan
Canonicalsself-referential URL regression test addedNpmRepositorysearch-by-URL behavior with and without packagesDependencyRoleClassifierversion normalization in both directionscqf-fhir-crvisitor test suite - 337 tests, no regressionscqf-fhir-utilitytest suite - no regressionsspotlessCheckpasseshl7.fhir.uv.cql 2.0.0IG: 27/27 expected key ValueSets surface withcrmi-dependencyRole=key