import streamlit as st import pandas as pd from datetime import datetime import hl7 # Define the age groups age_groups = ["Age0to18", "Age19to44", "Age44to64", "Age64to84", "Age85andOver"] # Define the questions and their corresponding terminology types and codes questions = { "Choose a Gender (M/F)": ["LOINC", "76690-1"], "Choose an age group": ["LOINC", "65970-0"], "What is the diastolic blood pressure?": ["LOINC", "8462-4"], "What is the systolic blood pressure?": ["LOINC", "8480-6"] } # Define the file to store the results filename = "FHIR-ASMT.csv" # Create a function to save the results def save_results(gender, age, q1, q2, q3, q4, q5, q6, q7): now = datetime.now() timestamp = now.strftime("%Y-%m-%d") # timestamp = now.strftime("%Y-%m-%d %H:%M:%S") result = f"{gender},{age},{q1},{q2},{q3},{q4},{q5},{q6},{q7},{timestamp}" with open(filename, "a") as f: f.write(result + "\n") # Create a function to load the results def load_results(): try: df = pd.read_csv(filename, header=None, names=["Gender", "Age Group", "Question 1", "Question 2", "Question 3", "Question 4", "Question 5", "Question 6", "Question 7", "Timestamp"]) return df except: return pd.DataFrame(columns=["Gender", "Age Group", "Question 1", "Question 2", "Question 3", "Question 4", "Question 5", "Question 6", "Question 7", "Timestamp"]) # Create the Streamlit app def app(): st.sidebar.title("Generalized Anixety User Assessment") # Add the gender question gender = st.sidebar.selectbox("Choose a Gender", ["M", "F"]) # Add the age group question age = st.sidebar.selectbox("Choose an age group", age_groups) # Add the diastolic blood pressure question # diastolic_bp = st.sidebar.number_input("What is the diastolic blood pressure?") # Add the systolic blood pressure question # systolic_bp = st.sidebar.number_input("What is the systolic blood pressure?") q1 = st.sidebar.number_input("Over the last two weeks, how often have you been bothered by feeling nervous, anxious or on edge?", min_value=0, max_value=3, step=1) q2 = st.sidebar.number_input("Over the last two weeks, how often have you been bothered by not being able to stop or control worrying?", min_value=0, max_value=3, step=1) q3 = st.sidebar.number_input("Over the last two weeks, how often have you been bothered by worrying too much about different things?", min_value=0, max_value=3, step=1) q4 = st.sidebar.number_input("Over the last two weeks, how often have you been bothered by having trouble relaxing?", min_value=0, max_value=3, step=1) q5 = st.sidebar.number_input("Over the last two weeks, how often have you been bothered by being so restless that it's hard to sit still?", min_value=0, max_value=3, step=1) q6 = st.sidebar.number_input("Over the last two weeks, how often have you been bothered by becoming easily annoyed or irritable?", min_value=0, max_value=3, step=1) q7 = st.sidebar.number_input("Over the last two weeks, how often have you been bothered by feeling afraid, as if something awful might happen?", min_value=0, max_value=3, step=1) # Add the Save button if st.sidebar.button("Save"): save_results(gender, age, q1, q2, q3, q4, q5, q6, q7) # Load the results and show them as a table df = load_results() st.write(df) # if __name__ == "__main__": app()