Build progress
37 / 39
95% complete · target demo Thu Oct 1, 1:30 PM ET
Deepak
10/10 · 2.85h
Mason
20/20 · 37h
Anthony
4/5 · 0.75h
Cristian
3/3 · 0.75h
Justin
0/1 · 0.5h
The ask (from Wed Sep 24 call)
One number: cost per new patient by marketing channel.
▾
"How much does a new patient cost me? ... We need a system in place where we know of the calls that are being driven into the numbers, what are pre-existing patients and what are new converted leads."
"Cross-reference their number that's calling in against their first appointment date in Simple Practice. If they already have a first appointment date — last month or 3 years prior — we know that number is just a patient calling in."
Hard constraints:
  • Only tools: SimplePractice + CallTrackingMetrics
  • Zero manual tagging by front-desk staff (Justin explicit)
  • Automated extraction + cross-reference
  • Deadline: Thu Oct 1, 1:30 PM ET meeting
Success = Justin can answer these 4 questions on Oct 1
Using the dashboard, on his own, no explanation needed.
▾
  1. 1. How many calls did I get last week? How many were existing patients vs new-patient inquiries?
  2. 2. Of the new-patient inquiries, how many booked a first appointment?
  3. 3. How much did each marketing channel (Google Ads, SEO, Meta, direct/GBP) cost me per new patient booked?
  4. 4. Which specific landing pages or campaigns are driving the most booked patients?
End-to-end flow
Follow the data from patient touch to Justin's dashboard. Each owner's tasks are labeled on the boxes they own.
OPP Websiteorlandopremierpsychiatry.comGoogle Ads swap4 tracked-number poolsGoogle Ads · Subdomain LPsGA4 + Gravity FormsG-Z5G9RXCB62Deepak D-07SimplePracticecontact@allgoodseo.com accountScheduled Reports (Daily · CSV)Clients report + Appointments reportDeepak D-02CallTrackingMetricswebhook w/ source +GA4 client_id stampedDeepak D-06 (GA4 integration)Mason M-06 (ingest)GA4 Data APImulti-touch attributionsession history by client_idCristian D-11 (grant Viewer)Mason M-08, M-09📧 Email routing — pick a pathSP sends "Your export is ready" email →Deepak routes to a Mason-reachable inbox🔥 BLOCKING — Deepak D-01Mailgun Inboundingest.verifiedhealthos.comemail → webhookMason M-03inbound callsession + formdaily emailVHOS on VPS 144.202.33.136Next.js 14 + Prisma + Postgres · PM2 vhos-app/api/ingest/ctmclassify + attributeMason M-06, M-07/api/ingest/sp-exportfetch CSV + UPSERTMason M-05, M-19Postgres tablesopp_patients · opp_calls_classifiedopp_appointments · opp_ad_spendMason M-01, M-02/dashboardCPA per channel · funnelmulti-touch attributionMason M-10, M-11 (live now)CSV payloadforwarded emailGoogle Ads + Meta Marketing APIsdaily spend puller · 4:00 AM ET cronCristian D-09, D-10 (grant access)Mason M-12, M-13, M-14👤 Justin — Oct 1, 1:30 PM ETOpens /dashboard, sees CPA per channel,validates numbers match his gut ±15%Justin J-04daily spend UPSERTlive dashboardMarketing toolEmail routingIngest infraVHOS coreClient-facing
Real-time side (every call)
Visitor lands on Google Ads → native Ads number-swap shows a tracked number → OR visitor lands on a per-source subdomain LP with its own tracked number → they call → OPP CTM fires webhook to VHOS with GA4 client_id → matcher joins against SP patient directory → classified as existing / new / converted within seconds.
Daily side (SP + ad spend)
SP scheduled export fires nightly → email routed through Deepak's D-01 path → Mailgun webhook to VHOS → Playwright follows link → CSV parsed into Postgres. Google Ads + Meta APIs push daily spend at 4 AM ET. Dashboard reflects all of it live.
Architecture
Event-driven, cloud-only. Nothing runs on Justin's or the front-desk's computer.
▾
Website (GTM)
   ├── Google Ads native number-swap (paid-search) + per-source subdomain LP tracked numbers (main funnel)
   └── GA4 (G-Z5G9RXCB62) + Gravity Forms conversion trigger
        │                          │
        ▼ inbound call              ▼ session + form
     CTM webhook                 GA4 Data API
        │                          │
        └────────┬─────────────────┘
                 ▼
       VHOS on VPS 144.202.33.136
       Next.js 14 + Prisma + Postgres
       /api/ingest/ctm    /api/ingest/sp-export
       /dashboard (live)
                 ▲
                 │ SP scheduled export → Mailgun inbound
                 │
       SimplePractice (Deepak has login)
       Scheduled Reports: Clients + Appointments
