← All projects
Case Study · Healthcare Tooling

Biopsy Log Automation: no result falls through the cracks

A Google Apps Script that reads each pathology result in a dermatology clinic's biopsy log, color-codes it by diagnosis, closes finished cases, and builds daily work queues for staff.

Google Apps ScriptJavaScriptGoogle SheetsRegex
Where
Reserve Dermatology
Role
Designed and built it
Users
Clinic staff
Code
View on GitHub ↗
01.

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.

02.

What it does

It classifies every result and colors the row:

ColorCategoryExamples
RedMelanomaMelanoma in situ, lentigo maligna
YellowNon-melanoma skin cancerBasal cell carcinoma, SCC, keratoacanthoma
MagentaDysplastic / atypical nevusDysplastic nevus, moderate atypia
WhiteBenignSeborrheic 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:

28 days

Melanoma

42 days

Basal or squamous cell carcinoma

56 days

Dysplastic nevus

It runs live whenever staff edit the Results, Notified, or Treated columns, and there's also a menu for manual runs.

03.

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:

  1. Melanoma terms → red
  2. Basal or squamous cell carcinoma terms → yellow
  3. Dysplastic or atypical nevus terms → magenta
  4. Benign terms → white
  5. Graded atypia with no benign diagnosis → magenta
  6. Anything else → white
The result A mistake now produces an extra row for a person to review, never a missed cancer.

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.

04.

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.

05.

Privacy

No patient data in the code The script holds only logic and sheet structure, which is what makes it safe to share publicly. The sample data in the repo is fictional.
06.

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