File size: 1,315 Bytes
dfc9fe7
a061b45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import pandas as pd

# Create a dataset for stories and votes
df = pd.DataFrame({
    'story': [
        "A 45-year-old man presents with a long history of ulcers on the bottom of his feet. 👣🚑",
        "A 24-year-old man, an information technology professional, gets himself tested for serum immunoglobulin M (IgM) levels. 💻🧪",
        "A 33-year-old woman who was recently involved in a motor vehicle accident presents to a medical clinic for a follow-up visit. 🚗🏥",
    ],
    'votes': [0, 0, 0]
})

# Function to vote on a story
def vote_story(index):
    df.loc[index, 'votes'] += 1

# Function to break story into sentences
def break_into_sentences(story):
    return story.split(". ")

# Function to display story and voting
def display_story(index, row):
    sentences = break_into_sentences(row['story'])
    for sentence in sentences:
        st.text(sentence)
    st.button(f"Vote for Story {index + 1}", on_click=vote_story, args=(index,))

# Main app
st.title('Medical Story Voting 🗳️')

# Display stories and voting buttons
for index, row in df.iterrows():
    col1, col2 = st.columns([3,1])
    with col1:
        display_story(index, row)
    col2.write(f"Votes: {row['votes']}")

# Display total votes
st.markdown("### 📊 Vote Summary")
st.table(df)