Commit Graph

11 Commits

Author SHA1 Message Date
ff
d4b9c1b889 feat: save claim attachments to cloud storage and documents page
- Claim file uploads (chatbot or manual) now save to both the Cloud
  Storage patient folder and the Documents page via new
  POST /api/claims/upload-to-cloud endpoint
- MH submit flow now calls uploadAttachmentsToLocalFolder (same as
  DDMA/United/Tufts) so chatbot-attached X-rays are persisted
- Removed old /upload-attachments disk route and attachmentDiskStorage
  multer config; deleted uploads/patients/ folder
- uploadAttachmentsToLocalFolder now points to /upload-to-cloud and
  sends patientId so the backend can create the patient folder

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-11 00:30:32 -04:00
ff
a8ec1a21c0 feat: include uploads folder in network sync (all three subfolders)
Daily sync and Sync Now both pull database + uploads in one operation.
PC1 streams uploads/ as a zip via GET /network-backup-files (archiver).
PC2 clears cloud-storage, patients, and patient-documents then extracts
the fresh copy before resolving. Timeout extended to 5 min for large files.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-09 10:10:46 -04:00
ff
f5f3768108 feat: add Network Backup section to Database Management
PC2 can now automatically pull and restore a fresh copy of PC1's database
on a daily schedule. Config and API key are stored in local JSON files so
they survive database restores.

- New networkSyncConfigService: file-based config (network-backup-key.json,
  network-sync-config.json) that persists through DB restores
- New networkSyncService: streams live pg_dump from source PC over HTTP and
  pipes into psql, then reconnects Prisma and applies missing migrations
- 6 new endpoints: get/regenerate API key, serve backup stream (key-auth
  only), get/save sync config, trigger immediate sync
- Hourly cron job that fires only when current hour matches configured syncHour
- NetworkBackupManager component: shows this machine's key (show/copy/regen)
  and receiver config (enable toggle, hour picker 0-23, source URL + key,
  Save + Sync Now, last sync status)
- README setup guide for both PCs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-09 00:15:42 -04:00
ff
8cab823d60 feat: share patients across all users
Removed per-user patient filtering so all staff accounts see the same
patient pool. Previously each user only saw patients they created.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 23:04:26 -04:00
ff
b148c0de30 fix: apply missing migrations directly after DB restore
Replace the prisma migrate deploy subprocess with a custom
applyMissingMigrations() that reads each migration SQL file and runs it
via prisma.$executeRawUnsafe. This avoids the Prisma CLI aborting when
the restored _prisma_migrations table contains orphaned entries (migration
names that no longer have a corresponding file in the migrations folder).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 22:36:35 -04:00
ff
5508a90d28 fix: auto-migrate after DB restore and force re-login
- After importing a backup, run prisma migrate deploy so any schema
  migrations the backup is missing are applied automatically. This
  prevents pages from failing due to missing tables/columns when the
  backup was taken on an older version of the app.
- Force logout and redirect to login after a successful restore so the
  JWT is refreshed against the restored database (prevents userId
  mismatch causing user-scoped queries to return empty results).
- Fix getTotalPatientCount() in /status route to pass userId so it
  counts only the current user's patients instead of all patients.
- Add prisma.$connect() after $disconnect() to ensure a clean reconnect.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 22:31:12 -04:00
Gitead
79e20b693d feat: improve backup management, settings UI, and Twilio webhooks
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-04 00:52:42 -04:00
ff
f415100cdb fix: fix db restore not applying and auto-create USB backup folder
- Reset public schema before psql restore so existing tables don't
  block CREATE TABLE statements (pg_dump without --clean has no DROPs)
- Disconnect Prisma connection pool after restore so next request
  gets fresh connections against the restored data
- Auto-create the USB backup subfolder if it doesn't exist instead
  of failing; only fail if the destination drive itself is missing

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-13 23:12:41 -04:00
ff
66a3d271f1 feat: change backup format to plain SQL, admin-only cron, backup now button, import restore UI 2026-04-11 23:37:43 -04:00
ff
4025ca45e0 feat: database management - auto/USB backup toggles, folder browser, cron jobs 2026-04-11 00:32:39 -04:00
5d77e207c9 initial commit 2026-04-04 22:13:55 -04:00