Skip to content

Fix/ocl cache invalidation#198

Merged
grahamegrieve merged 18 commits intomainfrom
fix/ocl-cache-invalidation
Apr 9, 2026
Merged

Fix/ocl cache invalidation#198
grahamegrieve merged 18 commits intomainfrom
fix/ocl-cache-invalidation

Conversation

@italomacedo
Copy link
Copy Markdown
Collaborator

This pull request improves the robustness and correctness of code and value set lookups in the OCL (Open Concept Lab) FHIR terminology provider. The main focus is on handling case-insensitive code lookups, improving cache management, and ensuring that value set expansions do not unintentionally broaden due to missing concept enumerations. The changes also enhance how designations are preserved and propagated in value set expansions.

Case-insensitive code lookup and caching:

  • Added logic to perform case-insensitive lookups in conceptCache for codes, ensuring that codes differing only by case (e.g., "y" vs "Y") are matched and cached under the requested case for faster future access.
  • When fetching concepts from the network, if a code is not found, the provider now attempts to fetch using both lower-case and upper-case variants before giving up, and caches the result under the originally requested code. [1] [2]

Value set cache and expansion improvements:

  • When updating value sets, if a new value set lacks an enumerated compose.include but the existing cached version has one, the compose from the cache is carried over to prevent fallback to "include whole CodeSystem" behavior.
  • During expansion, if the compose already contains enumerated concepts (from a background expansion), further system-only entries are not added, preserving the authoritative set of concepts and avoiding unintended expansion.
  • Improved cache invalidation logic for background expansions: if a cache entry is invalidated due to metadata changes, freshness checks are skipped to avoid using stale data. [1] [2]

Value set expansion output enhancements:

  • Modified the expansion output to include concept designations when present, preserving additional information about each concept in the expanded value set. [1] [2]

italomacedo and others added 18 commits March 12, 2026 18:59
Two issues fixed in the OCL ValueSet provider:

1. #indexValueSet rejected fresh discovery metadata when a cold-cached
   entry already existed (different object identity check). This meant
   updated `lastUpdated` timestamps from OCL were never propagated,
   so #isCachedExpansionValid always passed and stale compose data
   was never invalidated.

2. #ensureComposeIncludes called #normalizeComposeIncludes which stripped
   `concept` arrays from compose entries built by background expansion.
   This caused the expand engine to fall back to "include whole CodeSystem",
   returning concepts that were deliberately excluded from the collection
   (e.g. LCVMA1DE001 appearing despite not being referenced in the
   ValueSet collection on OCL).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add case-insensitive fallback for concept cache lookups to handle
  OCL concept IDs that differ in case from FHIR codes (e.g. "y" vs "Y")
- Extract #fetchConceptByCode helper and retry with lower/upper case
  alternatives before returning not-found
- Carry over enumerated compose when re-indexing a ValueSet so that
  fresh discovery metadata does not discard background expansion results
- Guard against overwriting enumerated concepts with system-only includes
  that would cause the expand engine to include all CodeSystem concepts
- Skip cold cache freshness check when the in-memory cache was just
  invalidated, ensuring stale files do not suppress re-expansion
- Preserve concept designation data in background expansion compose

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@grahamegrieve grahamegrieve left a comment

Choose a reason for hiding this comment

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

ok

@grahamegrieve grahamegrieve merged commit 3ac177c into main Apr 9, 2026
7 checks passed
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