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