forked from ZU-Hospital/zu-hospital-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ZU-Hospital#42 from MohamedHamed12/softdelete
readme
- Loading branch information
Showing
23 changed files
with
443 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,34 @@ | ||
# Hospital-Backend | ||
|
||
Our System serves as the core engine, responsible for handling data storage, processing, and serving requests from the frontend. It is built on the Django REST Framework, a powerful toolkit for building Web APIs in Python. | ||
|
||
### Technologies Used | ||
- **Django REST Framework** | ||
- **SQLite** (for development) | ||
- **PostgreSQL** (for production) | ||
- **GitHub Actions** (for CI/CD) | ||
- **Docker** (for containerization) | ||
- **Azure** (for deployment) | ||
|
||
### Key Features | ||
- **API Development:** Utilized Django REST Framework to build a scalable and maintainable API, enabling smooth interaction between the client and the server. | ||
- **Database Management:** | ||
- **SQLite:** Used during the development phase for its simplicity and ease of setup. | ||
- **PostgreSQL:** Chosen for the production environment due to its robustness, scalability, and advanced features. | ||
- **Continuous Integration/Continuous Deployment (CI/CD):** Implemented CI/CD pipelines using GitHub Actions to automate testing, building, and deployment processes, ensuring that code changes are reliably and efficiently deployed to production. | ||
- **Containerization:** Deployed the application using Docker to ensure consistency across different environments. Docker allows for easy replication of the development environment, ensuring that the application behaves the same way in development, testing, and production. | ||
|
||
### Automated Testing | ||
- **Unit Tests:** Developed unit tests to validate the functionality of individual components and ensure that each part of the codebase performs as expected. | ||
- **Integration Tests:** Conducted integration tests to verify that different components of the system work together correctly, ensuring that the interactions between various parts of the system are seamless. | ||
|
||
|
||
### Development Workflow | ||
- **Version Control:** Used Git for version control, hosting the repository on GitHub to facilitate collaboration and maintain a history of code changes. | ||
- **CI/CD Pipeline:** Configured GitHub Actions to automate the CI/CD pipeline, including steps for running tests, building the application, and deploying it to the production environment. | ||
- **Docker:** Employed Docker for containerization, enabling consistent deployment across different environments by packaging the application and its dependencies into a single container. | ||
- **Azure:** Deployed the application to Azure using the Azure CLI. | ||
|
||
### Conclusion | ||
|
||
The backend of the Patient and Doctor Management System is designed to be robust, scalable, and maintainable. By leveraging Django REST Framework, automated testing, CI/CD pipelines, and Docker, the backend ensures reliable data management and seamless interactions with the frontend. This setup provides a solid foundation for building and deploying a high-quality healthcare management system. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 5.0.3 on 2024-05-19 08:13 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("accounts", "0001_initial"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="employee", | ||
name="postion", | ||
field=models.CharField(default="test", max_length=255), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from .models import * | ||
class Employee(Profile): | ||
|
||
postion=models.CharField(max_length=255,default="test") | ||
def __str__(self): | ||
return self.national_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,56 @@ | ||
# from django.contrib.auth import get_user_model | ||
# from django.test import TestCase | ||
# from rest_framework.test import APIClient | ||
|
||
# User=get_user_model() | ||
# class AuthTest(TestCase): | ||
# def setUp(self) -> None: | ||
# self.client = APIClient() | ||
# def test_#(self): | ||
# url = '/accounts/#/' | ||
# data = { | ||
# 'username': 'test', | ||
# 'password': 'test', | ||
# } | ||
# response = self.client.post(url, data, format='json') | ||
# self.assertEqual(response.status_code, 201) | ||
# def test_login(self): | ||
# ''' | ||
# create user first | ||
# ''' | ||
# url = '/accounts/#/' | ||
# data = { | ||
# 'username': 'test', | ||
# 'password': 'test', | ||
# } | ||
# response = self.client.post(url, data, format='json') | ||
# ''' | ||
# test login | ||
# ''' | ||
# url = '/accounts/token/' | ||
# data = { | ||
# 'username': 'test', | ||
# 'password': 'test', | ||
# } | ||
# response = self.client.post(url, data, format='json') | ||
# self.assertEqual(response.status_code, 200) | ||
# self.assertIn('access',response.data) | ||
# self.assertIn('user',response.data) | ||
# def test_creaet_employee(self): | ||
# url = '/accounts/#/' | ||
# data = { | ||
# 'username': 'test', | ||
# 'password': 'test', | ||
# } | ||
# response = self.client.post(url, data, format='json') | ||
# url = '/accounts/employee/' | ||
# data = { | ||
# 'user': response.data['user']['id'], | ||
# 'first_name': 'test', | ||
# 'last_name': 'test', | ||
# 'date_of_birth': '2000-01-01', | ||
# 'gender': 'M', | ||
|
||
# } | ||
# response = self.client.post(url, data, format='json') | ||
# self.assertEqual(response.status_code, 201) | ||
from django.test import TestCase | ||
from rest_framework.test import APIClient | ||
from django.contrib.auth import get_user_model | ||
User=get_user_model() | ||
from .test_setup import * | ||
import os | ||
from django.test import TestCase, override_settings | ||
from django.core.files.uploadedfile import SimpleUploadedFile | ||
|
||
|
||
def create_image_test(): | ||
if os.path.exists("test_image.jpg"): | ||
return | ||
from PIL import Image, ImageDraw | ||
|
||
image = Image.new("RGB", (200, 200), "white") | ||
draw = ImageDraw.Draw(image) | ||
draw.rectangle([(50, 50), (150, 150)], fill="red") | ||
image.save("test_image.jpg") | ||
image.show() | ||
|
||
|
||
|
||
|
||
class attachmentTestCase(TestSetup): | ||
def setUp(self) -> None: | ||
super().setUp() | ||
self.staff, self.staff_token = self.create_staff() | ||
self.patient1, self.patient1_token = self.create_patient(self.staff_token,national_id='11111111111111') | ||
self.patient2, self.patient2_token = self.create_patient(self.staff_token,national_id='22222222222222') | ||
self.doctor,self.doctor_token = self.create_doctor(self.staff_token,national_id='111111111111171') | ||
self.visit1 = self.create_visit(self.staff_token,patient_id=self.patient1['id']) | ||
self.visit2 = self.create_visit(self.staff_token,patient_id=self.patient2['id']) | ||
self.employee, self.employee_token = self.create_employee(self.staff_token) | ||
|
||
|
||
def test_get_patients(self): | ||
url = '/accounts/patient/' | ||
response= self.client.get( | ||
url, HTTP_AUTHORIZATION='Bearer ' + self.employee_token ) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertEqual(len(response.data['results']), 2) | ||
def test_create_patient(self): | ||
|
||
data = { | ||
'full_name': 'test', | ||
'national_id': '012345678901234', | ||
|
||
|
||
} | ||
url = '/accounts/patient/' | ||
response= self.client.post( | ||
url, data, HTTP_AUTHORIZATION='Bearer ' + self.employee_token ) | ||
self.assertEqual(response.status_code, 201) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.