Data Dictionary Standardization¶
Context and Decision¶
The iMednet platform provides study metadata across multiple surfaces, primarily through 4-file CSV data dictionary exports (FORMS.csv, QUESTIONS.csv, CHOICES.csv, BUSINESS_LOGIC.csv) and through EDC REST API endpoints (/forms, /variables). Previously, data dictionary handling was minimal, consisting of untyped dictionary rows in imednet.validation.data_dictionary, with no unified schema, structural diffing, or typed representations of complex business logic rules.
Furthermore, several inconsistencies existed in nomenclature and structure:
Domain Nomenclature: Domain terminology in
CONTEXT.mdestablishesVariableas the canonical term for a CRF data point, yet CSV exports historically labeled the fileQUESTIONS.csv.Field Casing: Headers in raw CSV files use mixed title casing (
Form Key,Variable Name,Special Patient ID).Date Formats: iMednet CSV exports empirically use
MM-DD-YYYYtimestamp formatting.Required Field Policy:
Required Fieldin iMednet is not a binary boolean; it carries semantic values such asAuto Query.Business Logic XML Rules: Rule logic is defined in XML containing empty tag markers (
<true/>,<new_record/>,<last/>) and repeated sibling elements representing condition groups and action sets.
We decided to establish a canonical imednet.datadict module with the following architecture:
Strict Domain Alignment: Model child collections on
Formasvariables: list[Variable](deprecating “question” in documentation and domain models), mappingQUESTIONS.csvintovariables.Lexical camelCasing: Normalize headers strictly using lexical camelCasing (e.g.,
formKey,variableName,specialPatientId,patientRecordReport) without semantic renames.Pydantic v2 Canonical Models: Implement
DataDictionary,Form,Variable,Choice,BusinessLogicRule, andMetadatamodels with JSON Schema emission and deterministic formatting.Empirical Timestamp Assertion: Strictly assert and validate
MM-DD-YYYYtimestamps at parse time.Business Logic XML Parsing: Transform XML logic into a structured AST dictionary where empty tags become boolean
Truemarkers, repeated sibling tags collapse into arrays, and outer envelopes unwrap to(systemGenerated, conditions, actions).Dual Representation and Optional Raw XML: Support both structured
logicAST and verbatimlogicRawXml, allowinglogicRawXmlto be omitted via--no-raw-xml. Unknown columns are tracked inmetadata.validationWarningsandextraAttributes.Rule Routing: Route
Form-scoped rules toform.businessLogic, and other rule types (Workflow,Query,Approval,Required) to top-levelunassignedBusinessLogic.Deterministic JSON Emission & Equality: Sort forms by
formKey, variables bysequencethenvariableName, choices byposition, and rules bysequencethenid. ExcludegeneratedAtduring fixture and model equality comparisons.Backward-Compatible Shims: Refactor
imednet.validation.data_dictionaryto re-exportDataDictionaryand provide deprecatedDataDictionaryLoadermethods issuingFutureWarning.Argparse CLI Integration: Integrate
imednet datadictsubcommands (from-csv,from-api,from-odm,to-odm,validate,diff,schema) into the core CLI framework.Read-Only CDISC Clinical, Administrative, and Audit Exchange Extension: Extend standardization beyond
MetaDataVersionmetadata to immutable (frozen=True,extra="forbid") exchange models inimednet.datadict.exchange—re-exported acrossimednet.spi.cdiscandimednet.spi.modelsso workflow and provider extensions never import internal core modules:CDISC ODM 1.3.2 Archive Models:
OdmArchive,OdmAdminData(OdmUser,OdmLocation,OdmMetaDataVersionRef),OdmReferenceData,OdmClinicalData(OdmSubjectData,OdmStudyEventData,OdmFormData,OdmItemGroupData,OdmItemData),OdmAuditRecord(mapped from iMednetRecordRevisionchains), andOdmAnnotation/OdmFlag(mapped from iMednetQueryandQueryCommentitems).CDISC Dataset-JSON v1.1 Exchange Models:
DatasetJsonEnvelope,DatasetJsonColumn(DatasetJsonItem),DatasetJsonSourceSystem, andDatasetJsonBundlerepresenting flat single-dataset CDISC Dataset-JSON v1.1 envelopes (datasetJSONCreationDateTime,datasetJSONVersion,fileOID,sourceSystem,studyOID,metaDataVersionOID,itemGroupOID,records,name,label,columns,rows) and typed multi-dataset Python bundles for both CDASHFormdefinitions and normalized SDTM domains without custom vendor JSON hierarchies.Strict Inbound Safety & Default PHI Redaction: Enforce
defusedxmlparsing on all ODM XML inputs, fail fast inload_from_cdisc_odm(..., strict=True)when non-metadata containers appear while providingload_odm_archivefor full archive snapshots, and applySensitivityRegistryPHI masking by default across ODM<ItemData>values,<Annotation>comments, and Dataset-JSON tuples.
Consequences¶
All tools, pipelines, and agents share canonical read-only representations and bundled official schemas (
resources/data-dictionary-1.0.0.schema.json,resources/cdisc-odm-1.3.2.xsd, andresources/dataset-json-1.1.0.schema.json) across study metadata, clinical records, 21 CFR Part 11 audit trails, and query annotations.Automated diffing, migration testing, regulatory archive exports (
imednet export odm,imednet export dataset-json), and CI validation deterministically exchange CDISC-compliant snapshots without upstream EDC mutations or cross-package boundary violations.Full backward compatibility is preserved for existing tests and consumers, including
UATExecutionEngine.