imednet.datadict package¶
iMednet Data Dictionary module.
Provides canonical modeling, 4-file CSV loading, live SDK extraction, deterministic JSON emission, structural diffing, and schema validation.
Subpackages¶
Submodules¶
imednet.datadict.cdisc_builders module¶
Builders, PHI redactors, and schema validators for CDISC ODM 1.3.2 and Dataset-JSON v1.1.
- imednet.datadict.cdisc_builders.build_datadict_from_sdk_metadata(study_key, *, forms=(), variables=(), intervals=(), study_name=None, study_description=None, protocol_name=None)[source]¶
Construct a canonical
DataDictionaryfrom SDK Form/Variable/Interval objects.- Parameters:
study_key (str) –
forms (Sequence[Any]) –
variables (Sequence[Any]) –
intervals (Sequence[Any]) –
study_name (str | None) –
study_description (str | None) –
protocol_name (str | None) –
- Return type:
- imednet.datadict.cdisc_builders.build_dataset_json_bundle(study_key, *, records=(), forms=(), variables=(), visits=(), data_dictionary=None, as_sdtm=None, sdtm_domain=None, form_key=None, use_labels_as_columns=False, variable_whitelist=None, form_whitelist=None, naming_convention=None, preserve_record_id=False, include_deleted=False, mask_phi=True, custom_phi_keys=None, enrichment_pipeline=<object object>, metadata_version_oid='MDV.001', file_oid=None, creation_datetime=None, source_system_version=None, seq_counters=None, domain_seq_counters=None, seq_overrides=None, lineage_out=None)[source]¶
Build a multi-dataset
DatasetJsonBundleof flat CDISC Dataset-JSON v1.1 envelopes.- Parameters:
study_key (str) –
records (Iterable[Any]) –
forms (Sequence[Any]) –
variables (Sequence[Any]) –
visits (Iterable[Any]) –
data_dictionary (DataDictionary | None) –
as_sdtm (bool | None) –
sdtm_domain (str | None) –
form_key (str | None) –
use_labels_as_columns (bool) –
variable_whitelist (Collection[str] | None) –
form_whitelist (Collection[int] | None) –
naming_convention (str | None) –
preserve_record_id (bool) –
include_deleted (bool) –
mask_phi (bool) –
custom_phi_keys (Collection[str] | None) –
enrichment_pipeline (Any) –
metadata_version_oid (str) –
file_oid (str | None) –
creation_datetime (str | None) –
source_system_version (str | None) –
seq_counters (dict[str, int] | None) –
domain_seq_counters (dict[str, dict[str, int]] | None) –
seq_overrides (Mapping[str, int] | None) –
lineage_out (dict[str, dict[str, Any]] | None) –
- Return type:
- imednet.datadict.cdisc_builders.build_dataset_json_envelope(study_key, *, records=(), forms=(), variables=(), visits=(), data_dictionary=None, as_sdtm=None, sdtm_domain=None, form_key=None, use_labels_as_columns=False, variable_whitelist=None, form_whitelist=None, naming_convention=None, preserve_record_id=False, include_deleted=False, mask_phi=True, custom_phi_keys=None, enrichment_pipeline=<object object>, metadata_version_oid='MDV.001', file_oid=None, creation_datetime=None, source_system_version=None, seq_counters=None, domain_seq_counters=None, seq_overrides=None, lineage_out=None)[source]¶
Build a flat CDISC Dataset-JSON v1.1 single-dataset envelope.
- Parameters:
study_key (str) –
records (Iterable[Any]) –
forms (Sequence[Any]) –
variables (Sequence[Any]) –
visits (Iterable[Any]) –
data_dictionary (DataDictionary | None) –
as_sdtm (bool | None) –
sdtm_domain (str | None) –
form_key (str | None) –
use_labels_as_columns (bool) –
variable_whitelist (Collection[str] | None) –
form_whitelist (Collection[int] | None) –
naming_convention (str | None) –
preserve_record_id (bool) –
include_deleted (bool) –
mask_phi (bool) –
custom_phi_keys (Collection[str] | None) –
enrichment_pipeline (Any) –
metadata_version_oid (str) –
file_oid (str | None) –
creation_datetime (str | None) –
source_system_version (str | None) –
seq_counters (dict[str, int] | None) –
domain_seq_counters (dict[str, dict[str, int]] | None) –
seq_overrides (Mapping[str, int] | None) –
lineage_out (dict[str, dict[str, Any]] | None) –
- Return type:
- imednet.datadict.cdisc_builders.build_odm_archive(study_key, *, study=None, data_dictionary=None, forms=(), variables=(), intervals=(), subjects=(), visits=(), records=(), revisions=(), queries=(), sites=(), users=(), reference_data=(), metadata_version_oid='MDV.001', metadata_version_name=None, file_oid=None, file_type='Snapshot', creation_datetime=None, mask_phi=True, custom_phi_keys=None, enrichment_pipeline=None, include_deleted=False)[source]¶
Build a complete, deterministic CDISC ODM 1.3.2
OdmArchivesnapshot.- Parameters:
study_key (str) –
study (Any) –
data_dictionary (DataDictionary | None) –
forms (Sequence[Any]) –
variables (Sequence[Any]) –
intervals (Sequence[Any]) –
subjects (Iterable[Any]) –
visits (Iterable[Any]) –
records (Iterable[Any]) –
revisions (Iterable[Any]) –
queries (Iterable[Any]) –
sites (Iterable[Any]) –
users (Iterable[Any]) –
reference_data (Sequence[OdmReferenceData]) –
metadata_version_oid (str) –
metadata_version_name (str | None) –
file_oid (str | None) –
file_type (Literal['Snapshot', 'Transactional']) –
creation_datetime (str | None) –
mask_phi (bool) –
custom_phi_keys (Collection[str] | None) –
enrichment_pipeline (Any) –
include_deleted (bool) –
- Return type:
- imednet.datadict.cdisc_builders.get_dataset_json_schema()[source]¶
Load the bundled official CDISC Dataset-JSON v1.1 JSON Schema.
- Return type:
dict[str, Any]
- imednet.datadict.cdisc_builders.load_dataset_json(source)[source]¶
Load and validate a CDISC Dataset-JSON v1.1 envelope from JSON text, path, or dict.
- Parameters:
source (str | Path | Mapping[str, Any]) –
- Return type:
- imednet.datadict.cdisc_builders.make_location_oid(site_token)[source]¶
Return a deterministic ODM
LocationOIDfor site_token.- Parameters:
site_token (Any) –
- Return type:
str
- imednet.datadict.cdisc_builders.make_oid_slug(raw, fallback='UNKNOWN')[source]¶
Normalize an arbitrary token into a deterministic CDISC OID segment.
- Parameters:
raw (Any) –
fallback (str) –
- Return type:
str
- imednet.datadict.cdisc_builders.make_study_event_oid(visit_token)[source]¶
Return a deterministic ODM
StudyEventOIDfor visit_token.- Parameters:
visit_token (Any) –
- Return type:
str
- imednet.datadict.cdisc_builders.make_user_oid(user_token)[source]¶
Return a deterministic ODM
UserOIDfor user_token.- Parameters:
user_token (Any) –
- Return type:
str
- imednet.datadict.cdisc_builders.make_xml_ncname(prefix, *parts, used_ids=None)[source]¶
Construct a valid XML
xs:IDNCName token starting with an ASCII letter.- Parameters:
prefix (str) –
parts (Any) –
used_ids (set[str] | None) –
- Return type:
str
- imednet.datadict.cdisc_builders.map_queries_to_annotations(queries, *, mask_phi=True, custom_phi_keys=None, used_xml_ids=None)[source]¶
Map iMednet
QueryandQueryCommenthistories into ODM<Annotation>objects.Returns
(by_record_and_var, by_record_only, by_subject_only, unattached_annotations).- Parameters:
queries (Iterable[Any]) –
mask_phi (bool) –
custom_phi_keys (Collection[str] | None) –
used_xml_ids (set[str] | None) –
- Return type:
tuple[dict[tuple[int, str], list[OdmAnnotation]], dict[int, list[OdmAnnotation]], dict[str, list[OdmAnnotation]], list[OdmAnnotation]]
- imednet.datadict.cdisc_builders.map_revisions_to_audit_records(revisions, *, default_location_oid=None, site_oid_by_record_id=None, mask_phi=True, custom_phi_keys=None, used_xml_ids=None)[source]¶
Map iMednet
RecordRevisionitems into ODM<AuditRecord>objects.Returns
(by_record_id, all_ordered_audit_records).- Parameters:
revisions (Iterable[Any]) –
default_location_oid (str | None) –
site_oid_by_record_id (Mapping[int, str] | None) –
mask_phi (bool) –
custom_phi_keys (Collection[str] | None) –
used_xml_ids (set[str] | None) –
- Return type:
tuple[dict[int, list[OdmAuditRecord]], list[OdmAuditRecord]]
- imednet.datadict.cdisc_builders.map_sites_and_users_to_admin_data(study_key, *, sites=(), users=(), inferred_site_tokens=(), inferred_user_tokens=(), metadata_version_oid='MDV.001', effective_date='1970-01-01', mask_phi=True, custom_phi_keys=None)[source]¶
Map iMednet
SiteandUsermetadata into a deterministicOdmAdminDatamodel.- Parameters:
study_key (str) –
sites (Iterable[Any]) –
users (Iterable[Any]) –
inferred_site_tokens (Iterable[tuple[Any, str | None]]) –
inferred_user_tokens (Iterable[Any]) –
metadata_version_oid (str) –
effective_date (str) –
mask_phi (bool) –
custom_phi_keys (Collection[str] | None) –
- Return type:
- imednet.datadict.cdisc_builders.normalize_odm_datetime(value, *, fallback='1970-01-01T00:00:00Z', strict=False)[source]¶
Format temporal scalars or EDC date strings into deterministic UTC ISO-8601 timestamps.
- Parameters:
value (Any) –
fallback (str) –
strict (bool) –
- Return type:
str
- imednet.datadict.cdisc_builders.to_dataset_json(envelope, *, indent=2)[source]¶
Serialize a validated
DatasetJsonEnvelopeto deterministic UTF-8 JSON text.- Parameters:
envelope (DatasetJsonEnvelope) –
indent (int) –
- Return type:
str
- imednet.datadict.cdisc_builders.to_dataset_json_file(envelope, file_path, *, indent=2)[source]¶
Write a
DatasetJsonEnvelopedeterministically to file_path.- Parameters:
envelope (DatasetJsonEnvelope) –
file_path (Path | str) –
indent (int) –
- Return type:
None
- imednet.datadict.cdisc_builders.validate_dataset_json(target)[source]¶
Validate a flat CDISC Dataset-JSON v1.1 document against JSON Schema and tuple invariants.
- Parameters:
target (DatasetJsonEnvelope | Mapping[str, Any] | str | Path) –
- Return type:
list[str]
imednet.datadict.diff module¶
Structural comparison and diffing for DataDictionary instances.
- class imednet.datadict.diff.DiffItem[source]¶
Bases:
objectA single change item.
- action: str¶
Required.
- path: str¶
Required.
- old_value: Any = None¶
- new_value: Any = None¶
- class imednet.datadict.diff.DiffReport[source]¶
Bases:
objectStructural diff report between two DataDictionary models.
- add(action, path, old_val=None, new_val=None)[source]¶
Add a diff item.
- Parameters:
action (str) –
path (str) –
old_val (Any) –
new_val (Any) –
- Return type:
None
- property has_changes: bool¶
Return True if any changes exist between the two dictionaries.
- imednet.datadict.diff.diff(old_dict, new_dict)[source]¶
Compute structural differences between two DataDictionary instances.
- Parameters:
old_dict (DataDictionary) – Baseline DataDictionary.
new_dict (DataDictionary) – Updated DataDictionary.
- Returns:
DiffReport summarizing additions, removals, and modifications.
- Return type:
imednet.datadict.emit module¶
Canonical JSON and CDISC ODM XML emission for iMednet Data Dictionary.
- imednet.datadict.emit.sort_data_dictionary(datadict)[source]¶
Return a deep copy of DataDictionary with deterministic ordering.
Ordering guarantees: - Forms sorted by formKey. - Variables on each form sorted by sequence, then variableName. - Choices on each variable sorted by position, then choiceValue. - Business logic rules sorted by sequence, then id.
- Parameters:
datadict (DataDictionary) –
- Return type:
- imednet.datadict.emit.to_file(datadict, file_path, *, indent=2, exclude_generated_at=False)[source]¶
Write canonical DataDictionary JSON to a UTF-8 encoded file.
- Parameters:
datadict (DataDictionary) – DataDictionary instance.
file_path (Path | str) – Destination file path.
indent (int) – Indentation level.
exclude_generated_at (bool) – If True, omit metadata.generatedAt.
- Return type:
None
- imednet.datadict.emit.to_json(datadict, *, indent=2, exclude_generated_at=False)[source]¶
Serialize DataDictionary to canonical, deterministic JSON.
- Parameters:
datadict (DataDictionary) – DataDictionary instance.
indent (int) – Indentation level (default: 2 spaces).
exclude_generated_at (bool) – If True, omit metadata.generatedAt for deterministic diffs/tests.
- Returns:
Canonical JSON string encoded with UTF-8 representation.
- Return type:
str
- imednet.datadict.emit.to_odm_file(datadict, file_path, *, file_oid=None, creation_datetime=None, meta_data_version_oid='MDV.001', meta_data_version_name=None, indent=' ', odm_version=None, file_type=None, originator=None, source_system=None, source_system_version=None, admin_data=(), reference_data=(), clinical_data=(), mask_phi=True, custom_phi_keys=None, validate_xsd=True)[source]¶
Write CDISC ODM 1.3 / 1.3.2 XML content to a UTF-8 encoded file.
- Parameters:
datadict (DataDictionary | OdmArchive) –
file_path (Path | str) –
file_oid (str | None) –
creation_datetime (str | None) –
meta_data_version_oid (str) –
meta_data_version_name (str | None) –
indent (str) –
odm_version (str | None) –
file_type (str | None) –
originator (str | None) –
source_system (str | None) –
source_system_version (str | None) –
admin_data (Sequence[OdmAdminData]) –
reference_data (Sequence[OdmReferenceData]) –
clinical_data (Sequence[OdmClinicalData]) –
mask_phi (bool) –
custom_phi_keys (Collection[str] | None) –
validate_xsd (bool) –
- Return type:
None
- imednet.datadict.emit.to_odm_xml(datadict, *, file_oid=None, creation_datetime=None, meta_data_version_oid='MDV.001', meta_data_version_name=None, indent=' ', odm_version=None, file_type=None, originator=None, source_system=None, source_system_version=None, admin_data=(), reference_data=(), clinical_data=(), mask_phi=True, custom_phi_keys=None, validate_xsd=True)[source]¶
Serialize DataDictionary or OdmArchive to CDISC ODM 1.3 / 1.3.2 XML format.
This function does not mutate the input DataDictionary or OdmArchive instance.
- Parameters:
datadict (DataDictionary | OdmArchive) –
file_oid (str | None) –
creation_datetime (str | None) –
meta_data_version_oid (str) –
meta_data_version_name (str | None) –
indent (str) –
odm_version (str | None) –
file_type (str | None) –
originator (str | None) –
source_system (str | None) –
source_system_version (str | None) –
admin_data (Sequence[OdmAdminData]) –
reference_data (Sequence[OdmReferenceData]) –
clinical_data (Sequence[OdmClinicalData]) –
mask_phi (bool) –
custom_phi_keys (Collection[str] | None) –
validate_xsd (bool) –
- Return type:
str
- imednet.datadict.emit.write_odm_xml_stream(datadict, target, *, file_oid=None, creation_datetime=None, meta_data_version_oid='MDV.001', meta_data_version_name=None, indent=' ', odm_version=None, file_type=None, originator=None, source_system=None, source_system_version=None, admin_data=(), reference_data=(), clinical_data=(), subject_stream=None, mask_phi=True, custom_phi_keys=None, validate_xsd=True)[source]¶
Stream CDISC ODM XML (1.3 or 1.3.2) incrementally without materializing all SubjectData.
- Parameters:
datadict (DataDictionary | OdmArchive) –
target (TextIO | BinaryIO | Path | str) –
file_oid (str | None) –
creation_datetime (str | None) –
meta_data_version_oid (str) –
meta_data_version_name (str | None) –
indent (str) –
odm_version (str | None) –
file_type (str | None) –
originator (str | None) –
source_system (str | None) –
source_system_version (str | None) –
admin_data (Sequence[OdmAdminData]) –
reference_data (Sequence[OdmReferenceData]) –
clinical_data (Sequence[OdmClinicalData]) –
subject_stream (Iterable[OdmSubjectData] | None) –
mask_phi (bool) –
custom_phi_keys (Collection[str] | None) –
validate_xsd (bool) –
- Return type:
None
imednet.datadict.exchange module¶
Canonical read-only exchange models for CDISC ODM 1.3.2 and Dataset-JSON v1.1.
- class imednet.datadict.exchange.DatasetJsonBundle[source]¶
Bases:
objectTyped multi-dataset Python bundle mapping
itemGroupOIDkeys to v1.1 envelopes.- study_oid: str¶
Required. API field
studyOID.
- metadata_version_oid: str = 'MDV.001'¶
API field
metaDataVersionOID.
- dataset_json_creation_datetime: str¶
Required. API field
datasetJSONCreationDateTime.
- datasets: dict[str, DatasetJsonEnvelope] = dict()¶
- get(key, default=None)[source]¶
Return dataset envelope for key if present, else default.
- Parameters:
key (str) –
default (DatasetJsonEnvelope | None) –
- Return type:
DatasetJsonEnvelope | None
- items()[source]¶
Return view of
(itemGroupOID, DatasetJsonEnvelope)pairs.- Return type:
ItemsView[str, DatasetJsonEnvelope]
- values()[source]¶
Return view of
DatasetJsonEnvelopevalues.- Return type:
ValuesView[DatasetJsonEnvelope]
- class imednet.datadict.exchange.DatasetJsonColumn[source]¶
Bases:
objectCDISC Dataset-JSON v1.1 column definition inside top-level
columns.- item_oid: str¶
Required. API field
itemOID.
- name: str¶
Required.
- label: str¶
Required.
- data_type: Literal['string', 'integer', 'float', 'double', 'decimal', 'boolean', 'date', 'time', 'datetime', 'URI']¶
Required. API field
dataType.
- target_data_type: Literal['integer', 'decimal'] | None = None¶
API field
targetDataType.
- length: int | None = None¶
- display_format: str | None = None¶
API field
displayFormat.
- key_sequence: int | None = None¶
API field
keySequence.
- property oid: str¶
Return
item_oidfor ergonomic Python inspection.
- property type: Literal['string', 'integer', 'float', 'double', 'decimal', 'boolean', 'date', 'time', 'datetime', 'URI']¶
Return
data_typefor ergonomic Python inspection.
- class imednet.datadict.exchange.DatasetJsonEnvelope[source]¶
Bases:
objectCanonical read-only flat CDISC Dataset-JSON v1.1 single-dataset envelope.
- dataset_json_creation_datetime: str¶
Required. API field
datasetJSONCreationDateTime.
- dataset_json_version: Literal['1.1.0'] = '1.1.0'¶
API field
datasetJSONVersion.
- file_oid: str | None = None¶
API field
fileOID.
- db_last_modified_datetime: str | None = None¶
API field
dbLastModifiedDateTime.
- originator: str | None = None¶
- source_system: DatasetJsonSourceSystem | None = None¶
API field
sourceSystem.
- study_oid: str | None = None¶
API field
studyOID.
- metadata_version_oid: str | None = None¶
API field
metaDataVersionOID.
- metadata_ref: str | None = None¶
API field
metaDataRef.
- item_group_oid: str¶
Required. API field
itemGroupOID.
- is_reference_data: bool | None = None¶
API field
isReferenceData.
- records: int¶
Required.
- name: str¶
Required.
- label: str¶
Required.
- columns: tuple[DatasetJsonColumn, ...] = ()¶
- rows: tuple[tuple[str | int | float | bool | None, ...], ...] = ()¶
- imednet.datadict.exchange.DatasetJsonItem¶
alias of
DatasetJsonColumn
- class imednet.datadict.exchange.DatasetJsonSourceSystem[source]¶
Bases:
objectCDISC Dataset-JSON v1.1
sourceSystemmetadata descriptor.- name: str¶
Required.
- version: str¶
Required.
- class imednet.datadict.exchange.OdmAdminData[source]¶
Bases:
objectCDISC ODM 1.3.2
<AdminData>container for study users and locations.- study_oid: str | None = None¶
API field
studyOID.
- locations: tuple[OdmLocation, ...] = ()¶
- extra_attributes: dict[str, Any] = dict()¶
API field
extraAttributes.
- class imednet.datadict.exchange.OdmAnnotation[source]¶
Bases:
objectCDISC ODM 1.3.2
<Annotation>element for EDC queries and query comments.- seq_num: int¶
Required. API field
seqNum.
- id: str | None = None¶
- transaction_type: str | None = None¶
API field
transactionType.
- comment: str | None = None¶
- sponsor_or_site: str | None = None¶
API field
sponsorOrSite.
- class imednet.datadict.exchange.OdmArchive[source]¶
Bases:
objectCanonical read-only CDISC ODM 1.3.2 archive snapshot extending DataDictionary.
- file_oid: str = 'IMEDNET_ODM_EXPORT'¶
API field
fileOID.
- file_type: Literal['Snapshot', 'Transactional'] = 'Snapshot'¶
API field
fileType.
- odm_version: str = '1.3.2'¶
API field
odmVersion.
- creation_datetime: str | None = None¶
API field
creationDateTime.
- as_of_datetime: str | None = None¶
API field
asOfDateTime.
- originator: str | None = None¶
- source_system: str | None = None¶
API field
sourceSystem.
- source_system_version: str | None = None¶
API field
sourceSystemVersion.
- description: str | None = None¶
- metadata_version_oid: str = 'MDV.001'¶
API field
metaDataVersionOID.
- metadata_version_name: str | None = None¶
API field
metaDataVersionName.
- data_dictionary: DataDictionary¶
Required. API field
dataDictionary.
- admin_data: tuple[OdmAdminData, ...] = ()¶
API field
adminData.
- reference_data: tuple[OdmReferenceData, ...] = ()¶
API field
referenceData.
- clinical_data: tuple[OdmClinicalData, ...] = ()¶
API field
clinicalData.
- validation_warnings: tuple[str, ...] = ()¶
API field
validationWarnings.
- class imednet.datadict.exchange.OdmAuditRecord[source]¶
Bases:
objectCDISC ODM 1.3.2
<AuditRecord>element for 21 CFR Part 11 revision trails.- id: str | None = None¶
- edit_point: str | None = None¶
API field
editPoint.
- used_imputation_method: str | None = None¶
API field
usedImputationMethod.
- user_oid: str¶
Required. API field
userOID.
- location_oid: str¶
Required. API field
locationOID.
- datetime_stamp: str¶
Required. API field
dateTimeStamp.
- reason_for_change: str | None = None¶
API field
reasonForChange.
- source_id: str | None = None¶
API field
sourceID.
- class imednet.datadict.exchange.OdmClinicalData[source]¶
Bases:
objectCDISC ODM 1.3.2
<ClinicalData>container for clinical, audit, and query records.- study_oid: str¶
Required. API field
studyOID.
- metadata_version_oid: str¶
Required. API field
metaDataVersionOID.
- subjects: tuple[OdmSubjectData, ...] = ()¶
- audit_records: tuple[OdmAuditRecord, ...] = ()¶
API field
auditRecords.
- annotations: tuple[OdmAnnotation, ...] = ()¶
- class imednet.datadict.exchange.OdmFlag[source]¶
Bases:
objectCDISC ODM 1.3.2
<Flag>child of<Annotation>.- flag_value: str¶
Required. API field
flagValue.
- flag_value_codelist_oid: str = 'CL.IMEDNET_FLAG_VALUE'¶
API field
flagValueCodeListOID.
- flag_type: str | None = None¶
API field
flagType.
- flag_type_codelist_oid: str | None = None¶
API field
flagTypeCodeListOID.
- class imednet.datadict.exchange.OdmFormData[source]¶
Bases:
objectCDISC ODM 1.3.2
<FormData>container.- form_oid: str¶
Required. API field
formOID.
- form_repeat_key: str | None = None¶
API field
formRepeatKey.
- transaction_type: str | None = None¶
API field
transactionType.
- audit_record: OdmAuditRecord | None = None¶
API field
auditRecord.
- annotations: tuple[OdmAnnotation, ...] = ()¶
- item_groups: tuple[OdmItemGroupData, ...] = ()¶
API field
itemGroups.
- property item_group_data: tuple[imednet.datadict.exchange.OdmItemGroupData, ...]¶
Alias for
item_groupsmatching ODMItemGroupDataterminology.
- class imednet.datadict.exchange.OdmItemData[source]¶
Bases:
objectCDISC ODM 1.3.2
<ItemData>value cell.- item_oid: str¶
Required. API field
itemOID.
- value: str | None = None¶
- is_null: bool = False¶
API field
isNull.
- transaction_type: str | None = None¶
API field
transactionType.
- audit_record_id: str | None = None¶
API field
auditRecordID.
- annotation_id: str | None = None¶
API field
annotationID.
- measurement_unit_oid: str | None = None¶
API field
measurementUnitOID.
- audit_record: OdmAuditRecord | None = None¶
API field
auditRecord.
- annotations: tuple[OdmAnnotation, ...] = ()¶
- class imednet.datadict.exchange.OdmItemGroupData[source]¶
Bases:
objectCDISC ODM 1.3.2
<ItemGroupData>record container.- item_group_oid: str¶
Required. API field
itemGroupOID.
- item_group_repeat_key: str | None = None¶
API field
itemGroupRepeatKey.
- transaction_type: str | None = None¶
API field
transactionType.
- audit_record: OdmAuditRecord | None = None¶
API field
auditRecord.
- annotations: tuple[OdmAnnotation, ...] = ()¶
- items: tuple[OdmItemData, ...] = ()¶
- property audit_records: tuple[imednet.datadict.exchange.OdmAuditRecord, ...]¶
Return inline
AuditRecordas a read-only tuple.
- class imednet.datadict.exchange.OdmLocation[source]¶
Bases:
objectCDISC ODM 1.3.2
<Location>site/institution definition.- oid: str¶
Required.
- name: str¶
Required.
- location_type: str = 'Site'¶
API field
locationType.
- metadata_version_refs: tuple[OdmMetaDataVersionRef, ...] = ()¶
API field
metaDataVersionRefs.
- extra_attributes: dict[str, Any] = dict()¶
API field
extraAttributes.
- class imednet.datadict.exchange.OdmMetaDataVersionRef[source]¶
Bases:
objectCDISC ODM 1.3.2
<MetaDataVersionRef>child of<Location>.- study_oid: str¶
Required. API field
studyOID.
- metadata_version_oid: str¶
Required. API field
metaDataVersionOID.
- effective_date: str = '1970-01-01'¶
API field
effectiveDate.
- class imednet.datadict.exchange.OdmReferenceData[source]¶
Bases:
objectCDISC ODM 1.3.2
<ReferenceData>container for non-subject reference tables.- study_oid: str¶
Required. API field
studyOID.
- metadata_version_oid: str¶
Required. API field
metaDataVersionOID.
- item_groups: tuple[OdmItemGroupData, ...] = ()¶
API field
itemGroups.
- property item_group_data: tuple[imednet.datadict.exchange.OdmItemGroupData, ...]¶
Alias for
item_groupsmatching ODMItemGroupDataterminology.
- class imednet.datadict.exchange.OdmStudyEventData[source]¶
Bases:
objectCDISC ODM 1.3.2
<StudyEventData>scheduled or unscheduled visit container.- study_event_oid: str¶
Required. API field
studyEventOID.
- study_event_repeat_key: str | None = None¶
API field
studyEventRepeatKey.
- transaction_type: str | None = None¶
API field
transactionType.
- audit_record: OdmAuditRecord | None = None¶
API field
auditRecord.
- annotations: tuple[OdmAnnotation, ...] = ()¶
- forms: tuple[OdmFormData, ...] = ()¶
- class imednet.datadict.exchange.OdmSubjectData[source]¶
Bases:
objectCDISC ODM 1.3.2
<SubjectData>subject clinical hierarchy.- subject_key: str¶
Required. API field
subjectKey.
- transaction_type: str | None = None¶
API field
transactionType.
- investigator_user_oid: str | None = None¶
API field
investigatorUserOID.
- site_location_oid: str | None = None¶
API field
siteLocationOID.
- audit_record: OdmAuditRecord | None = None¶
API field
auditRecord.
- annotations: tuple[OdmAnnotation, ...] = ()¶
- study_events: tuple[OdmStudyEventData, ...] = ()¶
API field
studyEvents.
- forms: tuple[OdmFormData, ...] = ()¶
- class imednet.datadict.exchange.OdmUser[source]¶
Bases:
objectCDISC ODM 1.3.2
<User>administrative definition.- oid: str¶
Required.
- user_type: str | None = None¶
API field
userType.
- login_name: str | None = None¶
API field
loginName.
- display_name: str | None = None¶
API field
displayName.
- full_name: str | None = None¶
API field
fullName.
- first_name: str | None = None¶
API field
firstName.
- last_name: str | None = None¶
API field
lastName.
- organization: str | None = None¶
- email: str | None = None¶
- phone: str | None = None¶
- location_refs: tuple[str, ...] = ()¶
API field
locationRefs.
- extra_attributes: dict[str, Any] = dict()¶
API field
extraAttributes.
imednet.datadict.logic module¶
Business logic XML parsing and AST evaluation for iMednet data dictionary.
- class imednet.datadict.logic.ExtractedCondition[source]¶
Bases:
objectFlattened representation of a single XML condition leaf.
- variable: str¶
Required.
- operator: str = '=='¶
- value: Any = ''¶
- expected_truth: bool = True¶
- form: str | None = None¶
- compare_variable: str | None = None¶
- class imednet.datadict.logic.ExtractedRuleMetadata[source]¶
Bases:
objectStructured metadata extracted from a BusinessLogicRule AST.
- rule_id: str | int | None¶
Required.
- rule_name: str¶
Required.
- form: str | None¶
Required.
- rule_type: str | None¶
Required.
- severity: Literal['error', 'warning', 'none']¶
Required.
- logical_operator: Literal['AND', 'OR']¶
Required.
- conditions: list[ExtractedCondition] = list()¶
- message: str | None = None¶
- is_cross_scope: bool = False¶
- is_ui_only: bool = False¶
- class imednet.datadict.logic.LogicEvaluationReport[source]¶
Bases:
objectAggregated results of evaluating multiple BusinessLogicRules.
- results: list[RuleEvaluationResult] = list()¶
- property errors: list[imednet.datadict.logic.RuleEvaluationResult]¶
Blocking rule violations (e.g. Form or Required edit checks).
- property has_errors: bool¶
Return True when one or more blocking rules triggered.
- property skipped: list[imednet.datadict.logic.RuleEvaluationResult]¶
Rules skipped due to inactive status, missing logic, UI actions, or cross-scope refs.
- property warnings: list[imednet.datadict.logic.RuleEvaluationResult]¶
Non-blocking rule triggers (e.g. Query or Auto Query rules).
- class imednet.datadict.logic.LogicTreeEvaluator[source]¶
Bases:
objectDeterministic, non-
evalevaluator for parsed BusinessLogicRule XML ASTs.- evaluate_rule(rule, data, *, form_key=None)[source]¶
Evaluate a single BusinessLogicRule or dict against
data.- Parameters:
rule (Any) –
data (Mapping[str, Any]) –
form_key (str | None) –
- Return type:
- evaluate_rules(rules, data, *, form_key=None)[source]¶
Evaluate a sequence of BusinessLogicRule instances or dicts against
data.- Parameters:
rules (Iterable[Any]) –
data (Mapping[str, Any]) –
form_key (str | None) –
- Return type:
- evaluate_tree(logic_tree, data, *, form_key=None, rule_type=None)[source]¶
Evaluate an unwrapped logic AST against
data.- Returns:
(triggered, is_cross_scope, skip_reason)- Parameters:
logic_tree (Mapping[str, Any]) –
data (Mapping[str, Any]) –
form_key (str | None) –
rule_type (str | None) –
- Return type:
tuple[bool, bool, str | None]
- extract_rule_metadata(rule, *, default_form=None)[source]¶
Extract structured condition and target metadata from an XML BusinessLogicRule.
- Parameters:
rule (Any) –
default_form (str | None) –
- Return type:
ExtractedRuleMetadata | None
- class imednet.datadict.logic.RangeCheckConstraint[source]¶
Bases:
objectNormalized CDISC ODM RangeCheck comparator, check values, and SoftHard severity.
- comparator: Literal['LT', 'LE', 'GT', 'GE', 'EQ', 'NE', 'IN', 'NOTIN']¶
Required.
- check_values: tuple[str, ...]¶
Required.
- soft_hard: Literal['Soft', 'Hard'] = 'Hard'¶
- error_message: str | None = None¶
- class imednet.datadict.logic.RuleEvaluationResult[source]¶
Bases:
objectOutcome of evaluating a single BusinessLogicRule against a Record.
- rule_id: str | int | None¶
Required.
- rule_name: str¶
Required.
- rule_type: str | None¶
Required.
- severity: Literal['error', 'warning', 'none']¶
Required.
- triggered: bool¶
Required.
- message: str¶
Required.
- skipped: bool = False¶
- skip_reason: str | None = None¶
- is_cross_scope: bool = False¶
- class imednet.datadict.logic.VariableConstraints[source]¶
Bases:
objectNormalized validation constraints extracted from a DataDictionary Variable.
- choices: list[str] = list()¶
- required_policy: Literal['yes', 'auto_query', 'no'] = 'no'¶
- min_value: float | None = None¶
- max_value: float | None = None¶
- min_length: int | None = None¶
- max_length: int | None = None¶
- range_checks: tuple[RangeCheckConstraint, ...] = ()¶
- imednet.datadict.logic.extract_variable_constraints(var)[source]¶
Extract choices, required policy, numeric bounds, and string lengths from a Variable.
- Parameters:
var (Any) –
- Return type:
- imednet.datadict.logic.parse_logic_xml(xml_content)[source]¶
Parse BusinessLogic XML into a structured AST dictionary.
- Parameters:
xml_content (str | None) – Verbatim XML string, or None.
- Returns:
Structured dictionary representation of the rule logic, or None if input is empty.
- Raises:
ValueError – If XML parsing fails due to invalid syntax.
- Return type:
dict[str, Any] | None
- imednet.datadict.logic.validate_regex_pattern(pattern)[source]¶
Validate that
patternis syntactically valid and safe against ReDoS.- Parameters:
pattern (str) – Regular expression string to inspect.
- Raises:
ValueError – If
patternexceeds length limits, fails syntax parsing, or contains backtracking-prone constructs.- Return type:
None
imednet.datadict.models module¶
Canonical Pydantic v2 data models for iMednet Data Dictionary.
- class imednet.datadict.models.BusinessLogicRule[source]¶
Bases:
DictCompatMixin,BaseModelAn edit check, workflow trigger, or business logic rule.
- id: str | int | None = None¶
Unique rule identifier
- name: str | None = None¶
Descriptive name of the rule
- type: str | None = None¶
Rule category: Form, Workflow, Query, Approval, Required
- status: str | None = None¶
Rule status (Active, Inactive)
- form: str | None = None¶
Form key if rule is form-scoped or attached
- sequence: int | None = None¶
Execution sequence
- logic: dict[str, Any] | None = None¶
Structured parsed AST of the business logic
- logicRawXml: str | None = None¶
Verbatim XML string (optional, omitted with –no-raw-xml)
- extraAttributes: dict[str, Any] = dict()¶
Additional rule properties or unknown columns
- get(key, default=None)¶
Return value for key or default if absent.
- Parameters:
key (str) –
default (Any) –
- Return type:
Any
- items()¶
Return list of (key, value) pairs.
- Return type:
list[tuple[str, Any]]
- keys()¶
Return list of accessible keys.
- Return type:
list[str]
- class imednet.datadict.models.Choice[source]¶
Bases:
DictCompatMixin,BaseModelA choice option for single-select or multi-select variables.
- choiceText: str¶
Required. Display text of the choice
- choiceValue: str¶
Required. Coded value of the choice
- position: int | None = None¶
Display order sequence
- extraAttributes: dict[str, Any] = dict()¶
Unknown columns for this choice
- get(key, default=None)¶
Return value for key or default if absent.
- Parameters:
key (str) –
default (Any) –
- Return type:
Any
- items()¶
Return list of (key, value) pairs.
- Return type:
list[tuple[str, Any]]
- keys()¶
Return list of accessible keys.
- Return type:
list[str]
- class imednet.datadict.models.DataDictionary[source]¶
Bases:
DictCompatMixin,BaseModelCanonical root data dictionary container.
- unassignedBusinessLogic: list[BusinessLogicRule] = list()¶
Business logic not tied to a single form (Workflow, Query, Approval, Required)
- property business_logic: list[Any]¶
Backward-compatible access to all business logic rules.
- property choices: list[imednet.datadict.models.Choice]¶
Backward-compatible access to all choices.
- form_for_key(form_key)[source]¶
Return the Form model matching
form_key, or None if absent.- Parameters:
form_key (str) –
- Return type:
Form | None
- form_key_from_id(form_id)[source]¶
Resolve a
formKeyfrom a numeric or stringformId.- Parameters:
form_id (int | str) –
- Return type:
str | None
- get(key, default=None)¶
Return value for key or default if absent.
- Parameters:
key (str) –
default (Any) –
- Return type:
Any
- items()¶
Return list of (key, value) pairs.
- Return type:
list[tuple[str, Any]]
- keys()¶
Return list of accessible keys.
- Return type:
list[str]
- property questions: list[imednet.datadict.models.Variable]¶
Backward-compatible access to all variables as questions.
- rules_for_form(form_key)[source]¶
Return all business logic rules scoped or attached to
form_key.- Parameters:
form_key (str) –
- Return type:
list[BusinessLogicRule]
- class imednet.datadict.models.DictCompatMixin[source]¶
Bases:
objectProvides dictionary-like interface for legacy callers.
- class imednet.datadict.models.Form[source]¶
Bases:
DictCompatMixin,BaseModelA form defining data fields and rules for clinical data entry.
- formKey: str¶
Required. Unique short code/mnemonic for the form
- formName: str | None = None¶
Human-readable form title
- formId: str | int | None = None¶
Unique form identifier
- formType: str | None = None¶
Type of form (Subject, Study, Admin, etc.)
- businessLogic: list[BusinessLogicRule] = list()¶
Form-scoped business logic rules
- extraAttributes: dict[str, Any] = dict()¶
Unknown columns for this form
- get(key, default=None)¶
Return value for key or default if absent.
- Parameters:
key (str) –
default (Any) –
- Return type:
Any
- items()¶
Return list of (key, value) pairs.
- Return type:
list[tuple[str, Any]]
- keys()¶
Return list of accessible keys.
- Return type:
list[str]
- class imednet.datadict.models.Metadata[source]¶
Bases:
BaseModelMetadata envelope for the study data dictionary.
- schemaVersion: str = '1.0.0'¶
Data dictionary schema version
- studyKey: str | None = None¶
Study key
- generatedAt: str | None = None¶
Timestamp of data dictionary generation
- source: str | None = None¶
Source of generation (csv, api)
- validationWarnings: list[str] = list()¶
Warnings generated during loading/validation
- extraAttributes: dict[str, Any] = dict()¶
Unknown metadata columns or properties
- class imednet.datadict.models.Variable[source]¶
Bases:
DictCompatMixin,BaseModelA clinical data variable (data point) on a form.
- variableName: str¶
Required. Unique identifier for variable within form
- label: str | None = None¶
Display prompt/label on the Form for a Subject
- variableType: str | None = None¶
Field type (Text, Radio, Date/Time Precision, etc.)
- sequence: int | None = None¶
Display order within form
- required: str | None = None¶
Required policy (e.g. ‘Yes’, ‘No’, ‘Auto Query’)
- format: str | None = None¶
Format mask or pattern
- precision: str | None = None¶
Date/Time or number precision
- extraAttributes: dict[str, Any] = dict()¶
Unknown columns for this variable
- get(key, default=None)¶
Return value for key or default if absent.
- Parameters:
key (str) –
default (Any) –
- Return type:
Any
- items()¶
Return list of (key, value) pairs.
- Return type:
list[tuple[str, Any]]
- keys()¶
Return list of accessible keys.
- Return type:
list[str]
- property variable_name: str¶
Snake-case alias for variableName matching core Variable models.
- property variable_type: str | None¶
Snake-case alias for variableType matching core Variable models.
imednet.datadict.normalize module¶
Field normalization and date policy for data dictionary.
- imednet.datadict.normalize.normalize_form_id(form_id, form_key=None)[source]¶
Normalize formId values, stripping synthetic formKey fallbacks and coercing numeric IDs.
- Parameters:
form_id (Any) – Raw formId value from a loader or model.
form_key (str | None) – Associated formKey to detect synthetic formId == formKey defaults.
- Returns:
Normalized integer or string formId, or None if unset or synthetic.
- Return type:
int | str | None
- imednet.datadict.normalize.normalize_form_type(value, *, default=None)[source]¶
Normalize formType values across loaders using canonical ‘Subject’ terminology.
Legacy ‘Patient’ (and ‘CRF’/’Participant’) values normalize to ‘Subject’.
- Parameters:
value (str | None) – Raw formType value.
default (str | None) – Default canonical formType when value is empty or None.
- Returns:
Normalized formType string or default.
- Return type:
str | None
- imednet.datadict.normalize.normalize_measurement_units(extra_attrs)[source]¶
Extract and normalize measurement unit definitions from extraAttributes.
- Parameters:
extra_attrs (dict[str, Any] | None) – Dictionary of extra attributes on Metadata or Variable.
- Returns:
List of normalized unit dictionaries containing ‘oid’, ‘name’, and ‘symbol’.
- Return type:
list[dict[str, str]]
- imednet.datadict.normalize.normalize_row_data(row, known_camel_fields, source_name='CSV')[source]¶
Normalize a CSV row: map known headers to camelCase and isolate unknown attributes.
- Parameters:
row (dict[str, str]) – Raw dictionary of CSV header to string value.
known_camel_fields (set[str]) – Set of known fields in camelCase.
source_name (str) – Name of the source file for warning messages.
- Returns:
Tuple of (known_fields_dict, extra_attributes_dict, warning_messages).
- Return type:
tuple[dict[str, Any], dict[str, Any], list[str]]
- imednet.datadict.normalize.normalize_variable_bounds(extra_attrs)[source]¶
Extract and normalize validation bounds or ODM RangeChecks from extraAttributes.
- Parameters:
extra_attrs (dict[str, Any] | None) – Variable extraAttributes dictionary.
- Returns:
List of normalized range check dictionaries ready for ODM serialization.
- Return type:
list[dict[str, Any]]
- imednet.datadict.normalize.normalize_variable_type(value, *, precision=None)[source]¶
Normalize variableType values across CSV, ODM, REDCap, and SDK sources.
- Parameters:
value (str | None) – Raw variableType string.
precision (str | None) – Optional precision string to disambiguate generic ‘Number’ types.
- Returns:
Canonical variableType string, or None if empty.
- Return type:
str | None
- imednet.datadict.normalize.to_camel_case(text)[source]¶
Strict lexical camelCasing for headers without semantic renames.
Examples
‘Patient Record Report’ -> ‘patientRecordReport’ ‘Special Patient ID’ -> ‘specialPatientId’ ‘Form Key’ -> ‘formKey’ ‘Form ID’ -> ‘formId’ ‘BUSINESS_LOGIC’ -> ‘businessLogic’ ‘variableName’ -> ‘variableName’ ‘Form’ -> ‘form’
- Parameters:
text (str) – The string to convert.
- Returns:
The camelCased string.
- Return type:
str
- imednet.datadict.normalize.validate_timestamp(timestamp_str)[source]¶
Assert that a timestamp string adheres strictly to the MM-DD-YYYY format.
- Parameters:
timestamp_str (str) – The timestamp string to validate.
- Returns:
The validated timestamp string.
- Raises:
ValueError – If the timestamp does not adhere to MM-DD-YYYY or has invalid calendar date.
- Return type:
str
imednet.datadict.schema module¶
JSON Schema generation and validation for iMednet Data Dictionary.
- imednet.datadict.schema.get_schema()[source]¶
Generate or retrieve the canonical JSON Schema for DataDictionary.
- Returns:
JSON Schema dictionary.
- Return type:
dict[str, Any]
- imednet.datadict.schema.validate(target, schema=None)[source]¶
Validate a data dictionary against the canonical model or an optional JSON schema.
- Parameters:
target (dict[str, Any] | str | Path | DataDictionary) – DataDictionary instance, dict, JSON string, or path to JSON file.
schema (dict[str, Any] | None) – Optional JSON Schema to validate against via jsonschema.
- Returns:
List of error strings (empty if valid).
- Return type:
list[str]