Skip to content

Add ClinicalTrials.gov data source for evidence-based drug safety #2

@sarvanithin

Description

@sarvanithin

Overview

ClinicalTrials.gov has a free REST API with data on 500k+ trials. This can augment drug safety checks with real trial-level evidence — e.g., checking if a drug combination was studied in a trial and what the outcomes were.

API

GET https://clinicaltrials.gov/api/v2/studies?query.term=warfarin+aspirin&fields=protocolSection&pageSize=5

No API key required. Returns JSON.

What to build

  • medguard/knowledge/clinicaltrials.pyClinicalTrialsClient
    • search_trials(drug_a, drug_b) → list of relevant trial summaries
    • Cache results with diskcache (same pattern as RxNormClient)
  • Hook into DrugSafetyChecker as an optional third source alongside OpenFDA and static table
  • Add use_clinical_trials: bool = False to DrugSafetyConfig

Value

Catches drug interactions that appear in trials but not yet in FDA labeling. Especially useful for newer drug combinations.

Files to modify

  • medguard/knowledge/clinicaltrials.py — new file
  • medguard/guardrails/drug_safety.py — integrate as optional source
  • medguard/config.py — add flag to DrugSafetyConfig
  • tests/test_drug_safety.py — add mocked tests

Acceptance criteria

  • ClinicalTrialsClient.search_trials("warfarin", "aspirin") returns results
  • Results integrated into DrugSafetyResult
  • Graceful fallback if API is down
  • Tests with respx mocks (no real network in unit tests)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions