# Codebook: how long each trial watched for serious adverse events

Some trials record adverse events only while a participant takes the study drug, perhaps with a short window after the last dose; others record them for every participant until the trial ends, whether or not they still take it. Where more participants stop the drug than placebo, the first kind watches the drug arm for less time. This coding sorts the trials by what their ClinicalTrials.gov record says about it, so the analysis can be repeated in the trials that watched everyone to the end.

You see, for each trial, only the adverse-event module's two text fields as the record states them: `time_frame` and `description`. You see no arms, groups, or counts, and must not look for them: do not open any other file, and do not use what you may know about a trial from elsewhere. Code from the words in front of you.

## What to decide

For each trial, the period over which its **serious** adverse events were recorded and reported, as one of:

| Code | When to use it |
|---|---|
| `on_treatment` | The record ties the period to taking the study drug: events while on treatment, an on-treatment or treatment period, from the first dose to the last dose plus a fixed number of days or weeks, or "treatment-emergent" defined as events up to a set time after the last dose. |
| `in_trial` | The record says the period does not end when a participant stops the drug: an in-trial observation period, events regardless of treatment status or discontinuation, or follow-up of every randomized participant until the end of the trial, death, or withdrawal of consent. |
| `calendar` | The record gives a period on the trial's calendar (for example "week 0 to week 26", "baseline to week 56 plus 7 weeks of follow-up", "up to study completion, up to 5 years") and says nothing that ties it to taking the drug or that frees it from that. |
| `unstated` | Neither field gives a period for serious events, or what they say can't be placed in any of the codes above. |

Rules:

1. Serious events decide. If the record gives one period for serious events and another for non-serious ones, code the serious one. If it gives one period for deaths and another for adverse events, code the adverse events'.
2. "Treatment-emergent" alone means an event that began after the first dose; it does not by itself end the period at the last dose. Code `on_treatment` only when the record says the period ends with treatment (at the last dose, or a fixed time after it).
3. A period that names the trial's calendar *and* says participants were followed whether or not they stayed on the drug is `in_trial`. A calendar period with nothing either way is `calendar`.
4. Analysis populations ("safety set: all who took at least one dose", "full analysis set") say who is counted, not for how long; on their own they don't change the code.
5. When the two fields disagree, the more specific statement about serious events decides; if they genuinely conflict, use `unstated` and say why.

## What to write

A JSON array with one object per trial, in the order given:

```json
{"nct": "NCT00000000", "window": "on_treatment", "basis": "the words from the record that decide it, quoted exactly, at most 40 words"}
```

`basis` is empty for `unstated` when the record says nothing. Do not add other fields.
