Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -9,57 +9,72 @@ Prompt:
|
|
9 |
Write a streamlit python program that uses the python hl7 library to render a clinical terminology based assessment with LOINC, ICD10, CPT, and SNOMED code types and codes for an assessment user interface that asks four questions: 1) Choose a Gender (M/F), 2) Choose an age group ["Age0to18","Age19to44","Age44to64","Age64to84", "Age85andOver"], 3) What is the diastolic blood pressure?, 4) What is the systolic blood pressure? For the interface have user controls on the sidebar. In the center area have a text file named FHIR-ASMT.csv store the fields each time the user submits using a button labeled Save. Each time reload the file and show it as a table in the center area. Instrument the questions and answers with their corresponding clinical terminology type and code. If the file is not created yet on reading it, create the file as an empty CSV with just the column headers in CSV format. Include a python list dictionary with the map of the clinical terminology code types and codes for each question and the overall blood pressure clinical terminology code type and codes.
|
10 |
""")
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
#
|
20 |
clinical_terminology_map = {
|
21 |
-
'gender': {'LOINC':
|
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 |
else:
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
writer.writerow(['Gender', 'Age Group', 'Diastolic BP', 'Systolic BP',
|
53 |
-
'Gender Code Type', 'Gender Code',
|
54 |
-
'Age Group Code Type', 'Age Group Code',
|
55 |
-
'Diastolic BP Code Type', 'Diastolic BP Code',
|
56 |
-
'Systolic BP Code Type', 'Systolic BP Code',
|
57 |
-
'Blood Pressure Code Type', 'Blood Pressure Code'])
|
58 |
-
|
59 |
-
# Read and display the CSV file
|
60 |
-
if os.path.exists('FHIR-ASMT.csv'):
|
61 |
-
with open('FHIR-ASMT.csv', 'r') as f:
|
62 |
-
reader = csv.reader(f)
|
63 |
-
data = list(reader)
|
64 |
-
if len(data) > 1:
|
65 |
-
st.dataframe(data[1:], data[0])
|
|
|
9 |
Write a streamlit python program that uses the python hl7 library to render a clinical terminology based assessment with LOINC, ICD10, CPT, and SNOMED code types and codes for an assessment user interface that asks four questions: 1) Choose a Gender (M/F), 2) Choose an age group ["Age0to18","Age19to44","Age44to64","Age64to84", "Age85andOver"], 3) What is the diastolic blood pressure?, 4) What is the systolic blood pressure? For the interface have user controls on the sidebar. In the center area have a text file named FHIR-ASMT.csv store the fields each time the user submits using a button labeled Save. Each time reload the file and show it as a table in the center area. Instrument the questions and answers with their corresponding clinical terminology type and code. If the file is not created yet on reading it, create the file as an empty CSV with just the column headers in CSV format. Include a python list dictionary with the map of the clinical terminology code types and codes for each question and the overall blood pressure clinical terminology code type and codes.
|
10 |
""")
|
11 |
|
12 |
+
|
13 |
+
|
14 |
+
|
15 |
+
import streamlit as st
|
16 |
+
import pandas as pd
|
17 |
+
import hl7
|
18 |
+
|
19 |
+
# Define the clinical terminology map
|
20 |
clinical_terminology_map = {
|
21 |
+
'gender': {'LOINC': '76690-1', 'code_system': 'http://loinc.org'},
|
22 |
+
'age': {'LOINC': '21840-4', 'code_system': 'http://loinc.org'},
|
23 |
+
'diastolic_blood_pressure': {'SNOMED-CT': '16303008', 'code_system': 'http://snomed.info/sct'},
|
24 |
+
'systolic_blood_pressure': {'SNOMED-CT': '271649006', 'code_system': 'http://snomed.info/sct'},
|
25 |
+
'blood_pressure': {'LOINC': '85354-9', 'code_system': 'http://loinc.org'}
|
26 |
}
|
27 |
|
28 |
+
# Define a function to read the data from the CSV file
|
29 |
+
def read_data():
|
30 |
+
try:
|
31 |
+
df = pd.read_csv('FHIR-ASMT.csv')
|
32 |
+
except FileNotFoundError:
|
33 |
+
df = pd.DataFrame(columns=['Gender', 'Age', 'Diastolic Blood Pressure', 'Systolic Blood Pressure'])
|
34 |
+
return df
|
35 |
+
|
36 |
+
# Define the Streamlit user interface
|
37 |
+
def app():
|
38 |
+
st.sidebar.header('Assessment Questions')
|
39 |
+
|
40 |
+
# Gender
|
41 |
+
st.sidebar.subheader('Choose a Gender')
|
42 |
+
gender = st.sidebar.radio('', ('M', 'F'))
|
43 |
+
gender_code_type, gender_code = list(clinical_terminology_map['gender'].items())[0]
|
44 |
+
|
45 |
+
# Age
|
46 |
+
st.sidebar.subheader('Choose an age group')
|
47 |
+
age_group = st.sidebar.selectbox('', ['Age0to18', 'Age19to44', 'Age44to64', 'Age64to84', 'Age85andOver'])
|
48 |
+
age_code_type, age_code = list(clinical_terminology_map['age'].items())[0]
|
49 |
+
|
50 |
+
# Diastolic blood pressure
|
51 |
+
st.sidebar.subheader('What is the diastolic blood pressure?')
|
52 |
+
diastolic_bp = st.sidebar.number_input('', value=0, step=1)
|
53 |
+
diastolic_bp_code_type, diastolic_bp_code = list(clinical_terminology_map['diastolic_blood_pressure'].items())[0]
|
54 |
+
|
55 |
+
# Systolic blood pressure
|
56 |
+
st.sidebar.subheader('What is the systolic blood pressure?')
|
57 |
+
systolic_bp = st.sidebar.number_input('', value=0, step=1)
|
58 |
+
systolic_bp_code_type, systolic_bp_code = list(clinical_terminology_map['systolic_blood_pressure'].items())[0]
|
59 |
+
|
60 |
+
# Save button
|
61 |
+
if st.sidebar.button('Save'):
|
62 |
+
df = read_data()
|
63 |
+
|
64 |
+
# Append the new data to the dataframe
|
65 |
+
new_data = {'Gender': gender, 'Age': age_group, 'Diastolic Blood Pressure': diastolic_bp,
|
66 |
+
'Systolic Blood Pressure': systolic_bp}
|
67 |
+
df = df.append(new_data, ignore_index=True)
|
68 |
+
|
69 |
+
# Save the dataframe to the CSV file
|
70 |
+
df.to_csv('FHIR-ASMT.csv', index=False)
|
71 |
+
|
72 |
+
# Show the current data
|
73 |
+
st.header('Assessment Data')
|
74 |
+
data = read_data()
|
75 |
+
if not data.empty:
|
76 |
+
st.write(data)
|
77 |
else:
|
78 |
+
st.write('No data available')
|
79 |
+
|
80 |
+
app()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|