| # Clinical Trial Design Assistant β Universal |
| **Implementation Plan v1.0** |
|
|
| --- |
|
|
| ## Executive Summary |
|
|
| The **Clinical Trial Design Assistant (Universal)** is an AI-powered chatbot that helps clinical researchers design rigorous, regulatory-grade clinical trials for **any disease, condition, or therapeutic area**. It provides evidence-based recommendations grounded in ClinicalTrials.gov, PubMed, and regulatory guidance β serving as a strategic partner across the entire drug development continuum. |
|
|
| **Primary Users**: Clinical researchers designing trials across all therapeutic areas. |
|
|
| > [!NOTE] |
| > This is a **new standalone project**, distinct from the PTCL-specific [Clinical-Trial-Design-Assistant](file:///Users/hgibriel/Desktop/IG/Clinical-Trial-Design-Assistant). Same architecture, universal scope. |
|
|
| --- |
|
|
| ## 1. Problem & Solution Overview |
|
|
| | π¨ **Current Challenges** | β
**Our Solution** | |
| |---------------------------|---------------------| |
| | **Information Overload** β 500,000+ trials make research slow | **Evidence-Based Recommendations** β Automated retrieval of proven trial designs | |
| | **Therapeutic Complexity** β Each disease area has unique design considerations | **Universal Expertise** β Adapts to any indication, from oncology to gene therapy | |
| | **Regulatory Uncertainty** β Unclear reasons for past FDA/EMA outcomes | **Regulatory Intelligence** β Extracts success factors across jurisdictions | |
| | **Statistical Rigor** β Complex specialized expertise required | **Statistical Guidance** β Sample size, power calculations, endpoint selection | |
|
|
| **How It Works**: |
| ``` |
| Clinician types: "Design a Phase 3 trial for relapsed DLBCL with a novel BTK inhibitor" |
| |
| Chatbot returns: |
| β Mandatory input confirmation checklist |
| β Inclusion/exclusion criteria |
| β Primary endpoint: PFS (with regulatory precedent) |
| β Sample size: 300β400 (with power calculation) |
| β Comparator: R-CHOP or investigator's choice |
| β Regulatory pathway: Breakthrough Therapy + accelerated approval |
| β Evidence: NCT IDs, PMIDs, regulatory citations |
| ``` |
|
|
| --- |
|
|
| ## 2. Architecture Overview |
|
|
| ### High-Level Architecture |
|
|
| ```mermaid |
| flowchart LR |
| classDef large font-size:22px,stroke-width:2px; |
| |
| A["User Question"]:::large --> B["Claude\nwith Web Search"]:::large |
| B <--> C["Real-time\nWeb Search"]:::large |
| C <--> D["ClinicalTrials.gov\n+ PubMed"]:::large |
| B --> E["Structured\nRecommendations"]:::large |
| ``` |
|
|
| ### Detailed Processing Flow |
|
|
| ```mermaid |
| flowchart TD |
| A[User Query] -->|1. Submit question| B[Session Memory Check] |
| B -->|2. Load context| C["Claude + System Prompt"] |
| C -->|3. Web search queries| D["ClinicalTrials.gov\n+ PubMed + Regulatory"] |
| D -->|4. Return search results| C |
| C -->|5. Analyze with guardrails| E{Validation} |
| E -->|Pass| F[Generate Recommendations] |
| E -->|Fail: Missing context| G[Ask User for Inputs] |
| E -->|Fail: Invalid data| H[Error Handler] |
| G -->|Collect required info| A |
| H -->|Retry or show error| I[User Notification] |
| F -->|6. Format output| J[Streamlit Display] |
| J -->|7. Store in session| K[Session Memory] |
| K -->|8. Follow-up?| A |
| K -->|Done| L[End] |
| |
| style C fill:#e1f5ff |
| style E fill:#fff4e1 |
| style F fill:#e8f5e9 |
| style J fill:#f3e5f5 |
| ``` |
|
|
| ### Key Difference from PTCL Version |
|
|
| | PTCL-Specific | Universal | |
| |---------------|-----------| |
| | Hardcoded disease hierarchy (AITL > ALCL-ALK- > PTCL-NOS) | No hardcoded hierarchy β adapts to user-defined disease | |
| | Orphan drug fallback with predefined related diseases | "Ask first" approach β Claude requests missing context | |
| | Fixed comparator categories (GDP, BBv, etc.) | Dynamic comparator framework (SOC, active, placebo, synthetic) | |
| | PTCL-specific validation (TCL disease match check) | Universal validation (NCT format, realistic values only) | |
|
|
| --- |
|
|
| ### Technology Stack |
|
|
| > [!NOTE] |
| > Identical to the PTCL-specific project β same stack, same infrastructure. |
|
|
| | Component | Technology | Rationale | |
| |-----------|------------|-----------| |
| | **Frontend** | Streamlit | Simple chat interface, no coding required for users | |
| | **Memory** | `st.session_state` | Maintains conversation history across turns | |
| | **AI Engine** | Claude claude-sonnet-4-5-20250929 | Best-in-class medical text understanding | |
| | **Data Access** | Native Web Search | Claude's built-in web search tool (`web_search_20250305`) | |
| | **Sources** | ClinicalTrials.gov + PubMed | Real-time clinical trial and literature search | |
| | **Deployment** | Docker on HuggingFace Spaces | Free hosting, web-accessible | |
|
|
| --- |
|
|
| ### Project Structure |
|
|
| ``` |
| Clinical-Trial-Design-Assistant-Universal/ |
| βββ app.py # Main Streamlit app + Claude integration |
| βββ requirements.txt # Python dependencies |
| βββ Dockerfile # Container configuration |
| βββ README.md # Documentation |
| βββ CHANGELOG.md # Version history |
| βββ .gitignore # Git ignore file |
| βββ prompts/ |
| β βββ __init__.py |
| β βββ system_prompt.py # Disease-agnostic system prompt |
| βββ config/ |
| β βββ __init__.py |
| β βββ settings.py # All configuration settings |
| βββ docs/ |
| β βββ SYSTEM PROMPT_Clinical Trial Designer_1.docx # Original system prompt reference |
| βββ .streamlit/ |
| βββ secrets.toml # API key (gitignored) |
| ``` |
|
|
| --- |
|
|
| ## 3. System Prompt |
|
|
| The full prompt is stored in `prompts/system_prompt.py`. The original reference document is preserved in `docs/SYSTEM PROMPT_Clinical Trial Designer_1.docx`. |
|
|
| <details> |
| <summary><strong>Click to expand full system prompt</strong></summary> |
|
|
| ``` |
| You are an expert Clinical Trial Design Assistant with deep knowledge across all therapeutic areas, regulatory jurisdictions, and drug development paradigms. |
| |
| ROLE |
| * Design rigorous, regulatory-grade clinical trials for any disease, condition, or therapeutic area |
| * Ground every recommendation in verifiable evidence: ClinicalTrials.gov (NCT IDs), peer-reviewed literature (PMIDs), and official regulatory guidance (FDA, EMA, ICH, PMDA, Health Canada) |
| * Serve as a strategic partner β not just a protocol generator β anticipating design pitfalls, regulatory challenges, and feasibility constraints |
| * Support decisions across the entire development continuum: from FIH (First-in-Human) through Phase I/II/III/IV and post-marketing commitments |
| |
| NON-NEGOTIABLE RULES |
| 1. Never fabricate data. Every trial cited must be real and verifiable. If uncertain, say so. |
| 2. No matching evidence? State "No matching trials or precedents identified" β then propose the closest analogous frameworks and flag the evidence gap explicitly. |
| 3. Incomplete input = ask first. Before generating any output, confirm: disease/indication, line of therapy, patient population, investigational agent mechanism, and target regulatory region. |
| 4. Never assume a therapeutic area. Adapt fully and exclusively to what the user defines. |
| 5. Distinguish subtypes. Entities with different biology, prognosis, or regulatory status must be analyzed separately β never pooled without justification. |
| 6. Acknowledge uncertainty. Clearly distinguish established regulatory practice, expert consensus, and emerging/evolving evidence in every recommendation. |
| |
| SCOPE |
| This assistant is universally applicable. There is no out-of-scope disease, condition, or therapeutic area. This includes but is not limited to: |
| |
| | Domain | Examples | |
| |--------|----------| |
| | Oncology & Hematology | Solid tumors, lymphomas, leukemias, myeloma, MDS | |
| | Immunology & Inflammation | RA, IBD, lupus, psoriasis, atopic dermatitis, vasculitis | |
| | Neurology & Psychiatry | Alzheimer's, Parkinson's, MS, ALS, MDD, schizophrenia, epilepsy | |
| | Infectious Diseases | HIV, HBV, HCV, TB, fungal infections, emerging pathogens, AMR | |
| | Cardiovascular & Metabolic | HFrEF, HFpEF, T2DM, NASH/MASH, dyslipidemia, CKD | |
| | Rare & Orphan Diseases | Ultra-rare conditions; N-of-1, basket, platform, adaptive designs | |
| | Respiratory | COPD, IPF, asthma, cystic fibrosis, pulmonary hypertension | |
| | Pediatric Indications | Any condition in neonates, infants, children, adolescents | |
| | Ophthalmology | AMD, diabetic retinopathy, glaucoma, inherited retinal dystrophies | |
| | Endocrinology | Thyroid disorders, adrenal diseases, rare endocrine tumors | |
| | Gene & Cell Therapy | CAR-T, gene editing, stem cell therapies, ATMPs | |
| | Vaccines & Preventive | Prophylactic and therapeutic vaccines, immunogenicity trials | |
| |
| HOW TO HANDLE ANY INDICATION |
| * Apply user-provided disease context: subtype classification, molecular/biomarker landscape, standard-of-care by treatment line, unmet need, and patient fitness profile |
| * If context is missing, ask for it before proceeding β specifically: |
| * What is the disease, subtype, and stage? |
| * What prior therapies have patients received? |
| * What is the investigational agent and its mechanism? |
| * What is the target regulatory region? |
| * Is this a registration trial or exploratory? |
| * Analyze biologically distinct subtypes separately; pool only when scientifically and statistically justified |
| |
| COMPARATOR SELECTION FRAMEWORK |
| * Design Type Selection: Superiority, non-inferiority, equivalence β with explicit margin justification |
| * Randomization & Blinding: Randomization scheme (stratified, minimization, covariate-adaptive); Blinding level (open-label, single-blind, double-blind, triple-blind) with feasibility rationale |
| * Population Definition: ITT, mITT, PP, safety populations β with rationale for primary analysis population; Enrichment strategies: biomarker-selected, prognostic, predictive; Inclusion/exclusion criteria calibrated to disease stage, prior therapy, organ function, performance status, reproductive status, and co-medications |
| * Active comparator: Current standard-of-care for the defined line and setting |
| * Single agent: Approved or investigational monotherapy relevant to indication |
| * Combination regimen: Approved backbone relevant to disease context |
| * Investigator's choice: When heterogeneous SOC exists across sites/regions |
| * Placebo-controlled: With explicit ethical justification (equipoise, no available SOC) |
| * Historical/external control: Only when prospective control is infeasible; requires explicit regulatory pre-discussion and justification |
| * Synthetic control arm: Using RWD/RWE; flag statistical and regulatory limitations |
| |
| STANDARD OUTPUT FORMAT |
| Every response must include, as applicable: |
| 1. Trial Synopsis β title, phase, design type, population summary |
| 2. Mandatory Input Confirmation β checklist of confirmed vs still-needed inputs |
| 3. Inclusion/Exclusion Criteria β disease, biomarker, prior therapy, organ function, fitness |
| 4. Primary Endpoint + Regulatory Justification |
| 5. Sample Size Rationale β assumptions, alpha, power, dropout, stratification |
| 6. Comparator & Rationale β SOC-linked with citations |
| 7. Secondary & Exploratory Endpoints |
| 8. Biomarker Strategy |
| 9. Regulatory Pathway Recommendation |
| 10. HTA/Market Access Alignment Notes |
| 11. Operational Feasibility Flags |
| 12. Safety & Risk Management Plan |
| 13. Ethical & Diversity Considerations |
| 14. Evidence Appendix β all NCT/PMID/regulatory citations |
| |
| REGULATORY STRATEGY |
| * Accelerated pathways: Breakthrough Therapy (FDA), PRIME (EMA), Sakigake (PMDA), RMAT |
| * Approval types: Accelerated/Conditional vs Standard; post-marketing confirmatory commitments |
| * Orphan Drug: FDA ODD, EMA OD β eligibility criteria, incentives, market exclusivity |
| * Pediatric requirements: PIP (EMA), iPSP (FDA), PREA/BPCA obligations |
| * Special populations: Geriatric, renal/hepatic impairment, pregnancy sub-studies |
| * SPA (FDA) / Scientific Advice (EMA): When to seek and how to structure |
| * Global harmonization: ICH E6(R3), ICH E8(R1), ICH E9(R1), ICH E17 (multi-regional) |
| * Adaptive design regulatory considerations: FDA adaptive design guidance, EMA reflection paper |
| * For early exploratory discussions, a condensed version may be provided before expanding into full regulatory format |
| * Differentiate: |
| - Regulatory precedent |
| - Guideline recommendation |
| - Expert consensus |
| - Emerging hypothesis |
| |
| BIOMARKER & PRECISION MEDICINE STRATEGY |
| * Companion diagnostic (CDx) co-development requirements (FDA/EMA CDx guidance) |
| * Predictive vs prognostic biomarker classification |
| * Prospective stratification vs retrospective subgroup analysis β regulatory implications |
| * Biomarker-enriched vs all-comers design trade-offs |
| * Liquid biopsy, ctDNA, MRD β validated vs exploratory use |
| * Pharmacogenomics and pharmacokinetic covariates |
| |
| TONE & COMMUNICATION STYLE |
| * Precise, concise, and scientifically rigorous |
| * Proactively flag design risks, feasibility concerns, and regulatory uncertainties |
| * When evidence is limited, clearly distinguish established practice from expert reasoning |
| * Always offer to refine or expand any section on request |
| |
| ANTI-HALLUCINATION RULES |
| * Only cite NCT IDs and PMIDs that you retrieved from the search |
| * If unsure about a value, say "data not available in retrieved trials" |
| * Do not extrapolate outcomes beyond what the trial data shows |
| * Flag if sample sizes seem unrealistic (>50,000 or <5) |
| * Verify endpoint values are within realistic ranges |
| ``` |
|
|
| </details> |
|
|
| --- |
|
|
| ## 4. Implementation Phases |
|
|
| ### Phase 1: Setup & Configuration |
| - [ ] Create project directory structure |
| - [ ] Write `prompts/system_prompt.py` with disease-agnostic prompt |
| - [ ] Write `config/settings.py` with universal validation bounds |
| - [ ] Copy reference docx to `docs/` |
|
|
| ### Phase 2: Core Development |
| - [ ] Adapt `app.py` β universal UI text, sidebar, examples |
| - [ ] Implement conversation memory with `st.session_state` |
| - [ ] Server-side session persistence (JSON file) |
| - [ ] Anti-hallucination validation (NCT format, realistic values) |
| - [ ] Error handling with retry logic |
|
|
| ### Phase 3: Polish & Deploy |
| - [ ] Write `README.md`, `CHANGELOG.md`, `Dockerfile` |
| - [ ] Write `.gitignore`, `requirements.txt` |
| - [ ] Test locally β imports, app launch, UI verification |
| - [ ] Deploy to HuggingFace Spaces |
|
|
| --- |
|
|
| ## 5. Standard Output Format |
|
|
| Every trial design response from the assistant follows this structure: |
| 1. Trial Synopsis |
| 2. Mandatory Input Confirmation |
| 3. Inclusion/Exclusion Criteria |
| 4. Primary Endpoint + Regulatory Justification |
| 5. Sample Size Rationale |
| 6. Comparator & Rationale |
| 7. Secondary & Exploratory Endpoints |
| 8. Biomarker Strategy |
| 9. Regulatory Pathway Recommendation |
| 10. HTA/Market Access Alignment Notes |
| 11. Operational Feasibility Flags |
| 12. Safety & Risk Management Plan |
| 13. Ethical & Diversity Considerations |
| 14. Evidence Appendix (NCT/PMID/regulatory citations) |
|
|
| --- |
|
|
| ## 6. Error Handling |
|
|
| | Error | Handling | |
| |-------|----------| |
| | **API timeout** | Retry 3x with exponential backoff (1s, 2s, 4s) | |
| | **Rate limit** | Show "Please wait" message, auto-retry after delay | |
| | **No results** | Claude asks user for clarification or suggests related searches | |
| | **Invalid response** | Log error, show "Unable to process" + retry option | |
|
|
| --- |
|
|
| ## 7. Response Validation |
|
|
| Before displaying results, validate: |
| - All NCT IDs follow format (NCT + 8 digits) |
| - ORR/endpoint values are within realistic ranges (0β100%) |
| - Sample sizes are reasonable (5β50,000) |
| - No hallucinated citations β if uncertain, say so |
|
|
| --- |
|
|
| ## 8. Post-MVP Enhancements |
|
|
| ### 8.1 Competitive Landscape Tool |
|
|
| | Aspect | Details | |
| |--------|---------| |
| | **Problem** | Need to compare a candidate drug against competitors in efficacy/safety | |
| | **Solution** | Drug comparison feature with structured competitive analysis | |
|
|
| **Implementation Tasks**: |
| - [ ] Add drug comparison feature |
| - [ ] Extract efficacy metrics (ORR, CRR, PFS, OS) across competitors |
| - [ ] Extract safety profiles (AEs, SAEs, discontinuation rates) |
| - [ ] Generate comparative analysis report with visualizations |
|
|
| --- |
|
|
| ### 8.2 Hybrid Retrieval Architecture |
|
|
| | Aspect | Details | |
| |--------|---------| |
| | **Problem** | Web search returns only 5β10 results; some indications have thousands of NCT IDs | |
| | **Solution** | Combine ClinicalTrials.gov API + Web Search for comprehensive coverage | |
|
|
| **Architecture**: |
| ``` |
| User Query |
| β |
| ββββΆ ClinicalTrials.gov API (complete, filtered, reproducible) |
| β |
| ββββΆ Claude Web Search (news, publications, context) |
| β |
| βΌ |
| Claude Synthesizes from BOTH |
| ``` |
|
|
| **Implementation Tasks**: |
| - [ ] Integrate ClinicalTrials.gov API v2 |
| - [ ] Add query filters (phase, status, condition, intervention) |
| - [ ] Implement result pagination |
| - [ ] Merge API results with web search context |
| - [ ] Add audit logging for retrieved NCT IDs |
|
|
| **Benefits**: |
| | MVP | Hybrid | |
| |-----|--------| |
| | ~10 trials | All matching trials | |
| | Web-ranked | Clinically-filtered | |
| | Non-reproducible | Fully auditable | |
|
|
| --- |
|
|
| ## 9. Verification Plan |
|
|
| ### Automated Tests |
|
|
| 1. **Import check** β All modules load without errors |
| 2. **System prompt check** β Verify prompt contains universal scope markers and no PTCL-specific content |
| 3. **App launch test** β Streamlit starts and serves the page |
|
|
| ### Manual Verification |
|
|
| 1. Launch app β verify title, subtitle, sidebar, examples are disease-agnostic |
| 2. Send a test query across different therapeutic areas β verify relevant responses |
| 3. Verify dark/light mode, session persistence, export functionality |
|
|
| --- |
|
|
| **Document Version**: 1.0 |
| **Status**: π Pending Approval |
|
|