The identity resolver (Justin's own logic)
FOR every CTM call event:
  IF caller_phone NOT IN opp_patients:
    → NEW_PATIENT_INQUIRY (attribute to source)
  IF caller_phone IN opp_patients:
    IF first_appt_date < call_date → EXISTING (noise, exclude)
    IF first_appt_date ≥ call_date → NEW_CONVERTED (attribute)
Filter tasks:
Shown: 39 tasks · 41.85h estimated
D-01DeepakBLOCKING0.1h
Pick a path so Mason can read SP 'export ready' emails from contact@allgoodseo.com
▾
SimplePractice sends 'Your export is ready to download' notifications to whichever email is on the SP account — currently contact@allgoodseo.com. Mason already has IMAP access to anthony@allgoodseo.com but NOT contact@. Deepak: pick ONE of the three paths below (details in the expanded task view) and complete it, then ping Mason. This unblocks the entire SP ingest chain. === PATH A — Auto-forward contact@ → anthony@ (RECOMMENDED, ~2 min) === Google Workspace Admin → Gmail → set up automatic forwarding from contact@allgoodseo.com to anthony@allgoodseo.com. contact@ keeps its own copy; anthony@ gets a mirror. Zero credential-sharing. Every future SP email lands where Mason already reads. Docs linked below. Pros: no creds shared, works forever, reversible in 30 sec. Cons: anthony@ inbox gets some extra noise (SP notifications). === PATH B — Generate an app password for contact@ and send it to Mason (~3 min) === Workspace Admin → Users → contact@allgoodseo.com → Security → Generate app password → send to Mason via Anthony's secure channel. Mason adds contact@ as a third account in himalaya and reads it directly. Pros: cleaner (reads the actual account, no cross-mailbox noise). Cons: another credential to store + rotate. === PATH C — Change the SP account email to a VHOS-controlled inbox (~5 min) === Log into SP with contact@allgoodseo.com → Settings → Account → change primary email from contact@allgoodseo.com to sp-opp@ingest.verifiedhealthos.com (a Mailgun inbox Mason controls). All SP notifications route directly to Mason. Pros: cleanest technically — Mason gets the emails at an address he already owns. Cons: changes SP account settings — SP may require an email-verification click to confirm the change. Also breaks if anyone else at OPP needs SP notifications (probably no one). === FALLBACK — Manual forward on demand === If none of A/B/C are viable this week, Deepak can just watch contact@ and manually forward SP notification emails to allgoodanthony3@gmail.com whenever they arrive. Works but adds a human step every time — not sustainable at scale.
D-02Deepak0.25h← M-04
Configure scheduled Clients + Appointments exports to VHOS ingest email
▾
Once Mason confirms the download link format, set up two scheduled reports in SP: Clients report (Daily, CSV, delivered to sp-opp@ingest.verifiedhealthos.com) AND Appointments report (Daily, CSV, same email). Mason CAN also do this since he now has SP creds — assign to whoever moves first.
D-03Deepak0.5h← post Oct 15
POST-PILOT: rotate to dedicated 'VHOS Integration' service user
▾
Not blocking pilot. After the Oct 1 demo and 2 weeks of stable operation, migrate away from the shared contact@allgoodseo.com credential to a purpose-built 'VHOS Integration' team member in OPP's SP account with read-only access. Cleaner blast radius, easier to revoke, no shared login.
D-04Deepak0h
[OBSOLETE 2026-09-29] Deploy CTM DNI — Google Ads has native number-swap; subdomain LPs carry other attribution
▾
CTM provides an install snippet. Paste into GTM as a Custom HTML tag firing on All Pages. Test in GTM Preview mode before publishing.
D-05Deepak0h
[OBSOLETE 2026-09-29] Create 4 CTM number pools — Google Ads swap + subdomain per-LP tracked numbers replace this
▾
In CTM admin: Google Ads pool (utm_source=google, utm_medium=cpc), Google Organic pool (referrer google.com/search), Meta/FB pool (utm_source=facebook OR instagram), Direct/Other fallback.
D-06Deepak0.5h← D-05
Toggle CTM → GA4 native integration ON
▾
In CTM → Integrations → Google Analytics 4, connect OPP's GA4 property G-Z5G9RXCB62. Toggle: send call events with GA4 client_id stamped on them. This closes the loop between web sessions and phone calls.
D-07Deepak0.5h
Add Gravity Forms → GA4 conversion event trigger in GTM
▾
New GTM tag: trigger = form-submit event (gform_confirmation_loaded), tag = GA4 event 'form_submit' with parameters {form_id, page_path, form_type: 'appointment_request'}. Test with GA4 DebugView.
D-08Deepak0h
Access matrix — CONFIRMED (Anthony 2026-09-24 3:45 PM): Deepak has all needed access
▾
Anthony confirmed on Sep 24: Deepak has admin/operator access on CTM, GA4, Google Ads, Meta Business Manager, AND GTM for OPP. This means Justin only needs to attend the demo — no access-grants required from him. Ad-platform grants for Mason move to Deepak (see D-09, D-10, D-11). This task auto-completes.
M-01Mason1h
Postgres schema: opp_patients, opp_appointments, opp_calls_classified
▾
Prisma migration adding 3 tables. opp_patients (patient_id PK, phone_e164 indexed, email_lower indexed, first_appointment_date, last_updated_at). opp_appointments (appointment_id PK, patient_id FK, scheduled_date, service_date). opp_calls_classified (call_id PK, caller_phone_e164, call_datetime, source, campaign, landing_page, classification enum, ga4_client_id, matched_patient_id).
M-02Mason2h← M-01
CSV parser + E.164 phone normalizer
▾
Node.js CSV parser using csv-parse. Phone normalization using libphonenumber-js to E.164 format. Handles SP-specific column layout after M-04 confirms actual CSV shape.
M-03Mason1h
Mailgun inbound domain ingest.verifiedhealthos.com → POST endpoint
▾
Configure MX records on ingest.verifiedhealthos.com pointing at Mailgun. Route inbound mail matching sp-opp@* to POST https://app.verifiedhealthos.com/api/ingest/sp-export. HMAC signature verification.
M-19MasonBLOCKING0.5h← D-01
Trigger SP test export using stored creds — capture 'export ready' email
▾
Once Deepak completes D-01 (whichever path chosen), Mason runs this end-to-end: Playwright logs into simplepractice.com with contact@allgoodseo.com → Analytics → Reports → Clients report → Export. The 'Your export is ready' email arrives at whichever inbox D-01 routed it to. Mason reads via himalaya CLI, extracts the download link, hands to M-04 for shape classification.
M-04MasonBLOCKING0.5h← M-19
Inspect captured email → decide Shape A / B / C download strategy
▾
Open the captured email. Inspect the URL behind 'Download Report Now'. Signed URL with token/signature params → Shape A (2 hrs build). Naked ID URL requiring session → Shape B (needs Playwright login, 4 hrs). SSO redirect → Shape C (needs full auth, 6 hrs). Branches the rest of the build. Since 2FA is off, Shape B is now cheap.
M-05Mason3h← M-04
Build spDownloadFetcher + /api/ingest/sp-export route handler
▾
Handler verifies Mailgun HMAC signature → parses email body → extracts download link → calls fetcher (Shape A curl / Shape B/C Playwright) → parses CSV → UPSERTs into opp_patients + opp_appointments.
M-06Mason1h← M-01, M-07
Extend /api/ingest/ctm to write into opp_calls_classified + call matcher
▾
CTM webhook already shipped 2026-09-22 (per VHOS PRD.md line 121). Add: write call into opp_calls_classified table, invoke matcher engine, enrich with GA4 client_id session data.
M-07Mason2h← M-01
Matcher engine: classifyCall(callerPhone, callDate)
▾
Query opp_patients by phone_e164. Not found → NEW_PATIENT_INQUIRY. Found + first_appt < call_date → EXISTING_PATIENT (excluded from CPA). Found + first_appt >= call_date → NEW_PATIENT_CONVERTED (attributed).
M-08Mason1h
GCP service account for GA4 Data API access
▾
Create Google Cloud project (or reuse existing). Enable analyticsdata.googleapis.com. Generate service account, download JSON creds, store on VPS. Hand service account email to Deepak/Justin for GA4 property grant.
M-09Mason3h← M-08 + GA4 grant
GA4 attribution puller: getSessionsByClientId()
▾
Node.js function using google-analytics-data npm client. Given a client_id, returns full session history with source/medium/campaign/landing_page/timestamp. Caches for 60s.
M-10Mason3h← M-01, M-06, M-07
Wire /dashboard to live Postgres (currently mock data)
▾
Replace all hardcoded arrays in dashboard/page.tsx with Prisma queries. Preserve UI structure — only swap data source. Empty state when 0 rows.
M-11Mason1h← M-10
Empty-state UI for pre-data window
▾
If opp_patients has 0 rows OR opp_calls_classified has <5 rows, show 'Preview data — real numbers arrive after first SP sync completes' banner. Once live data exists, banner disappears.
M-12Mason4h← Google Ads access
Google Ads API: daily spend puller
▾
OAuth setup with OPP account. Function: getDailySpendByCampaign(customerId, dateRange). Handles rate limits. Stores in opp_ad_spend table.
M-13Mason3h← Meta BM access
Meta Marketing API: daily spend puller
▾
Meta Business Manager System User token setup. Function: getDailyMetaSpend(adAccountId, dateRange). Stores in opp_ad_spend table.
M-14Mason1h← M-12, M-13
Daily ad-spend cron on VPS
▾
Node script + LaunchAgent-style cron at 4:00 AM ET. Pulls yesterday's spend from Google Ads + Meta, UPSERTs into opp_ad_spend.
M-15Mason1h← M-03, M-05
Monitoring: alert if SP email doesn't arrive in 24 hrs
▾
LaunchAgent monitor. If no email received at sp-opp@ingest.verifiedhealthos.com within 24 hrs of expected time, POST to Mason's Telegram via existing gateway.
M-16Mason3h← Everything above
E2E test with 48 hrs of real data
▾
Cross-check 5 known calls → confirm correct classification. Cross-check 5 known ad spends → confirm CPA math matches. Fix any classification errors surfaced.
M-17Mason1h← M-16
Deploy + verify dashboard renders with real data
▾
Deploy to VPS. PM2 restart. Curl-verify /dashboard returns HTTP 200. Visual smoke test on mobile + desktop.
M-18Mason2h← M-17
Polish + edge cases + monitoring dashboard
▾
Handle: no-match calls (unknown numbers), duplicate patients (SP data quality), timezone edge cases (calls near midnight), rate-limit backoffs, retries.
A-01AnthonyBLOCKING0.25h
Approve this PRD + green-light spend for extra SP seat if needed
▾
Read PRD. Reply 'approved — go' or edit and go. Approve up to $40/mo additional SP seat cost if D-03 (dedicated service user) is required.
A-02AnthonyBLOCKING0.05h← A-01
Send Deepak the PRD URL — flag D-01 as the blocker
▾
Now that Mason has SP creds stored + Deepak's access matrix is confirmed, Mason runs all the ingest work himself. The ONLY thing Deepak needs is a link + one clear message: 'Here's the PRD, click your name to filter, D-01 (email routing) is BLOCKING everything else — pick a path and complete it today.' No test-export ask, no matrix questions, no wall of text. 60-second Telegram/message to Deepak with the PRD URL and that sentence.
A-03Anthony0.25h← A-01
Send Justin the 'heads up, no action needed yet' message
▾
Short note telling Justin: we're building the tracking system he asked for, we may need him to grant Mason access to Google Ads / Meta / GA4 later this week — Deepak will let him know which. Zero front-desk changes.
A-04Anthony0.1h
Confirm demo target: Thu Oct 1, 1:30 PM ET
▾
Verify the merged weekly OPP meeting time still holds. Justin said 'next Thursday, first, 1:30' in the transcript.
A-05Anthony0.1h
Approve any downstream infrastructure spend (Mailgun / fallback tools)
▾
Mailgun free tier likely covers this pilot (5,000 emails/mo free). If Shape B/C download fails and we need Kadoa/Browse AI fallback (~$100/mo), Anthony approves before Mason sets up.
M-20Mason3h
Build /api/ingest/gravity-form endpoint + opp_form_fills schema
▾
New endpoint for Gravity Forms webhook direct-post (bypasses CTM form-capture, which Deepak tried and hit against — CTM autodetect can't reliably map WordPress AJAX form fields). Endpoint: POST /api/ingest/gravity-form?facility=opp&form_id=X&secret=<token>. New Postgres table opp_form_fills(formEntryId PK, formId, name, phone, email, gaClientId, utmSource/Medium/Campaign, gclid, landingPageUrl, submittedAt, matchedPatientId). Idempotent on (facilityId, formEntryId). Extends matcher to join form-fill phone/email → opp_patients (same rules as call matcher). Dashboard 'Website form conversions' section flips from mocked to live.
D-13Deepak0.5h← M-20
Configure Gravity Forms Webhooks add-on on OPP forms 1 (site-wide) + 9 (/book-an-appointment/)
▾
After Mason ships M-20, configure the webhook on each form. WordPress Admin → Forms → Edit Form → Settings → Webhooks → Add New. URL: https://app.verifiedhealthos.com/api/ingest/gravity-form?facility=opp&form_id=<1 or 9>&secret=<MASON_TOKEN>. Method: POST. Format: JSON. Request Body: Select Fields. Add all form fields plus merge tags: {entry_id}, {form_id}, {embed_url}, {Source URL Parameter:utm_source}, {Source URL Parameter:utm_medium}, {Source URL Parameter:utm_campaign}, {Source URL Parameter:gclid}, {Source URL Parameter:_ga}. Save → submit test entry → verify green checkmark in Entries webhook log. Repeat for form 9.
D-09Cristian0.25h
Grant Mason access to OPP's Google Ads account (Anthony + Cristian)
▾
Anthony or Cristian: Google Ads → Tools & Settings → Access & security → Invite → Mason's email (allgoodanthony3@gmail.com) with Admin or Standard access. Also send Mason the customer ID (format XXX-XXX-XXXX). OPP lives inside AGM's Google Ads MCC — Anthony has manager access, Cristian handles day-to-day ad ops. Enables M-12 (daily ad-spend puller).
D-10Cristian0.25h
Add Mason as analyst on OPP's Meta Business Manager (Anthony + Cristian)
▾
Anthony or Cristian: Meta Business Manager → Business Settings → Users → People → Add → Mason's email → assign Analyst role on OPP's ad account. Send Mason the ad account ID. Meta ad management lives with AGM's ad-ops team, not Deepak. Enables M-13 (Meta ad-spend puller).
D-11Cristian0.25h← M-08
Grant GA4 service account Viewer access on property G-Z5G9RXCB62 (Anthony + Cristian)
▾
After Mason completes M-08 and provides the service account email (format vhos-attribution@<project>.iam.gserviceaccount.com): Anthony or Cristian → GA4 → Admin → Property Access Management → add that address as Viewer on OPP's GA4 property G-Z5G9RXCB62. GA4 sits with AGM's analytics/ad-ops team. Enables M-09 (GA4 attribution puller).
D-12DeepakBLOCKING0.5h
Configure webhook on OPP's OWN CTM account (not 363409 / SHC) to POST to VHOS
▾
Discovered 2026-09-29 09:37 EDT while stress-testing the pipeline: the CTM API credentials in our shared vault (Account ID 363409) belong to Orlando Treatment Solutions / Palm Coast / SHC — NOT Orlando Premier Psychiatry. So calls arriving at OPP's tracked numbers never reach VHOS unless OPP's own CTM account is configured to POST webhooks to Mason's endpoint. Questions for Deepak: (1) Does OPP have its own separate CTM account, or share the AGM/SHC master 363409? (2) Who has admin? (3) Can Deepak add the webhook or does Justin's team need to? Webhook config: URL https://app.verifiedhealthos.com/api/ingest/ctm?facility=opp, Method POST, Trigger '1 hour after call data is captured' (transcript included), Body type Log Data. Generate HMAC secret under Account Settings → API Integration and send to Mason.
J-04Justin0.5h
Attend Oct 1 1:30 PM demo + validate numbers
▾
Show up to the merged weekly meeting. Verify dashboard numbers match his gut within ±15%. Green-light continued build.
Day-by-day timeline
Today → demo Thu Oct 1
▾
DayWhat happens
Thu Sep 24 (today)PRD v1.2 shipped. Deepak picks a path for D-01 (email routing so Mason sees SP notifications). Mason has SP creds stored securely.
Fri Sep 25 AMDeepak completes D-01 (path A/B/C). Mason triggers SP test export using stored creds (M-19), reads the 'ready' email via himalaya, inspects link → decides Shape (M-04).
Fri Sep 25Mason ships M-01, M-02, M-03, M-05, M-07, M-08, M-10 (~10h). Deepak works D-09, D-10, D-11 (ad-platform access grants for Mason) in parallel.
Sat Sep 26Mason completes M-06, M-09, M-11. Deepak starts D-02.
Sun Sep 27SP ingest live. GA4 puller (M-09). Deepak finishes D-06, D-07. Ad-spend APIs start (M-12, M-13).
Mon Sep 29E2E test with real 24-hr data (M-16). Fix issues. First real numbers on dashboard.
Tue Sep 30Polish + ad-spend cron (M-14) + alerting (M-15).
Wed Oct 1 AMFinal dry-run. Anthony reviews dashboard.
Thu Oct 1, 1:30 PM ET🎯 Live demo with real OPP data.
Risks + mitigations
9 named risks worth knowing before Thursday
▾
RiskPIMitigation
SP download link is Shape B/C (auth needed)MedLowPlaywright login well-understood; +4h build
SP CSV missing first_appointment_dateMedLowDeepak scheduling both reports covers this
Deepak lacks Google Ads / Meta adminMedMedAd spend manually entered for demo; automate wk 2
GTM edits break existing trackingLowHighTest in GTM Preview + GA DebugView before publishing
SP UI changes → Playwright breaksLow (pilot)MedAlert catches within 24h; ~30 min fix
Phone match rate low (many callers not in SP)MedLowThat's the correct behavior — they're new inquiries
Justin's estimates wildly off (300/wk, 80% existing)HighLowDashboard shows real numbers; narrative adjusts
First 3 days data sparseCertainLowEmpty-state UI (M-11); demo uses 'as of yesterday'
HIPAA concerns (PHI over Mailgun)MedMedSign Mailgun BAA before go-live; encrypt at rest
Reference docs + links
Every external system referenced in this PRD
▾
Verified this session
Facts Mason confirmed via live tool calls, not memory
▾

OPP website (curl of orlandopremierpsychiatry.com): GA4 property G-Z5G9RXCB62, GTM container GTM-W7VGDGLP, Gravity Forms IDs 1 (site-wide) and 9 (/book-an-appointment/), static phone (407) 565-3546. CTM DNI intentionally NOT deployed per 2026-09-29 architecture — Google Ads native swap + per-source subdomain LP tracked numbers replace it.

VHOS state (SSH + curl): VPS 144.202.33.136 uptime 9d, PM2 vhos-app online, /dashboard returns HTTP 200 in ~200ms.

SP scheduled reports (SP support docs): Delivery is a LINK not an attachment. Email subject "Your export is ready to download". Link expires ~24-36 hrs. Available formats: CSV or XLSX.

HIPAA session enforcement (Compliancy Group + AccountableHQ): §164.312(a)(2)(iii) auto-logoff. EHR best practice 10-15 min inactivity — session cookies do NOT persist for months.

SP credentials (received 2026-09-24 15:07 from Anthony): Account email contact@allgoodseo.com, no 2FA. Stored on VPS at /opt/vhos-app/secrets/opp-sp-creds.env · dir 700 · file 600 · root-only. Never committed, never echoed.

Mail access (himalaya IMAP test): anthony@allgoodseo.com fully readable via himalaya envelope list --account allgoodseo. contact@allgoodseo.com is a separate mailbox — reachable only after Deepak completes D-01 (picks one of the three routing paths: auto-forward, app password, or SP-side email change).

Housekeeping owed: (1) Anthony deletes the Telegram message with the plaintext SP creds. (2) Post-pilot, rotate to dedicated service user (task D-03).