This project involves the development of a modern and scalable clinical system designed to facilitate efficient management of medical data and seamless interaction among patients, doctors, and administrative staff.
Technologies Used:
-
Backend: Django and Django REST Framework
- Django: High-level web framework that promotes rapid and clean development, using the MVC (Model-View-Controller) pattern.
- Django REST Framework: Powerful toolkit for building web APIs using Django, providing advanced serialization and class-based views for creating RESTful APIs.
-
Frontend: Vue.js
- Vue.js: Progressive library for building user interfaces, making it easy to create interactive and reactive interfaces using reusable components.
- Vuetify: Material Design component framework for Vue.js, used to ensure a consistent and appealing user interface.
System Features:
-
Patient Management: Allows registering patients, updating their personal and medical information, as well as managing their appointments and follow-ups.
-
Electronic Health Records: Safely and organized storage of each patient's complete medical history, including diagnoses, previous treatments, and test results.
-
Scheduling and Medical Appointments: Facilitates medical schedule management, allowing doctors to schedule appointments, receive notifications, and manage availability efficiently.
-
Electronic Prescriptions: Enables doctors to generate electronic prescriptions securely and efficiently, integrating functionalities for medication management and dosages.
-
Administration and Reports: Includes administrative tools for user management, roles, and permissions, as well as generating reports and statistics on the medical center's operation.
Project Objectives:
- Improve the operational efficiency of the medical center through process automation.
- Optimize communication between patients and medical staff.
- Comply with data security and privacy standards (such as HIPAA in the US context).
- Provide an intuitive and pleasant user experience through a modern and responsive interface.
Expected Benefits:
- Reduction in errors in medical data management.
- Improved accuracy of diagnoses and treatments.
- Increased satisfaction of both patients and medical staff.
- Adaptability and scalability for future system expansions and improvements.
This project integrates robust backend and frontend technologies to provide a comprehensive and efficient solution for medical information management and patient care in a modern clinical environment.
To install and run the project locally, follow these steps:
git clone https://github.com/JassonCu/django-api-medic
cd django-api-medic
It's a good practice to use a virtual environment to manage project dependencies in isolation.
python -m venv venv
python3 -m venv venv
Before installing project dependencies, activate the virtual environment:
venv\Scripts\activate
venv\Scripts\Activate.ps1
source venv/bin/activate
pip install -r requirements.txt
python manage.py makemigrations
python manage.py migrate
If you have test data in YAML format (fixtures) and want to load it into the database, use the loaddata
command:
python manage.py loaddata */fixtures/*.yaml
Finally, with migrations applied and test data loaded, you can run your Django project:
python manage.py runserver
To ensure the project runs correctly, configure the following environment variables. These variables are primarily used for MySQL database configuration and Docker container management. You can use the .env-example
file as a reference to create your own .env
file.
-
For MySQL database configuration:
MYSQLDB_HOST
: MySQL database host.MYSQLDB_PASSWORD
: Password for the MySQL user.MYSQLDB_ROOT_PASSWORD
: Password for the MySQL root user.MYSQLDB_DATABASE
: Name of the database your application will use.MYSQLDB_LOCAL_PORT
: Local port used to connect to MySQL from outside Docker.MYSQLDB_DOCKER_PORT
: Port inside the Docker container where MySQL is exposed (usually 3306).
-
For Docker container configuration:
DJANGO_LOCAL_PORT
: Local port used to access your Django application from outside Docker.DJANGO_DOCKER_PORT
: Port inside the Docker container where your Django application will run.
- It is recommended to have MySQL database management system installed. If not installed locally, you can use Docker to easily create and manage a MySQL container.
- Make sure to adjust the environment variables according to your development environment specifications and configurations.
To complement the documentation with the necessary commands for creating a MySQL instance using Docker, here's an additional section you can add:
If you do not have MySQL installed locally or prefer to use Docker to manage your database, follow these steps to create a MySQL instance using Docker.
Run the following command to download the official MySQL image from Docker Hub:
docker pull mysql:latest
Use the following command to create and run a MySQL container:
docker run -d --name my-mysql \
-e MYSQL_ROOT_PASSWORD=<root_password> \
-e MYSQL_DATABASE=<database_name> \
-p <local_port>:<docker_port> \
mysql:latest
- Replace
<root_password>
with the password you want to set for the MySQL root user. - Replace
<database_name>
with the name you want to assign to your database. - Replace
<local_port>
with the port on your local machine you want to map to the MySQL container. - Replace
<docker_port>
with the port inside the container where MySQL is exposed (usually 3306).
docker run -d --name my-mysql \
-e MYSQL_ROOT_PASSWORD=mysecretpassword \
-e MYSQL_DATABASE=mydatabase \
-p 3306:3306 \
mysql:latest
You can verify that the MySQL container is running by using the following command:
docker ps
This will display a list of all running Docker containers. You should see your MySQL container (my-mysql
in this example) listed.
Use the appropriate environment variables (MYSQLDB_HOST
, MYSQLDB_PASSWORD
, etc.) in your .env
file to configure your Django application's connection to the MySQL container you just created.
To run your application using Docker Compose, follow these steps:
-
Ensure Docker and Docker Compose are installed:
- Docker: Install Docker
- Docker Compose: Install Docker Compose
-
Set up your
.env
file:- Make sure your
.env
file is properly configured with the necessary environment variables for your services (DJANGO_LOCAL_PORT
,DJANGO_DOCKER_PORT
,MYSQLDB_USER
,MYSQLDB_PASSWORD
, etc.).
- Make sure your
-
Navigate to the root of your project where
docker-compose.yml
is located. -
Run Docker Compose:
-
Open a terminal or command line.
-
Execute the following command to build the services defined in your
docker-compose.yml
file and start the containers:docker-compose up -d
-d
(detach) is used to run the containers in the background.
-
This command will start building Docker images as per the specifications in
docker-compose.yml
, download necessary images (if not available locally), and launch the containers.
-
-
Verify execution:
-
To check if your containers are running, you can use the following command:
docker-compose ps
This will display the status of your services (
djangoapimedic
andmysqldb
).
-
-
Access your application:
- If the Django application is configured correctly, you should be able to access it from your web browser.
- For MySQL database, you can verify its status and connection from the Django application or another database management tool.
-
Stop and clean up:
-
When you want to stop and remove the containers created by Docker Compose, you can execute:
docker-compose down
This command will stop and remove the containers, while retaining persistent data volumes unless you specify the
-v
option to remove volumes as well.
-
Following these steps should enable you to run your application effectively using Docker Compose. Be sure to review the command output for any error or warning messages that may require adjustments in your configuration.
To verify that all functionalities of your application are working correctly, you can run the tests defined in your Django project.
If you haven't already activated your virtual environment, make sure to do so to isolate the project dependencies:
venv\Scripts\activate
venv\Scripts\Activate.ps1
source venv/bin/activate
Use the manage.py
command to run the tests defined in your Django application:
python manage.py test
This command will execute all tests defined in your project and display the results in the console.
-
Run tests for a specific application: If you want to run tests only for a specific application in your project, you can specify the application name after the
test
command.python manage.py test <app_name>
-
Generate HTML report: To generate an HTML report of the test results, you can use the
--html
option followed by the filename where you want to save the report.python manage.py test --html=test_report.html
After running the tests, check the console output to ensure that all tests passed successfully. If any test fails, review the error details to identify and correct any issues in your code.
-
User Authentication:
- New user registration.
- Secure login authentication.
- User session management.
-
Data Management:
- CRUD (Create, Read, Update, Delete) for core system entities.
- Data validation and form handling.
-
RESTful API:
- Exposing RESTful endpoints to interact with data.
- Support for HTTP methods (GET, POST, PUT, DELETE).
-
Database Integration:
- Connection and management of MySQL database.
-
Security:
- Implementation of security measures such as CSRF, CORS, and protection against XSS and SQL Injection.
- Use of JWT tokens for authentication and authorization.
-
User Interface (UI):
- Responsive and accessible design.
- Implementation of reusable Vuefly design components.
-
Automated Testing:
- Suite of unit and integration tests.
- Test coverage for all critical
functionalities.
- Internationalization (i18n) and Localization (l10n):
- Support for multiple languages and regions.
- Translation of dynamic and static content.
-
Session and Cookie Management:
- Maintenance of user sessions through secure cookies.
- Session expiration configuration.
-
File and Media Management:
- Upload, storage, and management of files (images, documents, etc.).
-
Role and Permission Management:
- User role definition and permissions based access.
- Management of access and authorization to different system functionalities.
-
Performance Optimization:
- Implementation of load and performance optimization techniques (caching, resource compression, etc.).
-
Monitoring and Logging:
- Logging of events and errors for analysis and debugging.
- Implementation of monitoring tools for system performance.
Thank you very much, and best regards. 🚀