File size: 1,925 Bytes
dfc9fe7
a061b45
86d2fb9
a061b45
abb8946
86d2fb9
abb8946
 
 
a061b45
86d2fb9
a061b45
ad081e3
86d2fb9
a061b45
86d2fb9
 
a061b45
86d2fb9
628a01b
 
 
 
86d2fb9
 
 
 
 
 
 
 
abb8946
 
 
 
 
 
 
 
 
86d2fb9
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
import streamlit as st
import pandas as pd
import json

# Load USMLE questions from a JSON file (Replace this with your actual data)
def load_questions():
    return pd.DataFrame([{"question": "What is the serum level in Alzheimer's?", "answer": "High", "topic": "Alzheimers"},
                         {"question": "What causes memory loss?", "answer": "Many factors", "topic": "Memory"},
                         {"question": "How is cognitive behavior therapy used?", "answer": "For mental health", "topic": "cognitive"}])

# Vote for a story
def vote_story(index):
    st.session_state.df.loc[index, 'votes'] += 1
    st.session_state.df.to_csv('votes.csv', index=False)

# Streamlit App
st.title("Medical App 🎙🗳️")

# Initialize session state
if 'df' not in st.session_state:
    try:
        st.session_state.df = pd.read_csv('votes.csv')
    except FileNotFoundError:
        st.session_state.df = pd.DataFrame({'story': ['Story 1', 'Story 2'], 'votes': [0, 0]})
        st.session_state.df.to_csv('votes.csv', index=False)

# Tab layout
tab = st.selectbox("Choose a Tab", ["USMLE Questions", "Story Voting"])

if tab == "USMLE Questions":
    questions_df = load_questions()
    
    medical_keywords = ["Brain 🧠", "Memory 📔", "Alzheimers 🌀", "Cognitive 🤔", "Mental 💭", "Behavior 🎭"]
    
    for keyword in medical_keywords:
        keyword_clean = keyword.split(" ")[0]
        if st.button(keyword):
            filtered_data = questions_df[questions_df['topic'].str.contains(keyword_clean, case=False)]
            st.write(f"Filtered Dataset by '{keyword_clean}' 📊")
            st.dataframe(filtered_data.iloc[:, :3])

elif tab == "Story Voting":
    for index, row in st.session_state.df.iterrows():
        if st.button(f"Vote for: {row['story']}"):
            vote_story(index)
    st.table(st.session_state.df)
    st.bar_chart(st.session_state.df.set_index('story')['votes'])