Source: https://github.com/aipoch/medical-research-skills
Clinical Data Cleaner
Clean, validate, and standardize clinical trial data to meet CDISC SDTM standards for regulatory submissions to FDA or EMA.
When to Use
- Use this skill when the task needs Use when cleaning clinical trial data, preparing data for FDA/EMA submission, standardizing SDTM datasets, handling missing values in clinical studies, detecting outliers in lab results, or converting raw CRF data to CDISC format. Cleans and standardizes clinical trial data for regulatory compliance with audit trails.
- Use this skill for data analysis tasks that require explicit assumptions, bounded scope, and a reproducible output format.
- Use this skill when you need a documented fallback path for missing inputs, execution errors, or partial evidence.
Key Features
- Scope-focused workflow aligned to: Use when cleaning clinical trial data, preparing data for FDA/EMA submission, standardizing SDTM datasets, handling missing values in clinical studies, detecting outliers in lab results, or converting raw CRF data to CDISC format. Cleans and standardizes clinical trial data for regulatory compliance with audit trails.
- Packaged executable path(s):
scripts/main.py.
- Reference material available in
references/ for task-specific guidance.
- Structured execution path designed to keep outputs consistent and reviewable.
Dependencies
Python: 3.10+. Repository baseline for current packaged skills.
numpy: unspecified. Declared in requirements.txt.
pandas: unspecified. Declared in requirements.txt.
scipy: unspecified. Declared in requirements.txt.
Example Usage
cd "20260318/scientific-skills/Data Analytics/clinical-data-cleaner"
python -m py_compile scripts/main.py
python scripts/main.py --help
Example run plan:
- Confirm the user input, output path, and any required config values.
- Edit the in-file
CONFIG block or documented parameters if the script uses fixed settings.
- Run
python scripts/main.py with the validated inputs.
- Review the generated output and return the final artifact with any assumptions called out.
Implementation Details
See ## Workflow above for related details.
- Execution model: validate the request, choose the packaged workflow, and produce a bounded deliverable.
- Input controls: confirm the source files, scope limits, output format, and acceptance criteria before running any script.
- Primary implementation surface:
scripts/main.py.
- Reference guidance:
references/ contains supporting rules, prompts, or checklists.
- Parameters to clarify first: input path, output path, scope filters, thresholds, and any domain-specific constraints.
- Output discipline: keep results reproducible, identify assumptions explicitly, and avoid undocumented side effects.
Quick Check
Use this command to verify that the packaged script entry point can be parsed before deeper execution.
python -m py_compile scripts/main.py
Audit-Ready Commands
Use these concrete commands for validation. They are intentionally self-contained and avoid placeholder paths.
python -m py_compile scripts/main.py
python scripts/main.py --help
python scripts/main.py --input "Audit validation sample with explicit symptoms, history, assessment, and next-step plan."
Workflow
- Confirm the user objective, required inputs, and non-negotiable constraints before doing detailed work.
- Validate that the request matches the documented scope and stop early if the task would require unsupported assumptions.
- Use the packaged script path or the documented reasoning path with only the inputs that are actually available.
- Return a structured result that separates assumptions, deliverables, risks, and unresolved items.
- If execution fails or inputs are incomplete, switch to the fallback path and state exactly what blocked full completion.
Quick Start
from scripts.main import ClinicalDataCleaner
# Initialize for Demographics domain
cleaner = ClinicalDataCleaner(domain='DM')
# Clean data with default settings
cleaned = cleaner.clean(raw_data)
# Save with audit trail
cleaner.save_report('output.csv')
Core Capabilities
1. SDTM Domain Validation
cleaner = ClinicalDataCleaner(domain='DM') # or 'LB', 'VS'
is_valid, missing = cleaner.validate_domain(data)
Required Fields:
- DM: STUDYID, USUBJID, SUBJID, RFSTDTC, RFENDTC, SITEID, AGE, SEX, RACE
- LB: STUDYID, USUBJID, LBTESTCD, LBCAT, LBORRES, LBORRESU, LBSTRESC, LBDTC
- VS: STUDYID, USUBJID, VSTESTCD, VSORRES, VSORRESU, VSSTRESC, VSDTC
2. Missing Value Handling
cleaner = ClinicalDataCleaner(
domain='DM',
missing_strategy='median' # mean, median, mode, forward, drop
)
cleaned = cleaner.handle_missing_values(data)
3. Outlier Detection
cleaner = ClinicalDataCleaner(
domain='LB',
outlier_method='domain', # iqr, zscore, domain
outlier_action='flag' # flag, remove, cap
)
flagged = cleaner.detect_outliers(data)
Clinical Thresholds:
| Parameter |
Range |
Unit |
| Glucose |
50-500 |
mg/dL |
| Hemoglobin |
5-20 |
g/dL |
| Systolic BP |
70-220 |
mmHg |
4. Date Standardization
standardized = cleaner.standardize_dates(data)
# Converts to ISO 8601: 2023-01-15T09:30:00
5. Complete Pipeline
cleaner = ClinicalDataCleaner(
domain='DM',
missing_strategy='median',
outlier_method='iqr',
outlier_action='flag'
)
cleaned_data = cleaner.clean(data)
cleaner.save_report('output.csv')
Output Files:
output.csv - Cleaned SDTM data
output.report.json - Audit trail for regulatory submission
CLI Usage
# Clean demographics
python scripts/main.py \
--input dm_raw.csv \
--domain DM \
--output dm_clean.csv \
--missing-strategy median \
--outlier-method iqr \
--outlier-action flag
# Clean lab data with clinical thresholds
python scripts/main.py \
--input lb_raw.csv \
--domain LB \
--output lb_clean.csv \
--outlier-method domain
Common Patterns
See references/common-patterns.md for detailed examples:
- Regulatory Submission Preparation
- Interim Analysis Data Preparation
- Database Migration Cleanup
- External Lab Data Integration
Troubleshooting
See references/troubleshooting.md for solutions to:
- Validation failures
- Date parsing errors
- Memory errors with large datasets
- Outlier detection issues
Quality Checklist
Pre-Cleaning:
Post-Cleaning:
References
references/sdtm_ig_guide.md - CDISC SDTM Implementation Guide
references/domain_specs.json - Domain-specific field requirements
references/outlier_thresholds.json - Clinical outlier thresholds
references/common-patterns.md - Detailed usage patterns
references/troubleshooting.md - Problem-solving guide
Skill ID: 189 | Version: 2.0 | License: MIT
Output Requirements
Every final response should make these items explicit when they are relevant:
- Objective or requested deliverable
- Inputs used and assumptions introduced
- Workflow or decision path
- Core result, recommendation, or artifact
- Constraints, risks, caveats, or validation needs
- Unresolved items and next-step checks
Error Handling
- If required inputs are missing, state exactly which fields are missing and request only the minimum additional information.
- If the task goes outside the documented scope, stop instead of guessing or silently widening the assignment.
- If
scripts/main.py fails, report the failure point, summarize what still can be completed safely, and provide a manual fallback.
- Do not fabricate files, citations, data, search results, or execution outcomes.
Input Validation
This skill accepts requests that match the documented purpose of clinical-data-cleaner and include enough context to complete the workflow safely.
Do not continue the workflow when the request is out of scope, missing a critical input, or would require unsupported assumptions. Instead respond:
clinical-data-cleaner only handles its documented workflow. Please provide the missing required inputs or switch to a more suitable skill.
Response Template
Use the following fixed structure for non-trivial requests:
- Objective
- Inputs Received
- Assumptions
- Workflow
- Deliverable
- Risks and Limits
- Next Checks
If the request is simple, you may compress the structure, but still keep assumptions and limits explicit when they affect correctness.
1---
2name: clinical-data-cleaner
3description: Use when cleaning clinical trial data, preparing data for FDA/EMA submission, standardizing SDTM datasets, handling missing values in clinical studies, detecting outliers in lab results, or converting raw CRF data to CDISC format. Cleans and standardizes clinical trial data for regulatory compliance with audit trails.
4license: MIT
5author: aipoch
6metadata:
7 source: https://skillmd.com/skills/aibot88/clinical-data-cleaner
8---
9
10> **Source**: [https://github.com/aipoch/medical-research-skills](https://github.com/aipoch/medical-research-skills)
11# Clinical Data Cleaner
12
13Clean, validate, and standardize clinical trial data to meet CDISC SDTM standards for regulatory submissions to FDA or EMA.
14
15## When to Use
16
17- Use this skill when the task needs Use when cleaning clinical trial data, preparing data for FDA/EMA submission, standardizing SDTM datasets, handling missing values in clinical studies, detecting outliers in lab results, or converting raw CRF data to CDISC format. Cleans and standardizes clinical trial data for regulatory compliance with audit trails.
18- Use this skill for data analysis tasks that require explicit assumptions, bounded scope, and a reproducible output format.
19- Use this skill when you need a documented fallback path for missing inputs, execution errors, or partial evidence.
20
21## Key Features
22
23- Scope-focused workflow aligned to: Use when cleaning clinical trial data, preparing data for FDA/EMA submission, standardizing SDTM datasets, handling missing values in clinical studies, detecting outliers in lab results, or converting raw CRF data to CDISC format. Cleans and standardizes clinical trial data for regulatory compliance with audit trails.
24- Packaged executable path(s): `scripts/main.py`.
25- Reference material available in `references/` for task-specific guidance.
26- Structured execution path designed to keep outputs consistent and reviewable.
27
28## Dependencies
29
30- `Python`: `3.10+`. Repository baseline for current packaged skills.
31- `numpy`: `unspecified`. Declared in `requirements.txt`.
32- `pandas`: `unspecified`. Declared in `requirements.txt`.
33- `scipy`: `unspecified`. Declared in `requirements.txt`.
34
35## Example Usage
36
37```bash
38cd "20260318/scientific-skills/Data Analytics/clinical-data-cleaner"
39python -m py_compile scripts/main.py
40python scripts/main.py --help
41```
42
43Example run plan:
441. Confirm the user input, output path, and any required config values.
452. Edit the in-file `CONFIG` block or documented parameters if the script uses fixed settings.
463. Run `python scripts/main.py` with the validated inputs.
474. Review the generated output and return the final artifact with any assumptions called out.
48
49## Implementation Details
50
51See `## Workflow` above for related details.
52
53- Execution model: validate the request, choose the packaged workflow, and produce a bounded deliverable.
54- Input controls: confirm the source files, scope limits, output format, and acceptance criteria before running any script.
55- Primary implementation surface: `scripts/main.py`.
56- Reference guidance: `references/` contains supporting rules, prompts, or checklists.
57- Parameters to clarify first: input path, output path, scope filters, thresholds, and any domain-specific constraints.
58- Output discipline: keep results reproducible, identify assumptions explicitly, and avoid undocumented side effects.
59
60## Quick Check
61
62Use this command to verify that the packaged script entry point can be parsed before deeper execution.
63
64```bash
65python -m py_compile scripts/main.py
66```
67
68## Audit-Ready Commands
69
70Use these concrete commands for validation. They are intentionally self-contained and avoid placeholder paths.
71
72```bash
73python -m py_compile scripts/main.py
74python scripts/main.py --help
75python scripts/main.py --input "Audit validation sample with explicit symptoms, history, assessment, and next-step plan."
76```
77
78## Workflow
79
801. Confirm the user objective, required inputs, and non-negotiable constraints before doing detailed work.
812. Validate that the request matches the documented scope and stop early if the task would require unsupported assumptions.
823. Use the packaged script path or the documented reasoning path with only the inputs that are actually available.
834. Return a structured result that separates assumptions, deliverables, risks, and unresolved items.
845. If execution fails or inputs are incomplete, switch to the fallback path and state exactly what blocked full completion.
85
86## Quick Start
87
88```python
89from scripts.main import ClinicalDataCleaner
90
91# Initialize for Demographics domain
92cleaner = ClinicalDataCleaner(domain='DM')
93
94# Clean data with default settings
95cleaned = cleaner.clean(raw_data)
96
97# Save with audit trail
98cleaner.save_report('output.csv')
99```
100
101## Core Capabilities
102
103### 1. SDTM Domain Validation
104
105```python
106cleaner = ClinicalDataCleaner(domain='DM') # or 'LB', 'VS'
107is_valid, missing = cleaner.validate_domain(data)
108```
109
110**Required Fields:**
111- **DM**: STUDYID, USUBJID, SUBJID, RFSTDTC, RFENDTC, SITEID, AGE, SEX, RACE
112- **LB**: STUDYID, USUBJID, LBTESTCD, LBCAT, LBORRES, LBORRESU, LBSTRESC, LBDTC
113- **VS**: STUDYID, USUBJID, VSTESTCD, VSORRES, VSORRESU, VSSTRESC, VSDTC
114
115### 2. Missing Value Handling
116
117```python
118cleaner = ClinicalDataCleaner(
119 domain='DM',
120 missing_strategy='median' # mean, median, mode, forward, drop
121)
122cleaned = cleaner.handle_missing_values(data)
123```
124
125### 3. Outlier Detection
126
127```python
128cleaner = ClinicalDataCleaner(
129 domain='LB',
130 outlier_method='domain', # iqr, zscore, domain
131 outlier_action='flag' # flag, remove, cap
132)
133flagged = cleaner.detect_outliers(data)
134```
135
136**Clinical Thresholds:**
137| Parameter | Range | Unit |
138|-----------|-------|------|
139| Glucose | 50-500 | mg/dL |
140| Hemoglobin | 5-20 | g/dL |
141| Systolic BP | 70-220 | mmHg |
142
143### 4. Date Standardization
144
145```python
146standardized = cleaner.standardize_dates(data)
147
148# Converts to ISO 8601: 2023-01-15T09:30:00
149```
150
151### 5. Complete Pipeline
152
153```python
154cleaner = ClinicalDataCleaner(
155 domain='DM',
156 missing_strategy='median',
157 outlier_method='iqr',
158 outlier_action='flag'
159)
160cleaned_data = cleaner.clean(data)
161cleaner.save_report('output.csv')
162```
163
164**Output Files:**
165- `output.csv` - Cleaned SDTM data
166- `output.report.json` - Audit trail for regulatory submission
167
168## CLI Usage
169
170```text
171
172# Clean demographics
173python scripts/main.py \
174 --input dm_raw.csv \
175 --domain DM \
176 --output dm_clean.csv \
177 --missing-strategy median \
178 --outlier-method iqr \
179 --outlier-action flag
180
181# Clean lab data with clinical thresholds
182python scripts/main.py \
183 --input lb_raw.csv \
184 --domain LB \
185 --output lb_clean.csv \
186 --outlier-method domain
187```
188
189## Common Patterns
190
191See [references/common-patterns.md](references/common-patterns.md) for detailed examples:
192- Regulatory Submission Preparation
193- Interim Analysis Data Preparation
194- Database Migration Cleanup
195- External Lab Data Integration
196
197## Troubleshooting
198
199See [references/troubleshooting.md](references/troubleshooting.md) for solutions to:
200- Validation failures
201- Date parsing errors
202- Memory errors with large datasets
203- Outlier detection issues
204
205## Quality Checklist
206
207**Pre-Cleaning:**
208- [ ] IACUC approval obtained (animal studies)
209- [ ] Sample size adequately powered
210- [ ] Randomization method documented
211
212**Post-Cleaning:**
213- [ ] Validate against CDISC SDTM IG
214- [ ] Review all cleaning actions in audit trail
215- [ ] Test import to analysis software
216
217## References
218
219- `references/sdtm_ig_guide.md` - CDISC SDTM Implementation Guide
220- `references/domain_specs.json` - Domain-specific field requirements
221- `references/outlier_thresholds.json` - Clinical outlier thresholds
222- `references/common-patterns.md` - Detailed usage patterns
223- `references/troubleshooting.md` - Problem-solving guide
224
225---
226
227**Skill ID**: 189 | **Version**: 2.0 | **License**: MIT
228
229## Output Requirements
230
231Every final response should make these items explicit when they are relevant:
232
233- Objective or requested deliverable
234- Inputs used and assumptions introduced
235- Workflow or decision path
236- Core result, recommendation, or artifact
237- Constraints, risks, caveats, or validation needs
238- Unresolved items and next-step checks
239
240## Error Handling
241
242- If required inputs are missing, state exactly which fields are missing and request only the minimum additional information.
243- If the task goes outside the documented scope, stop instead of guessing or silently widening the assignment.
244- If `scripts/main.py` fails, report the failure point, summarize what still can be completed safely, and provide a manual fallback.
245- Do not fabricate files, citations, data, search results, or execution outcomes.
246
247## Input Validation
248
249This skill accepts requests that match the documented purpose of `clinical-data-cleaner` and include enough context to complete the workflow safely.
250
251Do not continue the workflow when the request is out of scope, missing a critical input, or would require unsupported assumptions. Instead respond:
252
253> `clinical-data-cleaner` only handles its documented workflow. Please provide the missing required inputs or switch to a more suitable skill.
254
255## Response Template
256
257Use the following fixed structure for non-trivial requests:
258
2591. Objective
2602. Inputs Received
2613. Assumptions
2624. Workflow
2635. Deliverable
2646. Risks and Limits
2657. Next Checks
266
267If the request is simple, you may compress the structure, but still keep assumptions and limits explicit when they affect correctness.