How rubyproducti9n/ehr-system works
This is a multi-hospital EHR with two main workflows: authenticated staff manage clinical and operational records, while document-analysis tools extract structured data for review. The frontend uses Firebase Auth/Realtime Database, feature hooks, and shared session state; a local Python service provides OCR and extraction endpoints, with Gemini also available through Next.js routes. The graph follows documented capabilities and indexed references; unsampled UI and service wiring is represented conservatively, so some relationships are omitted.
Main entry points: server.py Extraction Server · useSearch.ts Search Aggregator · useAuth.ts Auth Session Hook · patientService.ts Patient Service
Components 34
Identity and Access
- Login and Registration
src/app/(auth) - Auth Session Hook
src/hooks/useAuth.ts - Authentication Service
src/lib/services/authService.ts - Firebase Auth
Clinical Operations
- Dashboard
src/app/(dashboard)/page.tsx - Patient Records
src/app/(dashboard)/patients/page.tsx - Patient Profile
src/app/(dashboard)/patients/[id]/page.tsx - Patient Data Hook
src/hooks/usePatients.ts - Patient Service
src/lib/services/patientService.ts - ADT Service
src/lib/services/adtService.ts - Provider Directory
src/app/(dashboard)/providers/page.tsx - Provider Service
src/lib/services/providerService.ts - Facility Directory
src/app/(dashboard)/facilities/page.tsx - Facility Service
src/lib/services/facilityService.ts - Appointment Scheduling
src/app/(dashboard)/scheduling/page.tsx - Clinical Subtabs
src/components/patients/tabs - Global Search
src/components/search/GlobalSearch.tsx - Search Aggregator
src/hooks/useSearch.ts
Application Data
- Session and App State
src/store/useAppStore.ts - Firebase Client
src/lib/firebase.ts - Realtime Database
Document Intelligence
- Document Analysis
src/app/(dashboard)/analyse/page.tsx - Extraction Review
src/components/dev/ReviewSummaryBar.tsx - Gemini API Routes
src/app/api/dev/gemini/extract/route.ts - Gemini Integration
src/lib/gemini.ts - Local LLM Route
src/app/api/dev/llm/route.ts - Extraction Server
backend/server.py - OCR Preprocessing
backend/ocr_engine.py - Backend Gemini OCR
backend/ocr_gemini.py - Extraction Prompts
backend/prompts.py - Output Validation
backend/validator.py
Administration
- Developer Console
src/app/(dashboard)/console/page.tsx - Developer Tools
src/app/(dashboard)/dev
Other components
- Hospital Staff
Connections 35
- Hospital Staff → Login and Registration: signs in
README.md - Login and Registration → Authentication Service: authenticates
- Authentication Service → Firebase Auth: creates session
src/lib/services/authService.ts - Auth Session Hook → Firebase Auth: observes session
src/hooks/useAuth.ts - Auth Session Hook → Session and App State: updates session
src/hooks/useAuth.ts - Auth Session Hook → Realtime Database: loads user profile
src/hooks/useAuth.ts - Firebase Client → Realtime Database: initializes client
src/lib/firebase.ts - Hospital Staff → Dashboard: views KPIs
README.md - Hospital Staff → Patient Records: manages patients
README.md - Patient Records → Patient Data Hook: loads patient data
- Patient Data Hook → Patient Service: delegates to
src/hooks/usePatients.ts - Patient Service → Firebase Client: uses client
- Patient Service → Realtime Database: reads and writes
- Patient Profile → Clinical Subtabs: presents subtabs
README.md - Clinical Subtabs → ADT Service: tracks ADT events
- Hospital Staff → Provider Directory: manages providers
README.md - Provider Directory → Provider Service: uses provider data
- Hospital Staff → Facility Directory: manages facilities
README.md - Facility Directory → Facility Service: uses facility data
- Hospital Staff → Appointment Scheduling: schedules visits
README.md - Global Search → Search Aggregator: gets matches
src/components/search/GlobalSearch.tsx - Search Aggregator → Patient Data Hook: searches patients
src/hooks/useSearch.ts - Search Aggregator → Provider Service: searches providers
- Search Aggregator → Facility Service: searches facilities
- Global Search → Session and App State: reads search state
src/components/search/GlobalSearch.tsx - Hospital Staff → Document Analysis: analyzes documents
README.md - Document Analysis → Extraction Review: reviews extraction
- Gemini API Routes → Gemini Integration: requests extraction
src/app/api/dev/gemini/extract/route.ts - Local LLM Route → Extraction Server: forwards extraction
src/app/api/dev/llm/route.ts - Extraction Server → OCR Preprocessing: processes OCR
backend/server.py - Extraction Server → Backend Gemini OCR: runs Gemini OCR
backend/server.py - Extraction Server → Extraction Prompts: uses prompts
backend/server.py - Extraction Server → Output Validation: validates output
backend/server.py - Hospital Staff → Developer Console: administers platform
README.md - Hospital Staff → Developer Tools: uses developer tools