π₯ Hospital Queue Reservation System
A web-based hospital queue reservation system that allows patients to search for doctors, make reservations, and receive digital tickets with QR codes. Features a complete FHIR-based patient health record management system.
β
Register & Login with JWT authentication
β
Patient Dashboard with health summary & hospital information
β
Doctor Search by name/specialization
β
Doctor Detail with practice schedule
β
Online Reservation with schedule validation
β
Digital Ticket with QR code
β
Status Monitoring for real-time reservation tracking
β
Admin Dashboard for hospital staff
β
Admin Reservation Detail with full information
β
FHIR-based Patient Health Records (Conditions, Observations, Medications, Allergies)
β
Lab Results with interpretation badges (Normal, High, Low, Critical)
β
Prescriptions with dosage, frequency, and dispensing info
β
Medical Records with diagnosis history and severity tracking
β
Allergy Management with criticality levels and reaction details
Layer
Technology
Frontend
Next.js 14 (App Router) + Tailwind CSS + Zustand
Backend
Go (Fiber framework)
Database
PostgreSQL 15
Container
Docker + Docker Compose
Auth
JWT
Health Standard
FHIR (Fast Healthcare Interoperability Resources)
hospital-reservation/
βββ backend/ # Golang Fiber Backend
β βββ cmd/server/ # Entry point
β βββ internal/
β β βββ config/ # Configuration
β β βββ database/ # Database connection
β β βββ handlers/ # HTTP handlers
β β βββ middleware/ # JWT middleware
β β βββ models/ # Data models (FHIR + Reservation)
β β βββ repository/ # Database queries
β β βββ services/ # Business logic
β βββ migrations/ # SQL migrations
β βββ scripts/ # Utility scripts
β βββ Dockerfile
β
βββ frontend/ # Next.js Frontend
β βββ app/ # App Router pages
β β βββ patient/ # Patient pages
β β β βββ dashboard/ # Health summary dashboard
β β β βββ appointments/ # Reservation list with status filter
β β β βββ lab-results/ # Lab results with category filter
β β β βββ prescriptions/ # Medication prescriptions
β β β βββ records/ # Medical records / conditions
β β β βββ allergies/ # Allergy data
β β β βββ profile/ # User profile management
β β βββ admin/ # Admin pages
β β βββ doctors/ # Doctor listing & detail
β βββ components/ # React components
β β βββ patient/ # Patient-specific components
β βββ store/ # Zustand stores
β βββ lib/ # API utilities (axios client)
β βββ Dockerfile
β
βββ docs/ # Documentation
βββ design-system/ # Design system assets
βββ docker-compose.yml # Docker Compose
βββ tests/ # Test files
βββ README.md # This file
βββ .env.example # Environment template
Option 1: Docker (Recommended)
# Clone repository
git clone < repository-url>
cd hospital-reservation
# Start all services
docker-compose up -d
# Or use the run script (Windows)
run.bat
# Create database
psql -U postgres -c " CREATE DATABASE hospital_db;"
psql -U postgres -d hospital_db -f backend/scripts/init_db.sql
psql -U postgres -d hospital_db -f backend/migrations/001_init.sql
psql -U postgres -d hospital_db -f backend/migrations/002_fhir_tables.sql
cd backend
go mod download
go run cmd/server/main.go
cd frontend
npm install
npm run dev
Method
Endpoint
Description
POST
/api/auth/register
Register new patient
POST
/api/auth/login
Login, return JWT token
GET
/api/auth/me
Get current user profile
POST
/api/auth/forgot-password
Request password reset
POST
/api/auth/reset-password
Reset password with token
Method
Endpoint
Description
GET
/api/hospital/info
Get hospital general information
Method
Endpoint
Description
GET
/api/doctors
List all doctors (+ query: ?search=&specialization=)
GET
/api/doctors/:id
Doctor detail with schedules
GET
/api/doctors/:id/schedules
Doctor schedules by date
GET
/api/doctors/specializations
List all specializations
Method
Endpoint
Description
POST
/api/reservations
Create new reservation
GET
/api/reservations/me
Patient's reservation history
GET
/api/reservations/:code
Get ticket by queue_code
PATCH
/api/reservations/:code/status
Update status (admin)
FHIR Patient Health Records
Method
Endpoint
Description
GET
/api/fhir/me
Get patient's full health summary
GET
/api/fhir/conditions
Get patient's conditions/diagnoses
POST
/api/fhir/conditions
Create new condition
GET
/api/fhir/observations
Get observations (+ query: ?category=laboratory|vital-signs|imaging)
GET
/api/fhir/observations/:category
Get observations by category
POST
/api/fhir/observations
Create new observation
GET
/api/fhir/medications
Get medication requests/prescriptions
POST
/api/fhir/medications
Create new medication request
GET
/api/fhir/allergies
Get allergy intolerances
POST
/api/fhir/allergies
Create new allergy record
GET
/api/fhir/Patient/:id
Get patient by ID (FHIR standard)
PUT
/api/fhir/Patient/:id
Update patient (FHIR standard)
Method
Endpoint
Description
GET
/api/admin/stats
Dashboard statistics
GET
/api/admin/reservations
List all reservations (filterable)
GET
/api/admin/reservations/:id
Reservation detail
GET
/api/admin/doctors
List all doctors
PUT
/api/admin/doctors/:id
Update doctor
DELETE
/api/admin/doctors/:id
Delete doctor
POST
/api/admin/doctors/:id/schedules
Add doctor schedule
PUT
/api/admin/schedules/:id
Update schedule
DELETE
/api/admin/schedules/:id
Delete schedule
GET
/api/admin/patients
List all patients
GET
/api/admin/patients/:id
Patient detail
PUT
/api/admin/patients/:id
Update patient
POST
/api/admin/patients/:id/deactivate
Deactivate patient
GET
/api/admin/patients/:id/ehr
Get full EHR for patient
POST
/api/admin/patients/:id/conditions
Create condition for patient
POST
/api/admin/patients/:id/observations
Create observation for patient
POST
/api/admin/patients/:id/medications
Create medication for patient
POST
/api/admin/patients/:id/allergies
Create allergy for patient
PATCH
/api/admin/medications/:id/status
Update medication status
PATCH
/api/admin/allergies/:id/status
Update allergy status
Format: [DOCTOR-CODE][DATE][NUMBER]
Example: DR01-100524-007
DR01 β Doctor code (2 digits)
100524 β Reservation date (DDMMYY)
007 β Queue number (3 digits)
π€ Default Test Accounts
Access: http://localhost:3000/admin/login
π‘ Patients can register directly through the UI at /register
users β Patient and doctor data
doctors β Doctor profiles
schedules β Doctor practice schedules
reservations β Reservation data with queue code
hospital_info β Hospital information
password_resets β Password reset tokens
fhir_patients β FHIR patient extension (links to users)
fhir_conditions β Diagnosis/conditions (ICD-10 coded)
fhir_observations β Lab results, vitals, imaging (LOINC coded)
fhir_medication_requests β Prescriptions and medication orders
fhir_allergies β Allergy and intolerance records
fhir_audit_log β FHIR resource audit trail
users (1) ββββββββββ< (N) reservations
β β
β βΌ
β doctors (1) ββββ< schedules
β
ββββ> fhir_patients (1) ββββ< fhir_conditions
βββββ< fhir_observations
βββββ< fhir_medication_requests
βββββ< fhir_allergies
π¨ Frontend Architecture
All patient pages follow a consistent pattern:
Page
Route
Description
Dashboard
/patient/dashboard
Health summary with counts
Appointments
/patient/appointments
Reservation list with status filter (Semua, Menunggu, Dipanggil, Selesai, Dibatalkan)
Lab Results
/patient/lab-results
Observations with category filter (Semua, Laboratory, Vital Signs, Imaging)
Prescriptions
/patient/prescriptions
Medication requests with status badges
Records
/patient/records
Medical conditions/diagnoses
Allergies
/patient/allergies
Allergy data with criticality levels
Profile
/patient/profile
Account & health info management
Loading state : Skeleton pulse animation in card container
Error state : Red error message in centered card
Empty state : Gray icon + contextual message (e.g., "Belum ada hasil laboratorium")
Data list : White card with divide-y borders, px-6 py-4 per item
Status badges : bg-<color>-100 text-<color>-800 with rounded-full pills
Filter buttons : Teal active state (bg-teal-600), gray inactive with hover
CTA buttons : Teal primary (bg-teal-600 hover:bg-teal-700)
All patient pages use consistent fetch pattern:
// 1. Set loading + clear error
setLoading ( true ) ;
setError ( null ) ;
// 2. Fetch data
const response = await api . getData ( ) ;
const data = response ?. data ;
// 3. Handle response
if ( Array . isArray ( data ) && data . length > 0 ) {
setData ( data ) ; // Show data list
} else {
setData ( [ ] ) ; // Show empty state (no error)
}
// 4. Handle error
catch ( err ) {
setError ( 'Gagal memuat...' ) ; // Show error state
}
cd backend
# Run
go run cmd/server/main.go
# Build
go build -o server ./cmd/server
# Test
go test ./...
cd frontend
# Development
npm run dev
# Build
npm run build
# Lint
npm run lint
# Connect to PostgreSQL
psql -U hospital_user -d hospital_db
# Run migrations
psql -U hospital_user -d hospital_db -f backend/migrations/001_init.sql
psql -U hospital_user -d hospital_db -f backend/migrations/002_fhir_tables.sql
# Check Docker status
docker info
# View logs
docker-compose logs -f
# Restart services
docker-compose restart
# Clean rebuild
docker-compose down -v
docker-compose up --build -d
Port already in use : Change port mapping in docker-compose.yml
Database connection failed : Ensure PostgreSQL is running and credentials are correct
Frontend can't connect to API : Check NEXT_PUBLIC_API_URL environment variable
500 error on FHIR endpoints : Check backend logs β may be SQL scan type mismatch (DECIMAL β *float64)
MIT License - see LICENSE file for details.
Made with β€οΈ for Hospital Queue Reservation System