← All runbooks
smnth / ctg-condition-search-extraction★ Featured · worked examples

ClinicalTrials.gov Condition Search Extraction

Search ClinicalTrials.gov for studies matching the condition {{condition}} that were first posted between {{posted_from}} and {{posted_to}}. For each matching study, open its own ClinicalTrials.gov study page (https://clinicaltrials.gov/study/{NCT_NUMBER})…

agent opencodemodel openai/gpt-5.6-terrasnapshot prism-playwrighteval programmatic9 stepsv1.3.0

Deploy ClinicalTrials.gov Condition Search Extraction to your jetty.io

One-click installs this runbook into a collection on your Jetty account. You can run it from the Spot dashboard, schedule it, or pipe inputs in via the API.

Run time15-25 mins
Headline outputstudies.csv

Runs on Jetty's managed sandbox. No setup. Free for your first 10 runs.

Worked examples · 3

Real runs, real outputs.

The shape of the run

9 steps · start to finish.

  1. 1
    Step 1

    Environment Setup

    pip install pandas playwright
    python -m playwright install chromium
    
    mkdir -p {{results_dir}}
    

    No secrets are required — both the API and the study pages are public.


  2. 2
    Step 2

    Build the Candidate List

    Use the ClinicalTrials.gov API v2 to narrow down which studies to visit. This step only produces a list of NCT numbers — it is NOT the source of any extracted field value.

  3. 3
    Step 3

    Extract Exact Field Values From Each Study Page

    For every candidate NCT number remaining after Step 2, open https://clinicaltrials.gov/study/{NCT} in a real browser (Playwright/Chromium) and wait for the page content to fully render (the page is a…

  4. 4
    Step 4

    Evaluate Outputs

    For each row, assign an evaluation status:

  5. 5
    Step 5

    Iterate on Errors (max 3 rounds)

    If any rows received FAIL or PARTIAL status:

  6. 6
    Step 6

    Write Extraction Audit Trail

    Write {{results_dir}}/extraction_audit.json — the full provenance trail assembled while working through Steps 2-5. This exists so a reader can verify no value was fabricated or backfilled from the…

  7. 7
    Step 7

    Write Executive Summary

    Write {{results_dir}}/summary.md with the following structure:

  8. 8
    Step 8

    Write Validation Report

    Write {{results_dir}}/validation_report.json:

  9. 9
    Step 9

    Final Checklist (MANDATORY — do not skip)

    echo "=== FINAL OUTPUT VERIFICATION ===" RESULTS_DIR="{{results_dir}}" for f in "$RESULTS_DIR/studies.csv" "$RESULTS_DIR/summary.md" "$RESULTS_DIR/validation_report.json"…