- 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>
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>
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>
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>
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>
- 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>
- 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>