diff --git a/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/buckets/.bloomcycle.bin/xl.meta b/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/buckets/.bloomcycle.bin/xl.meta index 35a00fc4..62c741c4 100644 Binary files a/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/buckets/.bloomcycle.bin/xl.meta and b/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/buckets/.bloomcycle.bin/xl.meta differ diff --git a/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/buckets/.tracker.bin b/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/buckets/.tracker.bin index 294f2c99..05ae68a7 100644 Binary files a/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/buckets/.tracker.bin and b/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/buckets/.tracker.bin differ diff --git a/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/buckets/.usage-cache.bin/xl.meta b/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/buckets/.usage-cache.bin/xl.meta index db700c73..4f31b8f0 100644 Binary files a/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/buckets/.usage-cache.bin/xl.meta and b/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/buckets/.usage-cache.bin/xl.meta differ diff --git a/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/buckets/.usage.json/xl.meta b/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/buckets/.usage.json/xl.meta index 9cb772c1..18c221c1 100644 Binary files a/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/buckets/.usage.json/xl.meta and b/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/buckets/.usage.json/xl.meta differ diff --git a/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/buckets/mih/.usage-cache.bin/xl.meta b/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/buckets/mih/.usage-cache.bin/xl.meta index 7aab462e..8a9e0749 100644 Binary files a/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/buckets/mih/.usage-cache.bin/xl.meta and b/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/buckets/mih/.usage-cache.bin/xl.meta differ diff --git a/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/buckets/replication/127.0.0.1_9000.stats/xl.meta b/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/buckets/replication/127.0.0.1_9000.stats/xl.meta index 4a709618..be7f233e 100644 Binary files a/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/buckets/replication/127.0.0.1_9000.stats/xl.meta and b/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/buckets/replication/127.0.0.1_9000.stats/xl.meta differ diff --git a/backend/database/__init__.py b/backend/database/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/backend/database/__pycache__/__init__.cpython-310.pyc b/backend/database/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 00000000..515081a7 Binary files /dev/null and b/backend/database/__pycache__/__init__.cpython-310.pyc differ diff --git a/backend/database/__pycache__/dbConnection.cpython-310.pyc b/backend/database/__pycache__/dbConnection.cpython-310.pyc new file mode 100644 index 00000000..12bd1fa4 Binary files /dev/null and b/backend/database/__pycache__/dbConnection.cpython-310.pyc differ diff --git a/backend/database/dbConnection.py b/backend/database/dbConnection.py new file mode 100644 index 00000000..ec0bcdad --- /dev/null +++ b/backend/database/dbConnection.py @@ -0,0 +1,9 @@ +import mysql.connector + +def dbConnect(): + return mysql.connector.connect( + host="mysqldb", + user="root", + passwd="C@rtoon1995", + database="patient_manager" + ) \ No newline at end of file diff --git a/backend/routers/__pycache__/docOffices.cpython-310.pyc b/backend/routers/__pycache__/docOffices.cpython-310.pyc index ca80f2d0..82e31ec7 100644 Binary files a/backend/routers/__pycache__/docOffices.cpython-310.pyc and b/backend/routers/__pycache__/docOffices.cpython-310.pyc differ diff --git a/backend/routers/__pycache__/patients.cpython-310.pyc b/backend/routers/__pycache__/patients.cpython-310.pyc index df9a801a..fad7e832 100644 Binary files a/backend/routers/__pycache__/patients.cpython-310.pyc and b/backend/routers/__pycache__/patients.cpython-310.pyc differ diff --git a/backend/routers/__pycache__/patients_files.cpython-310.pyc b/backend/routers/__pycache__/patients_files.cpython-310.pyc index 0b162d64..e8a8e682 100644 Binary files a/backend/routers/__pycache__/patients_files.cpython-310.pyc and b/backend/routers/__pycache__/patients_files.cpython-310.pyc differ diff --git a/backend/routers/__pycache__/patients_notes.cpython-310.pyc b/backend/routers/__pycache__/patients_notes.cpython-310.pyc index 2ea40c3a..c408c7d9 100644 Binary files a/backend/routers/__pycache__/patients_notes.cpython-310.pyc and b/backend/routers/__pycache__/patients_notes.cpython-310.pyc differ diff --git a/backend/routers/docOffices.py b/backend/routers/docOffices.py index 169686a6..abd5bfc7 100644 --- a/backend/routers/docOffices.py +++ b/backend/routers/docOffices.py @@ -1,20 +1,13 @@ import mysql.connector from fastapi import APIRouter, HTTPException +from ..database import dbConnection router = APIRouter() -def dbConnect(): - return mysql.connector.connect( - host="mysqldb", - user="root", - passwd="C@rtoon1995", - database="patient_manager" - ) - # Get Doctors Office By ID @router.get("/docOffices/{docOffic_id}", tags="DocOffice") async def read_docOfficeByID(docOffic_id: int): - db = dbConnect() + db = dbConnection.dbConnect() cursor = db.cursor() query = "SELECT * FROM doctor_offices WHERE iddoctor_offices=%s" cursor.execute(query, (docOffic_id,)) @@ -29,7 +22,7 @@ async def read_docOfficeByID(docOffic_id: int): # Get List of all Doctors Office @router.get("/docOffices/", tags="DocOffice") async def read_All_DoctorsOffice(): - db = dbConnect() + db = dbConnection.dbConnect() cursor = db.cursor() query = "SELECT * FROM doctor_offices" cursor.execute(query) diff --git a/backend/routers/patients.py b/backend/routers/patients.py index 1b19836c..69521860 100644 --- a/backend/routers/patients.py +++ b/backend/routers/patients.py @@ -1,6 +1,7 @@ import mysql.connector from fastapi import APIRouter, HTTPException from pydantic import BaseModel +from ..database import dbConnection router = APIRouter() @@ -29,18 +30,11 @@ class patientUpdateRequest(BaseModel): address: str doc_office_id: int -def dbConnect(): - return mysql.connector.connect( - host="mysqldb", - user="root", - passwd="C@rtoon1995", - database="patient_manager" - ) # Get Patient By ID Number @router.get("/patients/{id_no}", tags="patients") async def read_patientByID(id_no: str): - db = dbConnect() + db = dbConnection.dbConnect() cursor = db.cursor() query = "SELECT * FROM patients WHERE id_no=%s" cursor.execute(query, (id_no,)) @@ -64,7 +58,7 @@ async def read_patientByID(id_no: str): # Get List of all patients @router.get("/patients/", tags="patients") async def read_all_patients(): - db = dbConnect() + db = dbConnection.dbConnect() cursor = db.cursor() query = "SELECT * FROM patients" cursor.execute(query) @@ -91,7 +85,7 @@ async def read_all_patients(): # Get List of all patients by Doctors Office @router.get("/patients/docOffice/{docoff_id}", tags="patients") async def read_all_patientsby(docoff_id: str): - db = dbConnect() + db = dbConnection.dbConnect() cursor = db.cursor() query = "SELECT * FROM patients where doc_office_id=%s" cursor.execute(query, (docoff_id,)) @@ -118,7 +112,7 @@ async def read_all_patientsby(docoff_id: str): # Insert Patient into table @router.post("/patients/insert/", tags="patients", status_code=201) async def insertPatient(itemRequest : patientInsertRequest): - db = dbConnect() + db = dbConnection.dbConnect() cursor = db.cursor() query = "insert into patients " query += "(id_no, first_name, last_name, email, cell_no, medical_aid_name, " @@ -147,7 +141,7 @@ async def insertPatient(itemRequest : patientInsertRequest): # Update Patient on table @router.put("/patients/update/", tags="patients") async def UpdatePatient(itemRequest : patientUpdateRequest): - db = dbConnect() + db = dbConnection.dbConnect() cursor = db.cursor() query = "update patients " query += "set id_no=%s, first_name=%s, last_name=%s, email=%s, cell_no=%s, medical_aid_name=%s, " diff --git a/backend/routers/patients_files.py b/backend/routers/patients_files.py index 24080fd2..713a1a93 100644 --- a/backend/routers/patients_files.py +++ b/backend/routers/patients_files.py @@ -1,6 +1,7 @@ import mysql.connector from fastapi import APIRouter, HTTPException from pydantic import BaseModel +from ..database import dbConnection router = APIRouter() @@ -8,18 +9,10 @@ class fileRequest(BaseModel): DocOfficeID: int patientID: int -def dbConnect(): - return mysql.connector.connect( - host="mysqldb", - user="root", - passwd="C@rtoon1995", - database="patient_manager" - ) - # Get List of all files @router.get("/files/patients/", tags="patients_files") async def read_all_files(): - db = dbConnect() + db = dbConnection.dbConnect() cursor = db.cursor() query = "SELECT * FROM patient_files" cursor.execute(query) @@ -40,7 +33,7 @@ async def read_all_files(): # Get List of all files by patient @router.get("/files/patients/{patientID}", tags="patients_files") async def read_all_files_by_patient(patientID: int): - db = dbConnect() + db = dbConnection.dbConnect() cursor = db.cursor() query = "SELECT * FROM patient_files where patient_id = %s" cursor.execute(query, (patientID,)) @@ -61,7 +54,7 @@ async def read_all_files_by_patient(patientID: int): # Get List of all files by patient & DocOffice @router.get("/files/patients-docOffice/", tags="patients_files") async def read_all_files_by_patient(itemRequest: fileRequest): - db = dbConnect() + db = dbConnection.dbConnect() cursor = db.cursor() query = "select patient_files.idpatient_files, patient_files.file_path, patient_files.file_name, patient_files.patient_id, patient_files.insert_date, patients.doc_office_id " query += "from patient_manager.patient_files " diff --git a/backend/routers/patients_notes.py b/backend/routers/patients_notes.py index 66ea8ef5..5ab086f8 100644 --- a/backend/routers/patients_notes.py +++ b/backend/routers/patients_notes.py @@ -2,17 +2,10 @@ import mysql.connector from fastapi import APIRouter, HTTPException from pydantic import BaseModel from datetime import date +from ..database import dbConnection router = APIRouter() -def dbConnect(): - return mysql.connector.connect( - host="mysqldb", - user="root", - passwd="C@rtoon1995", - database="patient_manager" - ) - class fileRequest(BaseModel): DocOfficeID: int patientID: int @@ -31,7 +24,7 @@ class patientNoteUpdateRequest(BaseModel): # Get List of all notes @router.get("/notes/patients/", tags="patients_notes") async def read_all_notes(): - db = dbConnect() + db = dbConnection.dbConnect() cursor = db.cursor() query = "SELECT * FROM patient_notes" cursor.execute(query) @@ -51,7 +44,7 @@ async def read_all_notes(): # Get List of all notes by patient @router.get("/notes/patients/{patientID}", tags="patients_notes") async def read_all_patientsby(patientID: int): - db = dbConnect() + db = dbConnection.dbConnect() cursor = db.cursor() query = "SELECT * FROM patient_notes where patient_id = %s" cursor.execute(query, (patientID,)) @@ -71,7 +64,7 @@ async def read_all_patientsby(patientID: int): # Get List of all notes by patient @router.get("/notes/patients-docOffice/", tags="patients_notes") async def read_all_patientsby(itemRequest: fileRequest): - db = dbConnect() + db = dbConnection.dbConnect() cursor = db.cursor() query = "select patient_notes.idpatient_notes, patient_notes.note_name, patient_notes.note_text, patient_notes.patient_id, patient_notes.insert_date, patients.doc_office_id " query += "from patient_manager.patient_notes " @@ -96,7 +89,7 @@ async def read_all_patientsby(itemRequest: fileRequest): @router.post("/notes/insert/", tags="patients_notes", status_code=201) async def insertPatientNotes(itemRequest : patientNoteInsertRequest): today = date.today() - db = dbConnect() + db = dbConnection.dbConnect() cursor = db.cursor() query = "insert into patient_notes " query += "(note_name, note_text, patient_id, insert_date) " @@ -119,7 +112,7 @@ async def insertPatientNotes(itemRequest : patientNoteInsertRequest): @router.put("/notes/update/", tags="patients_notes") async def UpdatePatient(itemRequest : patientNoteUpdateRequest): today = date.today() - db = dbConnect() + db = dbConnection.dbConnect() cursor = db.cursor() query = "update patient_notes " query += "set note_name=%s, note_text=%s, patient_id=%s, insert_date=%s "