Spaces:
Runtime error
Runtime error
import streamlit as st | |
import pandas as pd | |
import base64 | |
# Define the list of questions with their corresponding codes and URLs | |
questions = [ | |
{"question": "Do you have any symptoms of COVID-19?", "code": "U07.1", "code_type": "ICD10", "url": "https://www.cdc.gov/nchs/icd/icd10cm.htm"}, | |
{"question": "Have you had any surgeries in the past year?", "code": "0JH60ZZ", "code_type": "ICD10-PCS", "url": "https://www.cms.gov/Medicare/Coding/ICD10/2022-ICD-10-PCS-Codes-Version-110"}, | |
{"question": "Have you been diagnosed with any chronic conditions?", "code": "443.9", "code_type": "ICD9-CM", "url": "https://www.cms.gov/Medicare/Coding/ICD9ProviderDiagnosticCodes/codes"}, | |
{"question": "Have you had any diagnostic imaging tests in the past year?", "code": "70450", "code_type": "CPT", "url": "https://www.cms.gov/Medicare/Coding/HCPCSReleaseCodeSets/Alpha-Numeric-HCPCS"}, | |
{"question": "Have you had any lab tests done in the past year?", "code": "19710-4", "code_type": "LOINC", "url": "https://loinc.org/"}, | |
{"question": "Have you used any medical equipment in the past year?", "code": "E1399", "code_type": "HCPCS", "url": "https://www.cms.gov/Medicare/Coding/HCPCSReleaseCodeSets/Alpha-Numeric-HCPCS"} | |
] | |
# Define a function to create a DataFrame with the user's responses | |
def create_survey_df(questions): | |
survey_dict = {"Assess Topic": [], "Assess Metric": [], "Code Emoji": [], "Code Topic": [], "Code Type": [], "Code": [], "Response": [], "Comment": []} | |
for q in questions: | |
survey_dict["Assess Topic"].append("Medical History") | |
survey_dict["Assess Metric"].append(q["question"]) | |
survey_dict["Code Emoji"].append("π") | |
survey_dict["Code Topic"].append(q["code"]) | |
survey_dict["Code Type"].append(q["code_type"]) | |
survey_dict["Code"].append(q["code"]) | |
survey_dict["Response"].append(st.radio("Answer", ["Yes", "No"])) | |
survey_dict["Comment"].append(st.text_input("Comment (optional)")) | |
return pd.DataFrame(survey_dict) | |
# Define the Streamlit app | |
def app(): | |
st.title("Medical History Survey") | |
st.markdown("Please answer the following questions about your medical history.") | |
survey_df = create_survey_df(questions) | |
st.write(survey_df) | |
# Allow the user to download the survey results as a CSV file | |
if st.button("Download CSV"): | |
csv = survey_df.to_csv(index=False) | |
b64 = base64.b64encode(csv.encode()).decode() | |
st.markdown(f'<a href="data:file/csv;base64,{b64}" download="survey_results.csv">Download CSV File</a>', unsafe_allow_html=True) | |