decentralizedsurvey commited on
Commit
4e813b8
·
1 Parent(s): 2b2c362

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +968 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,968 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+ import json
4
+ import web3
5
+
6
+ # Global variables
7
+ total_number_pages = 24
8
+ placeholder_buttons = None
9
+
10
+ # Radio Options
11
+ period_radio_options = ["Weekly", "Monthly", "Semi-annually", "Annually", "Less than Annually", "Never"]
12
+ yes_no_NotSure_radio_options = ["Yes", "No", "Not sure"]
13
+ yes_no_radio_options = ["Yes", "No"]
14
+ frequency_radio_options = ["Always", "Most of the time", "About half the time", "Sometimes", "Never"]
15
+ importance_radio_options = ["Extremely important", "Very important", "Moderately important", "Slightly important", "Not at all important"]
16
+ q7_radio_options = ["When I see a new doctor I want him/her to have access to my previous medical records.",
17
+ "When I see a new doctor I do not want him/her to have access to my previous medical records.",
18
+ "Not sure"]
19
+ q12_radio_options = ["Share my information automatically unless I say not to share it.",
20
+ "Share my information automatically in an emergency situation, but otherwise do not share unless I provide my consent.",
21
+ "Share my information only after I provide my consent."]
22
+ q14_radio_options = ["Paper consent form", "Electronic consent", "Both paper and electronic consent", "Not sure", "Not Applicable"]
23
+ q15_radio_options = ["Fill out a form at my provider's office", "Use the consent app"]
24
+ q17_radio_options = ["18-24 years old", "25-34 years old", "35-44 years old", "45-54 years old", "55-64 years old", "65+ years old"]
25
+ q18_radio_options = ["Male", "Female", "Non-binary/third gender", "Prefer not to say"]
26
+ q19_radio_options = ["Asian or Pacific Islander", "Black or African American", "Hispanic or Latino", "Native American or Alaska Native",
27
+ "White or Caucasian", "Multiracial/Biracial/Other"]
28
+ q20_radio_options = ["Less than high school", "High school education", "Some college", "College degree or higher"]
29
+ q21_radio_options = ["\$0-\$24,999", "\$25,000-\$49,999", "\$50,000-\$74,999",
30
+ "\$75,000-\$99,999", "\$100,000-\$149,999", "\$150,000-\$199,999", "\$200,000 and up"]
31
+ q22_radio_options = ["Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut",
32
+ "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas",
33
+ "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi",
34
+ "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York",
35
+ "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island",
36
+ "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington",
37
+ "West Virginia", "Wisconsin", "Wyoming", "I do not live in the United States"]
38
+
39
+ # Function that records radio element changes
40
+ def radio_change(element, state, key):
41
+ st.session_state[state] = element.index(st.session_state[key]) # Setting previously selected option
42
+
43
+ # Function that disables the last button while data is uploaded to IPFS
44
+ def button_disable():
45
+ st.session_state["disabled"] = True
46
+
47
+ # Changing the App title
48
+ st.set_page_config(page_title="IPFS-Based Survey",)
49
+
50
+ # Page title
51
+ st.title('Patient Consent for HIE')
52
+
53
+ # The following code centralizes all the buttons
54
+ st.markdown("<style>.row-widget.stButton {text-align: center;}</style>", unsafe_allow_html=True)
55
+
56
+ # The following code helps with the font size of text labels
57
+ st.markdown("<style>.big-font {font-size:24px;}</style>", unsafe_allow_html=True)
58
+
59
+ # Initialize state
60
+ if "current_page" not in st.session_state:
61
+ st.session_state["current_page"] = 1
62
+ st.session_state["Q1"] = None
63
+ st.session_state["Q2"] = None
64
+ st.session_state["Q3"] = None
65
+ st.session_state["Q4"] = None
66
+ st.session_state["Q5"] = None
67
+ st.session_state["Q6"] = None
68
+ st.session_state["Q7"] = None
69
+ st.session_state["Q8"] = None
70
+ st.session_state["Q9"] = None
71
+ st.session_state["Q10"] = None
72
+ st.session_state["Q11"] = None
73
+ st.session_state["Q12"] = None
74
+ st.session_state["Q13"] = None
75
+ st.session_state["Q14"] = None
76
+ st.session_state["Q15"] = None
77
+ st.session_state["Q16"] = None
78
+ st.session_state["Q17"] = None
79
+ st.session_state["Q18"] = None
80
+ st.session_state["Q19"] = None
81
+ st.session_state["Q20"] = None
82
+ st.session_state["Q21"] = None
83
+ st.session_state["Q22"] = None
84
+ st.session_state["Q23"] = None
85
+ st.session_state["Q24"] = None
86
+ st.session_state["disabled"] = False
87
+
88
+
89
+ # Page 1; Video
90
+ if st.session_state["current_page"] == 1:
91
+
92
+ st.markdown("""<p class="big-font">
93
+ This survey asks questions about your views and preferences regarding how your healthcare providers have access to your medical information and to what extent you are in control of that access. <br><br>
94
+ Health information exchange or HIE is the process of either transferring patient health information electronically (e.g., from a primary care physician to a specialist) or granting access to patient health information maintained digitally by a specific person or organization. The information could reside in an electronic medical record system or other digital repository maintained by a health provider (e.g., hospital, doctor’s office) or in a personal health record maintained by the patient on a personal computer or online. <br><br>
95
+ Health information exchange has the goal of making all relevant medical information about you available to your healthcare providers when they are making decisions about your care. The expected value of having access to all relevant medical information includes more timely and accurate treatment, fewer redundant tests, and better-quality outcomes. However, the concern with health information exchange is that as information is made more accessible, the potential for misuse of that information increases. <br><br>
96
+ Some states have an opt-in requirement where patients must give consent before HIE is allowed, while other states have an opt-out requirement where HIE is allowed unless the patient specifically withdraws consent. Some states have not established specific HIE consent requirements leaving that decision to individual health providers. The process of documenting patient consent for HIE is almost always a paper-based process where the patient fills out and signs a paper consent form at their provider’s office and the provider stores the signed document. Because consent requirements vary from state to state, consent for HIE must be managed separately in each state where a patient receives care or where existing medical information resides. <br><br>
97
+ The video below provides additional information about HIE in the context of Arizona.
98
+ </p>""", unsafe_allow_html=True)
99
+ st.video("https://www.youtube.com/watch?v=aJb6Dov0jlM")
100
+
101
+ if st.button('Next'):
102
+ st.session_state["current_page"] += 1
103
+ st.rerun()
104
+
105
+ # Progress bar
106
+ st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
107
+
108
+ # Page 2; Q1
109
+ elif st.session_state["current_page"] == 2:
110
+
111
+ st.radio(label = "How frequently do you visit a healthcare provider to receive care for a medical problem?",
112
+ options = period_radio_options,
113
+ index = None if st.session_state["Q1"] == None else st.session_state["Q1"],
114
+ key = 'Q1_radio',
115
+ on_change = radio_change,
116
+ args = (period_radio_options, "Q1", "Q1_radio",))
117
+
118
+ # The code below changes the font size of the above radio's label. The last two <br> tags create extra space before the buttons
119
+ st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 24px;}</style> <br><br>""", unsafe_allow_html=True)
120
+
121
+ # Placeholder for a potential warning message
122
+ placeholder = st.empty()
123
+
124
+ # Back/Next buttons
125
+ col1, col2 = st.columns(2)
126
+ with col1:
127
+ if st.button('Back'):
128
+ st.session_state["current_page"] -= 1
129
+ st.rerun()
130
+
131
+ with col2:
132
+ if st.button('Next'):
133
+ if st.session_state["Q1"] != None:
134
+ st.session_state["current_page"] += 1
135
+ st.rerun()
136
+ else: # Adding warning message to the placeholder
137
+ with placeholder.container():
138
+ st.warning(f"Please answer all the questions on this page.", icon="⚠️")
139
+
140
+ # Progress bar
141
+ st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
142
+
143
+ # Page 3; Q2
144
+ elif st.session_state["current_page"] == 3:
145
+
146
+ st.radio(label = "When receiving care for a medical problem, was there EVER a time when an important part of your health information was NOT available to your care provider to make a decision about your care at the time of your scheduled appointment?",
147
+ options = yes_no_NotSure_radio_options,
148
+ index = None if st.session_state["Q2"] == None else st.session_state["Q2"],
149
+ key = 'Q2_radio',
150
+ on_change = radio_change,
151
+ args = (yes_no_NotSure_radio_options, "Q2", "Q2_radio",))
152
+
153
+ # The code below changes the font size of the above radio's label. The last two <br> tags create extra space before the buttons
154
+ st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 24px;}</style> <br><br>""", unsafe_allow_html=True)
155
+
156
+ # Placeholder for a potential warning message
157
+ placeholder = st.empty()
158
+
159
+ # Back/Next buttons
160
+ col1, col2 = st.columns(2)
161
+ with col1:
162
+ if st.button('Back'):
163
+ st.session_state["current_page"] -= 1
164
+ st.rerun()
165
+
166
+ with col2:
167
+ if st.button('Next'):
168
+ if st.session_state["Q2"] != None:
169
+ st.session_state["current_page"] += 1
170
+ st.rerun()
171
+ else: # Adding warning message to the placeholder
172
+ with placeholder.container():
173
+ st.warning(f"Please answer all the questions on this page.", icon="⚠️")
174
+
175
+ # Progress bar
176
+ st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
177
+
178
+ # Page 4; Q3
179
+ elif st.session_state["current_page"] == 4:
180
+
181
+ st.radio(label = "When receiving care for a medical problem, was there EVER a time when you received conflicting information from different doctors or health care professionals?",
182
+ options = yes_no_NotSure_radio_options,
183
+ index = None if st.session_state["Q3"] == None else st.session_state["Q3"],
184
+ key = 'Q3_radio',
185
+ on_change = radio_change,
186
+ args = (yes_no_NotSure_radio_options, "Q3", "Q3_radio",))
187
+
188
+ # The code below changes the font size of the above radio's label. The last two <br> tags create extra space before the buttons
189
+ st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 24px;}</style> <br><br>""", unsafe_allow_html=True)
190
+
191
+ # Placeholder for a potential warning message
192
+ placeholder = st.empty()
193
+
194
+ # Back/Next buttons
195
+ col1, col2 = st.columns(2)
196
+ with col1:
197
+ if st.button('Back'):
198
+ st.session_state["current_page"] -= 1
199
+ st.rerun()
200
+
201
+ with col2:
202
+ if st.button('Next'):
203
+ if st.session_state["Q3"] != None:
204
+ st.session_state["current_page"] += 1
205
+ st.rerun()
206
+ else: # Adding warning message to the placeholder
207
+ with placeholder.container():
208
+ st.warning(f"Please answer all the questions on this page.", icon="⚠️")
209
+
210
+ # Progress bar
211
+ st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
212
+
213
+ # Page 5; Q4
214
+ elif st.session_state["current_page"] == 5:
215
+
216
+ st.radio(label = "When receiving care for a medical problem, was there EVER a time when a doctor ordered a medical test that you felt was unnecessary because the test had already been done?",
217
+ options = yes_no_NotSure_radio_options,
218
+ index = None if st.session_state["Q4"] == None else st.session_state["Q4"],
219
+ key = 'Q4_radio',
220
+ on_change = radio_change,
221
+ args = (yes_no_NotSure_radio_options, "Q4", "Q4_radio",))
222
+
223
+ # The code below changes the font size of the above radio's label. The last two <br> tags create extra space before the buttons
224
+ st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 24px;}</style> <br><br>""", unsafe_allow_html=True)
225
+
226
+ # Placeholder for a potential warning message
227
+ placeholder = st.empty()
228
+
229
+ # Back/Next buttons
230
+ col1, col2 = st.columns(2)
231
+ with col1:
232
+ if st.button('Back'):
233
+ st.session_state["current_page"] -= 1
234
+ st.rerun()
235
+
236
+ with col2:
237
+ if st.button('Next'):
238
+ if st.session_state["Q4"] != None:
239
+ st.session_state["current_page"] += 1
240
+ st.rerun()
241
+ else: # Adding warning message to the placeholder
242
+ with placeholder.container():
243
+ st.warning(f"Please answer all the questions on this page.", icon="⚠️")
244
+
245
+ # Progress bar
246
+ st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
247
+
248
+ # Page 6; Q5
249
+ elif st.session_state["current_page"] == 6:
250
+
251
+ st.radio(label = "When you need care or treatment, how often does your healthcare provider know important information about your medical history?",
252
+ options = frequency_radio_options,
253
+ index = None if st.session_state["Q5"] == None else st.session_state["Q5"],
254
+ key = 'Q5_radio',
255
+ on_change = radio_change,
256
+ args = (frequency_radio_options, "Q5", "Q5_radio",))
257
+
258
+ # The code below changes the font size of the above radio's label. The last two <br> tags create extra space before the buttons
259
+ st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 24px;}</style> <br><br>""", unsafe_allow_html=True)
260
+
261
+ # Placeholder for a potential warning message
262
+ placeholder = st.empty()
263
+
264
+ # Back/Next buttons
265
+ col1, col2 = st.columns(2)
266
+ with col1:
267
+ if st.button('Back'):
268
+ st.session_state["current_page"] -= 1
269
+ st.rerun()
270
+
271
+ with col2:
272
+ if st.button('Next'):
273
+ if st.session_state["Q5"] != None:
274
+ st.session_state["current_page"] += 1
275
+ st.rerun()
276
+ else: # Adding warning message to the placeholder
277
+ with placeholder.container():
278
+ st.warning(f"Please answer all the questions on this page.", icon="⚠️")
279
+
280
+ # Progress bar
281
+ st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
282
+
283
+ # Page 7; Q6
284
+ elif st.session_state["current_page"] == 7:
285
+
286
+ st.radio(label = "How important is it that your healthcare providers have access to ALL of your medical information to make care decisions?",
287
+ options = importance_radio_options,
288
+ index = None if st.session_state["Q6"] == None else st.session_state["Q6"],
289
+ key = 'Q6_radio',
290
+ on_change = radio_change,
291
+ args = (importance_radio_options, "Q6", "Q6_radio",))
292
+
293
+ # The code below changes the font size of the above radio's label. The last two <br> tags create extra space before the buttons
294
+ st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 24px;}</style> <br><br>""", unsafe_allow_html=True)
295
+
296
+ # Placeholder for a potential warning message
297
+ placeholder = st.empty()
298
+
299
+ # Back/Next buttons
300
+ col1, col2 = st.columns(2)
301
+ with col1:
302
+ if st.button('Back'):
303
+ st.session_state["current_page"] -= 1
304
+ st.rerun()
305
+
306
+ with col2:
307
+ if st.button('Next'):
308
+ if st.session_state["Q6"] != None:
309
+ st.session_state["current_page"] += 1
310
+ st.rerun()
311
+ else: # Adding warning message to the placeholder
312
+ with placeholder.container():
313
+ st.warning(f"Please answer all the questions on this page.", icon="⚠️")
314
+
315
+ # Progress bar
316
+ st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
317
+
318
+ # Page 8; Q7
319
+ elif st.session_state["current_page"] == 8:
320
+
321
+ st.radio(label = "Which of the following statements comes closest to expressing your overall view of how you prefer that information from your medical records are handled?",
322
+ options = q7_radio_options,
323
+ index = None if st.session_state["Q7"] == None else st.session_state["Q7"],
324
+ key = 'Q7_radio',
325
+ on_change = radio_change,
326
+ args = (q7_radio_options, "Q7", "Q7_radio",))
327
+
328
+ # The code below changes the font size of the above radio's label. The last two <br> tags create extra space before the buttons
329
+ st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 24px;}</style> <br><br>""", unsafe_allow_html=True)
330
+
331
+ # Placeholder for a potential warning message
332
+ placeholder = st.empty()
333
+
334
+ # Back/Next buttons
335
+ col1, col2 = st.columns(2)
336
+ with col1:
337
+ if st.button('Back'):
338
+ st.session_state["current_page"] -= 1
339
+ st.rerun()
340
+
341
+ with col2:
342
+ if st.button('Next'):
343
+ if st.session_state["Q7"] != None:
344
+ st.session_state["current_page"] += 1
345
+ st.rerun()
346
+ else: # Adding warning message to the placeholder
347
+ with placeholder.container():
348
+ st.warning(f"Please answer all the questions on this page.", icon="⚠️")
349
+
350
+ # Progress bar
351
+ st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
352
+
353
+ # Page 9; Q8
354
+ elif st.session_state["current_page"] == 9:
355
+
356
+ st.radio(label = "When selecting a healthcare provider, how important is it that they participate in a health information exchange that enables them to access ALL of your medical information?",
357
+ options = importance_radio_options,
358
+ index = None if st.session_state["Q8"] == None else st.session_state["Q8"],
359
+ key = 'Q8_radio',
360
+ on_change = radio_change,
361
+ args = (importance_radio_options, "Q8", "Q8_radio",))
362
+
363
+ # The code below changes the font size of the above radio's label. The last two <br> tags create extra space before the buttons
364
+ st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 24px;}</style> <br><br>""", unsafe_allow_html=True)
365
+
366
+ # Placeholder for a potential warning message
367
+ placeholder = st.empty()
368
+
369
+ # Back/Next buttons
370
+ col1, col2 = st.columns(2)
371
+ with col1:
372
+ if st.button('Back'):
373
+ st.session_state["current_page"] -= 1
374
+ st.rerun()
375
+
376
+ with col2:
377
+ if st.button('Next'):
378
+ if st.session_state["Q8"] != None:
379
+ st.session_state["current_page"] += 1
380
+ st.rerun()
381
+ else: # Adding warning message to the placeholder
382
+ with placeholder.container():
383
+ st.warning(f"Please answer all the questions on this page.", icon="��️")
384
+
385
+ # Progress bar
386
+ st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
387
+
388
+ # Page 10; Q9
389
+ elif st.session_state["current_page"] == 10:
390
+
391
+ st.radio(label = "Should patients have full control over which healthcare providers can access their medical information?",
392
+ options = yes_no_radio_options,
393
+ index = None if st.session_state["Q9"] == None else st.session_state["Q9"],
394
+ key = 'Q9_radio',
395
+ on_change = radio_change,
396
+ args = (yes_no_radio_options, "Q9", "Q9_radio",))
397
+
398
+ # The code below changes the font size of the above radio's label. The last two <br> tags create extra space before the buttons
399
+ st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 24px;}</style> <br><br>""", unsafe_allow_html=True)
400
+
401
+ # Placeholder for a potential warning message
402
+ placeholder = st.empty()
403
+
404
+ # Back/Next buttons
405
+ col1, col2 = st.columns(2)
406
+ with col1:
407
+ if st.button('Back'):
408
+ st.session_state["current_page"] -= 1
409
+ st.rerun()
410
+
411
+ with col2:
412
+ if st.button('Next'):
413
+ if st.session_state["Q9"] != None:
414
+ st.session_state["current_page"] += 1
415
+ st.rerun()
416
+ else: # Adding warning message to the placeholder
417
+ with placeholder.container():
418
+ st.warning(f"Please answer all the questions on this page.", icon="⚠️")
419
+
420
+ # Progress bar
421
+ st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
422
+
423
+ # Page 11; Q10
424
+ elif st.session_state["current_page"] == 11:
425
+
426
+ st.radio(label = "Are you aware of your rights as a patient to limit who can access your medical records for your own care and treatment?",
427
+ options = yes_no_radio_options,
428
+ index = None if st.session_state["Q10"] == None else st.session_state["Q10"],
429
+ key = 'Q10_radio',
430
+ on_change = radio_change,
431
+ args = (yes_no_radio_options, "Q10", "Q10_radio",))
432
+
433
+ # The code below changes the font size of the above radio's label. The last two <br> tags create extra space before the buttons
434
+ st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 24px;}</style> <br><br>""", unsafe_allow_html=True)
435
+
436
+ # Placeholder for a potential warning message
437
+ placeholder = st.empty()
438
+
439
+ # Back/Next buttons
440
+ col1, col2 = st.columns(2)
441
+ with col1:
442
+ if st.button('Back'):
443
+ st.session_state["current_page"] -= 1
444
+ st.rerun()
445
+
446
+ with col2:
447
+ if st.button('Next'):
448
+ if st.session_state["Q10"] != None:
449
+ st.session_state["current_page"] += 1
450
+ st.rerun()
451
+ else: # Adding warning message to the placeholder
452
+ with placeholder.container():
453
+ st.warning(f"Please answer all the questions on this page.", icon="⚠️")
454
+
455
+ # Progress bar
456
+ st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
457
+
458
+ # Page 12; Q11
459
+ elif st.session_state["current_page"] == 12:
460
+
461
+ st.radio(label = "How important is having control over which healthcare providers have access to your medical information?",
462
+ options = importance_radio_options,
463
+ index = None if st.session_state["Q11"] == None else st.session_state["Q11"],
464
+ key = 'Q11_radio',
465
+ on_change = radio_change,
466
+ args = (importance_radio_options, "Q11", "Q11_radio",))
467
+
468
+ # The code below changes the font size of the above radio's label. The last two <br> tags create extra space before the buttons
469
+ st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 24px;}</style> <br><br>""", unsafe_allow_html=True)
470
+
471
+ # Placeholder for a potential warning message
472
+ placeholder = st.empty()
473
+
474
+ # Back/Next buttons
475
+ col1, col2 = st.columns(2)
476
+ with col1:
477
+ if st.button('Back'):
478
+ st.session_state["current_page"] -= 1
479
+ st.rerun()
480
+
481
+ with col2:
482
+ if st.button('Next'):
483
+ if st.session_state["Q11"] != None:
484
+ st.session_state["current_page"] += 1
485
+ st.rerun()
486
+ else: # Adding warning message to the placeholder
487
+ with placeholder.container():
488
+ st.warning(f"Please answer all the questions on this page.", icon="⚠️")
489
+
490
+ # Progress bar
491
+ st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
492
+
493
+ # Page 13; Q12
494
+ elif st.session_state["current_page"] == 13:
495
+
496
+ st.radio(label = "Which of the following options would you prefer when it comes to permission needed to have your health information shared electronically between providers for medical care?",
497
+ options = q12_radio_options,
498
+ index = None if st.session_state["Q12"] == None else st.session_state["Q12"],
499
+ key = 'Q12_radio',
500
+ on_change = radio_change,
501
+ args = (q12_radio_options, "Q12", "Q12_radio",))
502
+
503
+ # The code below changes the font size of the above radio's label. The last two <br> tags create extra space before the buttons
504
+ st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 24px;}</style> <br><br>""", unsafe_allow_html=True)
505
+
506
+ # Placeholder for a potential warning message
507
+ placeholder = st.empty()
508
+
509
+ # Back/Next buttons
510
+ col1, col2 = st.columns(2)
511
+ with col1:
512
+ if st.button('Back'):
513
+ st.session_state["current_page"] -= 1
514
+ st.rerun()
515
+
516
+ with col2:
517
+ if st.button('Next'):
518
+ if st.session_state["Q12"] != None:
519
+ st.session_state["current_page"] += 1
520
+ st.rerun()
521
+ else: # Adding warning message to the placeholder
522
+ with placeholder.container():
523
+ st.warning(f"Please answer all the questions on this page.", icon="⚠️")
524
+
525
+ # Progress bar
526
+ st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
527
+
528
+ # Page 14; Q13
529
+ elif st.session_state["current_page"] == 14:
530
+
531
+ st.radio(label = "Do you recall ever giving consent for health information exchange?",
532
+ options = yes_no_radio_options,
533
+ index = None if st.session_state["Q13"] == None else st.session_state["Q13"],
534
+ key = 'Q13_radio',
535
+ on_change = radio_change,
536
+ args = (yes_no_radio_options, "Q13", "Q13_radio",))
537
+
538
+ # The code below changes the font size of the above radio's label. The last two <br> tags create extra space before the buttons
539
+ st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 24px;}</style> <br><br>""", unsafe_allow_html=True)
540
+
541
+ # Placeholder for a potential warning message
542
+ placeholder = st.empty()
543
+
544
+ # Back/Next buttons
545
+ col1, col2 = st.columns(2)
546
+ with col1:
547
+ if st.button('Back'):
548
+ st.session_state["current_page"] -= 1
549
+ st.rerun()
550
+
551
+ with col2:
552
+ if st.button('Next'):
553
+ if st.session_state["Q13"] != None:
554
+ st.session_state["current_page"] += 1
555
+ st.rerun()
556
+ else: # Adding warning message to the placeholder
557
+ with placeholder.container():
558
+ st.warning(f"Please answer all the questions on this page.", icon="⚠️")
559
+
560
+ # Progress bar
561
+ st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
562
+
563
+ # Page 15; Q14
564
+ elif st.session_state["current_page"] == 15:
565
+
566
+ st.radio(label = "If you answered yes to the previous questions, was the consent process completed on a paper form or was it done electronically?",
567
+ options = q14_radio_options,
568
+ index = None if st.session_state["Q14"] == None else st.session_state["Q14"],
569
+ key = 'Q14_radio',
570
+ on_change = radio_change,
571
+ args = (q14_radio_options, "Q14", "Q14_radio",))
572
+
573
+ # The code below changes the font size of the above radio's label. The last two <br> tags create extra space before the buttons
574
+ st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 24px;}</style> <br><br>""", unsafe_allow_html=True)
575
+
576
+ # Placeholder for a potential warning message
577
+ placeholder = st.empty()
578
+
579
+ # Back/Next buttons
580
+ col1, col2 = st.columns(2)
581
+ with col1:
582
+ if st.button('Back'):
583
+ st.session_state["current_page"] -= 1
584
+ st.rerun()
585
+
586
+ with col2:
587
+ if st.button('Next'):
588
+ if st.session_state["Q14"] != None:
589
+ st.session_state["current_page"] += 1
590
+ st.rerun()
591
+ else: # Adding warning message to the placeholder
592
+ with placeholder.container():
593
+ st.warning(f"Please answer all the questions on this page.", icon="⚠️")
594
+
595
+ # Progress bar
596
+ st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
597
+
598
+ # Page 16; Video + Q15 + Q16
599
+ elif st.session_state["current_page"] == 16:
600
+
601
+ st.markdown("""<p class="big-font">
602
+ Watch the video below, which explains both the current format for granting and revoking the electronic exchange of your individual health information and an app alternative that is not currently available, but could be offered.
603
+ </p>""", unsafe_allow_html=True)
604
+ st.video("https://www.youtube.com/watch?v=pJQt-pjSFTk")
605
+
606
+ #Q15
607
+ st.radio(label = "Based on the options presented in the video, how would you prefer to manage your health information exchange consent?",
608
+ options = q15_radio_options,
609
+ index = None if st.session_state["Q15"] == None else st.session_state["Q15"],
610
+ key = 'Q15_radio',
611
+ on_change = radio_change,
612
+ args = (q15_radio_options, "Q15", "Q15_radio",))
613
+
614
+ # The code below changes the font size of the above radio's label. The last two <br> tags create extra space before the buttons
615
+ st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 24px;}</style> <br><br>""", unsafe_allow_html=True)
616
+
617
+
618
+ #Q16
619
+ st.session_state["Q16"] = st.text_area("Why did you choose the above option?", st.session_state["Q16"])
620
+
621
+ # The code below changes the font size of the above radio's label. The last two <br> tags create extra space before the buttons
622
+ st.markdown("""<style> div[class*="stTextArea"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 24px;}</style> <br><br>""", unsafe_allow_html=True)
623
+
624
+ # Placeholder for a potential warning message
625
+ placeholder = st.empty()
626
+
627
+ # Back/Next buttons
628
+ col1, col2 = st.columns(2)
629
+ with col1:
630
+ if st.button('Back'):
631
+ st.session_state["current_page"] -= 1
632
+ st.rerun()
633
+
634
+ with col2:
635
+ if st.button('Next'):
636
+ if st.session_state["Q15"] != None and st.session_state["Q16"] != None:
637
+ st.session_state["current_page"] += 1
638
+ st.rerun()
639
+ else: # Adding warning message to the placeholder
640
+ with placeholder.container():
641
+ st.warning(f"Please answer all the questions on this page.", icon="⚠️")
642
+
643
+ # Progress bar
644
+ st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
645
+
646
+ # Page 17; Q17
647
+ elif st.session_state["current_page"] == 17:
648
+
649
+ st.radio(label = "How old are you?",
650
+ options = q17_radio_options,
651
+ index = None if st.session_state["Q17"] == None else st.session_state["Q17"],
652
+ key = 'Q17_radio',
653
+ on_change = radio_change,
654
+ args = (q17_radio_options, "Q17", "Q17_radio",))
655
+
656
+ # The code below changes the font size of the above radio's label. The last two <br> tags create extra space before the buttons
657
+ st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 24px;}</style> <br><br>""", unsafe_allow_html=True)
658
+
659
+ # Placeholder for a potential warning message
660
+ placeholder = st.empty()
661
+
662
+ # Back/Next buttons
663
+ col1, col2 = st.columns(2)
664
+ with col1:
665
+ if st.button('Back'):
666
+ st.session_state["current_page"] -= 1
667
+ st.rerun()
668
+
669
+ with col2:
670
+ if st.button('Next'):
671
+ if st.session_state["Q17"] != None:
672
+ st.session_state["current_page"] += 1
673
+ st.rerun()
674
+ else: # Adding warning message to the placeholder
675
+ with placeholder.container():
676
+ st.warning(f"Please answer all the questions on this page.", icon="⚠️")
677
+
678
+ # Progress bar
679
+ st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
680
+
681
+ # Page 18; Q18
682
+ elif st.session_state["current_page"] == 18:
683
+
684
+ st.radio(label = "How do you describe yourself?",
685
+ options = q18_radio_options,
686
+ index = None if st.session_state["Q18"] == None else st.session_state["Q18"],
687
+ key = 'Q18_radio',
688
+ on_change = radio_change,
689
+ args = (q18_radio_options, "Q18", "Q18_radio",))
690
+
691
+ # The code below changes the font size of the above radio's label. The last two <br> tags create extra space before the buttons
692
+ st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 24px;}</style> <br><br>""", unsafe_allow_html=True)
693
+
694
+ # Placeholder for a potential warning message
695
+ placeholder = st.empty()
696
+
697
+ # Back/Next buttons
698
+ col1, col2 = st.columns(2)
699
+ with col1:
700
+ if st.button('Back'):
701
+ st.session_state["current_page"] -= 1
702
+ st.rerun()
703
+
704
+ with col2:
705
+ if st.button('Next'):
706
+ if st.session_state["Q18"] != None:
707
+ st.session_state["current_page"] += 1
708
+ st.rerun()
709
+ else: # Adding warning message to the placeholder
710
+ with placeholder.container():
711
+ st.warning(f"Please answer all the questions on this page.", icon="⚠️")
712
+
713
+ # Progress bar
714
+ st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
715
+
716
+ # Page 19; Q19
717
+ elif st.session_state["current_page"] == 19:
718
+
719
+ st.radio(label = "Which of the following best describes you?",
720
+ options = q19_radio_options,
721
+ index = None if st.session_state["Q19"] == None else st.session_state["Q19"],
722
+ key = 'Q19_radio',
723
+ on_change = radio_change,
724
+ args = (q19_radio_options, "Q19", "Q19_radio",))
725
+
726
+ # The code below changes the font size of the above radio's label. The last two <br> tags create extra space before the buttons
727
+ st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 24px;}</style> <br><br>""", unsafe_allow_html=True)
728
+
729
+ # Placeholder for a potential warning message
730
+ placeholder = st.empty()
731
+
732
+ # Back/Next buttons
733
+ col1, col2 = st.columns(2)
734
+ with col1:
735
+ if st.button('Back'):
736
+ st.session_state["current_page"] -= 1
737
+ st.rerun()
738
+
739
+ with col2:
740
+ if st.button('Next'):
741
+ if st.session_state["Q19"] != None:
742
+ st.session_state["current_page"] += 1
743
+ st.rerun()
744
+ else: # Adding warning message to the placeholder
745
+ with placeholder.container():
746
+ st.warning(f"Please answer all the questions on this page.", icon="⚠️")
747
+
748
+ # Progress bar
749
+ st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
750
+
751
+ # Page 20; Q20
752
+ elif st.session_state["current_page"] == 20:
753
+
754
+ st.radio(label = "What is the highest level of education you have completed?",
755
+ options = q20_radio_options,
756
+ index = None if st.session_state["Q20"] == None else st.session_state["Q20"],
757
+ key = 'Q20_radio',
758
+ on_change = radio_change,
759
+ args = (q20_radio_options, "Q20", "Q20_radio",))
760
+
761
+ # The code below changes the font size of the above radio's label. The last two <br> tags create extra space before the buttons
762
+ st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 24px;}</style> <br><br>""", unsafe_allow_html=True)
763
+
764
+ # Placeholder for a potential warning message
765
+ placeholder = st.empty()
766
+
767
+ # Back/Next buttons
768
+ col1, col2 = st.columns(2)
769
+ with col1:
770
+ if st.button('Back'):
771
+ st.session_state["current_page"] -= 1
772
+ st.rerun()
773
+
774
+ with col2:
775
+ if st.button('Next'):
776
+ if st.session_state["Q20"] != None:
777
+ st.session_state["current_page"] += 1
778
+ st.rerun()
779
+ else: # Adding warning message to the placeholder
780
+ with placeholder.container():
781
+ st.warning(f"Please answer all the questions on this page.", icon="⚠️")
782
+
783
+ # Progress bar
784
+ st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
785
+
786
+ # Page 21; Q21
787
+ elif st.session_state["current_page"] == 21:
788
+
789
+ st.radio(label = "What is your approximate average household income?",
790
+ options = q21_radio_options,
791
+ index = None if st.session_state["Q21"] == None else st.session_state["Q21"],
792
+ key = 'Q21_radio',
793
+ on_change = radio_change,
794
+ args = (q21_radio_options, "Q21", "Q21_radio",))
795
+
796
+ # The code below changes the font size of the above radio's label. The last two <br> tags create extra space before the buttons
797
+ st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 24px;}</style> <br><br>""", unsafe_allow_html=True)
798
+
799
+ # Placeholder for a potential warning message
800
+ placeholder = st.empty()
801
+
802
+ # Back/Next buttons
803
+ col1, col2 = st.columns(2)
804
+ with col1:
805
+ if st.button('Back'):
806
+ st.session_state["current_page"] -= 1
807
+ st.rerun()
808
+
809
+ with col2:
810
+ if st.button('Next'):
811
+ if st.session_state["Q21"] != None:
812
+ st.session_state["current_page"] += 1
813
+ st.rerun()
814
+ else: # Adding warning message to the placeholder
815
+ with placeholder.container():
816
+ st.warning(f"Please answer all the questions on this page.", icon="⚠️")
817
+
818
+ # Progress bar
819
+ st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
820
+
821
+ # Page 22; Q22
822
+ elif st.session_state["current_page"] == 22:
823
+
824
+ st.selectbox(label = "In which state do you currently reside?",
825
+ options = q22_radio_options,
826
+ index = None if st.session_state["Q22"] == None else st.session_state["Q22"],
827
+ key = 'Q22_radio',
828
+ on_change = radio_change,
829
+ args = (q22_radio_options, "Q22", "Q22_radio",))
830
+
831
+ # The code below changes the font size of the above radio's label. The last two <br> tags create extra space before the buttons
832
+ st.markdown("""<style> div[class*="stSelectbox"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 24px;}</style> <br><br>""", unsafe_allow_html=True)
833
+
834
+ # Placeholder for a potential warning message
835
+ placeholder = st.empty()
836
+
837
+ # Back/Next buttons
838
+ col1, col2 = st.columns(2)
839
+ with col1:
840
+ if st.button('Back'):
841
+ st.session_state["current_page"] -= 1
842
+ st.rerun()
843
+
844
+ with col2:
845
+ if st.button('Next'):
846
+ if st.session_state["Q22"] != None:
847
+ st.session_state["current_page"] += 1
848
+ st.rerun()
849
+ else: # Adding warning message to the placeholder
850
+ with placeholder.container():
851
+ st.warning(f"Please answer all the questions on this page.", icon="⚠️")
852
+
853
+ # Progress bar
854
+ st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
855
+
856
+ # Page 23; Q23
857
+ elif st.session_state["current_page"] == 23:
858
+
859
+ st.radio(label = "Is there one doctor's group, health center, or clinic you usually go to for most of your medical care?",
860
+ options = yes_no_radio_options,
861
+ index = None if st.session_state["Q23"] == None else st.session_state["Q23"],
862
+ key = 'Q23_radio',
863
+ on_change = radio_change,
864
+ args = (yes_no_radio_options, "Q23", "Q23_radio",))
865
+
866
+ # The code below changes the font size of the above radio's label. The last two <br> tags create extra space before the buttons
867
+ st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 24px;}</style> <br><br>""", unsafe_allow_html=True)
868
+
869
+ # Placeholder for a potential warning message
870
+ placeholder = st.empty()
871
+
872
+ # Back/Next buttons
873
+ col1, col2 = st.columns(2)
874
+ with col1:
875
+ if st.button('Back'):
876
+ st.session_state["current_page"] -= 1
877
+ st.rerun()
878
+
879
+ with col2:
880
+ if st.button('Next'):
881
+ if st.session_state["Q23"] != None:
882
+ st.session_state["current_page"] += 1
883
+ st.rerun()
884
+ else: # Adding warning message to the placeholder
885
+ with placeholder.container():
886
+ st.warning(f"Please answer all the questions on this page.", icon="⚠️")
887
+
888
+ # Progress bar
889
+ st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
890
+
891
+ # Page 24
892
+ elif st.session_state["current_page"] == 24:
893
+
894
+ st.markdown('<p class="big-font">Thank you for participating! <br> Click on the button below to submit your answers. </p>', unsafe_allow_html=True)
895
+
896
+ st.button('Submit Responses', disabled = st.session_state["disabled"], on_click = button_disable)
897
+
898
+ if st.session_state["disabled"]:
899
+ with st.spinner(r"$\textsf{\normalsize Storing data on IPFS and Ethereum. This operation might take a few minutes. Please wait to receive your confirmation code!}$"):
900
+ try:
901
+ response = {'file': json.dumps({"Q1":period_radio_options[st.session_state["Q1"]],
902
+ "Q2":yes_no_NotSure_radio_options[st.session_state["Q2"]],
903
+ "Q3":yes_no_NotSure_radio_options[st.session_state["Q3"]],
904
+ "Q4":yes_no_NotSure_radio_options[st.session_state["Q4"]],
905
+ "Q5":frequency_radio_options[st.session_state["Q5"]],
906
+ "Q6":importance_radio_options[st.session_state["Q6"]],
907
+ "Q7":q7_radio_options[st.session_state["Q7"]],
908
+ "Q8":importance_radio_options[st.session_state["Q8"]],
909
+ "Q9":yes_no_radio_options[st.session_state["Q9"]],
910
+ "Q10":yes_no_radio_options[st.session_state["Q10"]],
911
+ "Q11":importance_radio_options[st.session_state["Q11"]],
912
+ "Q12":q12_radio_options[st.session_state["Q12"]],
913
+ "Q13":yes_no_radio_options[st.session_state["Q13"]],
914
+ "Q14":q14_radio_options[st.session_state["Q14"]],
915
+ "Q15":q15_radio_options[st.session_state["Q15"]],
916
+ "Q16":st.session_state["Q16"],
917
+ "Q17":q17_radio_options[st.session_state["Q17"]],
918
+ "Q18":q18_radio_options[st.session_state["Q18"]],
919
+ "Q19":q19_radio_options[st.session_state["Q19"]],
920
+ "Q20":q20_radio_options[st.session_state["Q20"]],
921
+ "Q21":q21_radio_options[st.session_state["Q21"]],
922
+ "Q22":q22_radio_options[st.session_state["Q22"]],
923
+ "Q23":yes_no_radio_options[st.session_state["Q23"]],
924
+ })
925
+ }
926
+
927
+
928
+ response = requests.post('https://ipfs.infura.io:5001/api/v0/add',
929
+ files=response,
930
+ auth=(st.secrets["username"], st.secrets["password"]))
931
+
932
+ IPFS_hash = response.json()["Hash"]
933
+ print(IPFS_hash)
934
+
935
+ # Connect to the Ethereum blockchain
936
+ w3 = web3.Web3(web3.HTTPProvider(st.secrets["infura"]))
937
+
938
+ # Create a contract instance. Address is equal to the address of the smart contract
939
+ contract = w3.eth.contract(address= "0x42b76d8c32f914630627Bf924BD1e06055673cF8", abi = '[ { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "string", "name": "data", "type": "string" } ], "name": "Store", "type": "event" }, { "inputs": [ { "internalType": "string", "name": "_IPFSHash", "type": "string" } ], "name": "storeHash", "outputs": [], "stateMutability": "nonpayable", "type": "function" } ]')
940
+
941
+ # Call your function: 11155111 is Sepolia's id
942
+ call_function = contract.functions.storeHash(IPFS_hash).build_transaction({"chainId": 11155111,
943
+ "from": "0xbdB61Ada027eF27ef0709D3848Db1Dd13c96F970",
944
+ "nonce": w3.eth.get_transaction_count("0xbdB61Ada027eF27ef0709D3848Db1Dd13c96F970")}) # Initialize address nonce
945
+
946
+ # Sign transaction
947
+ signed_tx = w3.eth.account.sign_transaction(call_function, private_key=st.secrets["pk"])
948
+
949
+ # Send transaction
950
+ send_tx = w3.eth.send_raw_transaction(signed_tx.rawTransaction)
951
+
952
+ # Wait for transaction receipt
953
+ tx_receipt = w3.eth.wait_for_transaction_receipt(send_tx)
954
+
955
+ print(tx_receipt)
956
+
957
+ st.success('Data successfully stored. Thank you for taking the survey!', icon="✅")
958
+ st.info(f'The IPFS hash is: {IPFS_hash}', icon="ℹ️")
959
+ st.info(f'The Ethereum hash is: {tx_receipt.logs[0].transactionHash.hex()}', icon="ℹ️")
960
+
961
+ st.markdown('<p class="big-font">Please report your IPFS and Ethereum Hash to receive your payment.</p>', unsafe_allow_html=True)
962
+
963
+ except Exception as e:
964
+ print(e)
965
+ st.error(f'An error ocurred. Here is the error message: {e}', icon="🚨")
966
+
967
+ # Progress bar
968
+ st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ web3==6.11.2
2
+ requests==2.31.0
3
+ streamlit==1.28.2