Skip to content

About

Synthetic pharmacovigilance (PV) data generation infrastructure for CIOMS I, MedWatch 3500A, and ICH E2B adverse event safety cases.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

39 Commits

Folders and files

Repository files navigation

Raxtik Synth

CI Docs codecov PyPI version Python Versions License: AGPL v3

raxtik-synth is an open-source Python library for generating realistic synthetic pharmacovigilance (PV) data. It provides structured adverse-event cases, patient demographics, medicinal products, clinical reactions, reporters, outcomes, and unstructured narratives for developing, testing, and evaluating safety systems.

The generated datasets are synthetic and privacy-preserving by design, enabling robust pipeline development, model benchmarking, and QA without dealing with sensitive Protected Health Information (PHI).


🎯 Use Cases

  • Pharmacovigilance Pipeline Testing: Simulate complete safety datasets for end-to-end ingestion, validation, and analytics pipeline verification.
  • Regulatory Form Generation (Downstream): Provide rich, schema-valid synthetic cases to document renderers (such as raxtik-forms) to test layout boundaries and overflow handling on standard CIOMS I and MedWatch 3500A documents.
  • AI & Document Extraction Benchmarking: Train and evaluate OCR, Document Layout Analysis, and LLM-based structured data extraction models on diverse synthetic medical scenarios.
  • Empirical Data Grounding: Seed synthetic cases with authentic co-occurrence patterns, dosages, and outcomes sampled from FDA FAERS safety data via raxtik-etl.

🛠️ Project Structure

raxtik-synth/
├── pyproject.toml         # Package definition and dependencies
├── README.md              # Project documentation
├── src/
│   └── raxtik_synth/
│       ├── __init__.py
│       ├── cli.py         # Command-line interface to generate datasets
│       ├── generators/    # Domain generators (patient, drug, event, narrative, reporter)
│       ├── models/        # Pydantic data models (BFC/E2B aligned)
│       └── sources/       # Empirical data sources (FAERS via raxtik-etl)
└── tests/                 # Unit and integration test suites

📦 Installation

Core Package

Install raxtik-synth using pip:

pip install raxtik-synth

Or using uv:

uv pip install raxtik-synth

Optional FAERS Integration

To enable empirical case sampling grounded in FDA FAERS datasets:

pip install "raxtik-synth[faers]"

For local development in editable mode:

pip install -e ".[faers]"

💻 Command-Line Interface (CLI)

Generate synthetic safety cases directly from the terminal:

# Print a single case to stdout
raxtik-synth

# Generate 10 reproducible cases and export to JSON
raxtik-synth --count 10 --seed 42 --output cases.json

# Generate line-delimited JSON (JSONL) for bulk streaming / ML training
raxtik-synth -n 100 -s 42 -o dataset.jsonl

🚀 Basic Python Usage

from raxtik_synth.generators import CaseGenerator

# Generate a reproducible adverse event case payload
generator = CaseGenerator(seed=42)
case = generator.generate_case()

print(case.model_dump_json(indent=2))

🧬 Regulatory & Clinical Data Models (E2B-Aligned)

raxtik-synth implements E2B(R2/R3)-aligned synthetic data models informed by the Backward and Forward Compatibility (BFC v2.02) specification covering CIOMS I, FDA Form 3500A (MedWatch), and ICH E2B (R2/R3):

  • Patient (Patient): Demographics, explicit CIOMS Box 2 Initials (initials), death details, and pre-existing conditions (medical_history).
  • Products (Product): Suspect and concomitant medications, indications, dosage regimens, routes, lot numbers, and therapy dates.
  • Reactions (Reaction & SeriousnessCriteria): MedDRA Preferred Terms (PT), Lower Level Terms (LLT), onset dates, dechallenge/rechallenge outcomes, and ICH seriousness criteria.
  • Laboratory Investigations (LabTest): CIOMS Box 12 / E2B Section F.r test results, reference ranges (normal_low, normal_high), units, and clinical comments.
  • Clinical Context:
    • ParentInfo (Section D.10): For parent-child / in-utero exposure reports.
    • StudyInfo (Section C.5): Clinical study protocols, phases, and sponsor numbers.
    • DeviceDetails (Section G.k): Medical devices and drug-device combination products.
    • CausalityAssessment (Section G.k.9.i.2.r): Drug-event causality determinations (e.g. WHO-UMC).
  • Clinical Narrative (CaseNarrative): Unstructured case narrative text and structured medical history items (MedicalHistoryItem for CIOMS Box 13).

⚡ Integration with raxtik-etl (FDA FAERS Data)

raxtik-synth supports optional empirical data integration through raxtik-etl, enabling synthetic PV datasets informed by real-world FAERS distributions:

# Optional empirical data integration through raxtik-etl
try:
    from raxtik_synth.sources.faers import FAERSSource

    # Initialize data source grounded in empirical FAERS package
    source = FAERSSource(period="2004Q1")
    # case = source.generate_case()
except (ImportError, FileNotFoundError):
    pass

Interactive demonstrations and benchmarks are available in notebooks/raxtik_faers_integration_demo.ipynb.


👥 Contributors

Contributions are welcome! Please see contributor.md for the list of people who have contributed to this project.

About

Synthetic pharmacovigilance (PV) data generation infrastructure for CIOMS I, MedWatch 3500A, and ICH E2B adverse event safety cases.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages