Reports - All Locations (API)

Treatment Tracking

Path/treatment-tracking
Statuslive
Drill-down pages—
Pop-ups—
Tabs—
API routes/api/data/offices
/api/treatment-tracking

What's on the page

  • Filters (all kept in the page link, so a refresh or a shared link keeps them):
    • Office Location — one office or all;
    • Date Range — Last 7 Days (default), Last 30 Days, This Month, Last Month, Year to Date, All Time, Custom Range (From / To date pickers);
    • Patient — search by name or Dentrix patient id;
    • Provider, Treatment, Category, Status — lists built from the rows in the chosen dates and office;
    • Financing — Self-Pay or Insurance;
    • Started Today button — only procedures presented today (Pacific) and started;
    • Clear — back to the defaults.
  • Cards: Total Records, Total Diagnosed, Total Accepted, Total Collected (for all rows the filters match).
  • Table columns: Patient Name (stays in view when scrolling sideways), Date Presented, Patient ID, Provider, Treatment Type, Diagnosed, Accepted, Started (Y/N), Collected, Declined (Y/N), Reason for Decline, Financing Option, Follow-Up Status, Patient Record (View link).
  • Links:
    • Patient Record → View opens the patient's chart in Dentrix Ascend (new tab; staff sign in there). Before 26 Nov it went to /patients/<id>, a Pulse page that does not exist (Not Found).
  • Sort: click any column header except Reason for Decline and Patient Record. Default: newest Date Presented first. Text columns start A–Z, numbers and dates start biggest/newest.
  • Paging: 25 / 50 (default) / 100 / 250 / 1000 rows per page; "Showing x–y of total".
  • Export CSV: every row the filters match (up to 25,000), in the order on screen, with ADA code, bill to insurance, insurance portion, patient portion and write-off as extra columns.
  • Dentrix data as of: when the procedures copy last ran.
  • Opening on Last 7 Days with nothing in it widens once to the first range that has data, and says so.

Business rules

Data comes from: Dentrix API, read from our copy. The nightly procedures sync copies every Dentrix patient procedure into dh_patient_procedures; claim money comes from dh_claim_procedures (claims sync). The page reads the treatment_rows view over those tables — no Dentrix calls when the page opens. Names are looked up by id (patient, provider, office).

How the numbers are worked out (one row = one Dentrix procedure):

  • Date presented: the procedure's service date.
  • Diagnosed: the procedure fee in Dentrix.
  • Accepted: same as Diagnosed, except declined/rejected procedures count 0.
  • Started: Yes when the procedure is complete, existing or in progress.
  • Collected:
    • not billed to insurance and started → the full fee;
    • the claim is paid → the insurance amount;
    • started, no paid insurance money → the patient's part;
    • otherwise 0.
  • Insurance / Patient portion / Write-off: from the active claim line furthest down the payer chain (newest first).
  • Financing: "Insurance" when billed to insurance, otherwise "Self-Pay".
  • Follow-up status: Complete (done/existing), Scheduled (treatment plan), Referred, In Progress, Pending Follow-Up (declined), else Pending.
  • Cards: totals of Diagnosed, Accepted and Collected for everything the filters match (not just the page shown).
  • Started Today: date presented is today (Pacific time) and Started = Yes.
  • Treatment type: the Dentrix description, else the ADA code, else "Other (<status>)".
  • Reason for decline: "Patient declined" for declined procedures, else "—".

Database tables & columns

TableColumns used
treatment_rows viewaccepted, ada_code, bill_to_insurance, category, collected, date_presented, declined_yn, diagnosed, financing_option, follow_up_status, insurance_portion, location_id, patient_id, patient_portion, procedure_id, provider_id, reason_for_decline, started_yn, status, treatment_type, write_off
dentrix_officesdentrix_id, name
dh_claim_proceduresread through the view treatment_rows
dh_patient_proceduresread through the view treatment_rows
dh_patientsdentrix_id, first_name, first_name_encrypted, last_name, last_name_encrypted
dh_providersdentrix_id, first_name, last_name
dh_sync_stateid, last_synced_at

File structure

Its own files

  • apps/
    • web/
      • src/
        • features/
          • treatment-tracking/
            • pages/
              • TreatmentTrackingPage.tsx
            • api.ts
            • index.ts
    • worker/
      • src/
        • features/
          • treatment-tracking/
            • __tests__/
              • service.test.ts
            • index.ts
            • queries.ts
            • routes.ts
            • service.ts

Shared code it uses (followed through its imports and the helpers its API calls; sign-in/access plumbing and UI primitives left out)

  • apps/
    • web/
      • src/
        • components/
          • data/
            • DataTable.tsx
          • forms/
            • DatePicker.tsx
          • reports/
            • DataAsOf.tsx
            • DentrixSourceNote.tsx
            • FilterSelect.tsx
            • HowItWorksNote.tsx
            • ReportDateRange.tsx
            • ReportHeader.tsx
            • sortable-grid.tsx
          • TablePagination.tsx
        • hooks/
          • useApi.ts
          • usePagedList.ts
        • lib/
          • csv.ts
          • date-presets.ts
          • dentrix.ts
        • services/
          • api.ts
    • worker/
      • src/
        • db/
          • index.ts
        • lib/
          • dates.ts
          • list-query.ts
          • text-sort.ts
        • routes/
          • data.ts
        • services/
          • phi-read-dh.ts
          • phi-read.ts
          • treatment-rows.ts
        • utils/
          • crypto.ts
          • office.ts
          • timestamps.ts