{"data":{"slug":"github-aipoch-medical-research-skills-scientific-skills-data-analysis-clinical-data-cleaner-578580719f39","title":"Clinical Data Cleaner for SDTM Compliance","summary":"Clean, validate, and standardize clinical trial data for FDA\/EMA submissions with audit trails, focusing on SDTM domains such as DM, LB, and VS.","url":"https:\/\/skillshunter.net\/skills\/github-aipoch-medical-research-skills-scientific-skills-data-analysis-clinical-data-cleaner-578580719f39","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-aipoch-medical-research-skills-scientific-skills-data-analysis-clinical-data-cleaner-578580719f39","markdown_url":"https:\/\/skillshunter.net\/skills\/github-aipoch-medical-research-skills-scientific-skills-data-analysis-clinical-data-cleaner-578580719f39.md","download_url":"https:\/\/skillshunter.net\/skills\/github-aipoch-medical-research-skills-scientific-skills-data-analysis-clinical-data-cleaner-578580719f39\/download","category":{"slug":"data-research","name":"Data & Research"},"editor_note":"Ensure the required fields for the specified SDTM domain (e.g., DM: STUDYID, USUBJID, SUBJID, RFSTDTC, RFENDTC, SITEID, AGE, SEX, RACE) are present before execution. If missing, request only the minimum additional information required for the task.","instructions":"---\nname: clinical-data-cleaner\ndescription: 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 fo...\nlicense: MIT\nauthor: AIPOCH\n---\n> **Source**: [https:\/\/github.com\/aipoch\/medical-research-skills](https:\/\/github.com\/aipoch\/medical-research-skills)\n\n# Clinical Data Cleaner\n\nClean, validate, and standardize clinical trial data to meet CDISC SDTM standards for regulatory submissions to FDA or EMA.\n\n## Quick Check\n\nUse this command to verify that the packaged script entry point can be parsed before deeper execution.\n\n```bash\npython -m py_compile scripts\/main.py\n```\n\n## Audit-Ready Commands\n\nUse these concrete commands for validation. They are intentionally self-contained and avoid placeholder paths.\n\n```bash\npython -m py_compile scripts\/main.py\npython scripts\/main.py --help\npython scripts\/main.py --input \"Audit validation sample with explicit symptoms, history, assessment, and next-step plan.\"\n```\n\n## When to Use\n\n- 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.\n- Use this skill for data analysis tasks that require explicit assumptions, bounded scope, and a reproducible output format.\n- Use this skill when you need a documented fallback path for missing inputs, execution errors, or partial evidence.\n\n## Workflow\n\n1. Confirm the user objective, required inputs, and non-negotiable constraints before doing detailed work.\n2. Validate that the request matches the documented scope and stop early if the task would require unsupported assumptions.\n3. Use the packaged script path or the documented reasoning path with only the inputs that are actually available.\n4. Return a structured result that separates assumptions, deliverables, risks, and unresolved items.\n5. If execution fails or inputs are incomplete, switch to the fallback path and state exactly what blocked full completion.\n\n## Quick Start\n\n```python\nfrom scripts.main import ClinicalDataCleaner\n\n# Initialize for Demographics domain\ncleaner = ClinicalDataCleaner(domain='DM')\n\n# Clean data with default settings\ncleaned = cleaner.clean(raw_data)\n\n# Save with audit trail\ncleaner.save_report('output.csv')\n```\n\n## Core Capabilities\n\n### 1. SDTM Domain Validation\n\n```python\ncleaner = ClinicalDataCleaner(domain='DM')  # or 'LB', 'VS'\nis_valid, missing = cleaner.validate_domain(data)\n```\n\n**Required Fields:**\n- **DM**: STUDYID, USUBJID, SUBJID, RFSTDTC, RFENDTC, SITEID, AGE, SEX, RACE\n- **LB**: STUDYID, USUBJID, LBTESTCD, LBCAT, LBORRES, LBORRESU, LBSTRESC, LBDTC\n- **VS**: STUDYID, USUBJID, VSTESTCD, VSORRES, VSORRESU, VSSTRESC, VSDTC\n\n### 2. Missing Value Handling\n\n```python\ncleaner = ClinicalDataCleaner(\n    domain='DM',\n    missing_strategy='median'  # mean, median, mode, forward, drop\n)\ncleaned = cleaner.handle_missing_values(data)\n```\n\n### 3. Outlier Detection\n\n```python\ncleaner = ClinicalDataCleaner(\n    domain='LB',\n    outlier_method='domain',  # iqr, zscore, domain\n    outlier_action='flag'     # flag, remove, cap\n)\nflagged = cleaner.detect_outliers(data)\n```\n\n**Clinical Thresholds:**\n| Parameter | Range | Unit |\n|-----------|-------|------|\n| Glucose | 50-500 | mg\/dL |\n| Hemoglobin | 5-20 | g\/dL |\n| Systolic BP | 70-220 | mmHg |\n\n### 4. Date Standardization\n\n```python\nstandardized = cleaner.standardize_dates(data)\n# Converts to ISO 8601: 2023-01-15T09:30:00\n```\n\n### 5. Complete Pipeline\n\n```python\ncleaner = ClinicalDataCleaner(\n    domain='DM',\n    missing_strategy='median',\n    outlier_method='iqr',\n    outlier_action='flag'\n)\ncleaned_data = cleaner.clean(data)\ncleaner.save_report('output.csv')\n```\n\n**Output Files:**\n- `output.csv` - Cleaned SDTM data\n- `output.report.json` - Audit trail for regulatory submission\n\n## CLI Usage\n\n```text\n# Clean demographics\npython scripts\/main.py \\\n  --input dm_raw.csv \\\n  --domain DM \\\n  --output dm_clean.csv \\\n  --missing-strategy median \\\n  --outlier-method iqr \\\n  --outlier-action flag\n\n# Clean lab data with clinical thresholds\npython scripts\/main.py \\\n  --input lb_raw.csv \\\n  --domain LB \\\n  --output lb_clean.csv \\\n  --outlier-method domain\n```\n\n## Common Patterns\n\nSee [references\/common-patterns.md](references\/common-patterns.md) for detailed examples:\n- Regulatory Submission Preparation\n- Interim Analysis Data Preparation\n- Database Migration Cleanup\n- External Lab Data Integration\n\n## Troubleshooting\n\nSee [references\/troubleshooting.md](references\/troubleshooting.md) for solutions to:\n- Validation failures\n- Date parsing errors\n- Memory errors with large datasets\n- Outlier detection issues\n\n## Quality Checklist\n\n**Pre-Cleaning:**\n- [ ] IACUC approval obtained (animal studies)\n- [ ] Sample size adequately powered\n- [ ] Randomization method documented\n\n**Post-Cleaning:**\n- [ ] Validate against CDISC SDTM IG\n- [ ] Review all cleaning actions in audit trail\n- [ ] Test import to analysis software\n\n## References\n\n- `references\/sdtm_ig_guide.md` - CDISC SDTM Implementation Guide\n- `references\/domain_specs.json` - Domain-specific field requirements\n- `references\/outlier_thresholds.json` - Clinical outlier thresholds\n- `references\/common-patterns.md` - Detailed usage patterns\n- `references\/troubleshooting.md` - Problem-solving guide\n\n---\n\n**Skill ID**: 189 | **Version**: 2.0 | **License**: MIT\n\n## Output Requirements\n\nEvery final response should make these items explicit when they are relevant:\n\n- Objective or requested deliverable\n- Inputs used and assumptions introduced\n- Workflow or decision path\n- Core result, recommendation, or artifact\n- Constraints, risks, caveats, or validation needs\n- Unresolved items and next-step checks\n\n## Error Handling\n\n- If required inputs are missing, state exactly which fields are missing and request only the minimum additional information.\n- If the task goes outside the documented scope, stop instead of guessing or silently widening the assignment.\n- If `scripts\/main.py` fails, report the failure point, summarize what still can be completed safely, and provide a manual fallback.\n- Do not fabricate files, citations, data, search results, or execution outcomes.\n\n## Input Validation\n\nThis skill accepts requests that match the documented purpose of `clinical-data-cleaner` and include enough context to complete the workflow safely.\n\nDo not continue the workflow when the request is out of scope, missing a critical input, or would require unsupported assumptions. Instead respond:\n\n> `clinical-data-cleaner` only handles its documented workflow. Please provide the missing required inputs or switch to a more suitable skill.\n\n## Response Template\n\nUse the following fixed structure for non-trivial requests:\n\n1. Objective\n2. Inputs Received\n3. Assumptions\n4. Workflow\n5. Deliverable\n6. Risks and Limits\n7. Next Checks\n\nIf the request is simple, you may compress the structure, but still keep assumptions and limits explicit when they affect correctness.\n\n## When Not to Use\n\n- Do not proceed when required input files, identifiers, parameters, or context are missing \u2014 ask the user to provide them first.\n- Do not assume capabilities beyond this skill's declared scope when the user requests external operations or inferences.\n- Do not proceed without user confirmation when overwriting existing results, executing high-cost batch operations, or expanding task scope.\n\n## Required Inputs\n\n| Field | Required | Format\/Source | Example | If Missing |\n|---|---|---|---|---|\n| User task description | Yes | Text | Research question, writing goal, analysis objective | Stop and ask user to provide |\n| Primary input material | Depends on task | Text, file path, ID, table, or literature | PMID, PDF, CSV, DOCX, keywords, etc. | Specify which material type is missing |\n| Output preference | No | Text | Language, format, target journal, template | Use skill default format |\n\n## Output Contract\n\n- Primary output: Structured result or target file aligned with this skill's objective.\n- Optional output: Intermediate check notes, issue list, supplementary suggestions, or generated file paths.\n- Format requirement: Unless the user specifies otherwise, prefer stable, reviewable Markdown or JSON; if the skill's bundled script requires a fixed format, use that format.\n- If partially complete: Must explicitly mark as PARTIAL and state which steps are completed and which remain.\n\n## Failure Handling\n\n- Missing critical input: Explicitly state which fields, files, or identifiers are missing and pause.\n- Script, template, or resource execution failure: Report the failing step, likely cause, and recovery suggestions \u2014 do not silently degrade.\n- Partial completion only: Return the verified portion first, then list remaining blockers and suggested next steps.\n\n## User Checkpoints\n\n- Before executing batch processing, overwriting files, long-running searches, or multi-stage generation, confirm scope and output format with the user.\n- Before proceeding when a key judgment is ambiguous, evidence is insufficient, or the workflow is entering the next stage, confirm with the user.\n\n## Quick Validation\n\n- Check that key scripts, templates, or reference file paths this skill depends on exist.\n- Check that the final output contains the core fields, sections, or files specified for this task.\n- Check that results clearly mark assumptions, limitations, and incomplete items.\n","use_cases":["Cleaning clinical trial data for FDA\/EMA submissions","Standardizing SDTM datasets for regulatory compliance","Handling missing values in clinical studies","Detecting outliers in lab results","Converting raw CRF data to CDISC format"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/aipoch\/medical-research-skills\/blob\/686e09dfdb45d9fa1a08664f06bb93769b3c9d91\/scientific-skills\/Data%20Analysis\/clinical-data-cleaner\/SKILL.md","source_commit":"686e09dfdb45d9fa1a08664f06bb93769b3c9d91","license":"MIT","version":null,"listing_approved_at":"2026-11-24","created_at":"2026-11-23T11:12:11.000000Z","updated_at":"2026-11-24T07:14:40.000000Z","seo_title":"Clinical Data Cleaner for SDTM Compliance","seo_description":"Clean and standardize clinical trial data for FDA\/EMA submissions with audit trails and SDTM compliance, supporting domains like DM, LB, and VS.","seo_keywords":["clinical data cleaning","SDTM compliance","FDA\/EMA data submission","lab result outlier detection","CDISC data conversion"]}}