Repository navigation
Conversation
…inside create_tbl)
5 tasks
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #157 +/- ##
==========================================
+ Coverage 91.69% 93.60% +1.90%
==========================================
Files 9 11 +2
Lines 1421 1861 +440
==========================================
+ Hits 1303 1742 +439
- Misses 118 119 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
PR Summary: 156-expand-metacore-schema
What Changed
1. New MetacoreDefine R6 subclass (R/MetacoreDefine.R)
A new class MetacoreDefine inherits from Metacore and adds three extra tables needed to fully
describe a CDISC Define.xml document:
study_level: study-wide metadata (study name, protocol, standard, define version, language)documents: referenced external documents (ID, title, href)comments: comments cross-referenced fromvalue_specThe subclass overrides
initialize(),validate(), andmetacore_filter(). The filter method nowtrims documents and comments to only those still referenced after subsetting to a single dataset.
2. Schema formalised into a single source of truth (R/metacore-schema.R)
Previously column names and types were scattered across initializer code. Now there are two
explicit schema functions:
base_column_schema: the original 7-table schema (backwards-compatible)define_column_schema: extends the base with Define.xml-only columns and the 3 new tablesAlongside these,
base_col_regex()anddefine_col_regex()centralise the regex patterns used tolocate and rename columns when reading Excel specs. Internal helpers
fill_cols(),col_vars(),reorder_by_schema(), anddefine_only_cols()use these schemas to keep initialisation andvalidation in a single location.
3. Extended schema columns on existing tables
When
define_fields = TRUEthe following existing tables gain additional columns:4.
define_fieldsopt-in parameter added tospec_to_metacoreand allspec_type_to_*buildersAll reader functions now accept
define_fields = FALSE(the default). When FALSE the readersproduce the classic schema and return a plain Metacore object so existing code should remain valid. When
TRUE they read the extra columns, build the three new tables, and return a MetacoreDefine object.
5. Validators updated
Validators now inspect the active schema (base vs define) to decide which columns are required,
so they don't raise spurious errors about missing Define.xml columns on plain Metacore objects,
and vice versa.
6. metacore.R refactored to R6 naming convention
The core R6 class was renamed from mixed internal naming to MetaCore (internal R6 class name),
following proper R6 conventions. Public-facing constructor and active binding names are
unchanged. Shared initialisation logic was extracted into
.metacore_init_base_tables()so bothMetaCore and MetaCoreDefine share it without duplication.
7.
spec_type_to_commentsandspec_type_to_documentsbuilder functions addedTwo new
spec_type_to_*functions read the Comments and Documents sheets from Excelspecifications when
define_fields = TRUE.Why it Changed
The driving need is Define.xml round-trip support. The xml_builders.R layer can already write
Define.xml content from a Metacore object, but the base schema lacks the metadata fields
required by the CDISC Define-XML 2.0 standard (method names/types, document references,
comments, study-level attributes, etc.). Without those fields, a Define.xml produced by the
package is incomplete.
The implementation deliberately keeps this opt-in
define_fields = FALSE(default) so that themajority of current users who use metacore for existing ADaM/SDTM programming workflows are
unaffected. Only users who want to work with experimental features and build Define.xml documents need to pass
define_fields = TRUE.