cdiscbuilder 1.2.1__tar.gz → 1.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/LICENSE +21 -21
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/MANIFEST.in +3 -3
- {cdiscbuilder-1.2.1/src/cdiscbuilder.egg-info → cdiscbuilder-1.2.3}/PKG-INFO +195 -195
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/README.md +181 -181
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/pyproject.toml +30 -30
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/setup.cfg +4 -4
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/__init__.py +10 -10
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/__init__.py +23 -23
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_derivation/__init__.py +11 -11
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_derivation/derivations/__init__.py +6 -6
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_derivation/derivations/base.py +47 -47
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_derivation/derivations/function_derivation.py +195 -195
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_derivation/derivations/sql_derivation.py +644 -644
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_derivation/engine.py +209 -199
- cdiscbuilder-1.2.3/src/cdiscbuilder/adam/adam_derivation/functions/__init__.py +6 -0
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_derivation/functions/get_bmi.py +11 -11
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_derivation/loaders/__init__.py +5 -5
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_derivation/loaders/sdtm_loader.py +129 -129
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_derivation/tests/test_engine.py +96 -96
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_derivation/utils/__init__.py +1 -1
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_derivation/utils/logger.py +86 -86
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_spec/__init__.py +15 -15
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_spec/adam_spec.py +413 -413
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_spec/merge_yaml.py +102 -102
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_spec/schema_validator.py +758 -758
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_spec/tests/__init__.py +1 -1
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_spec/tests/data/scenarios/organization/adsl_common.yaml +122 -122
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_spec/tests/data/scenarios/project/adsl_project.yaml +37 -37
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_spec/tests/data/scenarios/schema.yaml +227 -227
- cdiscbuilder-1.2.3/src/cdiscbuilder/adam/adam_spec/tests/data/scenarios/study1/adam_study1.yaml +3 -0
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_spec/tests/data/scenarios/study1/adsl_study1.yaml +15 -15
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_spec/tests/data/scenarios/study1/final_adsl_study1.yaml +123 -123
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_spec/tests/data/scenarios/study2/adsl_study2.yaml +21 -21
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_spec/tests/data/scenarios/study2/final_adsl_study2.yaml +137 -137
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_spec/tests/test_adam_spec.py +72 -72
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_spec/tests/test_merge_yaml.py +104 -104
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_spec/tests/test_schema_validator.py +121 -121
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_validation/__init__.py +5 -5
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_validation/data_validator.py +214 -214
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/schema.yaml +70 -70
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/cli.py +82 -82
- {cdiscbuilder-1.2.1/src/cdiscbuilder/adam/adam_derivation → cdiscbuilder-1.2.3/src/cdiscbuilder}/functions/__init__.py +68 -63
- cdiscbuilder-1.2.3/src/cdiscbuilder/functions/calculate_study_day.py +23 -0
- cdiscbuilder-1.2.1/src/cdiscbuilder/sdtm/engine/functions.py → cdiscbuilder-1.2.3/src/cdiscbuilder/functions/extract_value.py +50 -72
- cdiscbuilder-1.2.3/src/cdiscbuilder/functions/get_bmi.py +11 -0
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/sdtm/__init__.py +4 -4
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/sdtm/engine/classes/base.py +63 -63
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/sdtm/engine/classes/events.py +12 -12
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/sdtm/engine/classes/findings.py +177 -177
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/sdtm/engine/classes/general.py +491 -431
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/sdtm/engine/classes/interventions.py +12 -12
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/sdtm/engine/classes/special_purpose.py +11 -11
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/sdtm/engine/config.py +57 -57
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/sdtm/engine/processor.py +144 -125
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/sdtm/engine/tests/test_boundary_standardization.py +1 -1
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/sdtm/engine/tests/test_config.py +71 -71
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/sdtm/engine/tests/test_findings.py +58 -58
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/sdtm/engine/tests/test_general.py +115 -115
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/sdtm/engine/tests/test_processor.py +179 -179
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/sdtm/engine/tests/test_validate.py +94 -94
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/sdtm/engine/validate.py +119 -119
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/sdtm/loader/__init__.py +9 -9
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/sdtm/loader/load.py +180 -180
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/sdtm/loader/tests/__init__.py +3 -3
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/sdtm/loader/tests/test_load.py +272 -272
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/sdtm/odm_parser.py +208 -208
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/sdtm/sdtm.py +71 -71
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3/src/cdiscbuilder.egg-info}/PKG-INFO +195 -195
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder.egg-info/SOURCES.txt +4 -1
- cdiscbuilder-1.2.1/src/cdiscbuilder/adam/adam_spec/tests/data/scenarios/study1/adam_study1.yaml +0 -3
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/adam/adam_spec/tests/data/scenarios/study2/adam_study2.yaml +0 -0
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/sdtm/engine/__init__.py +0 -0
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/sdtm/engine/classes/__init__.py +0 -0
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/sdtm/engine/tests/test_metadata_extractor.py +0 -0
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder/tlf/__init__.py +0 -0
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder.egg-info/dependency_links.txt +0 -0
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder.egg-info/entry_points.txt +0 -0
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder.egg-info/requires.txt +0 -0
- {cdiscbuilder-1.2.1 → cdiscbuilder-1.2.3}/src/cdiscbuilder.egg-info/top_level.txt +0 -0
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Ming-Chun Chen
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ming-Chun Chen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
include src/cdiscbuilder/adam/schema.yaml
|
|
2
|
-
recursive-include src/cdiscbuilder/adam/adam_spec/tests/data *.yaml
|
|
3
|
-
include src/cdiscbuilder/metadata/*.yaml
|
|
1
|
+
include src/cdiscbuilder/adam/schema.yaml
|
|
2
|
+
recursive-include src/cdiscbuilder/adam/adam_spec/tests/data *.yaml
|
|
3
|
+
include src/cdiscbuilder/metadata/*.yaml
|
|
@@ -1,195 +1,195 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: cdiscbuilder
|
|
3
|
-
Version: 1.2.
|
|
4
|
-
Summary: A package to convert ODM XML to SDTM/ADaM Datasets
|
|
5
|
-
Author-email: Ming-Chun Chen <hellomingchun@gmail.com>
|
|
6
|
-
Requires-Python: >=3.9
|
|
7
|
-
Description-Content-Type: text/markdown
|
|
8
|
-
License-File: LICENSE
|
|
9
|
-
Requires-Dist: pandas
|
|
10
|
-
Requires-Dist: pyyaml
|
|
11
|
-
Requires-Dist: polars>=0.20.0
|
|
12
|
-
Requires-Dist: reactable>=0.1.6
|
|
13
|
-
Dynamic: license-file
|
|
14
|
-
|
|
15
|
-
# CDISC Builder
|
|
16
|
-
|
|
17
|
-
**`cdiscbuilder`** is a Python package designed to simplify the transformation of clinical trial data from **ODM (Operational Data Model)** XML format into **CDISC SDTM (Study Data Tabulation Model)** and **ADaM (Analysis Data Model)** datasets.
|
|
18
|
-
|
|
19
|
-
It provides a flexible, configuration-driven approach to data mapping, allowing users to define rules using simple YAML files or Python dictionaries without harcoding complex logic.
|
|
20
|
-
|
|
21
|
-
## Key Features
|
|
22
|
-
|
|
23
|
-
- **ODM XML Parsing**: Efficiently parses CDISC ODM strings and files into workable dataframes.
|
|
24
|
-
- **Configurable Mappings**: Define your mapping rules (source columns, hardcoded values, custom logic) in YAML.
|
|
25
|
-
- **Schema Validation**: Ensures your configuration files adhere to strict standards before processing.
|
|
26
|
-
- **Metadata-Driven Findings**: Powerful processor for Findings domains (VS, LB, FA, etc.) using granular metadata.
|
|
27
|
-
- **Excel/Parquet Output**: Generates regulatory-compliant datasets in modern formats.
|
|
28
|
-
|
|
29
|
-
## Installation
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
pip install cdiscbuilder
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## Quick Start
|
|
36
|
-
|
|
37
|
-
### 1. Command Line Interface
|
|
38
|
-
|
|
39
|
-
You can generate datasets directly from your terminal:
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
# Generate SDTM datasets from an ODM XML file
|
|
43
|
-
cdisc-sdtm --xml study_data.xml --output ./sdtm_data
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
### 2. Python API
|
|
47
|
-
|
|
48
|
-
```python
|
|
49
|
-
from cdiscbuilder.sdtm import create_sdtm_datasets
|
|
50
|
-
|
|
51
|
-
# Define paths
|
|
52
|
-
xml_file = "study_data.xml"
|
|
53
|
-
config_dir = "path/to/my/specs"
|
|
54
|
-
output_dir = "./sdtm_outputs"
|
|
55
|
-
|
|
56
|
-
# Generate Datasets
|
|
57
|
-
create_sdtm_datasets(config_dir, xml_file, output_dir)
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## Configuration
|
|
61
|
-
|
|
62
|
-
For detailed and complete references on how to structure mapping specifications, see:
|
|
63
|
-
* **[SDTM Mapping Specification](file:///c:/Users/mingc/Documents/projects/cdiscbuilder/cdisc_builder/docs/SDTM_MAPPING_SPECIFICATION.md)**: Details on the intermediate `odm_long.csv` schema, wide vs. findings domains, regex extraction, and validation rules.
|
|
64
|
-
* **[ADaM Mapping Specification](file:///c:/Users/mingc/Documents/projects/cdiscbuilder/cdisc_builder/docs/ADAM_MAPPING_SPECIFICATION.md)**: Details on ADaM yaml configuration schema, inheritance, SQL-like derivations, conditions, and aggregations.
|
|
65
|
-
|
|
66
|
-
The package comes with standard configurations for common domains (`DM`, `AE`, `VS`, etc.) in `src/cdisc_builder/specs`. You can override these or add new ones by creating your own configuration directory.
|
|
67
|
-
|
|
68
|
-
### Example YAML (`DM.yaml`)
|
|
69
|
-
|
|
70
|
-
```yaml
|
|
71
|
-
DM:
|
|
72
|
-
- formoid: "FORM.DEMOG"
|
|
73
|
-
keys: ["StudyOID", "StudySubjectID"]
|
|
74
|
-
columns:
|
|
75
|
-
STUDYID:
|
|
76
|
-
source: StudyOID
|
|
77
|
-
type: str
|
|
78
|
-
USUBJID:
|
|
79
|
-
source: StudySubjectID
|
|
80
|
-
prefix: "PPT-"
|
|
81
|
-
type: str
|
|
82
|
-
AGE:
|
|
83
|
-
source: IT.AGE
|
|
84
|
-
type: int
|
|
85
|
-
type: str
|
|
86
|
-
SEX:
|
|
87
|
-
source: I_DEMOG_SEX
|
|
88
|
-
type: str
|
|
89
|
-
value_mapping:
|
|
90
|
-
"M": "Male"
|
|
91
|
-
"F": "Female"
|
|
92
|
-
|
|
93
|
-
```
|
|
94
|
-
### Finding Domains (Dynamic Mapping)
|
|
95
|
-
|
|
96
|
-
For domains like `IE`, `LB`, `FA` where many input items map to a single `Test Code` / `Test Name` pair, use `type: finding`.
|
|
97
|
-
|
|
98
|
-
```yaml
|
|
99
|
-
IE:
|
|
100
|
-
- type: finding
|
|
101
|
-
formoid: "F_ELIGIBILITY"
|
|
102
|
-
# Filter rows using Regex
|
|
103
|
-
item_group_regex: "IG_ELIGI_.*"
|
|
104
|
-
item_oid_regex: "I_ELIGI_.*"
|
|
105
|
-
|
|
106
|
-
columns:
|
|
107
|
-
# Extract part of the OID for the Short Code
|
|
108
|
-
IETESTCD:
|
|
109
|
-
source: ItemOID
|
|
110
|
-
regex_extract: "I_ELIGI_(.*)"
|
|
111
|
-
|
|
112
|
-
# Use Metadata from parsed XML for the Description
|
|
113
|
-
IETEST:
|
|
114
|
-
source: Metadata.Question
|
|
115
|
-
|
|
116
|
-
IEORRES:
|
|
117
|
-
source: Value
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
### Advanced Mapping Features
|
|
121
|
-
|
|
122
|
-
**Prefixing**:
|
|
123
|
-
```yaml
|
|
124
|
-
USUBJID:
|
|
125
|
-
source: StudySubjectID
|
|
126
|
-
prefix: "PPT-"
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
**Substring Extraction** (extracts chars 3-5 before mapping):
|
|
130
|
-
```yaml
|
|
131
|
-
SITEID:
|
|
132
|
-
source: FULL_ID
|
|
133
|
-
substring_start: 3
|
|
134
|
-
substring_length: 3
|
|
135
|
-
|
|
136
|
-
**Fallback** (use secondary source if primary is missing):
|
|
137
|
-
```yaml
|
|
138
|
-
SUBJID:
|
|
139
|
-
source: RFSTDTC
|
|
140
|
-
fallback: USUBJID
|
|
141
|
-
```
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
**Default Values**:
|
|
145
|
-
```yaml
|
|
146
|
-
CUSTOM_COL:
|
|
147
|
-
source: ORG_COL
|
|
148
|
-
value_mapping:
|
|
149
|
-
"A": "Alpha"
|
|
150
|
-
mapping_default: "Other" # used if not A
|
|
151
|
-
# mapping_default_source: "AnotherCol" # Fallback to column value
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
**Case Sensitive Mapping**:
|
|
155
|
-
By default, mapping is case-sensitive. You can disable this to map values regardless of case (e.g. "Yes", "yes", "YES" -> "Y"). Unmapped values preserve their original casing.
|
|
156
|
-
```yaml
|
|
157
|
-
RESP:
|
|
158
|
-
source: INPUT_VAL
|
|
159
|
-
value_mapping:
|
|
160
|
-
"Yes": "Y"
|
|
161
|
-
"No": "N"
|
|
162
|
-
case_sensitive: false
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
## Development
|
|
166
|
-
|
|
167
|
-
This project uses modern tools for testing and maintaining code quality:
|
|
168
|
-
|
|
169
|
-
### 1. Running Tests
|
|
170
|
-
Run the automated test suite using `pytest`:
|
|
171
|
-
```bash
|
|
172
|
-
# Using standard pip/virtual environment
|
|
173
|
-
pytest
|
|
174
|
-
|
|
175
|
-
# Using uv
|
|
176
|
-
uv run pytest
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
### 2. Code Quality
|
|
180
|
-
We use `black` for code formatting, `ruff` for linting, and `mypy` for type checking:
|
|
181
|
-
|
|
182
|
-
```bash
|
|
183
|
-
# Code Formatting (in-place rewrite)
|
|
184
|
-
uv run --with black black src/
|
|
185
|
-
|
|
186
|
-
# Linting and style checks
|
|
187
|
-
uv run --with ruff ruff check src/
|
|
188
|
-
|
|
189
|
-
# Type Checking
|
|
190
|
-
uv run --with mypy mypy src/
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
## License
|
|
194
|
-
|
|
195
|
-
[MIT License](LICENSE)
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cdiscbuilder
|
|
3
|
+
Version: 1.2.3
|
|
4
|
+
Summary: A package to convert ODM XML to SDTM/ADaM Datasets
|
|
5
|
+
Author-email: Ming-Chun Chen <hellomingchun@gmail.com>
|
|
6
|
+
Requires-Python: >=3.9
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: pandas
|
|
10
|
+
Requires-Dist: pyyaml
|
|
11
|
+
Requires-Dist: polars>=0.20.0
|
|
12
|
+
Requires-Dist: reactable>=0.1.6
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
# CDISC Builder
|
|
16
|
+
|
|
17
|
+
**`cdiscbuilder`** is a Python package designed to simplify the transformation of clinical trial data from **ODM (Operational Data Model)** XML format into **CDISC SDTM (Study Data Tabulation Model)** and **ADaM (Analysis Data Model)** datasets.
|
|
18
|
+
|
|
19
|
+
It provides a flexible, configuration-driven approach to data mapping, allowing users to define rules using simple YAML files or Python dictionaries without harcoding complex logic.
|
|
20
|
+
|
|
21
|
+
## Key Features
|
|
22
|
+
|
|
23
|
+
- **ODM XML Parsing**: Efficiently parses CDISC ODM strings and files into workable dataframes.
|
|
24
|
+
- **Configurable Mappings**: Define your mapping rules (source columns, hardcoded values, custom logic) in YAML.
|
|
25
|
+
- **Schema Validation**: Ensures your configuration files adhere to strict standards before processing.
|
|
26
|
+
- **Metadata-Driven Findings**: Powerful processor for Findings domains (VS, LB, FA, etc.) using granular metadata.
|
|
27
|
+
- **Excel/Parquet Output**: Generates regulatory-compliant datasets in modern formats.
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install cdiscbuilder
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
### 1. Command Line Interface
|
|
38
|
+
|
|
39
|
+
You can generate datasets directly from your terminal:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Generate SDTM datasets from an ODM XML file
|
|
43
|
+
cdisc-sdtm --xml study_data.xml --output ./sdtm_data
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 2. Python API
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from cdiscbuilder.sdtm import create_sdtm_datasets
|
|
50
|
+
|
|
51
|
+
# Define paths
|
|
52
|
+
xml_file = "study_data.xml"
|
|
53
|
+
config_dir = "path/to/my/specs"
|
|
54
|
+
output_dir = "./sdtm_outputs"
|
|
55
|
+
|
|
56
|
+
# Generate Datasets
|
|
57
|
+
create_sdtm_datasets(config_dir, xml_file, output_dir)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Configuration
|
|
61
|
+
|
|
62
|
+
For detailed and complete references on how to structure mapping specifications, see:
|
|
63
|
+
* **[SDTM Mapping Specification](file:///c:/Users/mingc/Documents/projects/cdiscbuilder/cdisc_builder/docs/SDTM_MAPPING_SPECIFICATION.md)**: Details on the intermediate `odm_long.csv` schema, wide vs. findings domains, regex extraction, and validation rules.
|
|
64
|
+
* **[ADaM Mapping Specification](file:///c:/Users/mingc/Documents/projects/cdiscbuilder/cdisc_builder/docs/ADAM_MAPPING_SPECIFICATION.md)**: Details on ADaM yaml configuration schema, inheritance, SQL-like derivations, conditions, and aggregations.
|
|
65
|
+
|
|
66
|
+
The package comes with standard configurations for common domains (`DM`, `AE`, `VS`, etc.) in `src/cdisc_builder/specs`. You can override these or add new ones by creating your own configuration directory.
|
|
67
|
+
|
|
68
|
+
### Example YAML (`DM.yaml`)
|
|
69
|
+
|
|
70
|
+
```yaml
|
|
71
|
+
DM:
|
|
72
|
+
- formoid: "FORM.DEMOG"
|
|
73
|
+
keys: ["StudyOID", "StudySubjectID"]
|
|
74
|
+
columns:
|
|
75
|
+
STUDYID:
|
|
76
|
+
source: StudyOID
|
|
77
|
+
type: str
|
|
78
|
+
USUBJID:
|
|
79
|
+
source: StudySubjectID
|
|
80
|
+
prefix: "PPT-"
|
|
81
|
+
type: str
|
|
82
|
+
AGE:
|
|
83
|
+
source: IT.AGE
|
|
84
|
+
type: int
|
|
85
|
+
type: str
|
|
86
|
+
SEX:
|
|
87
|
+
source: I_DEMOG_SEX
|
|
88
|
+
type: str
|
|
89
|
+
value_mapping:
|
|
90
|
+
"M": "Male"
|
|
91
|
+
"F": "Female"
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
### Finding Domains (Dynamic Mapping)
|
|
95
|
+
|
|
96
|
+
For domains like `IE`, `LB`, `FA` where many input items map to a single `Test Code` / `Test Name` pair, use `type: finding`.
|
|
97
|
+
|
|
98
|
+
```yaml
|
|
99
|
+
IE:
|
|
100
|
+
- type: finding
|
|
101
|
+
formoid: "F_ELIGIBILITY"
|
|
102
|
+
# Filter rows using Regex
|
|
103
|
+
item_group_regex: "IG_ELIGI_.*"
|
|
104
|
+
item_oid_regex: "I_ELIGI_.*"
|
|
105
|
+
|
|
106
|
+
columns:
|
|
107
|
+
# Extract part of the OID for the Short Code
|
|
108
|
+
IETESTCD:
|
|
109
|
+
source: ItemOID
|
|
110
|
+
regex_extract: "I_ELIGI_(.*)"
|
|
111
|
+
|
|
112
|
+
# Use Metadata from parsed XML for the Description
|
|
113
|
+
IETEST:
|
|
114
|
+
source: Metadata.Question
|
|
115
|
+
|
|
116
|
+
IEORRES:
|
|
117
|
+
source: Value
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Advanced Mapping Features
|
|
121
|
+
|
|
122
|
+
**Prefixing**:
|
|
123
|
+
```yaml
|
|
124
|
+
USUBJID:
|
|
125
|
+
source: StudySubjectID
|
|
126
|
+
prefix: "PPT-"
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Substring Extraction** (extracts chars 3-5 before mapping):
|
|
130
|
+
```yaml
|
|
131
|
+
SITEID:
|
|
132
|
+
source: FULL_ID
|
|
133
|
+
substring_start: 3
|
|
134
|
+
substring_length: 3
|
|
135
|
+
|
|
136
|
+
**Fallback** (use secondary source if primary is missing):
|
|
137
|
+
```yaml
|
|
138
|
+
SUBJID:
|
|
139
|
+
source: RFSTDTC
|
|
140
|
+
fallback: USUBJID
|
|
141
|
+
```
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**Default Values**:
|
|
145
|
+
```yaml
|
|
146
|
+
CUSTOM_COL:
|
|
147
|
+
source: ORG_COL
|
|
148
|
+
value_mapping:
|
|
149
|
+
"A": "Alpha"
|
|
150
|
+
mapping_default: "Other" # used if not A
|
|
151
|
+
# mapping_default_source: "AnotherCol" # Fallback to column value
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**Case Sensitive Mapping**:
|
|
155
|
+
By default, mapping is case-sensitive. You can disable this to map values regardless of case (e.g. "Yes", "yes", "YES" -> "Y"). Unmapped values preserve their original casing.
|
|
156
|
+
```yaml
|
|
157
|
+
RESP:
|
|
158
|
+
source: INPUT_VAL
|
|
159
|
+
value_mapping:
|
|
160
|
+
"Yes": "Y"
|
|
161
|
+
"No": "N"
|
|
162
|
+
case_sensitive: false
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Development
|
|
166
|
+
|
|
167
|
+
This project uses modern tools for testing and maintaining code quality:
|
|
168
|
+
|
|
169
|
+
### 1. Running Tests
|
|
170
|
+
Run the automated test suite using `pytest`:
|
|
171
|
+
```bash
|
|
172
|
+
# Using standard pip/virtual environment
|
|
173
|
+
pytest
|
|
174
|
+
|
|
175
|
+
# Using uv
|
|
176
|
+
uv run pytest
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### 2. Code Quality
|
|
180
|
+
We use `black` for code formatting, `ruff` for linting, and `mypy` for type checking:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
# Code Formatting (in-place rewrite)
|
|
184
|
+
uv run --with black black src/
|
|
185
|
+
|
|
186
|
+
# Linting and style checks
|
|
187
|
+
uv run --with ruff ruff check src/
|
|
188
|
+
|
|
189
|
+
# Type Checking
|
|
190
|
+
uv run --with mypy mypy src/
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## License
|
|
194
|
+
|
|
195
|
+
[MIT License](LICENSE)
|