def generate_trial_event()

in 3-ai-native-e2e-sample/backend/agents/trials/event_producer/producer.py [0:0]


def generate_trial_event() -> Dict[str, Any]:
    """Generate a simulated trial event with random data."""
    return {
        "trialId": f"CTO{random.randint(1,1000):03d}",
        "patientId": f"P{random.randint(1,1000):03d}",
        "studyArm": random.choice(["Drug A", "Drug B", "Placebo"]),
        "timestamp": datetime.now(timezone.utc).isoformat(),
        "vitals": {
            "heartRate": random.randint(60, 100),
            "bloodPressure": f"{random.randint(110,140)}/{random.randint(60,90)}",
            "temperature": round(random.uniform(36.1, 37.2), 1),
            "respiratoryRate": random.randint(12, 20),
            "oxygenSaturation": random.randint(95, 100)
        },
        "adverseEvents": [
            {
                "type": random.choice(["Mild", "Moderate", "Severe"]),
                "description": random.choice([
                    "Headache",
                    "Nausea",
                    "Fatigue",
                    "Dizziness",
                    None,
                    None,
                    None
                ])
            }
        ] if random.random() < 0.3 else []
    }