Skip to content

fix(ocl): auto-register factories for post-startup sources + expose concept extras in $lookup#266

Open
italomacedo wants to merge 2 commits into
mainfrom
fix/ocl-post-startup-factories
Open

fix(ocl): auto-register factories for post-startup sources + expose concept extras in $lookup#266
italomacedo wants to merge 2 commits into
mainfrom
fix/ocl-post-startup-factories

Conversation

@italomacedo

Copy link
Copy Markdown
Collaborator

Two OCL fixes, verified against the current main base (9 OCL test suites / 80 tests passing). Scoped entirely to tx/ocl/ plus tests.

1. Auto-register factories for OCL sources discovered post-startup

New OCL sources created after the server starts were silently falling back to FhirCodeSystemProvider, which reads the raw content field and returns contentMode() = 'not-present', causing ValueSet expansions to fail with "The code system definition has no content".

Root cause: the refresh cycle detected new sources via getCodeSystemChanges() and called addCodeSystem(), but never created an OCLSourceCodeSystemFactory — so getCodeSystemProvider() never found a factory and fell through to the raw CodeSystem.

Fix (entirely within tx/ocl/):

  • OCLSourceCodeSystemFactory stores the first i18n instance in a static field so discovery-time factory creation can reuse it.
  • New static createForDiscoveredSource(httpClient, meta) creates and auto-registers a factory for a newly detected source.
  • #scheduleRefresh now creates factories for entries in changes.added that don't yet have one.
  • New patchProviderForOCLFactorySync (in shared/patches.cjs) syncs any factory not yet in provider.codeSystemFactories, following the same pattern already used for the SearchWorker and ValueSetExpander patches.

2. Expose concept extras as properties in $lookup

Carry OCL concept extras through toConceptContext (non-empty plain objects only) and implement extendLookup on OCLSourceCodeSystemProvider to emit each entry as a FHIR property parameter with typed value[x] (boolean/integer/decimal/string; arrays and objects JSON-stringified). Honors the $lookup property filter per key.

🤖 Generated with Claude Code

italomacedo and others added 2 commits July 10, 2026 11:33
…artup

New OCL sources created after the server starts were silently falling
back to FhirCodeSystemProvider, which reads the raw 'content' field
and returns contentMode() = 'not-present', causing ValueSet expansions
to fail with "The code system definition has no content".

Root cause: the 60-second refresh cycle detected new sources via
getCodeSystemChanges() and called addCodeSystem(), but never created
an OCLSourceCodeSystemFactory — so getCodeSystemProvider() never found
a factory and fell through to the raw CodeSystem.

Fix (entirely within tx/ocl/):
- OCLSourceCodeSystemFactory stores the first i18n instance in a static
  field (#sharedI18n) so discovery-time factory creation can reuse it
  without requiring library.js to pass i18n again
- Added static createForDiscoveredSource(httpClient, meta) that creates
  and auto-registers a factory for a newly detected source; factories
  self-register in the static factoriesByKey map on construction
- #scheduleRefresh now calls createForDiscoveredSource for each entry
  in changes.added that does not yet have a factory
- patchProviderForOCLFactorySync (new patch in shared/patches.cjs)
  monkey-patches Provider.prototype.updateCodeSystemList to sync any
  factory in factoriesByKey that is not yet in provider.codeSystemFactories,
  following the same idiomatic pattern used for SearchWorker and
  ValueSetExpander patches

No files outside tx/ocl/ were modified.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Carry OCL concept extras through toConceptContext (non-empty plain
objects only) and implement extendLookup on OCLSourceCodeSystemProvider
to emit each entry as a FHIR property parameter with typed value[x]
(boolean/integer/decimal/string; arrays and objects JSON-stringified).
Honors the $lookup property filter per key. Provider now extends
BaseCSServices for the _hasProp helper and is exported for tests.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant