-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
85 lines (69 loc) · 3.12 KB
/
Copy pathapp.py
File metadata and controls
85 lines (69 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
from flask import Flask, render_template, url_for, session, redirect, flash, request
from flask_mysqldb import MySQL, MySQLdb
from user_routes import user_routes # Import the user_routes blueprint
from doctor_routes import doctor_routes # Import the doctor_routes blueprint
from patient_routes import patient_routes # Import the patient_routes blueprint
from insurance_routes import insurance_routes # Import the insurance_routes blueprint
from billing_routes import billing_routes # Import the billing_routes blueprint
from admin_routes import admin_routes # Import the admin_routes blueprint
from datetime import datetime, timedelta
app = Flask(__name__)
app.config['MYSQL_HOST'] = '10.37.1.103'
app.config['MYSQL_USER'] = 'yoyojesus'
app.config['MYSQL_PASSWORD'] = 'veryOkIrTIcA'
app.config['MYSQL_DB'] = 'meditrack'
mysql = MySQL(app)
app.config['mysql'] = mysql
# Enable DictCursor for all queries - helps return results as dictionaries
app.config['MYSQL_CURSORCLASS'] = 'DictCursor'
user_routes.mysql = mysql
app.secret_key = '24932781d8d03f8a7ff6fdff8d8780f1'
# Register the blueprints
app.register_blueprint(user_routes, url_prefix='/user')
app.register_blueprint(doctor_routes)
app.register_blueprint(patient_routes)
app.register_blueprint(insurance_routes, url_prefix='/insurance')
app.register_blueprint(billing_routes)
app.register_blueprint(admin_routes, url_prefix='/admin')
@app.template_filter('format_time_12_hour')
def format_time_12_hour(value):
"""Convert time from 24-hour format (HH:MM:SS) or timedelta to 12-hour format (h:mm AM/PM)."""
try:
if isinstance(value, timedelta):
# Convert timedelta to string in HH:MM:SS format
total_seconds = int(value.total_seconds())
hours = total_seconds // 3600
minutes = (total_seconds % 3600) // 60
value = f"{hours:02}:{minutes:02}:00"
time_obj = datetime.strptime(value, '%H:%M:%S')
return time_obj.strftime('%I:%M %p')
except (ValueError, TypeError):
return value
@app.route('/')
def index():
return render_template('index.html', background_image=url_for('static', filename='background.jpg'))
@app.route('/datacheck')
def show_patients():
# Fetch patients from the meditrack database
cur = mysql.connection.cursor()
cur.execute("SELECT * FROM patient")
patients = cur.fetchall()
cur.close()
# Fetch users from the same database
cur = mysql.connection.cursor()
cur.execute("SELECT id, username, role FROM users")
users = cur.fetchall()
cur.close()
# Fetch doctors from the database
cur = mysql.connection.cursor()
cur.execute("SELECT doctor_id, first_name, last_name, speciality, phone FROM doctor")
doctors = cur.fetchall()
cur.close()
# Fetch insurance providers from the database
cur = mysql.connection.cursor()
cur.execute("SELECT insurance_id, insurance_name, insurance_type, contact_number FROM insurance_provider")
insurances = cur.fetchall()
cur.close()
return render_template('check.html', patients=patients, users=users, doctors=doctors, insurances=insurances)
if __name__ == "__main__":
app.run(debug=True)