Change to Patient Update and Add Patient Notes Instert & Update
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -145,9 +145,8 @@ async def insertPatient(itemRequest : patientInsertRequest):
|
|||||||
return {"message": "Successfully Created Record"}
|
return {"message": "Successfully Created Record"}
|
||||||
|
|
||||||
# Update Patient on table
|
# Update Patient on table
|
||||||
@router.put("/patients/update/{idpatient}", tags="patients")
|
@router.put("/patients/update/", tags="patients")
|
||||||
async def UpdatePatient(idpatient: int,
|
async def UpdatePatient(itemRequest : patientUpdateRequest):
|
||||||
itemRequest : patientUpdateRequest):
|
|
||||||
db = dbConnect()
|
db = dbConnect()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
query = "update patients "
|
query = "update patients "
|
||||||
@@ -164,7 +163,7 @@ async def UpdatePatient(idpatient: int,
|
|||||||
itemRequest.medical_aid_scheme,
|
itemRequest.medical_aid_scheme,
|
||||||
itemRequest.address,
|
itemRequest.address,
|
||||||
itemRequest.doc_office_id,
|
itemRequest.doc_office_id,
|
||||||
idpatient)
|
itemRequest.idpatients)
|
||||||
try:
|
try:
|
||||||
cursor.execute(query, patientData)
|
cursor.execute(query, patientData)
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
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 datetime import date
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
@@ -16,6 +17,17 @@ class fileRequest(BaseModel):
|
|||||||
DocOfficeID: int
|
DocOfficeID: int
|
||||||
patientID: int
|
patientID: int
|
||||||
|
|
||||||
|
class patientNoteInsertRequest(BaseModel):
|
||||||
|
note_name: str
|
||||||
|
note_text: str
|
||||||
|
patient_id: int
|
||||||
|
|
||||||
|
class patientNoteUpdateRequest(BaseModel):
|
||||||
|
idpatient_notes: int
|
||||||
|
note_name: str
|
||||||
|
note_text: str
|
||||||
|
patient_id: int
|
||||||
|
|
||||||
# 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():
|
async def read_all_notes():
|
||||||
@@ -80,3 +92,49 @@ async def read_all_patientsby(itemRequest: fileRequest):
|
|||||||
db.close()
|
db.close()
|
||||||
return items
|
return items
|
||||||
|
|
||||||
|
# Insert Patient note into table
|
||||||
|
@router.post("/notes/insert/", tags="patients_notes", status_code=201)
|
||||||
|
async def insertPatientNotes(itemRequest : patientNoteInsertRequest):
|
||||||
|
today = date.today()
|
||||||
|
db = dbConnect()
|
||||||
|
cursor = db.cursor()
|
||||||
|
query = "insert into patient_notes "
|
||||||
|
query += "(note_name, note_text, patient_id, insert_date) "
|
||||||
|
query += "values (%s, %s, %s, %s)"
|
||||||
|
notetData = (itemRequest.note_name,
|
||||||
|
itemRequest.note_text,
|
||||||
|
itemRequest.patient_id,
|
||||||
|
today)
|
||||||
|
try:
|
||||||
|
cursor.execute(query, notetData)
|
||||||
|
except Exception as error:
|
||||||
|
#raise HTTPException(status_code=404, detail="Failed to Create Record")
|
||||||
|
return {"message": error}
|
||||||
|
db.commit()
|
||||||
|
cursor.close()
|
||||||
|
db.close()
|
||||||
|
return {"message": "Successfully Created Record"}
|
||||||
|
|
||||||
|
# Update Patient note on table
|
||||||
|
@router.put("/notes/update/", tags="patients_notes")
|
||||||
|
async def UpdatePatient(itemRequest : patientNoteUpdateRequest):
|
||||||
|
today = date.today()
|
||||||
|
db = dbConnect()
|
||||||
|
cursor = db.cursor()
|
||||||
|
query = "update patient_notes "
|
||||||
|
query += "set note_name=%s, note_text=%s, patient_id=%s, insert_date=%s "
|
||||||
|
query += "where idpatient_notes=%s"
|
||||||
|
notetData = (itemRequest.note_name,
|
||||||
|
itemRequest.note_text,
|
||||||
|
itemRequest.patient_id,
|
||||||
|
today,
|
||||||
|
itemRequest.idpatient_notes)
|
||||||
|
try:
|
||||||
|
cursor.execute(query, notetData)
|
||||||
|
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"}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
database/ibdata1
BIN
database/ibdata1
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user