Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ SECRET_KEY=someCrazyS3cR3T!Key.!
DB_USER=root
DB_HOST=db
DB_PORT=3306
DB_NAME=northwind
DB_NAME=meditrack
MYSQL_ROOT_PASSWORD=<put a good password here>
83 changes: 0 additions & 83 deletions api/backend/customers/customer_routes.py

This file was deleted.

Empty file removed api/backend/ml_models/__init__.py
Empty file.
48 changes: 0 additions & 48 deletions api/backend/ml_models/model01.py

This file was deleted.

57 changes: 57 additions & 0 deletions api/backend/nurses/nurse_routes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
########################################################
# Nurse routes blueprint file
########################################################
from flask import Blueprint
from flask import request
from flask import jsonify
from flask import make_response
from flask import current_app
from backend.db_connection import db

# ------------------------------------------------------------
# Create a new Blueprint object, which is a collection of
# routes.
nurses = Blueprint("nurses", __name__)


# ------------------------------------------------------------
# Get all care tasks from the system
@nurses.route("/care-tasks", methods=["GET"])
def get_care_tasks():
current_app.logger.info("GET /care-tasks route")
cursor = db.get_db().cursor()
cursor.execute(
"""SELECT task_id, task_name, description,
priority, estimated_duration FROM CARE_TASKS"""
)

theData = cursor.fetchall()

the_response = make_response(jsonify(theData))
the_response.status_code = 200
return the_response

# ------------------------------------------------------------
# Add a new patient symptom entry
@nurses.route("/patient-symptoms", methods=["POST"])
def add_patient_symptom():
current_app.logger.info("POST /patient-symptoms route")

data = request.get_json()

patient_id = data.get("patient_id")
symptom_description = data.get("description")
observed_time = data.get("timestamp")

cursor = db.get_db().cursor()
query = """
INSERT INTO PATIENT_SYMPTOMS (patient_id, description, observed_time)
VALUES (%s, %s, %s)
"""
cursor.execute(query, (patient_id, symptom_description, observed_time))
db.get_db().commit()

the_response = make_response(jsonify({"message": "Symptom added"}))
the_response.status_code = 201
return the_response

31 changes: 31 additions & 0 deletions api/backend/nurses/symptoms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import streamlit as st
import requests

st.title("Submit Patient Symptom")

# Input fields
patient_id = st.text_input("Patient ID")
description = st.text_area("Symptom Description")
timestamp = st.text_input("Observed Time (YYYY-MM-DD HH:MM:SS)")

if st.button("Submit Symptom"):
if not patient_id or not description or not timestamp:
st.error("Please fill in all fields.")
else:
data = {
"patient_id": patient_id,
"description": description,
"timestamp": timestamp
}

try:
# External access: make sure the Flask API is running on the host (port 3111)
response = requests.post("http://localhost:3111/patient-symptoms", json=data)

if response.status_code == 201:
st.success("Symptom submitted successfully!")
else:
st.error(f"Error: {response.status_code} - {response.text}")

except Exception as e:
st.error(f"Connection error: {e}")
61 changes: 61 additions & 0 deletions api/backend/pharmacists/pharmacist_routes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
########################################################
# Pharmacist routes blueprint file
########################################################
from flask import Blueprint
from flask import request
from flask import jsonify
from flask import make_response
from flask import current_app
from backend.db_connection import db

# ------------------------------------------------------------
# Create a new Blueprint object, which is a collection of
# routes.
pharmacists = Blueprint("pharmacists", __name__)


# ------------------------------------------------------------
# Get medication history for a specific patient
@pharmacists.route("/medication-records/<patient_id>", methods=["GET"])
def get_medication_records(patient_id):
current_app.logger.info(f"GET /medication-records/{patient_id} route")
cursor = db.get_db().cursor()
cursor.execute(
"""SELECT mr.patient_id, m.medication_name,
mr.dosage, mr.frequency
FROM medication_record mr
JOIN MEDICATIONS m ON mr.medication_id = m.medication_id
WHERE mr.patient_id = {0}""".format(
patient_id
)
)

theData = cursor.fetchall()

the_response = make_response(jsonify(theData))
the_response.status_code = 200
return the_response

# ------------------------------------------------------------
# Update medication dosage/frequency for a given record
@pharmacists.route("/medication-records/<int:record_id>", methods=["PUT"])
def update_medication_record(record_id):
current_app.logger.info(f"PUT /medication-records/{record_id} route")

data = request.get_json()
new_dosage = data.get("dosage")
new_frequency = data.get("frequency")

cursor = db.get_db().cursor()
query = """
UPDATE MEDICATION_RECORD
SET dosage = %s,
frequency = %s
WHERE record_id = %s
"""
cursor.execute(query, (new_dosage, new_frequency, record_id))
db.get_db().commit()

the_response = make_response(jsonify({"message": "Record updated"}))
the_response.status_code = 200
return the_response
25 changes: 25 additions & 0 deletions api/backend/pharmacists/update_med.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import streamlit as st
import requests

st.title("Update Medication Record")

record_id = st.text_input("Medication Record ID")
new_dosage = st.text_input("New Dosage")
new_frequency = st.text_input("New Frequency")

if st.button("Update Record"):
if not record_id or not new_dosage or not new_frequency:
st.error("Please fill in all fields.")
else:
try:
response = requests.put(
f"http://localhost:3111/medication-records/{record_id}",
json={"dosage": new_dosage, "frequency": new_frequency}
)

if response.status_code == 200:
st.success("Medication record updated successfully.")
else:
st.error(f"Error: {response.status_code} - {response.text}")
except Exception as e:
st.error(f"Connection error: {e}")
34 changes: 34 additions & 0 deletions api/backend/physicians/physician_routes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
########################################################
# Physician routes blueprint file
########################################################
from flask import Blueprint
from flask import request
from flask import jsonify
from flask import make_response
from flask import current_app
from backend.db_connection import db

# ------------------------------------------------------------
# Create a new Blueprint object, which is a collection of
# routes.
physicians = Blueprint("physicians", __name__)


# ------------------------------------------------------------
# Get treatment outcomes with effectiveness ratings
@physicians.route("/treatment-outcomes", methods=["GET"])
def get_treatment_outcomes():
current_app.logger.info("GET /treatment-outcomes route")
cursor = db.get_db().cursor()
cursor.execute(
"""SELECT to1.outcome_id, t.treatment_name,
to1.outcome_name, to1.description, to1.is_positive
FROM TREATMENT_OUTCOMES to1
JOIN TREATMENT t ON to1.treatment_id = t.treatment_id"""
)

theData = cursor.fetchall()

the_response = make_response(jsonify(theData))
the_response.status_code = 200
return the_response
Loading