Skip to content

OpenConceptLab/ocl_online#452 | FHIR: $lookup, $subsumes and $translate on content the request carries - #1099

Draft
paynejd wants to merge 28 commits into
fhir-452-b-validatefrom
fhir-452-b-ops
Draft

paynejd wants to merge 28 commits into
fhir-452-b-validatefrom
fhir-452-b-ops

Conversation

@paynejd

@paynejd paynejd commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Branch fhir-452-b-ops, base fhir-452-b-validate (#1098). The last of the series: its tree is the whole that was tested.

What it does

  • $lookup (core/fhir/engine/lookup.py) of a code system the request carries, or FHIR's own.
    • The request's workspace loads it into OCL's tables. The concept is found in its loaded rows, and its hierarchy is read from them as $cascade reads it.
    • What OCL's model doesn't hold (a designation's use system, typed property values) comes from the resource beside them.
    • A code system OCL stores stays the stored path's.
  • $subsumes of a carried code system is the stored $subsumes over its loaded rows (CarriedCodeSystem in core/fhir/ops/subsumes.py). It names a code the code system doesn't define as the IG does.
  • $translate (core/fhir/engine/translate.py) with the ConceptMaps a request carries, as the IG's translate suites test it.
    • OCL's mappings have no dependsOn, unmapped or scopes, so this stays a FHIR-only capability. Its scope and target checks use the workspace.
    • A url naming a ConceptMap OCL stores, and none the request carries, stays the stored path's.
  • The R4 adapter writes the engine's $lookup and $translate answers. The capability statement now says the operations use CodeSystems passed in tx-resource (the IG's CodeSystemAsParameter feature).

Reading order

core/fhir/engine/lookup.py, core/fhir/ops/subsumes.py, core/fhir/engine/translate.py, core/fhir/ops/lookup.py and core/fhir/ops/translate.py (the hand-off), core/fhir/adapters/r4.py, core/fhir/capabilities.py. Then the tests: core/fhir/engine/tests_lookup.py, tests_translate.py, core/fhir/tests_ops_subsumes_carried.py, core/fhir/tests_carried_beside_stored.py, and core/fhir/workspace/tests_answer_snapshot.py (the stored answers through the workspace).

What a reviewer checks

  • $lookup and $subsumes read the loaded rows through OCL's own hierarchy step.
  • $translate stays on its own ConceptMap reader, as decided for this phase.

What changes for existing callers

  • $lookup, $subsumes and $translate with carried terminology resources are now answered for them. Before, the stored path didn't read them.
  • /fhir/metadata says CodeSystemAsParameter is true.

Size

About 0.9k lines of code and 1.2k of tests.

Rollback

Revert this PR, or turn FHIR_WORKSPACE_TOGGLE off. No migrations.

How it was tested

  • On this branch alone: pylint 10.00 (core); the FHIR, CodeSystem and ValueSet tests with Elasticsearch: 1,436 OK, 3 skipped.
  • HL7's txTests on this tree (validator 7.0.8, hl7.fhir.uv.tx-ecosystem 1.11.0, general mode), with OCL's stored copies of FHIR's definitions as staging stores them: 707 of 707 in scope pass (715 of 789 run; 82 out of scope, 81 of them supplements; 13 not run).
  • The full gate on this tree, as pr.yml runs it: pylint 10.00; 5,104 tests OK (3 skipped) and 823 search-index tests OK; coverage 97% (core/fhir 97%).
  • Its code was reviewed in the work it comes from: three Codex defect passes, a simplification review and checks of later commits on each part, and an adversarial review of who can see what, on the whole. This split was checked by building each PR's own tree and running its tests.

The series

The FHIR layer for OpenConceptLab/ocl_online#452. It is one linear series, and each PR is based on the one before:

  1. OpenConceptLab/ocl_online#452 | An expansion evaluation narrowed to some codes; an import's codes matched as a code reference matches them #1094: the end of the OCL API PRs (core changes, reviewed first)
  2. OpenConceptLab/ocl_online#452 | FHIR metadata: CapabilityStatement and TerminologyCapabilities for the Terminology Ecosystem IG #1083: capabilities
  3. OpenConceptLab/ocl_online#452 | FHIR on stored content: CodeSystem properties and filters, full $lookup, CodeSystem $subsumes #1084: stored CodeSystem properties and filters, $lookup, $subsumes
  4. OpenConceptLab/ocl_online#452 | FHIR: the request-scoped terminology engine's foundations #1095: the engine's foundations
  5. OpenConceptLab/ocl_online#452 | FHIR: carried content in OCL's own tables for one request, and the stored provider #1096: the workspace and the stored provider
  6. OpenConceptLab/ocl_online#452 | FHIR: $expand of a value set the request carries, over OCL's own expansion #1097: $expand on carried content, and dispatch
  7. OpenConceptLab/ocl_online#452 | FHIR: $validate-code and $batch-validate-code on content the request carries #1098: $validate-code and $batch-validate-code
  8. OpenConceptLab/ocl_online#452 | FHIR: $lookup, $subsumes and $translate on content the request carries #1099: $lookup, $subsumes and $translate on carried content

Each diff is its own. The last one's tree is the whole that was tested: 707 of the HL7 Terminology Ecosystem IG's 707 in-scope test cases pass (hl7.fhir.uv.tx-ecosystem 1.11.0, general mode; supplements are out of scope). The series stays in draft until the whole ships, after the OCL API PRs. As those land on master, each PR here is retargeted, never force-pushed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AaZ4qV2gzsF5GhF5BwTJ6x

…te on content the request carries

- $lookup (core.fhir.engine.lookup) of a code system the request carries, or FHIR's own: the
  request's workspace loads it into OCL's tables, the concept is found in its loaded rows and its
  hierarchy read from them as $cascade reads it; what OCL's model doesn't hold (a designation's
  use system, typed property values) comes from the resource beside them. A code system OCL stores
  stays the stored path's.
- $subsumes of a carried code system is the stored $subsumes over its loaded rows
  (CarriedCodeSystem), naming a code it doesn't define as the IG does.
- $translate (core.fhir.engine.translate) with the ConceptMaps a request carries, as the IG's
  translate suites test it. OCL's mappings have no dependsOn, unmapped or scopes, so this stays a
  FHIR-only capability; its scope and target checks use the workspace. A url naming a ConceptMap
  OCL stores, and none the request carries, stays the stored path's.
- The R4 adapter writes the engine's $lookup and $translate answers; the capability statement says
  the operations use CodeSystems passed in tx-resource.
- Tests: the engine's $lookup and $translate; $subsumes on a carried code system; carried content
  beside stored content; a snapshot of the stored answers through the workspace; the rest of the
  engine-over-stored tests.

With this the series' tree equals the whole: 707 of the IG's 707 in-scope test cases pass
(hl7.fhir.uv.tx-ecosystem 1.11.0, general mode; supplements are out of scope).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qV2gzsF5GhF5BwTJ6x
paynejd and others added 13 commits December 1, 2026 00:39
…into fhir-452-b-ops

Takes #1098's new head, which brings in master's
#1085, #1086 and
#1082. No change to this branch's own code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qWUTom6BGgjQy6oehZ
…into fhir-452-b-ops

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qWUTom6BGgjQy6oehZ
…us time limit, so a busy machine can't fail it

It proves an answer, subsumes, but ran under the 10-second request limit and timed out when the machine was busy.
With FHIR_TX_TIME_LIMIT_MS at 120 seconds for this test, the answer it checks is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qX3xher9sfoCLLKrTC
…imeout a few times, not before every query

FHIR's search timeout set statement_timeout before every query, and an expansion evaluation within it, unable to know
that timeout, set its own before every query too: two round trips a query (about 0.14 s of a 0.4 s carried $expand
of about 280 queries). Now:
- within_search_timeout keeps the timeout it sets on the connection, and with a margin lets one stand while it's within
  the margin of the time left; a savepoint's rollback has it set again. The engine's requests use the evaluation's
  margin (STATEMENT_TIMEOUT_MARGIN, 0.25 s), so a query may overrun the request's deadline by that much at most, as an
  evaluation's already may. The stored path's searches and operations keep a timeout set before every query.
- An evaluation within it reads the timeout it keeps rather than set its own; a shorter evaluation still sets its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qX3xher9sfoCLLKrTC
…statement timeout's margin too

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qX3xher9sfoCLLKrTC
…into fhir-452-b-ops

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qX3xher9sfoCLLKrTC
…the statement timeout change

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qX3xher9sfoCLLKrTC
… in milliseconds, and see it set again past the margin

Review fixes: the tests read statement_timeout from pg_settings (milliseconds, whatever unit SHOW gives), and one
checks that, with a margin, the timeout is set again once the time left drops past it and after a savepoint's
rollback undoes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qX3xher9sfoCLLKrTC
…search's clock by hand

Review fix: the test advances within_search_timeout's clock itself, so the timeout after a savepoint's rollback is
set again only because the rollback undid it, never because the test runner paused past the margin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qX3xher9sfoCLLKrTC
…(with fhir-452-b9-valueset and phase C's storage and core) into fhir-452-b-ops

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qWapJWFsFc1Xjopf9k
…into fhir-452-b-ops

Phase C's storage migrations and collections/0081 bound their lock waits; an import's stored expansion isn't read as
it is when a supplement may apply.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qWapJWFsFc1Xjopf9k
…into fhir-452-b-ops

An import is evaluated again only when a supplement applies to a version it used.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qWapJWFsFc1Xjopf9k
…into fhir-452-b-ops

The migrations bound their lock waits before their first DDL, both ways.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qWapJWFsFc1Xjopf9k
paynejd and others added 9 commits December 1, 2026 12:09
…into fhir-452-b-ops

$validate-code reads a carried value set's stored import as $expand does (e3e7bfc, 870fa43).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qXgSvP7oUQhCRnPJAH
…into fhir-452-b-ops

Review fixes to the stored-import membership (05da1ac).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qXgSvP7oUQhCRnPJAH
…into fhir-452-b-ops

Review fix to the stored-import membership (450bd1b).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qXgSvP7oUQhCRnPJAH
…into fhir-452-b-ops

Simplifications from review of the stored-import membership.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qXgSvP7oUQhCRnPJAH
…into fhir-452-b-ops

Final review fixes to the stored-import membership (a236bbe).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qXgSvP7oUQhCRnPJAH
…into fhir-452-b-ops

Final review fixes to the stored-import membership (4e50dd6).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qXgSvP7oUQhCRnPJAH
…into fhir-452-b-ops

Final review fixes to the stored-import membership (77a2ee6).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qXgSvP7oUQhCRnPJAH
…into fhir-452-b-ops

Stored imports: open answers judged in the release kept; an unknown version reported (43d9543).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qXgSvP7oUQhCRnPJAH
…into fhir-452-b-ops

Review fixes to the stored-import membership (0456bf1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qXgSvP7oUQhCRnPJAH
paynejd and others added 5 commits December 1, 2026 14:44
…into fhir-452-b-ops

Review fixes to the stored-import membership (535a15b).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qXgSvP7oUQhCRnPJAH
…into fhir-452-b-ops

Review fixes to the stored-import membership (36ea663).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qXgSvP7oUQhCRnPJAH
…into fhir-452-b-ops

Simplifications from review of the stored-import membership (c385bd2).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qXgSvP7oUQhCRnPJAH
…into fhir-452-b-ops

Final review fix to the stored-import membership (45d8f96).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qXgSvP7oUQhCRnPJAH
…into fhir-452-b-ops

Takes #1098's new head, which brings in master
(#1089, #1109 and
#1106): REFERENCE_SEARCH_OPTIONS_TOGGLE is on in every
environment, as on master. Merged cleanly; no change to this branch's own
code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed
paynejd added a commit that referenced this pull request Dec 2, 2026
…fhir-452-c-fhir

Takes #1099's new head, which brings in master
(#1089, #1109 and
#1106): REFERENCE_SEARCH_OPTIONS_TOGGLE is on in every
environment, as on master. Merged cleanly; no change to this branch's own
code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed

This branch has not been deployed

No deployments
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