update fastapi to guvicorn and improve supertoken integration
This commit is contained in:
@@ -1,6 +1,32 @@
|
|||||||
FROM python:3.12-slim
|
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.11-slim AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY ./requirements.txt ./
|
COPY requirements.txt ./
|
||||||
RUN pip3 install --no-cache-dir -r requirements.txt
|
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||||
|
pip install -r requirements.txt
|
||||||
|
|
||||||
|
# COPY . ./app
|
||||||
|
|
||||||
|
# FROM builder as dev-envs
|
||||||
|
|
||||||
|
# RUN <<EOF
|
||||||
|
# apt-get update
|
||||||
|
# apt-get install -y --no-install-recommends git
|
||||||
|
# EOF
|
||||||
|
|
||||||
|
# RUN <<EOF
|
||||||
|
# useradd -s /bin/bash -m vscode
|
||||||
|
# groupadd docker
|
||||||
|
# usermod -aG docker vscode
|
||||||
|
# EOF
|
||||||
|
# # install Docker tools (cli, buildx, compose)
|
||||||
|
# COPY --from=gloursdocker/docker / /
|
||||||
|
|
||||||
|
# FROM python:3.12-slim
|
||||||
|
|
||||||
|
# WORKDIR /app
|
||||||
|
|
||||||
|
# COPY ./requirements.txt ./
|
||||||
|
|
||||||
|
# RUN pip3 install --no-cache-dir -r requirements.txt
|
||||||
@@ -1,27 +1,28 @@
|
|||||||
from supertokens_python import init, InputAppInfo, SupertokensConfig
|
# from supertokens_python import init, InputAppInfo, SupertokensConfig
|
||||||
from supertokens_python.recipe import emailpassword, session, dashboard
|
# from supertokens_python.recipe import emailpassword, session, dashboard
|
||||||
|
|
||||||
init(
|
# init(
|
||||||
app_info=InputAppInfo(
|
# app_info=InputAppInfo(
|
||||||
app_name="MIH_API_HUB",
|
# app_name="MIH_API_HUB",
|
||||||
api_domain="http://localhost:8080/",
|
# api_domain="http://localhost:8080/",
|
||||||
website_domain="http://mzansi-innovation-hub.co.za",
|
# website_domain="http://mzansi-innovation-hub.co.za",
|
||||||
api_base_path="/auth",
|
# api_base_path="/auth",
|
||||||
website_base_path="/auth"
|
# website_base_path="/auth"
|
||||||
),
|
# ),
|
||||||
supertokens_config=SupertokensConfig(
|
# supertokens_config=SupertokensConfig(
|
||||||
# https://try.supertokens.com is for demo purposes. Replace this with the address of your core instance (sign up on supertokens.com), or self host a core.
|
# # https://try.supertokens.com is for demo purposes. Replace this with the address of your core instance (sign up on supertokens.com), or self host a core.
|
||||||
connection_uri="http://MIH-SuperTokens:3567/",
|
# connection_uri="supertokens:3567/",
|
||||||
api_key="leatucczyixqwkqqdrhayiwzeofkltds"
|
# api_key="leatucczyixqwkqqdrhayiwzeofkltds"
|
||||||
),
|
# ),
|
||||||
framework='fastapi',
|
# framework='fastapi',
|
||||||
recipe_list=[
|
# recipe_list=[
|
||||||
session.init(), # initializes session features
|
# # SuperTokens.init(),
|
||||||
emailpassword.init(),
|
# session.init(), # initializes session features
|
||||||
dashboard.init(admins=[
|
# emailpassword.init(),
|
||||||
"yasienmeth@gmail.com",
|
# dashboard.init(admins=[
|
||||||
],
|
# "yasienmeth@gmail.com",
|
||||||
)
|
# ],
|
||||||
],
|
# )
|
||||||
mode='asgi' # use wsgi if you are running using gunicorn
|
# ],
|
||||||
)
|
# mode='wsgi' # use wsgi instead of asgi if you are running using gunicorn
|
||||||
|
# )
|
||||||
@@ -1,21 +1,22 @@
|
|||||||
from fastapi import FastAPI, HTTPException
|
from fastapi import FastAPI, HTTPException
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from .routers import docOffices, patients, patients_files, patients_notes, users, fileStorage, medicine
|
# from .routers import docOffices, patients, patients_files, patients_notes, users, fileStorage, medicine
|
||||||
|
import routers.docOffices as docOffices
|
||||||
|
import routers.patients as patients
|
||||||
|
import routers.patients_files as patients_files
|
||||||
|
import routers.patients_notes as patients_notes
|
||||||
|
import routers.users as users
|
||||||
|
import routers.fileStorage as fileStorage
|
||||||
|
import routers.medicine as medicine
|
||||||
|
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
from fastapi.middleware import Middleware
|
from fastapi.middleware import Middleware
|
||||||
from supertokens_python import get_all_cors_headers
|
from supertokens_python import get_all_cors_headers
|
||||||
from supertokens_python.framework.fastapi import get_middleware
|
from supertokens_python.framework.fastapi import get_middleware
|
||||||
from supertokens_python.recipe.session.framework.fastapi import verify_session
|
|
||||||
from supertokens_python.recipe.session import SessionContainer
|
|
||||||
from fastapi import Depends
|
|
||||||
|
|
||||||
from supertokens_python.recipe.session.framework.fastapi import verify_session
|
from supertokens_python import init, InputAppInfo, SupertokensConfig
|
||||||
from supertokens_python.recipe.thirdparty.asyncio import (
|
from supertokens_python.recipe import emailpassword, session, dashboard
|
||||||
get_user_by_id as get_user_by_id_thirdparty,
|
|
||||||
)
|
|
||||||
from supertokens_python.recipe.passwordless.asyncio import (
|
|
||||||
get_user_by_id as get_user_by_id_passwordless,
|
|
||||||
)
|
|
||||||
|
|
||||||
origins = [
|
origins = [
|
||||||
"http://localhost",
|
"http://localhost",
|
||||||
@@ -27,15 +28,31 @@ origins = [
|
|||||||
"*",
|
"*",
|
||||||
]
|
]
|
||||||
|
|
||||||
# middleware = [
|
init(
|
||||||
# Middleware(
|
app_info=InputAppInfo(
|
||||||
# CORSMiddleware,
|
app_name="MIH_API_HUB",
|
||||||
# allow_origins=origins,
|
api_domain="http://localhost:8080/",
|
||||||
# allow_credentials=True,
|
website_domain="http://mzansi-innovation-hub.co.za",
|
||||||
# allow_methods=["GET", "PUT", "POST", "DELETE", "OPTIONS", "PATCH"],
|
api_base_path="/auth",
|
||||||
# allow_headers=["Content-Type"] + get_all_cors_headers(),
|
website_base_path="/auth"
|
||||||
# )
|
),
|
||||||
# ]
|
supertokens_config=SupertokensConfig(
|
||||||
|
# https://try.supertokens.com is for demo purposes. Replace this with the address of your core instance (sign up on supertokens.com), or self host a core.
|
||||||
|
connection_uri="http://MIH-SuperTokens:3567/",
|
||||||
|
api_key="leatucczyixqwkqqdrhayiwzeofkltds"
|
||||||
|
),
|
||||||
|
framework='fastapi',
|
||||||
|
recipe_list=[
|
||||||
|
# SuperTokens.init(),
|
||||||
|
session.init(), # initializes session features
|
||||||
|
emailpassword.init(),
|
||||||
|
dashboard.init(admins=[
|
||||||
|
"yasienmeth@gmail.com",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
mode='wsgi' # use wsgi instead of asgi if you are running using gunicorn
|
||||||
|
)
|
||||||
|
|
||||||
app = FastAPI()#middleware=middleware)
|
app = FastAPI()#middleware=middleware)
|
||||||
app.add_middleware(get_middleware())
|
app.add_middleware(get_middleware())
|
||||||
@@ -81,6 +98,6 @@ def read_root():
|
|||||||
# print(thirdparty_user)
|
# print(thirdparty_user)
|
||||||
|
|
||||||
def serverRunning():
|
def serverRunning():
|
||||||
return {"Status": "Server is Up and Running"}
|
return {"Status": "Server is Up and Running. whats good in the hood"}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ mysql-connector-python
|
|||||||
minio
|
minio
|
||||||
reportlab
|
reportlab
|
||||||
requests
|
requests
|
||||||
watchfiles==0.21.0
|
watchfiles
|
||||||
python-multipart
|
python-multipart
|
||||||
xlrd
|
xlrd
|
||||||
supertokens-python
|
supertokens-python
|
||||||
@@ -1,17 +1,20 @@
|
|||||||
import mysql.connector
|
import mysql.connector
|
||||||
from fastapi import APIRouter, HTTPException
|
from fastapi import APIRouter, HTTPException
|
||||||
from ..database import dbConnection
|
#from ..database import dbConnection
|
||||||
|
import database
|
||||||
#SuperToken Auth from front end
|
#SuperToken Auth from front end
|
||||||
from supertokens_python.recipe.session.framework.fastapi import verify_session
|
from supertokens_python.recipe.session.framework.fastapi import verify_session
|
||||||
from supertokens_python.recipe.session import SessionContainer
|
from supertokens_python.recipe.session import SessionContainer
|
||||||
from fastapi import Depends
|
from fastapi import Depends
|
||||||
|
|
||||||
|
import database.dbConnection
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
# Get Doctors Office By ID
|
# Get Doctors Office By ID
|
||||||
@router.get("/docOffices/{docOffic_id}", tags="DocOffice")
|
@router.get("/docOffices/{docOffic_id}", tags="DocOffice")
|
||||||
async def read_docOfficeByID(docOffic_id: int, session: SessionContainer = Depends(verify_session())):
|
async def read_docOfficeByID(docOffic_id: int, session: SessionContainer = Depends(verify_session())):
|
||||||
db = dbConnection.dbConnect()
|
db = database.dbConnection.dbConnect()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
query = "SELECT * FROM doctor_offices WHERE iddoctor_offices=%s"
|
query = "SELECT * FROM doctor_offices WHERE iddoctor_offices=%s"
|
||||||
cursor.execute(query, (docOffic_id,))
|
cursor.execute(query, (docOffic_id,))
|
||||||
@@ -26,7 +29,7 @@ async def read_docOfficeByID(docOffic_id: int, session: SessionContainer = Depen
|
|||||||
# Get Doctors Office By user
|
# Get Doctors Office By user
|
||||||
@router.get("/docOffices/user/{user}", tags="DocOffice")
|
@router.get("/docOffices/user/{user}", tags="DocOffice")
|
||||||
async def read_docOfficeByID(user: str, session: SessionContainer = Depends(verify_session())):
|
async def read_docOfficeByID(user: str, session: SessionContainer = Depends(verify_session())):
|
||||||
db = dbConnection.dbConnect()
|
db = database.dbConnection.dbConnect()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
query = "SELECT * FROM users WHERE email=%s"
|
query = "SELECT * FROM users WHERE email=%s"
|
||||||
cursor.execute(query, (user,))
|
cursor.execute(query, (user,))
|
||||||
@@ -47,7 +50,7 @@ async def read_docOfficeByID(user: str, session: SessionContainer = Depends(veri
|
|||||||
# Get List of all Doctors Office
|
# Get List of all Doctors Office
|
||||||
@router.get("/docOffices/", tags="DocOffice")
|
@router.get("/docOffices/", tags="DocOffice")
|
||||||
async def read_All_DoctorsOffice(session: SessionContainer = Depends(verify_session())):
|
async def read_All_DoctorsOffice(session: SessionContainer = Depends(verify_session())):
|
||||||
db = dbConnection.dbConnect()
|
db = database.dbConnection.dbConnect()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
query = "SELECT * FROM doctor_offices"
|
query = "SELECT * FROM doctor_offices"
|
||||||
cursor.execute(query)
|
cursor.execute(query)
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import mysql.connector
|
import mysql.connector
|
||||||
from fastapi import APIRouter, HTTPException
|
from fastapi import APIRouter, HTTPException
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from ..database import dbConnection
|
#from ..database import dbConnection
|
||||||
|
import database
|
||||||
#SuperToken Auth from front end
|
#SuperToken Auth from front end
|
||||||
from supertokens_python.recipe.session.framework.fastapi import verify_session
|
from supertokens_python.recipe.session.framework.fastapi import verify_session
|
||||||
from supertokens_python.recipe.session import SessionContainer
|
from supertokens_python.recipe.session import SessionContainer
|
||||||
@@ -46,7 +47,7 @@ class patientDeleteRequest(BaseModel):
|
|||||||
# Get Patient By ID Number
|
# Get Patient By ID Number
|
||||||
@router.get("/patients/id/{pat_id}", tags="patients")
|
@router.get("/patients/id/{pat_id}", tags="patients")
|
||||||
async def read_patientByID(pat_id: str, session: SessionContainer = Depends(verify_session())):
|
async def read_patientByID(pat_id: str, session: SessionContainer = Depends(verify_session())):
|
||||||
db = dbConnection.dbConnect()
|
db = database.dbConnection.dbConnect()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
query = "SELECT * FROM patients WHERE idpatients=%s"
|
query = "SELECT * FROM patients WHERE idpatients=%s"
|
||||||
cursor.execute(query, (pat_id,))
|
cursor.execute(query, (pat_id,))
|
||||||
@@ -71,7 +72,7 @@ async def read_patientByID(pat_id: str, session: SessionContainer = Depends(veri
|
|||||||
# Get Patient By ID Number
|
# Get Patient By ID Number
|
||||||
@router.get("/patients/{id_no}", tags="patients")
|
@router.get("/patients/{id_no}", tags="patients")
|
||||||
async def read_patientByID(id_no: str):
|
async def read_patientByID(id_no: str):
|
||||||
db = dbConnection.dbConnect()
|
db = database.dbConnection.dbConnect()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
query = "SELECT * FROM patients WHERE id_no=%s"
|
query = "SELECT * FROM patients WHERE id_no=%s"
|
||||||
cursor.execute(query, (id_no,))
|
cursor.execute(query, (id_no,))
|
||||||
@@ -95,7 +96,7 @@ async def read_patientByID(id_no: str):
|
|||||||
# Get List of all patients
|
# Get List of all patients
|
||||||
@router.get("/patients/user/{email}", tags="patients")
|
@router.get("/patients/user/{email}", tags="patients")
|
||||||
async def read_all_patientsByUser(email: str, session: SessionContainer = Depends(verify_session())):
|
async def read_all_patientsByUser(email: str, session: SessionContainer = Depends(verify_session())):
|
||||||
db = dbConnection.dbConnect()
|
db = database.dbConnection.dbConnect()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
#query = "SELECT * FROM patients"
|
#query = "SELECT * FROM patients"
|
||||||
query = "Select * from patients "
|
query = "Select * from patients "
|
||||||
@@ -129,7 +130,7 @@ async def read_all_patientsByUser(email: str, session: SessionContainer = Depend
|
|||||||
# Get List of all patients
|
# Get List of all patients
|
||||||
@router.get("/patients/", tags="patients")
|
@router.get("/patients/", tags="patients")
|
||||||
async def read_all_patients(session: SessionContainer = Depends(verify_session())):
|
async def read_all_patients(session: SessionContainer = Depends(verify_session())):
|
||||||
db = dbConnection.dbConnect()
|
db = database.dbConnection.dbConnect()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
query = "SELECT * FROM patients"
|
query = "SELECT * FROM patients"
|
||||||
cursor.execute(query)
|
cursor.execute(query)
|
||||||
@@ -156,7 +157,7 @@ async def read_all_patients(session: SessionContainer = Depends(verify_session()
|
|||||||
# Get List of all patients by Doctors Office
|
# Get List of all patients by Doctors Office
|
||||||
@router.get("/patients/docOffice/{docoff_id}", tags="patients")
|
@router.get("/patients/docOffice/{docoff_id}", tags="patients")
|
||||||
async def read_all_patientsby(docoff_id: str, session: SessionContainer = Depends(verify_session())):
|
async def read_all_patientsby(docoff_id: str, session: SessionContainer = Depends(verify_session())):
|
||||||
db = dbConnection.dbConnect()
|
db = database.dbConnection.dbConnect()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
query = "SELECT * FROM patients where doc_office_id=%s"
|
query = "SELECT * FROM patients where doc_office_id=%s"
|
||||||
cursor.execute(query, (docoff_id,))
|
cursor.execute(query, (docoff_id,))
|
||||||
@@ -183,7 +184,7 @@ async def read_all_patientsby(docoff_id: str, session: SessionContainer = Depend
|
|||||||
# Insert Patient into table
|
# Insert Patient into table
|
||||||
@router.post("/patients/insert/", tags="patients", status_code=201)
|
@router.post("/patients/insert/", tags="patients", status_code=201)
|
||||||
async def insertPatient(itemRequest : patientInsertRequest, session: SessionContainer = Depends(verify_session())):
|
async def insertPatient(itemRequest : patientInsertRequest, session: SessionContainer = Depends(verify_session())):
|
||||||
db = dbConnection.dbConnect()
|
db = database.dbConnection.dbConnect()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
query = "insert into patients "
|
query = "insert into patients "
|
||||||
query += "(id_no, first_name, last_name, email, cell_no, medical_aid, "
|
query += "(id_no, first_name, last_name, email, cell_no, medical_aid, "
|
||||||
@@ -216,7 +217,7 @@ async def insertPatient(itemRequest : patientInsertRequest, session: SessionCont
|
|||||||
# Update Patient on table
|
# Update Patient on table
|
||||||
@router.put("/patients/update/", tags="patients")
|
@router.put("/patients/update/", tags="patients")
|
||||||
async def UpdatePatient(itemRequest : patientUpdateRequest, session: SessionContainer = Depends(verify_session())):
|
async def UpdatePatient(itemRequest : patientUpdateRequest, session: SessionContainer = Depends(verify_session())):
|
||||||
db = dbConnection.dbConnect()
|
db = database.dbConnection.dbConnect()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
query = "update patients "
|
query = "update patients "
|
||||||
query += "set id_no=%s, first_name=%s, last_name=%s, email=%s, cell_no=%s, medical_aid=%s, "
|
query += "set id_no=%s, first_name=%s, last_name=%s, email=%s, cell_no=%s, medical_aid=%s, "
|
||||||
@@ -251,7 +252,7 @@ async def UpdatePatient(itemRequest : patientUpdateRequest, session: SessionCont
|
|||||||
# delete Patient on table
|
# delete Patient on table
|
||||||
@router.delete("/patients/delete/", tags="patients")
|
@router.delete("/patients/delete/", tags="patients")
|
||||||
async def DeletePatient(itemRequest : patientDeleteRequest, session: SessionContainer = Depends(verify_session())):
|
async def DeletePatient(itemRequest : patientDeleteRequest, session: SessionContainer = Depends(verify_session())):
|
||||||
db = dbConnection.dbConnect()
|
db = database.dbConnection.dbConnect()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
query = "delete from patients "
|
query = "delete from patients "
|
||||||
query += "where id_no=%s and doc_office_id=%s"
|
query += "where id_no=%s and doc_office_id=%s"
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import mysql.connector
|
import mysql.connector
|
||||||
from fastapi import APIRouter, HTTPException
|
from fastapi import APIRouter, HTTPException
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from ..database import dbConnection
|
#from ..database import dbConnection
|
||||||
|
import database
|
||||||
from datetime import date
|
from datetime import date
|
||||||
#SuperToken Auth from front end
|
#SuperToken Auth from front end
|
||||||
from supertokens_python.recipe.session.framework.fastapi import verify_session
|
from supertokens_python.recipe.session.framework.fastapi import verify_session
|
||||||
@@ -22,7 +23,7 @@ class fileInsertRequest(BaseModel):
|
|||||||
# Get List of all files
|
# Get List of all files
|
||||||
@router.get("/files/patients/", tags="patients_files")
|
@router.get("/files/patients/", tags="patients_files")
|
||||||
async def read_all_files(session: SessionContainer = Depends(verify_session())):
|
async def read_all_files(session: SessionContainer = Depends(verify_session())):
|
||||||
db = dbConnection.dbConnect()
|
db = database.dbConnection.dbConnect()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
query = "SELECT * FROM patient_files"
|
query = "SELECT * FROM patient_files"
|
||||||
cursor.execute(query)
|
cursor.execute(query)
|
||||||
@@ -43,7 +44,7 @@ async def read_all_files(session: SessionContainer = Depends(verify_session())):
|
|||||||
# Get List of all files by patient
|
# Get List of all files by patient
|
||||||
@router.get("/files/patients/{patientID}", tags="patients_files")
|
@router.get("/files/patients/{patientID}", tags="patients_files")
|
||||||
async def read_all_files_by_patient(patientID: int, session: SessionContainer = Depends(verify_session())):
|
async def read_all_files_by_patient(patientID: int, session: SessionContainer = Depends(verify_session())):
|
||||||
db = dbConnection.dbConnect()
|
db = database.dbConnection.dbConnect()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
query = "SELECT * FROM patient_files where patient_id = %s ORDER BY insert_date DESC"
|
query = "SELECT * FROM patient_files where patient_id = %s ORDER BY insert_date DESC"
|
||||||
cursor.execute(query, (patientID,))
|
cursor.execute(query, (patientID,))
|
||||||
@@ -64,7 +65,7 @@ async def read_all_files_by_patient(patientID: int, session: SessionContainer =
|
|||||||
# Get List of all files by patient & DocOffice
|
# Get List of all files by patient & DocOffice
|
||||||
@router.get("/files/patients-docOffice/", tags="patients_files")
|
@router.get("/files/patients-docOffice/", tags="patients_files")
|
||||||
async def read_all_files_by_patient(itemRequest: fileRequest, session: SessionContainer = Depends(verify_session())):
|
async def read_all_files_by_patient(itemRequest: fileRequest, session: SessionContainer = Depends(verify_session())):
|
||||||
db = dbConnection.dbConnect()
|
db = database.dbConnection.dbConnect()
|
||||||
cursor = db.cursor()
|
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 = "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 += "from patient_manager.patient_files "
|
||||||
@@ -92,7 +93,7 @@ async def read_all_files_by_patient(itemRequest: fileRequest, session: SessionCo
|
|||||||
@router.post("/files/insert/", tags="patients_notes", status_code=201)
|
@router.post("/files/insert/", tags="patients_notes", status_code=201)
|
||||||
async def insertPatientFiles(itemRequest : fileInsertRequest, session: SessionContainer = Depends(verify_session())):
|
async def insertPatientFiles(itemRequest : fileInsertRequest, session: SessionContainer = Depends(verify_session())):
|
||||||
today = date.today()
|
today = date.today()
|
||||||
db = dbConnection.dbConnect()
|
db = database.dbConnection.dbConnect()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
query = "insert into patient_files "
|
query = "insert into patient_files "
|
||||||
query += "(file_path, file_name, patient_id, insert_date) "
|
query += "(file_path, file_name, patient_id, insert_date) "
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ import mysql.connector
|
|||||||
from fastapi import APIRouter, HTTPException
|
from fastapi import APIRouter, HTTPException
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from datetime import date
|
from datetime import date
|
||||||
from ..database import dbConnection
|
#from ..database import dbConnection
|
||||||
|
import database
|
||||||
#SuperToken Auth from front end
|
#SuperToken Auth from front end
|
||||||
from supertokens_python.recipe.session.framework.fastapi import verify_session
|
from supertokens_python.recipe.session.framework.fastapi import verify_session
|
||||||
from supertokens_python.recipe.session import SessionContainer
|
from supertokens_python.recipe.session import SessionContainer
|
||||||
@@ -28,7 +29,7 @@ class patientNoteUpdateRequest(BaseModel):
|
|||||||
# Get List of all notes
|
# Get List of all notes
|
||||||
@router.get("/notes/patients/", tags="patients_notes")
|
@router.get("/notes/patients/", tags="patients_notes")
|
||||||
async def read_all_notes(session: SessionContainer = Depends(verify_session())):
|
async def read_all_notes(session: SessionContainer = Depends(verify_session())):
|
||||||
db = dbConnection.dbConnect()
|
db = database.dbConnection.dbConnect()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
query = "SELECT * FROM patient_notes"
|
query = "SELECT * FROM patient_notes"
|
||||||
cursor.execute(query)
|
cursor.execute(query)
|
||||||
@@ -48,7 +49,7 @@ async def read_all_notes(session: SessionContainer = Depends(verify_session())):
|
|||||||
# Get List of all notes by patient
|
# Get List of all notes by patient
|
||||||
@router.get("/notes/patients/{patientID}", tags="patients_notes")
|
@router.get("/notes/patients/{patientID}", tags="patients_notes")
|
||||||
async def read_all_patientsby(patientID: int, session: SessionContainer = Depends(verify_session())):
|
async def read_all_patientsby(patientID: int, session: SessionContainer = Depends(verify_session())):
|
||||||
db = dbConnection.dbConnect()
|
db = database.dbConnection.dbConnect()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
query = "SELECT * FROM patient_notes where patient_id = %s ORDER BY insert_date DESC"
|
query = "SELECT * FROM patient_notes where patient_id = %s ORDER BY insert_date DESC"
|
||||||
cursor.execute(query, (patientID,))
|
cursor.execute(query, (patientID,))
|
||||||
@@ -69,7 +70,7 @@ async def read_all_patientsby(patientID: int, session: SessionContainer = Depend
|
|||||||
# Get List of all notes by patient
|
# Get List of all notes by patient
|
||||||
@router.get("/notes/patients-docOffice/", tags="patients_notes")
|
@router.get("/notes/patients-docOffice/", tags="patients_notes")
|
||||||
async def read_all_patientsby(itemRequest: fileRequest, session: SessionContainer = Depends(verify_session())):
|
async def read_all_patientsby(itemRequest: fileRequest, session: SessionContainer = Depends(verify_session())):
|
||||||
db = dbConnection.dbConnect()
|
db = database.dbConnection.dbConnect()
|
||||||
cursor = db.cursor()
|
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 = "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 += "from patient_manager.patient_notes "
|
||||||
@@ -94,7 +95,7 @@ async def read_all_patientsby(itemRequest: fileRequest, session: SessionContaine
|
|||||||
@router.post("/notes/insert/", tags="patients_notes", status_code=201)
|
@router.post("/notes/insert/", tags="patients_notes", status_code=201)
|
||||||
async def insertPatientNotes(itemRequest : patientNoteInsertRequest, session: SessionContainer = Depends(verify_session())):
|
async def insertPatientNotes(itemRequest : patientNoteInsertRequest, session: SessionContainer = Depends(verify_session())):
|
||||||
today = date.today()
|
today = date.today()
|
||||||
db = dbConnection.dbConnect()
|
db = database.dbConnection.dbConnect()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
query = "insert into patient_notes "
|
query = "insert into patient_notes "
|
||||||
query += "(note_name, note_text, patient_id, insert_date) "
|
query += "(note_name, note_text, patient_id, insert_date) "
|
||||||
@@ -117,7 +118,7 @@ async def insertPatientNotes(itemRequest : patientNoteInsertRequest, session: Se
|
|||||||
@router.put("/notes/update/", tags="patients_notes")
|
@router.put("/notes/update/", tags="patients_notes")
|
||||||
async def UpdatePatient(itemRequest : patientNoteUpdateRequest, session: SessionContainer = Depends(verify_session())):
|
async def UpdatePatient(itemRequest : patientNoteUpdateRequest, session: SessionContainer = Depends(verify_session())):
|
||||||
today = date.today()
|
today = date.today()
|
||||||
db = dbConnection.dbConnect()
|
db = database.dbConnection.dbConnect()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
query = "update patient_notes "
|
query = "update patient_notes "
|
||||||
query += "set note_name=%s, note_text=%s, patient_id=%s, insert_date=%s "
|
query += "set note_name=%s, note_text=%s, patient_id=%s, insert_date=%s "
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from fastapi import APIRouter, HTTPException
|
from fastapi import APIRouter, HTTPException
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from ..database import dbConnection
|
#from ..database import dbConnection
|
||||||
|
import database
|
||||||
#SuperToken Auth from front end
|
#SuperToken Auth from front end
|
||||||
from supertokens_python.recipe.session.framework.fastapi import verify_session
|
from supertokens_python.recipe.session.framework.fastapi import verify_session
|
||||||
from supertokens_python.recipe.session import SessionContainer
|
from supertokens_python.recipe.session import SessionContainer
|
||||||
@@ -25,7 +26,7 @@ class userUpdateRequest(BaseModel):
|
|||||||
#get user by email & doc Office ID
|
#get user by email & doc Office ID
|
||||||
@router.get("/users/profile/{email}", tags="users")
|
@router.get("/users/profile/{email}", tags="users")
|
||||||
async def read_all_users(email: str, session: SessionContainer = Depends(verify_session())):
|
async def read_all_users(email: str, session: SessionContainer = Depends(verify_session())):
|
||||||
db = dbConnection.dbConnect()
|
db = database.dbConnection.dbConnect()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
query = "SELECT * FROM users where email = %s"
|
query = "SELECT * FROM users where email = %s"
|
||||||
cursor.execute(query, (email.lower(),))
|
cursor.execute(query, (email.lower(),))
|
||||||
@@ -49,7 +50,7 @@ async def read_all_users(email: str, session: SessionContainer = Depends(verify_
|
|||||||
# Get List of all files
|
# Get List of all files
|
||||||
@router.get("/users/", tags="users")
|
@router.get("/users/", tags="users")
|
||||||
async def read_all_users(session: SessionContainer = Depends(verify_session())):
|
async def read_all_users(session: SessionContainer = Depends(verify_session())):
|
||||||
db = dbConnection.dbConnect()
|
db = database.dbConnection.dbConnect()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
query = "SELECT * FROM users"
|
query = "SELECT * FROM users"
|
||||||
cursor.execute(query)
|
cursor.execute(query)
|
||||||
@@ -73,7 +74,7 @@ async def read_all_users(session: SessionContainer = Depends(verify_session())):
|
|||||||
# Get List of all files
|
# Get List of all files
|
||||||
@router.get("/user/{uid}", tags="users")
|
@router.get("/user/{uid}", tags="users")
|
||||||
async def read_all_users(uid: str, session: SessionContainer = Depends(verify_session())):
|
async def read_all_users(uid: str, session: SessionContainer = Depends(verify_session())):
|
||||||
db = dbConnection.dbConnect()
|
db = database.dbConnection.dbConnect()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
query = "SELECT * FROM users where app_id = %s"
|
query = "SELECT * FROM users where app_id = %s"
|
||||||
cursor.execute(query, (uid,))
|
cursor.execute(query, (uid,))
|
||||||
@@ -97,7 +98,7 @@ async def read_all_users(uid: str, session: SessionContainer = Depends(verify_se
|
|||||||
# Insert Patient into table
|
# Insert Patient into table
|
||||||
@router.post("/user/insert/", tags="user", status_code=201)
|
@router.post("/user/insert/", tags="user", status_code=201)
|
||||||
async def insertPatient(itemRequest : userInsertRequest, session: SessionContainer = Depends(verify_session())):
|
async def insertPatient(itemRequest : userInsertRequest, session: SessionContainer = Depends(verify_session())):
|
||||||
db = dbConnection.dbConnect()
|
db = database.dbConnection.dbConnect()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
query = "insert into users "
|
query = "insert into users "
|
||||||
query += "(email, docOffice_id, fname, lname, type, app_id, username) "
|
query += "(email, docOffice_id, fname, lname, type, app_id, username) "
|
||||||
@@ -117,7 +118,7 @@ async def insertPatient(itemRequest : userInsertRequest, session: SessionContain
|
|||||||
# Update User on table
|
# Update User on table
|
||||||
@router.put("/user/update/", tags="user")
|
@router.put("/user/update/", tags="user")
|
||||||
async def UpdateUser(itemRequest : userUpdateRequest, session: SessionContainer = Depends(verify_session())):
|
async def UpdateUser(itemRequest : userUpdateRequest, session: SessionContainer = Depends(verify_session())):
|
||||||
db = dbConnection.dbConnect()
|
db = database.dbConnection.dbConnect()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
query = "update users "
|
query = "update users "
|
||||||
query += "set username=%s, fname=%s, lname=%s "
|
query += "set username=%s, fname=%s, lname=%s "
|
||||||
|
|||||||
@@ -1,13 +1,19 @@
|
|||||||
services:
|
services:
|
||||||
#============== API Hub ====================================================================
|
#============== API Hub ====================================================================
|
||||||
api:
|
api:
|
||||||
build: ./backend/
|
build:
|
||||||
|
context: ./backend
|
||||||
|
target: builder
|
||||||
container_name: MIH-API-Hub
|
container_name: MIH-API-Hub
|
||||||
command: sh -c "sleep 10s; uvicorn backend.main:app --reload --port=8080 --host=0.0.0.0"
|
#command: sh -c "sleep 10s; uvicorn backend.main:app --reload --port=8080 --host=0.0.0.0"
|
||||||
|
#============Dev=================
|
||||||
|
# command: sh -c "sleep 10s; fastapi dev main.py --port 8080"
|
||||||
|
#============prod=================
|
||||||
|
#command: sh -c "sleep 10s; fastapi run backend/main.py --proxy-headers --port 8080"
|
||||||
ports:
|
ports:
|
||||||
- 8080:8080
|
- 8080:80
|
||||||
volumes:
|
volumes:
|
||||||
- .:/app
|
- ./backend:/app
|
||||||
networks:
|
networks:
|
||||||
- MIH-network
|
- MIH-network
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|||||||
Reference in New Issue
Block a user