The Medical Appointment API provides a robust backend system for patients, doctors, and administrators to manage appointments, medical records, and doctor availability. Built with Node.js, Express.js, and PostgreSQL, it ensures secure JWT-based authentication, role-based access control, and integrates AI-powered department classification via AWS Bedrock.
- 🔐 Authentication & Authorization: JWT-based login, registration, password change, and role-based access (patient, doctor, admin).
- 📆 Appointment Scheduling: 30-minute time slots, booking, cancellation, and calendar management.
- 🏥 Medical Records: CRUD operations with full audit trail via history logs.
- 🩺 Doctor Availability: Weekly scheduling with customizable blocks.
- 💼 Services Management: CRUD for medical services and fee management.
- 🤖 AI Classification: AWS Bedrock integration to classify patient issues into appropriate departments.
- 📷 Image Upload: Profile photo handling using Sharp.
- 📚 API Documentation: Swagger UI available at
/api-docs
.
- Backend: Node.js, Express.js 5.1.0
- Database: PostgreSQL with
pg
driver - Auth: JWT (
jsonwebtoken
), bcrypt - AI: AWS SDK for Bedrock
- Validation: Joi
- Logging: Winston, Morgan
- File Processing: Sharp
- Documentation: Swagger UI (OpenAPI 3.0.1)
- Environment: dotenv
- Node.js v16+
- PostgreSQL v12+
- AWS account (for Bedrock AI)
-
Clone the repository:
git clone https://github.com/kallash04/swe-medical-backend.git cd swe-medical-backend
-
Install dependencies:
npm install
Create a .env
file in the root directory and populate it with the following variables:
PGUSER=
PGHOST=
PGDATABASE=
PGPASSWORD=
PGPORT=
PG_MAX_CLIENTS=
PG_IDLE_TIMEOUT=
PG_CONN_TIMEOUT=
JWT_SECRET=
SALT_ROUNDS=
AWS_REGION=
PORT=3000
npm start
The server will start on http://localhost:3000
(or your configured PORT
).
Variable | Description |
---|---|
PGUSER |
PostgreSQL username |
PGHOST |
PostgreSQL host |
PGDATABASE |
PostgreSQL database name |
PGPASSWORD |
PostgreSQL password |
PGPORT |
PostgreSQL port |
PG_MAX_CLIENTS |
Max DB connections for pool |
PG_IDLE_TIMEOUT |
Pool idle timeout (ms) |
PG_CONN_TIMEOUT |
Connection timeout (ms) |
JWT_SECRET |
Secret key for JWT signing |
SALT_ROUNDS |
bcrypt salt rounds |
AWS_REGION |
AWS region for Bedrock |
PORT |
Express server port |
POST /register
– User registrationPOST /login
– User loginPOST /change-password
– Update password
GET /profile
– Fetch user profilePUT /profile
– Update user profileGET /doctors
– List available doctors
POST /
– Book an appointmentGET /
– List user appointmentsPUT /:id
– Update appointment statusDELETE /:id
– Cancel appointment
GET /patients
– List assigned patientsGET /records/:patientId
– Fetch patient medical recordsPUT /availability
– Set weekly availability
GET /users
– List all usersPOST /doctors
– Create doctor accountDELETE /users/:id
– Remove user
GET /
– List departmentsPOST /
– Create departmentPUT /:id
– Update departmentDELETE /:id
– Delete department
GET /:doctorId
– Get doctor availabilityPOST /:doctorId
– Set availability blocks
- CRUD operations for medical services and fees
- Audit trail endpoints for record changes
POST /classify
– Classify issue description into department
- Controllers: Handle HTTP requests and responses
- Services: Encapsulate business logic
- Models: Database schemas and queries
- Middleware: Authentication, authorization, validation, error handling
- Utilities: Helper functions, logger setup
- Docs: Swagger specification (
/swagger.json
)
Utilizes AWS Bedrock to analyze patient issue descriptions and automatically assign the correct medical department, improving triage efficiency.