Classify AE vs SAE and set reporting due dates from day-0 with overdue status flags. The workbook becomes the system of record; Apps Script owns the joins and business rules so analysts are not pasting monthly formulas.
Entry point `processAdverseEvents` reads typed columns with SpreadsheetApp batch APIs. SpreadsheetApp is the primary service; onEdit describes how you usually invoke it after authorization.
Keep thresholds (grace days, bands, alert emails, API keys) in Config cells or Script Properties so the same .gs file promotes from sandbox to production without code edits.
This page is technical only: sheet layout, edge cases, runnable code, deploy steps, and FAQs for process adverse event reporting clocks. No consulting pitch—just the pattern you can paste and harden.
Need this built? Hire a Google Apps Script developer →
Sheet / project setup
| Tab | Columns | Notes |
|---|---|---|
| Events | Id, Subject, Day0, Serious, Class, Due, Status | Clocks |
What this script does
processAdverseEvents() classify AE vs SAE and set reporting due dates from day-0 with overdue status flags.
- SAE vs AE clocks
- Day-0 anchor
- OVERDUE flag
Prerequisites
Container-bound script on the workbook that contains the tabs in the setup table. Authorize SpreadsheetApp scopes on first run.
- V8 runtime
- Exact sheet names
- Script timezone = ops timezone
Walkthrough
Serious→SAE with 7-day clock else AE 15-day; mark OVERDUE if past due and not SUBMITTED.
Paste the code, set Config/Properties, run processAdverseEvents once, verify the output tab, then attach a onEdit trigger.
Edge cases
Clocks use calendar days here; swap in working-day logic if your SOP requires it.
Testing
Use a sandbox copy with 3–5 known rows. Compute expected outputs for process adverse event reporting clocks offline, run processAdverseEvents, and diff the output tab including one intentional bad row.
Hardening
Add LockService around multi-sheet writes if triggers can overlap. Log run timestamps. Keep API keys and alert emails in PropertiesService—not in shared cells.
Variations
Fork ideas: filter to one business unit, change grain (daily→weekly), or POST a summary payload after processAdverseEvents succeeds.
Operations notes
Assign an owner for the output tab, document regenerate steps, and treat `processAdverseEvents` as source of truth over ad-hoc cell formulas.
Full code: processAdverseEvents()
Run processAdverseEvents when source tabs are current. Edit sheet names and Config/Properties first.
function processAdverseEvents(){
const ss=SpreadsheetApp.getActive();
const sh=ss.getSheetByName('Events');
const data=sh.getDataRange().getValues();
for(let i=1;i<data.length;i++){
const serious=String(data[i][3]).toUpperCase()==='Y';
const day0=new Date(data[i][2]);
const dueDays=serious?7:15;
const due=new Date(day0.getTime()+dueDays*86400000);
data[i][4]=serious?'SAE':'AE';
data[i][5]=due;
data[i][6]= new Date()>due && String(data[i][7])!=='SUBMITTED' ? 'OVERDUE':'OPEN';
}
sh.getRange(2,5,data.length,7).setValues(data.slice(1).map(r=>[r[4],r[5],r[6]]));
}- Line 1: Entry point — bind triggers to processAdverseEvents.
- Line 4: Batch read; avoid per-cell getValue in loops.
- Line 14: Batch write output rows in one setValues call.
- Line 5: Rename sheet constants before production.
- Line 6: Rename sheet constants before production.
Deploy this example
- 01
Open Apps Script
In the bound spreadsheet: Extensions → Apps Script. For standalone projects, create one at script.google.com and link your Sheet by ID.
- 02
Paste and save
Add a .gs file, paste the code below, rename constants at the top (sheet names, column letters, API property keys), then save.
- 03
Authorize once
Run the main function from the editor. Accept OAuth scopes when prompted — triggers cannot run until authorization succeeds once.
- 04
Add the trigger
Triggers → Add trigger → choose the handler function and event (time-driven, on edit, or on form submit). Delete test triggers before production.
Before you run: process adverse event reporting clocks
- 1Setup tabs exist with headers matching processAdverseEvents
- 2Dry-run on a copy workbook
- 3Timezone verified
- 4SpreadsheetApp authorization completed
- 5Output spot-checked against hand calc
- 6onEdit trigger added only after validation
- 7Owners + alert recipients documented
Frequently asked questions
At minimum the tabs listed in the setup table for Process Adverse Event Reporting Clocks. Output tabs may be cleared each run—do not store source-of-truth data there.
Run from the Apps Script editor for dry runs. Production usually uses a onEdit trigger after OAuth succeeds once.
Clocks use calendar days here; swap in working-day logic if your SOP requires it.
Per-cell calls burn quota and wall time. One read + one write keeps this pattern under the 6-minute execution cap longer.
PropertiesService (Script Properties) for API keys and alert inboxes. Config sheet is fine for non-secret thresholds.
Simple ratios maybe; process adverse event reporting clocks needs joins, branching, or side effects (email/Docs/API) that Apps Script handles cleanly.
Keep the .gs in clasp/git. Avoid divergent copies of formulas on the output tab—regenerate from the script.