Add cohort scripting commands: ExportCohortAsScript / BuildCohortFromScript#2360
Draft
mtinti wants to merge 3 commits into
Draft
Add cohort scripting commands: ExportCohortAsScript / BuildCohortFromScript#2360mtinti wants to merge 3 commits into
mtinti wants to merge 3 commits into
Conversation
e161219 to
70920bf
Compare
Two CLI commands under CommandExecution/AtomicCommands/CohortScript: - ExportCohortAsScript: decompiles a CohortIdentificationConfiguration into a portable, data-free folder: requirement.md placeholder, build.script.yaml, query.sql, and catalogue-manifest.yaml (the extractable columns, patient identifier column(s) and published filters of ONLY the catalogues this cohort uses). The build script captures set operations, nested cohort sub-containers and child order, published-filter imports with parameters, hand-written filters, global and aggregate-level parameters, nested AND/OR filter containers, patient index tables (joinables) with their joins/filters/params, forced joins, disabled sets and sub-containers, customised dimension SQL, and the Project association. No patient data leaves - only catalogue/table/column names and filter logic. - BuildCohortFromScript: the inverse - replays a build.script.yaml in-process to recreate an identical cohort (binds handles via NewObjectPool, restores child order, rebuilds patient index tables and rewrites their instance-specific alias). Round-trip verified on a fixture exercising all of the above: export -> rebuild -> re-export -> execute returns identical cohort membership. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
TestCohortScriptRoundTrip builds a cohort in the in-memory MemoryDataExportRepository (set operation, nested AND/OR filter containers, an aggregate-level parameter and a patient index table with an Inner join-use), runs ExportCohortAsScript then BuildCohortFromScript, and asserts the rebuilt object graph matches the original. No database required. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…rial Adds an "Exporting and rebuilding a cohort" section to RdmpCommandLine.md covering both commands and what the build script captures. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
70920bf to
1701d3c
Compare
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.
Proposed Change
Adds two CLI commands under
CommandExecution/AtomicCommands/CohortScript:CohortIdentificationConfigurationinto a portable,data-free folder:
requirement.md(placeholder),build.script.yaml(a runnable commandscript that recreates the cohort),
query.sql(the SQL RDMP would run; if the cohort cannot be expressed as one query - sets span servers/credentials with no QueryCache - this falls back to a best-effort per-set decomposition plus notes) andcatalogue-manifest.yaml(the extractable columns, patient-identifier column(s) and publishedfilters of only the catalogues this cohort uses). The build script captures set operations,
nested cohort sub-containers + child order, published-filter imports with parameters,
hand-written filters, global (cohort-level) and aggregate-level parameters, nested AND/OR filter
containers, patient index tables (joinables) with their joins/filters/parameters + the
ix####alias, forced joins, disabled sets and sub-containers, customised dimension SQL, and the Project
association. No patient data is emitted — only catalogue/table/column names and filter logic.
build.script.yamlto rebuild an identical cohort.The captured set was cross-checked against RDMP's native "clone Cohort Identification Configuration"
cascade so that an export → file → rebuild reproduces the same object graph the clone would, for
every aspect that affects cohort membership.
Notes for reviewers: CLI-only — the commands also appear in the GUI "Run…" palette automatically,
but there's no right-click wiring in this PR. No database migration; metadata only (no data processing).
A CHANGELOG entry will be added before this leaves draft.
The
query.sqlcross-server fallback is verified with a two-server docker fixture: the real "different server ... no QueryCache" error is captured, each set's SQL is emitted individually and executes against its own server, while a single-server cohort still produces the real combined query.Type of change
Checklist