This Django REST Framework application aims to efficiently manage a hospital by providing functionalities such as scheduling appointments, managing patient records, and generating medical reports.
I built this project from scratch with the purpose of grasping a good understanding of the Django Rest Framework and its integration with technologies like Postgres, Celery, and RabbitMQ.
- CRUD operations for users: Doctors, assistants, and patients can be created, updated, and deleted.
- JWT Authentication: Secure authentication using JSON Web Tokens.
- Role-Based Access Control: Different levels of access based on user roles (e.g., doctors, patients, admins).
- Specific permission: For example, only an assigned doctor can update recommended treatment for a patient.
- Appointments system: A patient can make an appointment with a specific doctor, and the doctor and the patient receive an automated confirmation mail.
- Reports: designated enpoints for generating reports
- Django REST Framework: For API development, model management and APITestCases for unit and API testing.
- PostgreSQL: As the relational database for data storage
- Celery and RabbitMQ: For asynchronous task processing (e.g., sending emails).
- Insomnia: Real-time testing of API endpoints.
- Docker: For containerization and deployment of the application, providing a consistent and isolated environment.
- Python: The version specified in the requirements.txt file. It is recommended to use a Python version manager like pyenv to manage different Python versions.
- A Python package manager: pip is the most common, but you can also use others like poetry.
- A text editor or an IDE: Popular options include Visual Studio Code, PyCharm, Sublime Text.
- A terminal or command line: To run installation and project management commands.
- Docker: Required for running the project in a containerized environment.
Follow these steps to set up the project locally:
- Clone the Repository:
git clone https://github.com/cristiol/hospital_management_api.git
- Navigate to the Project Directory:
cd hospital_management_api - Set up the email
- Create a .env file in the root of the project directory if it doesn't already exist.
- Add your email address and other required email settings to the .env file.
- If you are using a different email service provider than Outlook, make sure to update the EMAIL_HOST setting. For example, if you are using Gmail, you should change it to:
EMAIL_HOST='smtp.gmail.com'
-
Build and Run the Docker Containers:
docker-compose up --build
-
Access the API: Once the Docker containers are running, the API will be accessible at http://localhost:8000.
-
Access the RabbitMQ Management UI: You can access the RabbitMQ Management UI at http://localhost:15672 using the credentials:
Username: admin Password: admin
users/
doctors/
assistants/
treatments/
patients/
reports/
appointments/
Usage
To interact with the API, use tools like Insomnia or Postman. Below are some example requests:
Authentication
Obtain a JWT token by sending a POST request with your credentials.
CRUD Operations
Get All Patients:
Create a new patient
Read a patient
Update a patient
Delete a patient
The API has a test suite implemented containing unit tests. You can check tests by doing:
$ docker-compose exec web python manage.py test
How to Contribute: You can contribute by forking the repository, making your changes on a new branch, and submitting a pull request.
Code Conventions: Follow PEP 8 for Python code. Use clear commit messages and add docstrings for all functions and classes.
License: This project is licensed under the MIT License.
Cristian Olteanu (Project Lead)













