feat(hts): coexisting multi-version CodeSystems with version-aware co…#99
Merged
Merged
Conversation
…mpose Drop the column-level UNIQUE on `code_systems.url` (both SQLite and PG schemas) and replace it with a composite UNIQUE index on (url, version). Two CodeSystems sharing a canonical URL now coexist whenever they declare distinct `version` values, matching tx-ecosystem fixtures `version/codesystem-version-1.json` / `-2.json` (both ship `id:"version"`, url `http://hl7.org/fhir/test/CodeSystem/version`, versions `1.0.0` and `1.2.0`). Add an idempotent SQLite migration (`migrate_code_systems_drop_url_unique`) that rebuilds the table without the legacy constraint, plus a PG DO-block that drops any pre-existing `UNIQUE (url)` constraint. Storage id is now `<fhir-id>|<version>` (or `<fhir-id>` when version absent) so per-(url, version) rows have stable, distinct PK values without colliding when fixtures reuse the FHIR `id` across versions. Concepts / hierarchy / properties / designations FK to that synthetic storage id, so each version owns its own normalized data. `resolve_code_system` (both backends) now picks the highest version when no `version` parameter is supplied, exact-matches when a literal version is given, and supports tx-ecosystem version-pattern syntax (`1.x.x`, `1.x`, bare `1`) — each `x` segment is a wildcard, bare numeric prefixes match any version starting with that segment, and the highest matching version wins. Compose includes that pin a `version` (`compose.include[].version`) now resolve to the matching `code_systems` row instead of arbitrarily grabbing the first row by URL. The mixed value set `tests/version/valueset-version-mixed.json` (which pulls `code1` from 1.0.0 and `code2` from 1.2.0 of the same canonical URL) expands correctly. CRUD lookups by FHIR id (e.g. `/CodeSystem/version`) fall back to matching `resource_json.id` and pick the latest version when the synthetic storage id miss occurs. The hierarchy/concept-map helpers that look up `system_id` from a URL now `ORDER BY version DESC LIMIT 1` so subsumption walks the most recent revision. Targets the largest remaining tx-ecosystem bucket — the 147 failing `version/` tests including coding-v10-vs1w, vs-expand-v1, code-vnn-* families, codeableconcept-v10-* and the mixed-version paths. Adds 8 new unit tests covering: dual-version coexistence after import, exact / wildcard / short-prefix / unknown-version lookup, and three compose-version pinning scenarios (pin v1, pin v2, mixed). Updates the existing `cs_create_indexes_into_hts_tables` and `cs_delete_removes_hts_normalized_rows` tests to match by URL rather than the now-synthetic storage id. cargo test -p helios-hts --lib: 473 passed, 0 failed
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.
…mpose
Drop the column-level UNIQUE on
code_systems.url(both SQLite and PG schemas) and replace it with a composite UNIQUE index on (url, version). Two CodeSystems sharing a canonical URL now coexist whenever they declare distinctversionvalues, matching tx-ecosystem fixturesversion/codesystem-version-1.json/-2.json(both shipid:"version", urlhttp://hl7.org/fhir/test/CodeSystem/version, versions1.0.0and1.2.0). Add an idempotent SQLite migration (migrate_code_systems_drop_url_unique) that rebuilds the table without the legacy constraint, plus a PG DO-block that drops any pre-existingUNIQUE (url)constraint.Storage id is now
<fhir-id>|<version>(or<fhir-id>when version absent) so per-(url, version) rows have stable, distinct PK values without colliding when fixtures reuse the FHIRidacross versions. Concepts / hierarchy / properties / designations FK to that synthetic storage id, so each version owns its own normalized data.resolve_code_system(both backends) now picks the highest version when noversionparameter is supplied, exact-matches when a literal version is given, and supports tx-ecosystem version-pattern syntax (1.x.x,1.x, bare1) — eachxsegment is a wildcard, bare numeric prefixes match any version starting with that segment, and the highest matching version wins.Compose includes that pin a
version(compose.include[].version) now resolve to the matchingcode_systemsrow instead of arbitrarily grabbing the first row by URL. The mixed value settests/version/valueset-version-mixed.json(which pullscode1from 1.0.0 andcode2from 1.2.0 of the same canonical URL) expands correctly. CRUD lookups by FHIR id (e.g./CodeSystem/version) fall back to matchingresource_json.idand pick the latest version when the synthetic storage id miss occurs. The hierarchy/concept-map helpers that look upsystem_idfrom a URL nowORDER BY version DESC LIMIT 1so subsumption walks the most recent revision.Targets the largest remaining tx-ecosystem bucket — the 147 failing
version/tests including coding-v10-vs1w, vs-expand-v1, code-vnn-* families, codeableconcept-v10-* and the mixed-version paths.Adds 8 new unit tests covering: dual-version coexistence after import, exact / wildcard / short-prefix / unknown-version lookup, and three compose-version pinning scenarios (pin v1, pin v2, mixed). Updates the existing
cs_create_indexes_into_hts_tablesandcs_delete_removes_hts_normalized_rowstests to match by URL rather than the now-synthetic storage id.cargo test -p helios-hts --lib: 473 passed, 0 failed