This project is a backend service for managing patients, doctors, and administrative workflows for an orthodontist clinic. It includes user authentication, patient record management, and appointment scheduling, with role-based access control for different user types.
- Role-based Authentication:
- Admin, Doctor, and Patient roles.
- Secure access using JWT.
- Patient Record Management:
- Doctors can manage records of their assigned patients.
- Patients can view their own records.
- Admins have full access.
- Appointment Scheduling:
- Patients can book appointments with doctors.
- Doctors can manage their assigned appointments.
- Admins can view and manage all appointments.
- Node.js with TypeScript
- TypeORM
- SQLite
- Express.js
- JWT for authentication
- Postman for API testing
- Node.js (>=16.x)
- npm or yarn
- Git
git clone https://github.com/luharinos/patient-management-system.git
cd patient-management-systemnpm installCreate a .env file in the root directory and add the following variables:
PORT=3000
DATABASE="database.sqlite"
JWT_SECRET="myappsecret"The project uses SQLite as the database.
- Run the TypeORM migrations to set up the database schema:
npm run typeorm:syncTo start the development server:
npm run start:devFor production:
npm run build
npm start| Method | Endpoint | Description |
|---|---|---|
| POST | /user/register |
Register a new user |
| POST | /user/login |
Login and get a JWT token |
| Method | Endpoint | Role | Description |
|---|---|---|---|
| GET | /patients |
Admin/Doctor | Get a patient's record |
| POST | /patients |
Admin/Doctor | Add a new patient record |
| PUT | /patients/:id |
Admin/Doctor | Update a patient record |
| DELETE | /patients/:id |
Admin | Delete a patient record |
| Method | Endpoint | Role | Description |
|---|---|---|---|
| GET | /appointments |
All | View all/assigned appointments |
| POST | /appointments |
Admin/Patient | Book an appointment |
| PUT | /appointments/:id |
All | Update an appointment |
| DELETE | /appointments/:id |
Admin/Patient | Cancel an appointment |
- ESLint and Prettier are configured for linting and formatting.
-
To check linting:
npm run lint
-
To format code:
npm run format
-
- Use Postman to test the API endpoints.
- A sample Postman collection is included in the project for convenience.
src/
├── entities/ # TypeORM entities
├── controllers/ # API controllers
├── middleware/ # Middleware for authentication and validation
├── services/ # Business logic and database queries
├── routes/ # Express routes
├── utils/ # Utility functions
└── index.ts # Entry point
-
Fork the repository.
-
Create a new branch for your feature:
git checkout -b feature-name
-
Commit your changes:
git commit -m "Add feature-name" -
Push to your branch:
git push origin feature-name
-
Create a pull request.
This project is licensed under the MIT License.