The problem
The clinic tracked every biopsy in a shared Google Sheet. For each row, staff had to read the pathology result, color it by diagnosis, decide whether the case was closed, and work out by hand which patients were overdue for a follow-up letter. It was slow, and it was easy to miss a case.
What it does
It classifies every result and colors the row:
| Color | Category | Examples |
|---|---|---|
| Red | Melanoma | Melanoma in situ, lentigo maligna |
| Yellow | Non-melanoma skin cancer | Basal cell carcinoma, SCC, keratoacanthoma |
| Magenta | Dysplastic / atypical nevus | Dysplastic nevus, moderate atypia |
| White | Benign | Seborrheic keratosis, solar lentigo |
It closes cases automatically when treatment is recorded, or when a benign result has been communicated. It never overwrites a case someone already closed.
It builds three work queues as separate sheets:
Check if closed out
Open cases that have a result or notification. Edits made here sync back to the main log.
Need letters / follow-up
Untreated cases that are past their follow-up deadline.
Need results
Biopsies still waiting on a pathology report.
Follow-up deadlines by diagnosis:
Melanoma
Basal or squamous cell carcinoma
Dysplastic nevus
It runs live whenever staff edit the Results, Notified, or Treated columns, and there's also a menu for manual runs.
The key decision: a cancer diagnosis always wins
Pathology reports mix diagnoses with reassuring phrases like “margins negative.” My first version checked benign phrases before cancer terms, so a report like “basal cell carcinoma, margins negative” could be marked benign and closed automatically.
I reordered the classifier so malignant terms are always checked first:
- Melanoma terms → red
- Basal or squamous cell carcinoma terms → yellow
- Dysplastic or atypical nevus terms → magenta
- Benign terms → white
- Graded atypia with no benign diagnosis → magenta
- Anything else → white
The order also avoids false alarms: “solar lentigo” stays white instead of matching “lentigo maligna.” Phrases like “negative for melanoma” are flagged for a person to review instead of being treated as benign.
Bugs worth learning from
Regex word boundaries
Patterns like \b scc \b look strict, but \b needs a letter next
to the space, so terms at the start or end of a result never matched. Normalizing the
text (lowercase, no punctuation, padded with spaces) made matching simple and correct.
Overlapping runs
Several staff editing at once could start overlapping runs. A “running” flag could get
stuck after a timeout and silently stop the script. A document lock
(LockService) solved it cleanly.
Privacy
What I learned
- In healthcare tools, rule order is a safety decision.
- Test the edge cases, not just the happy path. A small table of tricky result phrases caught bugs that everyday use hadn't.
- Build for the people using it. Staff work from the queue sheets, not the code, so edits there sync back automatically.
Known limitations: classification is keyword-based, so new or unusual wording should still get a person's review. Google's edit triggers also have a 30-second limit, so very large logs may need the manual run.
Next case study → DorinaServer: a media server that reports on itself