Skip to content

Commit c8996ab

Browse files
committed
SDTM desin draft
1 parent 8966e7d commit c8996ab

2 files changed

Lines changed: 139 additions & 0 deletions

File tree

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ will be driven by the audit trail.
4040
data_export_combined
4141
validation
4242
odm_mapping
43+
sdtm_design
4344
api

docs/source/sdtm_design.rst

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
SDTM Export — Design Notes
2+
==========================
3+
4+
Status: **design / exploration** (no code yet). Target: **SDTMIG 3.4**,
5+
primary output **Dataset-JSON v1.1**.
6+
7+
This document scopes a future SDTM (Study Data Tabulation Model) export
8+
alongside the existing ODM 1.3.1 export. SDTM is one of the foundational
9+
standards required for data submission to the FDA (and PMDA).
10+
11+
Why SDTM is a different kind of problem from ODM
12+
------------------------------------------------
13+
14+
The ODM exporter is **mechanical and lossless**: it walks the clinicedc
15+
structure (``RegisteredSubject`` → related visit → CRF → fields) and emits a
16+
faithful hierarchical XML mirror. OIDs are derived from model labels and
17+
field names; no clinical interpretation is needed, which is why it is generic
18+
across any clinicedc trial.
19+
20+
SDTM is the opposite. It is a **fixed target model**, not a dump of the
21+
source. Data must be reshaped and re-coded into a standard set of flat
22+
domain tables.
23+
24+
.. list-table::
25+
:header-rows: 1
26+
:widths: 20 40 40
27+
28+
* - Aspect
29+
- ODM (today)
30+
- SDTM (proposed)
31+
* - Shape
32+
- Hierarchical XML mirror of the EDC
33+
- One flat table per **domain** (DM, AE, VS, LB, EX, CM, MH, …)
34+
* - Direction
35+
- Source-faithful
36+
- Conform-to-standard
37+
* - Variable names
38+
- Your field names (OIDs)
39+
- Fixed CDISC names (``USUBJID``, ``--TESTCD``, ``--ORRES``,
40+
``VISITNUM``, …)
41+
* - Coding
42+
- As entered
43+
- CDISC Controlled Terminology + MedDRA / WHODrug
44+
* - Mapping
45+
- Automatic
46+
- **Requires per-CRF SME mapping**
47+
* - Output
48+
- ODM XML
49+
- ``.xpt`` (SAS v5) and/or **Dataset-JSON**, plus **define.xml**
50+
51+
The honest headline: SDTM **cannot** be fully auto-generated from arbitrary
52+
clinicedc data the way ODM can. A *Findings* domain such as VS or LB is
53+
**vertical** — one row per measurement (``VSTESTCD=SYSBP``, ``VSORRES=120``,
54+
``VSORRESU=mmHg``) — whereas a CRF stores those as horizontal columns. That
55+
transpose, plus the controlled-terminology decisions, is inherently a
56+
study-specific, human-in-the-loop mapping exercise.
57+
58+
SDTM observation classes
59+
------------------------
60+
61+
Every domain belongs to one general observation class. Identify the class
62+
first; the domain follows.
63+
64+
* **Interventions** — CM (concomitant meds), EX (exposure), EC, SU, PR
65+
* **Events** — AE (adverse events), MH (medical history), DS (disposition),
66+
CE
67+
* **Findings** — VS (vital signs), LB (labs), EG (ECG), QS (questionnaires),
68+
FA (findings about)
69+
* **Special Purpose** — DM (demographics), CO, SE (subject elements),
70+
SV (subject visits)
71+
* **Trial Design** — TS, TA, TE, TV, TI, TD, TM
72+
73+
What clinicedc can supply (mostly) for free
74+
--------------------------------------------
75+
76+
clinicedc already holds the structured metadata SDTM needs for a meaningful
77+
slice:
78+
79+
* **Trial Design domains** (``TS, TA, TE, TV, TI, SV, SE``) — the
80+
``visit_schedule`` + ``edc_protocol`` config already encode visits, epochs,
81+
arms, and timing. These map almost directly and are the most "free" win.
82+
* **DM (Demographics)** — assembled from ``RegisteredSubject`` + consent +
83+
screening + a demographics CRF. Mostly derivable with a thin mapping.
84+
* **SV / SE (Subject Visits / Elements)** — straight from the related-visit
85+
model already iterated in :file:`clinical_data_serializer.py`.
86+
87+
Everything else (AE, CM, MH, VS, LB, EG, EX, …) needs a **mapping-spec
88+
layer**: a declarative config saying "CRF model ``X`` field ``Y`` → domain VS,
89+
variable ``VSORRES``, ``VSTESTCD=SYSBP``, unit mmHg".
90+
91+
What existing code is directly reusable
92+
---------------------------------------
93+
94+
#. **define.xml is ODM.** Define-XML 2.0/2.1 is a CDISC extension of the same
95+
ODM schema already emitted (``MetaDataVersion``, ``ItemGroupDef``,
96+
``ItemDef``, ``CodeList``). ``MetadataSerializer`` is the natural
97+
foundation for the define.xml that must accompany every SDTM submission.
98+
#. **PII guards** (encrypted-field skip, consent whitelist) carry over
99+
unchanged and remain mandatory — SDTM datasets must never leak
100+
``django_crypto_fields`` data.
101+
#. The subject/visit traversal in :file:`clinical_data_serializer.py` is the
102+
same traversal a domain builder needs.
103+
104+
Output format: Dataset-JSON
105+
---------------------------
106+
107+
Target **Dataset-JSON v1.1** (released 2024-12-05) first:
108+
109+
* No SAS dependency; trivially generated from a pandas ``DataFrame``
110+
(records = rows, columns carry name/label/type metadata).
111+
* Can optionally reference a Define-XML document for full metadata.
112+
113+
``.xpt`` (SAS Transport v5) is the definitively FDA-required format and can be
114+
added later as an additional serialization target (e.g. via ``pyreadstat``),
115+
subject to its 8-char name / value-length constraints.
116+
117+
Proposed phased plan
118+
--------------------
119+
120+
#. **Phase 1 — Trial Design + DM, Dataset-JSON.** Auto-derive
121+
``TS/TA/TE/TV/TI/SV/SE`` and ``DM`` from the visit schedule +
122+
registration/consent. Emit Dataset-JSON. Proves the pipeline end-to-end
123+
with zero SME mapping.
124+
#. **Phase 2 — Mapping-spec layer + 1–2 domains** (e.g. VS and AE) to
125+
validate the transpose + controlled-terminology approach.
126+
#. **Phase 3 — define.xml** reusing ``MetadataSerializer``, plus **CORE**
127+
validation (CDISC's open-source conformance engine) wired into a
128+
management command, analogous to ``validate_odm_export``.
129+
130+
Open questions
131+
--------------
132+
133+
* Controlled Terminology source / version pinning (CDISC CT packages;
134+
MedDRA & WHODrug licensing for AE/CM).
135+
* How mapping specs are declared and stored (per-trial Python config vs.
136+
data-driven).
137+
* Whether ``--SEQ`` and ``RELREC`` relationships are needed in early phases.
138+
* SUPPQUAL handling for non-standard CRF variables.

0 commit comments

Comments
 (0)