Skip to content

OpenConceptLab/ocl_online#452 | FHIR on stored content: CodeSystem properties and filters, full $lookup, CodeSystem $subsumes - #1084

Draft
paynejd wants to merge 11 commits into
fhir-452-capabilitiesfrom
fhir-452-stored-ops
Draft

paynejd wants to merge 11 commits into
fhir-452-capabilitiesfrom
fhir-452-stored-ops

Conversation

@paynejd

@paynejd paynejd commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

Branch fhir-452-stored-ops, base fhir-452-capabilities (#1083). The second FHIR PR of the series for OpenConceptLab/ocl_online#452.

Updated Nov 30: the series now sits on all of the OCL API PRs, which end in #1094. This branch merges #1083's new head (5ccd6405). Its earlier merge of the $cascade fix is now the API PRs' own (#1085, with #1088's level-at-a-time step). Its two changes to Concept (get_property_value, and the hierarchy step reading an annotated latest version) moved to #1094, so no core change ships only in a FHIR PR. Two conflicts, both in the merge message: core/concepts/models.py takes the API PRs' version, and core/settings.py keeps both sides. The diff now holds only the FHIR layer.

What it does

For content OCL stores (sources and their versions):

  • CodeSystem properties and filters in FHIR's shape (Expose OCL source.properties & source.filters through FHIR CodeSystem.property, CodeSystem.filter, and CodeSystem.concept.property ocl_issues#2262)
    • CodeSystem.property: the source version's own declarations, then OCL's (conceptclass, datatype), and the standard inactive (boolean; it was declared as a Coding) and status (code), each with its concept-properties uri.
    • CodeSystem.filter in R4's shape, replacing the non-FHIR filters key. R5-only operators are left out. Written CodeSystems accept filter and keep what R4 can't show.
    • Each concept's property values, read from its extras the way the API reads them (Concept.get_property_value, in OpenConceptLab/ocl_online#452 | An expansion evaluation narrowed to some codes; an import's codes matched as a code reference matches them #1094), typed as declared. A value that isn't of the declared type is left out. A retired concept is also status: retired.
  • Full $lookup: property (repeating, *, lang.X), returning definition, designations, the declared properties, and parent / child with each one's display. GET and POST with coding. Without property, the answer is unchanged.
  • CodeSystem $subsumes, type and instance level, GET and POST, with codeA/codeB + system (version) or codingA/codingB. Outcomes equivalent, subsumes, subsumed-by, not-subsumed. The IG's errors: no system (SUBSUMPTION_NO_SYSTEM, 400), an unknown code (404 code-invalid, naming the code, the code system and the input), two code systems or versions, an unresolved code system (422).
  • The CapabilityStatement and the FHIR Swagger declare $subsumes; the Swagger documents $lookup's property.

Why

The IG asks for $lookup with property and for $subsumes (requirements.md; the simple-cases, parameters and tho suites test them). FHIR's CodeSystem resource has property and filter, and OCL's filters key wasn't FHIR.

How it was tested

  • pylint 10.00; the FHIR, code-system, CodeSystem integration and concept tests on this branch: 1,330 OK, 2 skipped (core.fhir, core.code_systems, core.concepts and their integration tests); CI runs the full suite once it's pushed. The whole stack's full gate is in the last PR of the series.
  • Unit and Django tests for properties, filters, $lookup and $subsumes (core/fhir/tests_properties.py, tests_ops_hierarchy.py, tests_capabilities.py, tests_swagger.py, core/integration_tests/tests_code_systems.py).
  • HL7 txTests: these operations run on content a request carries only once the engine and the PRs after it in the series are in; see the last PR of the series.
  • Reviewed before opening: three Codex defect passes and a simplification review on the integrated work, all findings answered. The rework onto $cascade's step: Codex checks, every finding answered (two about the API's HEAD hierarchy and $cascade's own walk, outside this PR, are recorded for a later fix).

What changes for existing callers

  • CodeSystem read: filter replaces filters. A client that reads filters must read filter (FHIR's name and shape). inactive is declared as boolean; status is declared; concept property values are typed as their source declares them (CIEL's datatype is valueCode); a retired concept carries status: retired.
  • CodeSystem write: takes filter; the legacy filters key is no longer read, so a writer must send filter. It also reads inactive under any code the written CodeSystem declares with the standard inactive meaning, so a read written back keeps a retired concept retired.
  • New: CodeSystem/$subsumes and CodeSystem/{id}/$subsumes.
  • $lookup without property answers as before.
  • At HEAD (only when a request names it), $lookup's parent and child, and $subsumes, read the hierarchy as the API's HEAD hierarchy does.

Risks

  • The filters to filter rename is the one breaking change for API clients that read or write FHIR CodeSystems.
  • $subsumes reads up to the limit's ancestors per code, one query a level. The limit and the search timeout bound it.

Rollback

Revert this PR. No migrations; the two new settings have defaults.

Rechecked on the updated branch (Nov 30)

On 68818bd7: pylint 10.00 (core); the FHIR, CodeSystem, ValueSet, concept and their integration tests with Elasticsearch: 1,372 OK, 2 skipped, and one failure that passes run alone (ConceptRetiredFacetCountsTest.test_global_facets: a search-index test that can see another test's documents when they run together; 12 of 12 OK alone).

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_01AaZ4qTFRu4tcrkh4W8bA4T
https://claude.ai/code/session_01AaZ4qV2gzsF5GhF5BwTJ6x

paynejd and others added 4 commits November 29, 2026 07:14
…operties and filters, full $lookup, CodeSystem $subsumes

CodeSystem reads show what the OCL API holds about properties and filters
(OpenConceptLab/ocl_issues#2262):
- CodeSystem.property: the source version's own declarations, then OCL's conceptclass
  and datatype, and the standard inactive (boolean, was declared as a Coding) and status
  (code), each with its concept-properties uri.
- CodeSystem.filter in R4's shape, replacing the non-FHIR filters key; R5-only operators
  are left out. Written CodeSystems take filter too, keeping what R4 can't show, and
  read inactive under any code they declare with the standard inactive meaning, so a
  read written back keeps a retired concept retired.
- Each concept's property values, read from its extras as the API reads them
  (Concept.get_property_value, factored out of Concept.properties), as the declared
  type's value[x]. A retired concept also has status retired.

$lookup takes property (repeating, *, lang.X): definition, designations, the declared
properties, and parent and child with each one's display, read with the step the API's
version views use (get_version_hierarchy_queryset), at most FHIR_LOOKUP_RELATED_LIMIT
of each. Without property the answer is unchanged.

CodeSystem/$subsumes and CodeSystem/{id}/$subsumes, GET and POST, with codeA/codeB and
system (version) or codingA/codingB: equivalent, subsumes, subsumed-by or not-subsumed,
on the same hierarchy step, whatever hierarchyMeaning says (ICD-10, ICD-11 and ATC declare
grouped-by). Bounded by FHIR_SUBSUMES_HIERARCHY_LIMIT and FHIR_SEARCH_TIMEOUT_MS; a walk
cut before the answer is too costly (422). The IG's errors: no system
(SUBSUMPTION_NO_SYSTEM), an unknown code (404 code-invalid), two code systems or
versions, an unresolved code system. Declared in the CapabilityStatement and documented
in the FHIR Swagger with $lookup's property.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qXmZjc3rGYio3yCj6V
…52-cascade) the FHIR hierarchy builds on

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qXRkP3QEc5U3NfPZp9
…nd child read the hierarchy by $cascade's step

- core.fhir.hierarchy no longer has its own step. $lookup's parents and children, and $subsumes's ancestors, take
  $cascade's hierarchy step (Concept.get_hierarchy_queryset, the one $cascade takes from each concept, retired
  concepts included), so FHIR and the API share one definition of the hierarchy, as fixed in the $cascade change it
  builds on (#1085).
- FHIR keeps its bounded walk around that step, reading each concept once (a release can hold two rows of a code):
  parents and children are a probe of at most FHIR_LOOKUP_RELATED_LIMIT + 1 concepts; the walk up is a level at a
  time, one query a level (the step from each of its concepts in one union), reading at most
  FHIR_SUBSUMES_HIERARCHY_LIMIT + 1 concepts with the code itself, the first by concept across a level. The extra one
  only shows a cut, and what it found within the limit is kept. At HEAD a level also reads each concept's latest
  version (Concept.get_hierarchy_ids takes it from an annotation when a query gives one), so the walk stays one
  query a level. Both run within FHIR_SEARCH_TIMEOUT_MS.
- Answers are unchanged on this branch's tests, the LOINC 2.81 shape included. Tests check the probes' limits, one
  query a level (at HEAD too), the last place in a cut level, and duplicate rows.

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

Two conflicts:
- core/concepts/models.py: the API PRs' version. It holds this PR's two changes there
  (Concept.get_property_value, and the hierarchy step reading an annotated latest version), which
  now come with the API PRs, beside #1088's level-at-a-time hierarchy step.
- core/settings.py: both sides' settings.

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

Takes #1083'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
…d into fhir-452-stored-ops

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

One conflict, in CodeSystemDetailSerializer.to_internal_value: this branch adds the codes a written CodeSystem declares
the standard inactive property under (inactive_codes); B-9 reads whether it's a supplement and its language from HEAD,
which an update saves onto (update_head). Both are kept: the context reads HEAD and carries inactive_codes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qWapJWFsFc1Xjopf9k
…d into fhir-452-stored-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
…d into fhir-452-stored-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
…d into fhir-452-stored-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
…d into fhir-452-stored-ops

Takes #1083'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
…into fhir-452-b-engine

Takes #1084'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