Skip to content

nvcy/hospital-appointment-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hospital Appointment Management System (GRH)

Front-end - Patient Application

Overview

This is a complete React.js frontend application for a Hospital Appointment Management System that allows patients to book, modify, and cancel appointments with doctors. The application includes email notifications for all patient actions.

Technology Stack

  • React 18 - Frontend framework with functional components and hooks
  • React Router DOM - Client-side routing
  • Tailwind CSS - Utility-first CSS framework
  • Axios - HTTP client for API requests
  • React Toastify - User notifications and alerts
  • Context API - Global state management

Project Structure

src/
├── components/
│   ├── common/
│   │   ├── Header.js          - Main navigation header
│   │   └── Footer.js          - Application footer
│   └── patient/
│       └── PatientLogin.js    - Patient login component
├── pages/
│   ├── Home.js                - Landing/home page
│   ├── Register.js            - Patient registration
│   ├── Login.js               - Patient login
│   ├── BookAppointment.js     - Appointment booking form
│   └── MyAppointments.js      - View & manage appointments
├── services/
│   ├── api.js                 - API client and endpoints
│   └── emailService.js        - Email notification service
├── contexts/
│   └── PatientContext.js      - Authentication context
├── App.js                     - Main application component
├── index.js                   - React entry point
└── index.css                  - Global styles

Features

1. Patient Registration

  • Register with patient ID, name, email, phone, address, date of birth, and gender
  • Validates patient ID uniqueness
  • Auto-login after successful registration
  • Sends registration confirmation email

2. Patient Authentication

  • Login using patient ID and email
  • Persistent session using localStorage
  • Protected routes for authenticated users
  • Logout functionality

3. Appointment Booking

  • Doctor selection with specialization display
  • Real-time date picker (future dates only, up to 30 days)
  • Available time slots display
  • Reason for visit (optional)
  • Email confirmation after booking

4. Appointment Management

  • View all patient appointments
  • Filter/sort by status (Planifié, Confirmé, Annulé, Terminé)
  • Modify upcoming appointments
  • Cancel appointments
  • Email notifications for updates/cancellations

5. Email Notifications

  • Mock email service (ready for backend integration)
  • Registration welcome email
  • Appointment confirmation emails
  • Appointment update notifications
  • Cancellation confirmations

Installation

  1. Install Dependencies
npm install
  1. Configure Backend URL The API base URL is set to http://localhost:8080/api in src/services/api.js Modify this if your backend is hosted elsewhere.

  2. Start Development Server

npm start

The application will open at http://localhost:3000

Build for Production

npm run build

Creates an optimized production build in the build folder.

API Endpoints Used

Patients

  • POST /api/patients - Register new patient
  • GET /api/patients/:patientId - Get patient details

Doctors

  • GET /api/doctors - Get all doctors
  • GET /api/doctors/:doctorId - Get doctor details

Appointments

  • GET /api/appointments/patient/:patientId - Get patient appointments
  • GET /api/appointments/availability/:doctorId/:date - Get available slots
  • POST /api/appointments - Create appointment
  • PUT /api/appointments/:id - Update appointment
  • PUT /api/appointments/:id/cancel - Cancel appointment

UI/UX Design

Color Scheme

  • Primary Color: Blue (#3b82f6)
  • Secondary: Dark Blue (#1e40af)
  • Light Background: #eff6ff
  • Professional Healthcare Theme

Responsive Design

  • Mobile-first approach
  • Tailwind CSS breakpoints
  • Works on all devices
  • WCAG accessibility compliant

Key Pages

  1. Home - Hero section with features and CTA
  2. Register - Patient registration form
  3. Login - Simple authentication form
  4. Book Appointment - Multi-step appointment booking
  5. My Appointments - Appointment management dashboard

User Flows

Registration Flow

  1. User clicks "Sign Up" on home page
  2. Fills registration form with personal details
  3. System validates form and patient ID uniqueness
  4. Registration successful → Auto-login → Redirect to appointments
  5. Confirmation email sent

Appointment Booking Flow

  1. Authenticated user navigates to "Book Appointment"
  2. Selects doctor from dropdown
  3. Chooses date (tomorrow to 30 days ahead)
  4. Selects available time slot
  5. Adds reason for visit (optional)
  6. Confirms booking → Email notification sent
  7. Redirected to appointments list

Appointment Management Flow

  1. User views all appointments on dashboard
  2. Can edit upcoming appointments (date, time, reason)
  3. Can cancel appointments
  4. Email notifications sent for any changes

Error Handling

  • Form validation with clear error messages
  • API error handling with user-friendly notifications
  • Network error handling with retry suggestions
  • Loading states for async operations
  • Input sanitization for security

State Management

  • PatientContext - Manages authentication state
  • localStorage - Persists login session
  • Local State - Component-level form and data state
  • No additional state management needed due to Context API

Security Features

  • Input validation and sanitization
  • Protected routes for authenticated pages
  • Secure localStorage for session persistence
  • HTTPS-ready API endpoints
  • XSS protection through React's built-in escaping

Notifications

  • React Toastify - Toast notifications
  • Success messages for user actions
  • Error messages with helpful guidance
  • Auto-dismiss after 4 seconds
  • Position: bottom-right

Performance Optimizations

  • Lazy loading of routes
  • Optimized re-renders with React hooks
  • Efficient API calls (no unnecessary requests)
  • CSS minification via Tailwind
  • Image optimization ready

Environment Variables

Create a .env file if needed:

REACT_APP_API_BASE_URL=http://localhost:8080/api

Troubleshooting

Issue: "Cannot connect to backend"

  • Ensure backend is running on http://localhost:8080
  • Check API base URL in src/services/api.js
  • Check browser console for CORS errors

Issue: "Appointments not loading"

  • Verify patient is logged in
  • Check if patient ID in localStorage matches backend
  • Ensure backend database has appointment data

Issue: "Emails not sending"

  • Email service is currently mocked
  • Check browser console for email logs
  • For production, integrate with email service (SendGrid, etc.)

Future Enhancements

  • Email service backend integration
  • Advanced appointment filtering/search
  • Appointment reminders and notifications
  • Patient profile management
  • Medical history tracking
  • Prescription management
  • Payment integration
  • Doctor ratings and reviews

Browser Support

  • Chrome (latest)
  • Firefox (latest)
  • Safari (latest)
  • Edge (latest)

License

This project is part of the Hospital Appointment Management System.

Support

Frontend - ADMIN Application

Getting Started with Create React App

This project was bootstrapped with Create React App.

Available Scripts

In the project directory, you can run:

npm start

Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.

npm test

Launches the test runner in the interactive watch mode.
See the section about running tests for more information.

npm run build

Builds the app for production to the build folder.
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.
Your app is ready to be deployed!

See the section about deployment for more information.

npm run eject

Note: this is a one-way operation. Once you eject, you can’t go back!

If you aren’t satisfied with the build tool and configuration choices, you can eject at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except eject will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use eject. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

Learn More

You can learn more in the Create React App documentation.

To learn React, check out the React documentation.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors