add improve dashboard
Browse files- app.py +2 -2
- templates/dashboard.html +6 -1
app.py
CHANGED
@@ -82,11 +82,11 @@ def generate_meldrx_pdf():
|
|
82 |
@app.route('/dashboard', methods=['GET'])
|
83 |
def dashboard():
|
84 |
data = CALLBACK_MANAGER.get_patient_data()
|
85 |
-
if data.startswith('<span'):
|
86 |
return render_template('dashboard.html', error=data)
|
87 |
patients_data = json.loads(data)
|
88 |
patients = [entry['resource'] for entry in patients_data.get('entry', []) if entry['resource'].get('resourceType') == 'Patient']
|
89 |
-
return render_template('dashboard.html', patients=patients)
|
90 |
|
91 |
@app.route('/form', methods=['GET', 'POST'])
|
92 |
def discharge_form():
|
|
|
82 |
@app.route('/dashboard', methods=['GET'])
|
83 |
def dashboard():
|
84 |
data = CALLBACK_MANAGER.get_patient_data()
|
85 |
+
if data.startswith('<span'): # Indicates an error or unauthenticated state
|
86 |
return render_template('dashboard.html', error=data)
|
87 |
patients_data = json.loads(data)
|
88 |
patients = [entry['resource'] for entry in patients_data.get('entry', []) if entry['resource'].get('resourceType') == 'Patient']
|
89 |
+
return render_template('dashboard.html', patients=patients, authenticated=True)
|
90 |
|
91 |
@app.route('/form', methods=['GET', 'POST'])
|
92 |
def discharge_form():
|
templates/dashboard.html
CHANGED
@@ -3,7 +3,10 @@
|
|
3 |
<h2>Patient Data</h2>
|
4 |
{% if error %}
|
5 |
<div>{{ error | safe }}</div>
|
6 |
-
{%
|
|
|
|
|
|
|
7 |
{% for patient in patients %}
|
8 |
<div class="patient-card">
|
9 |
<h4>{{ patient.name[0].given|join(' ') }} {{ patient.name[0].family }}</h4>
|
@@ -12,5 +15,7 @@
|
|
12 |
<p><strong>ID:</strong> {{ patient.id }}</p>
|
13 |
</div>
|
14 |
{% endfor %}
|
|
|
|
|
15 |
{% endif %}
|
16 |
{% endblock %}
|
|
|
3 |
<h2>Patient Data</h2>
|
4 |
{% if error %}
|
5 |
<div>{{ error | safe }}</div>
|
6 |
+
{% if error.startswith("<span style='color:#FF8C00;'>Not authenticated") %}
|
7 |
+
<p>Please <a href="/auth" style="color:#00FFFF; text-shadow: 0 0 3px #00FFFF;">authenticate</a> to view patient data.</p>
|
8 |
+
{% endif %}
|
9 |
+
{% elif authenticated %}
|
10 |
{% for patient in patients %}
|
11 |
<div class="patient-card">
|
12 |
<h4>{{ patient.name[0].given|join(' ') }} {{ patient.name[0].family }}</h4>
|
|
|
15 |
<p><strong>ID:</strong> {{ patient.id }}</p>
|
16 |
</div>
|
17 |
{% endfor %}
|
18 |
+
{% else %}
|
19 |
+
<p>No patient data available. Please <a href="/auth" style="color:#00FFFF; text-shadow: 0 0 3px #00FFFF;">authenticate</a> first.</p>
|
20 |
{% endif %}
|
21 |
{% endblock %}
|