forked from yaso_meth/mih-project
v1 upload
First upload of project files
This commit is contained in:
6
backend/Dockerfile
Normal file
6
backend/Dockerfile
Normal file
@@ -0,0 +1,6 @@
|
||||
FROM python:3.10-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY ./requirements.txt ./
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
0
backend/__init__.py
Normal file
0
backend/__init__.py
Normal file
BIN
backend/__pycache__/Robot.cpython-311.pyc
Normal file
BIN
backend/__pycache__/Robot.cpython-311.pyc
Normal file
Binary file not shown.
BIN
backend/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
backend/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
backend/__pycache__/main.cpython-310.pyc
Normal file
BIN
backend/__pycache__/main.cpython-310.pyc
Normal file
Binary file not shown.
223
backend/backup.py
Normal file
223
backend/backup.py
Normal file
@@ -0,0 +1,223 @@
|
||||
from typing import Union
|
||||
#import DatabaseConnect
|
||||
import mysql.connector
|
||||
from fastapi import FastAPI, HTTPException
|
||||
from pydantic import BaseModel
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
def dbConnect():
|
||||
return mysql.connector.connect(
|
||||
host="mysqldb",
|
||||
user="root",
|
||||
passwd="root",
|
||||
database="patient_manager"
|
||||
)
|
||||
|
||||
class fileRequest(BaseModel):
|
||||
DocOfficeID: int
|
||||
patientID: int
|
||||
|
||||
# Check if server is up
|
||||
@app.get("/")
|
||||
def read_root():
|
||||
return serverRunning()
|
||||
|
||||
# Get Doctors Office By ID
|
||||
@app.get("/docOffices/{docOffic_id}")
|
||||
def read_docOfficeByID(docOffic_id: int):
|
||||
db = dbConnect()
|
||||
cursor = db.cursor()
|
||||
query = "SELECT * FROM doctor_offices WHERE iddoctor_offices=%s"
|
||||
cursor.execute(query, (docOffic_id,))
|
||||
item = cursor.fetchone()
|
||||
cursor.close()
|
||||
db.close()
|
||||
if item is None:
|
||||
raise HTTPException(status_code=404, detail="Item not found")
|
||||
return {"iddoctor_offices": item[0],
|
||||
"office_name": item[1]}
|
||||
|
||||
# Get List of all Doctors Office
|
||||
@app.get("/docOffices/")
|
||||
def read_All_DoctorsOffice():
|
||||
db = dbConnect()
|
||||
cursor = db.cursor()
|
||||
query = "SELECT * FROM doctor_offices"
|
||||
cursor.execute(query)
|
||||
items = [
|
||||
{
|
||||
"iddoctor_offices": item[0],
|
||||
"office_name": item[1]
|
||||
}
|
||||
for item in cursor.fetchall()
|
||||
]
|
||||
cursor.close()
|
||||
db.close()
|
||||
return items
|
||||
|
||||
# Get Patient By ID Number
|
||||
@app.get("/patients/{id_no}")
|
||||
def read_patientByID(id_no: str):
|
||||
db = dbConnect()
|
||||
cursor = db.cursor()
|
||||
query = "SELECT * FROM patients WHERE id_no=%s"
|
||||
cursor.execute(query, (id_no,))
|
||||
item = cursor.fetchone()
|
||||
cursor.close()
|
||||
db.close()
|
||||
if item is None:
|
||||
raise HTTPException(status_code=404, detail="Item not found")
|
||||
return {"idpatients": item[0],
|
||||
"id_no": item[1],
|
||||
"first_name": item[2],
|
||||
"last_name": item[3],
|
||||
"email": item[4],
|
||||
"cell_no": item[5],
|
||||
"medical_aid_name": item[6],
|
||||
"medical_aid_no": item[7],
|
||||
"medical_aid_scheme": item[8],
|
||||
"address": item[9],
|
||||
"doc_office_id": item[10]}
|
||||
|
||||
# Get List of all patients
|
||||
@app.get("/patients/")
|
||||
def read_all_patients():
|
||||
db = dbConnect()
|
||||
cursor = db.cursor()
|
||||
query = "SELECT * FROM patients"
|
||||
cursor.execute(query)
|
||||
items = [
|
||||
{
|
||||
"idpatients": item[0],
|
||||
"id_no": item[1],
|
||||
"first_name": item[2],
|
||||
"last_name": item[3],
|
||||
"email": item[4],
|
||||
"cell_no": item[5],
|
||||
"medical_aid_name": item[6],
|
||||
"medical_aid_no": item[7],
|
||||
"medical_aid_scheme": item[8],
|
||||
"address": item[9],
|
||||
"doc_office_id": item[10]
|
||||
}
|
||||
for item in cursor.fetchall()
|
||||
]
|
||||
cursor.close()
|
||||
db.close()
|
||||
return items
|
||||
|
||||
# Get List of all patients by Doctors Office
|
||||
@app.get("/docOffice/patients/{docoff_id}")
|
||||
def read_all_patientsby(docoff_id: str):
|
||||
db = dbConnect()
|
||||
cursor = db.cursor()
|
||||
query = "SELECT * FROM patients where doc_office_id=%s"
|
||||
cursor.execute(query, (docoff_id,))
|
||||
items = [
|
||||
{
|
||||
"idpatients": item[0],
|
||||
"id_no": item[1],
|
||||
"first_name": item[2],
|
||||
"last_name": item[3],
|
||||
"email": item[4],
|
||||
"cell_no": item[5],
|
||||
"medical_aid_name": item[6],
|
||||
"medical_aid_no": item[7],
|
||||
"medical_aid_scheme": item[8],
|
||||
"address": item[9],
|
||||
"doc_office_id": item[10]
|
||||
}
|
||||
for item in cursor.fetchall()
|
||||
]
|
||||
cursor.close()
|
||||
db.close()
|
||||
return items
|
||||
|
||||
# Get List of all files
|
||||
@app.get("/patients/files/")
|
||||
def read_all_files():
|
||||
db = dbConnect()
|
||||
cursor = db.cursor()
|
||||
query = "SELECT * FROM patient_files"
|
||||
cursor.execute(query)
|
||||
items = [
|
||||
{
|
||||
"idpatient_files": item[0],
|
||||
"file_path": item[1],
|
||||
"file_name": item[2],
|
||||
"patient_id": item[3],
|
||||
"insert_date": item[4],
|
||||
}
|
||||
for item in cursor.fetchall()
|
||||
]
|
||||
cursor.close()
|
||||
db.close()
|
||||
return items
|
||||
|
||||
# Get List of all files by patient
|
||||
@app.get("/patients/files/{patientID}")
|
||||
def read_all_files_by_patient(patientID: int):
|
||||
db = dbConnect()
|
||||
cursor = db.cursor()
|
||||
query = "SELECT * FROM patient_files where patient_id = %s"
|
||||
cursor.execute(query, (patientID,))
|
||||
items = [
|
||||
{
|
||||
"idpatient_files": item[0],
|
||||
"file_path": item[1],
|
||||
"file_name": item[2],
|
||||
"patient_id": item[3],
|
||||
"insert_date": item[4],
|
||||
}
|
||||
for item in cursor.fetchall()
|
||||
]
|
||||
cursor.close()
|
||||
db.close()
|
||||
return items
|
||||
|
||||
# Get List of all notes
|
||||
@app.get("/patients/notes/")
|
||||
def read_all_notes():
|
||||
db = dbConnect()
|
||||
cursor = db.cursor()
|
||||
query = "SELECT * FROM patient_notes"
|
||||
cursor.execute(query)
|
||||
items = [
|
||||
{
|
||||
"idpatient_notes": item[0],
|
||||
"note_name": item[1],
|
||||
"note_text": item[2],
|
||||
"insert_date": item[3],
|
||||
}
|
||||
for item in cursor.fetchall()
|
||||
]
|
||||
cursor.close()
|
||||
db.close()
|
||||
return items
|
||||
|
||||
# Get List of all notes by patient
|
||||
@app.get("/patients/notes/{patientID}")
|
||||
def read_all_patientsby(patientID: int):
|
||||
db = dbConnect()
|
||||
cursor = db.cursor()
|
||||
query = "SELECT * FROM patient_notes where patient_id = %s"
|
||||
cursor.execute(query, (patientID,))
|
||||
items = [
|
||||
{
|
||||
"idpatient_notes": item[0],
|
||||
"note_name": item[1],
|
||||
"note_text": item[2],
|
||||
"insert_date": item[3],
|
||||
}
|
||||
for item in cursor.fetchall()
|
||||
]
|
||||
cursor.close()
|
||||
db.close()
|
||||
return items
|
||||
|
||||
|
||||
def serverRunning():
|
||||
return {"Status": "Server is Up and Running"}
|
||||
|
||||
|
||||
20
backend/main.py
Normal file
20
backend/main.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from fastapi import FastAPI, HTTPException
|
||||
from pydantic import BaseModel
|
||||
from .routers import docOffices, patients, patients_files, patients_notes
|
||||
|
||||
app = FastAPI()
|
||||
app.include_router(docOffices.router)
|
||||
app.include_router(patients.router)
|
||||
app.include_router(patients_files.router)
|
||||
app.include_router(patients_notes.router)
|
||||
|
||||
# Check if server is up
|
||||
@app.get("/")
|
||||
def read_root():
|
||||
return serverRunning()
|
||||
|
||||
|
||||
def serverRunning():
|
||||
return {"Status": "Server is Up and Running"}
|
||||
|
||||
|
||||
3
backend/requirements.txt
Normal file
3
backend/requirements.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
fastapi
|
||||
uvicorn
|
||||
mysql-connector-python
|
||||
0
backend/routers/__init__.py
Normal file
0
backend/routers/__init__.py
Normal file
BIN
backend/routers/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
backend/routers/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
backend/routers/__pycache__/docOffice.cpython-310.pyc
Normal file
BIN
backend/routers/__pycache__/docOffice.cpython-310.pyc
Normal file
Binary file not shown.
BIN
backend/routers/__pycache__/docOffices.cpython-310.pyc
Normal file
BIN
backend/routers/__pycache__/docOffices.cpython-310.pyc
Normal file
Binary file not shown.
BIN
backend/routers/__pycache__/getFunctions.cpython-310.pyc
Normal file
BIN
backend/routers/__pycache__/getFunctions.cpython-310.pyc
Normal file
Binary file not shown.
BIN
backend/routers/__pycache__/patients.cpython-310.pyc
Normal file
BIN
backend/routers/__pycache__/patients.cpython-310.pyc
Normal file
Binary file not shown.
BIN
backend/routers/__pycache__/patients_files.cpython-310.pyc
Normal file
BIN
backend/routers/__pycache__/patients_files.cpython-310.pyc
Normal file
Binary file not shown.
BIN
backend/routers/__pycache__/patients_notes.cpython-310.pyc
Normal file
BIN
backend/routers/__pycache__/patients_notes.cpython-310.pyc
Normal file
Binary file not shown.
45
backend/routers/docOffices.py
Normal file
45
backend/routers/docOffices.py
Normal file
@@ -0,0 +1,45 @@
|
||||
import mysql.connector
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
def dbConnect():
|
||||
return mysql.connector.connect(
|
||||
host="mysqldb",
|
||||
user="root",
|
||||
passwd="root",
|
||||
database="patient_manager"
|
||||
)
|
||||
|
||||
# Get Doctors Office By ID
|
||||
@router.get("/docOffices/{docOffic_id}", tags="DocOffice")
|
||||
async def read_docOfficeByID(docOffic_id: int):
|
||||
db = dbConnect()
|
||||
cursor = db.cursor()
|
||||
query = "SELECT * FROM doctor_offices WHERE iddoctor_offices=%s"
|
||||
cursor.execute(query, (docOffic_id,))
|
||||
item = cursor.fetchone()
|
||||
cursor.close()
|
||||
db.close()
|
||||
if item is None:
|
||||
raise HTTPException(status_code=404, detail="Item not found")
|
||||
return {"iddoctor_offices": item[0],
|
||||
"office_name": item[1]}
|
||||
|
||||
# Get List of all Doctors Office
|
||||
@router.get("/docOffices/", tags="DocOffice")
|
||||
async def read_All_DoctorsOffice():
|
||||
db = dbConnect()
|
||||
cursor = db.cursor()
|
||||
query = "SELECT * FROM doctor_offices"
|
||||
cursor.execute(query)
|
||||
items = [
|
||||
{
|
||||
"iddoctor_offices": item[0],
|
||||
"office_name": item[1]
|
||||
}
|
||||
for item in cursor.fetchall()
|
||||
]
|
||||
cursor.close()
|
||||
db.close()
|
||||
return items
|
||||
176
backend/routers/patients.py
Normal file
176
backend/routers/patients.py
Normal file
@@ -0,0 +1,176 @@
|
||||
import mysql.connector
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from pydantic import BaseModel
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
class patientInsertRequest(BaseModel):
|
||||
id_no: str
|
||||
first_name: str
|
||||
last_name: str
|
||||
email: str
|
||||
cell_no: str
|
||||
medical_aid_name: str
|
||||
medical_aid_no: str
|
||||
medical_aid_scheme: str
|
||||
address: str
|
||||
doc_office_id: int
|
||||
|
||||
class patientUpdateRequest(BaseModel):
|
||||
idpatients: int
|
||||
id_no: str
|
||||
first_name: str
|
||||
last_name: str
|
||||
email: str
|
||||
cell_no: str
|
||||
medical_aid_name: str
|
||||
medical_aid_no: str
|
||||
medical_aid_scheme: str
|
||||
address: str
|
||||
doc_office_id: int
|
||||
|
||||
def dbConnect():
|
||||
return mysql.connector.connect(
|
||||
host="mysqldb",
|
||||
user="root",
|
||||
passwd="root",
|
||||
database="patient_manager"
|
||||
)
|
||||
|
||||
# Get Patient By ID Number
|
||||
@router.get("/patients/{id_no}", tags="patients")
|
||||
async def read_patientByID(id_no: str):
|
||||
db = dbConnect()
|
||||
cursor = db.cursor()
|
||||
query = "SELECT * FROM patients WHERE id_no=%s"
|
||||
cursor.execute(query, (id_no,))
|
||||
item = cursor.fetchone()
|
||||
cursor.close()
|
||||
db.close()
|
||||
if item is None:
|
||||
raise HTTPException(status_code=404, detail="Item not found")
|
||||
return {"idpatients": item[0],
|
||||
"id_no": item[1],
|
||||
"first_name": item[2],
|
||||
"last_name": item[3],
|
||||
"email": item[4],
|
||||
"cell_no": item[5],
|
||||
"medical_aid_name": item[6],
|
||||
"medical_aid_no": item[7],
|
||||
"medical_aid_scheme": item[8],
|
||||
"address": item[9],
|
||||
"doc_office_id": item[10]}
|
||||
|
||||
# Get List of all patients
|
||||
@router.get("/patients/", tags="patients")
|
||||
async def read_all_patients():
|
||||
db = dbConnect()
|
||||
cursor = db.cursor()
|
||||
query = "SELECT * FROM patients"
|
||||
cursor.execute(query)
|
||||
items = [
|
||||
{
|
||||
"idpatients": item[0],
|
||||
"id_no": item[1],
|
||||
"first_name": item[2],
|
||||
"last_name": item[3],
|
||||
"email": item[4],
|
||||
"cell_no": item[5],
|
||||
"medical_aid_name": item[6],
|
||||
"medical_aid_no": item[7],
|
||||
"medical_aid_scheme": item[8],
|
||||
"address": item[9],
|
||||
"doc_office_id": item[10]
|
||||
}
|
||||
for item in cursor.fetchall()
|
||||
]
|
||||
cursor.close()
|
||||
db.close()
|
||||
return items
|
||||
|
||||
# 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()
|
||||
cursor = db.cursor()
|
||||
query = "SELECT * FROM patients where doc_office_id=%s"
|
||||
cursor.execute(query, (docoff_id,))
|
||||
items = [
|
||||
{
|
||||
"idpatients": item[0],
|
||||
"id_no": item[1],
|
||||
"first_name": item[2],
|
||||
"last_name": item[3],
|
||||
"email": item[4],
|
||||
"cell_no": item[5],
|
||||
"medical_aid_name": item[6],
|
||||
"medical_aid_no": item[7],
|
||||
"medical_aid_scheme": item[8],
|
||||
"address": item[9],
|
||||
"doc_office_id": item[10]
|
||||
}
|
||||
for item in cursor.fetchall()
|
||||
]
|
||||
cursor.close()
|
||||
db.close()
|
||||
return items
|
||||
|
||||
# Insert Patient into table
|
||||
@router.post("/patients/insert/", tags="patients", status_code=201)
|
||||
async def insertPatient(itemRequest : patientInsertRequest):
|
||||
db = dbConnect()
|
||||
cursor = db.cursor()
|
||||
query = "insert into patients "
|
||||
query += "(id_no, first_name, last_name, email, cell_no, medical_aid_name, "
|
||||
query += "medical_aid_no, medical_aid_scheme, address, doc_office_id) "
|
||||
query += "values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
|
||||
patientData = (itemRequest.id_no,
|
||||
itemRequest.first_name,
|
||||
itemRequest.last_name,
|
||||
itemRequest.email,
|
||||
itemRequest.cell_no,
|
||||
itemRequest.medical_aid_name,
|
||||
itemRequest.medical_aid_no,
|
||||
itemRequest.medical_aid_scheme,
|
||||
itemRequest.address,
|
||||
itemRequest.doc_office_id)
|
||||
try:
|
||||
cursor.execute(query, patientData)
|
||||
except Exception as error:
|
||||
raise HTTPException(status_code=404, detail="Failed to Create Record")
|
||||
#return {"message": "Failed to Create Record"}
|
||||
db.commit()
|
||||
cursor.close()
|
||||
db.close()
|
||||
return {"message": "Successfully Created Record"}
|
||||
|
||||
# Update Patient on table
|
||||
@router.put("/patients/update/{idpatient}", tags="patients")
|
||||
async def UpdatePatient(idpatient: int,
|
||||
itemRequest : patientUpdateRequest):
|
||||
db = 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, "
|
||||
query += "medical_aid_no=%s, medical_aid_scheme=%s, address=%s, doc_office_id=%s "
|
||||
query += "where idpatients=%s"
|
||||
patientData = (itemRequest.id_no,
|
||||
itemRequest.first_name,
|
||||
itemRequest.last_name,
|
||||
itemRequest.email,
|
||||
itemRequest.cell_no,
|
||||
itemRequest.medical_aid_name,
|
||||
itemRequest.medical_aid_no,
|
||||
itemRequest.medical_aid_scheme,
|
||||
itemRequest.address,
|
||||
itemRequest.doc_office_id,
|
||||
idpatient)
|
||||
try:
|
||||
cursor.execute(query, patientData)
|
||||
except Exception as error:
|
||||
raise HTTPException(status_code=404, detail="Failed to Update Record")
|
||||
#return {"query": query, "message": error}
|
||||
db.commit()
|
||||
cursor.close()
|
||||
db.close()
|
||||
return {"message": "Successfully Updated Record"}
|
||||
86
backend/routers/patients_files.py
Normal file
86
backend/routers/patients_files.py
Normal file
@@ -0,0 +1,86 @@
|
||||
import mysql.connector
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from pydantic import BaseModel
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
class fileRequest(BaseModel):
|
||||
DocOfficeID: int
|
||||
patientID: int
|
||||
|
||||
def dbConnect():
|
||||
return mysql.connector.connect(
|
||||
host="mysqldb",
|
||||
user="root",
|
||||
passwd="root",
|
||||
database="patient_manager"
|
||||
)
|
||||
|
||||
# Get List of all files
|
||||
@router.get("/files/patients/", tags="patients_files")
|
||||
async def read_all_files():
|
||||
db = dbConnect()
|
||||
cursor = db.cursor()
|
||||
query = "SELECT * FROM patient_files"
|
||||
cursor.execute(query)
|
||||
items = [
|
||||
{
|
||||
"idpatient_files": item[0],
|
||||
"file_path": item[1],
|
||||
"file_name": item[2],
|
||||
"patient_id": item[3],
|
||||
"insert_date": item[4],
|
||||
}
|
||||
for item in cursor.fetchall()
|
||||
]
|
||||
cursor.close()
|
||||
db.close()
|
||||
return items
|
||||
|
||||
# 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()
|
||||
cursor = db.cursor()
|
||||
query = "SELECT * FROM patient_files where patient_id = %s"
|
||||
cursor.execute(query, (patientID,))
|
||||
items = [
|
||||
{
|
||||
"idpatient_files": item[0],
|
||||
"file_path": item[1],
|
||||
"file_name": item[2],
|
||||
"patient_id": item[3],
|
||||
"insert_date": item[4],
|
||||
}
|
||||
for item in cursor.fetchall()
|
||||
]
|
||||
cursor.close()
|
||||
db.close()
|
||||
return items
|
||||
|
||||
# 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()
|
||||
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 "
|
||||
query += "inner join patient_manager.patients "
|
||||
query += "on patient_files.patient_id = patients.idpatients "
|
||||
query += "where patient_files.patient_id = %s and patients.doc_office_id = %s"
|
||||
cursor.execute(query, (itemRequest.patientID, itemRequest.DocOfficeID,))
|
||||
|
||||
items = [
|
||||
{
|
||||
"idpatient_files": item[0],
|
||||
"file_path": item[1],
|
||||
"file_name": item[2],
|
||||
"patient_id": item[3],
|
||||
"insert_date": item[4],
|
||||
"doc_office_id": item[5]
|
||||
}
|
||||
for item in cursor.fetchall()
|
||||
]
|
||||
cursor.close()
|
||||
db.close()
|
||||
return items
|
||||
82
backend/routers/patients_notes.py
Normal file
82
backend/routers/patients_notes.py
Normal file
@@ -0,0 +1,82 @@
|
||||
import mysql.connector
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from pydantic import BaseModel
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
def dbConnect():
|
||||
return mysql.connector.connect(
|
||||
host="mysqldb",
|
||||
user="root",
|
||||
passwd="root",
|
||||
database="patient_manager"
|
||||
)
|
||||
|
||||
class fileRequest(BaseModel):
|
||||
DocOfficeID: int
|
||||
patientID: int
|
||||
|
||||
# Get List of all notes
|
||||
@router.get("/notes/patients/", tags="patients_notes")
|
||||
async def read_all_notes():
|
||||
db = dbConnect()
|
||||
cursor = db.cursor()
|
||||
query = "SELECT * FROM patient_notes"
|
||||
cursor.execute(query)
|
||||
items = [
|
||||
{
|
||||
"idpatient_notes": item[0],
|
||||
"note_name": item[1],
|
||||
"note_text": item[2],
|
||||
"insert_date": item[3],
|
||||
}
|
||||
for item in cursor.fetchall()
|
||||
]
|
||||
cursor.close()
|
||||
db.close()
|
||||
return items
|
||||
|
||||
# Get List of all notes by patient
|
||||
@router.get("/notes/patients/{patientID}", tags="patients_notes")
|
||||
async def read_all_patientsby(patientID: int):
|
||||
db = dbConnect()
|
||||
cursor = db.cursor()
|
||||
query = "SELECT * FROM patient_notes where patient_id = %s"
|
||||
cursor.execute(query, (patientID,))
|
||||
items = [
|
||||
{
|
||||
"idpatient_notes": item[0],
|
||||
"note_name": item[1],
|
||||
"note_text": item[2],
|
||||
"insert_date": item[3],
|
||||
}
|
||||
for item in cursor.fetchall()
|
||||
]
|
||||
cursor.close()
|
||||
db.close()
|
||||
return items
|
||||
|
||||
# Get List of all notes by patient
|
||||
@router.get("/notes/patients-docOffice/", tags="patients_notes")
|
||||
async def read_all_patientsby(itemRequest: fileRequest):
|
||||
db = 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 "
|
||||
query += "inner join patient_manager.patients "
|
||||
query += "on patient_notes.patient_id = patients.idpatients "
|
||||
query += "where patient_notes.patient_id = %s and patients.doc_office_id = %s"
|
||||
cursor.execute(query, (itemRequest.patientID, itemRequest.DocOfficeID,))
|
||||
items = [
|
||||
{
|
||||
"idpatient_notes": item[0],
|
||||
"note_name": item[1],
|
||||
"note_text": item[2],
|
||||
"insert_date": item[3],
|
||||
}
|
||||
for item in cursor.fetchall()
|
||||
]
|
||||
cursor.close()
|
||||
db.close()
|
||||
return items
|
||||
|
||||
Reference in New Issue
Block a user