Skip to content

Commit cbda8e3

Browse files
author
mounika
committed
update the app
1 parent 4a2abbf commit cbda8e3

2 files changed

Lines changed: 26 additions & 5 deletions

File tree

src/app.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,16 @@ def get_patient_demographics(patient_id, credentials):
4747
birth_date = patient['birthDate']
4848
age = calculate_age(birth_date)
4949
sex = patient['gender']
50-
race = next((extension['valueCodeableConcept']['text']
51-
for extension in patient.get('extension', [])
52-
if extension['url'] == 'http://hl7.org/fhir/StructureDefinition/us-core-race'), 'Not Found')
50+
race = 'Not Found'
51+
52+
# Extract race from extensions
53+
for extension in patient.get('extension', []):
54+
if extension['url'] == 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-race':
55+
for ext in extension.get('extension', []):
56+
if ext['url'] == 'ombCategory':
57+
race = ext['valueCoding']['display']
58+
break
59+
5360
return {'age': age, 'sex': sex, 'race': race}
5461
else:
5562
return {'age': 'Not Found', 'sex': 'Not Found', 'race': 'Not Found'}

src/templates/index.html

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ <h1>ASCVD Risk Calculator</h1>
8181
<form method="post" action="/calculate_risk" class="form-container">
8282
{% if demographics %}
8383
<div class="form-group">
84-
<label>Age:</label>
84+
<label>Age (20-79):</label>
8585
<input type="text" name="age" value="{{ demographics.age if demographics.age != 'Not Found' else '' }}" placeholder="{{ 'Not Found' if demographics.age == 'Not Found' else '' }}" required>
8686
</div>
8787
<div class="form-group">
@@ -97,7 +97,21 @@ <h1>ASCVD Risk Calculator</h1>
9797
{% if observations %}
9898
{% for obs_name, obs_value in observations.items() %}
9999
<div class="form-group">
100-
<label>{{ obs_name }}:</label>
100+
<label>
101+
{% if obs_name == 'Systolic Blood Pressure' %}
102+
Systolic Blood Pressure (90-200 mm Hg):
103+
{% elif obs_name == 'Diastolic Blood Pressure' %}
104+
Diastolic Blood Pressure (60-130 mm Hg):
105+
{% elif obs_name == 'Total Cholesterol' %}
106+
Total Cholesterol (130 - 320 mg/dL):
107+
{% elif obs_name == 'HDL Cholesterol' %}
108+
HDL Cholesterol (20 - 100 mg/dL):
109+
{% elif obs_name == 'LDL Cholesterol' %}
110+
LDL Cholesterol (30-300 mg/dL):
111+
{% else %}
112+
{{ obs_name }}:
113+
{% endif %}
114+
</label>
101115
<input type="text" name="{{ obs_name | replace(' ', '_') | lower }}" value="{{ obs_value if obs_value != 'Not Found' else '' }}" placeholder="{{ 'Not Found' if obs_value == 'Not Found' else '' }}" required>
102116
</div>
103117
{% endfor %}

0 commit comments

Comments
 (0)