sonali-tamhankar commited on
Commit
f98548e
1 Parent(s): d968d03

Modify app.py for additional documents

Browse files
Files changed (1) hide show
  1. app.py +86 -8
app.py CHANGED
@@ -27,9 +27,47 @@ qa_chain = RetrievalQA.from_chain_type(llm=llm,
27
  )
28
 
29
 
30
- source_dictionary = {"data\CMS_SOMA.pdf":"[CMS State Operations Manual Appendix A](https://www.cms.gov/regulations-and-guidance/guidance/manuals/downloads/som107ap_a_hospitals.pdf)",
31
- "data\DOH-RCW.pdf":"[Revised Code of Washington (RCW) Chapter 70.41](https://app.leg.wa.gov/rcw/default.aspx?cite=70.41)",
32
- "data\WAC 246-320.pdf":"[Washington Administrative Code (WAC) 246-320](https://app.leg.wa.gov/WAC/default.aspx?cite=246-320)"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
  with st.container():
35
  st.title("Hospital Regulation Chat")
@@ -37,10 +75,48 @@ with st.container():
37
  with st.sidebar:
38
  st.subheader("Find regulations for hospitals in the state of Washington.")
39
  st.markdown("""
40
- We look into three sources to find top ten most relevant excerpts:
41
  - [CMS State Operations Manual Appendix A](https://www.cms.gov/regulations-and-guidance/guidance/manuals/downloads/som107ap_a_hospitals.pdf)
42
- - [Revised Code of Washington (RCW) Chapter 70.41](https://app.leg.wa.gov/rcw/default.aspx?cite=70.41)
43
- - [Washington Administrative Code (WAC) 246-320](https://app.leg.wa.gov/WAC/default.aspx?cite=246-320)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  """) #, unsafe_allow_html=True)
45
  st.write("This is tool is meant to assist healthcare workers to the extent it can. Please note that the page numbers may be occasionally slightly off, use the matching excerpts to find the reference if this happens.")
46
 
@@ -54,8 +130,10 @@ if (st.button("Find excerpts")):
54
 
55
  for i in range(n):
56
  with st.container():
57
- st.subheader(source_dictionary[answer['source_documents'][i].metadata['source']])
58
- page_no = "**Page: " + str(answer['source_documents'][i].metadata['page']) + "**"
 
 
59
  st.markdown(page_no)
60
  st.write("...")
61
  st.write(answer['source_documents'][i].page_content)
 
27
  )
28
 
29
 
30
+ source_dictionary = {"pdf_files\\CMS_SOMA.pdf":"[CMS State Operations Manual Appendix A](https://www.cms.gov/regulations-and-guidance/guidance/manuals/downloads/som107ap_a_hospitals.pdf)",
31
+ 'pdf_files\\RCW-18-64.pdf': '[Pharmacists](https://app.leg.wa.gov/rcw/default.aspx?cite=18.64&full=true&pdf=true)',
32
+ 'pdf_files\\RCW-18-64A.pdf': '[Pharmacy Assistants](https://app.leg.wa.gov/rcw/default.aspx?cite=18.64A&full=true&pdf=true)',
33
+ 'pdf_files\\RCW-18-130.pdf': '[Regulation of Health Professions—Uniform Disciplinary Act](https://app.leg.wa.gov/rcw/default.aspx?cite=18.130&full=true&pdf=true)',
34
+ 'pdf_files\\RCW-26-44-030.pdf': '[Abuse of Children and Adult Dependent Persons](https://app.leg.wa.gov/rcw/default.aspx?cite=26.44.030&full=true&pdf=true)',
35
+ 'pdf_files\\RCW-34-05.pdf': '[Administrative Procedures Act](https://app.leg.wa.gov/rcw/default.aspx?cite=34.05&full=true&pdf=true)',
36
+ 'pdf_files\\RCW-42-56.pdf': '[Public Disclosure](https://app.leg.wa.gov/rcw/default.aspx?cite=42.56&full=true&pdf=true)',
37
+ 'pdf_files\\RCW-43-70.pdf': '[Department of Health](https://app.leg.wa.gov/rcw/default.aspx?cite=43.70&full=true&pdf=true)',
38
+ 'pdf_files\\RCW-69-04.pdf': '[Uniform Food, Drug and Cosmetic Act](https://app.leg.wa.gov/rcw/default.aspx?cite=69.04&full=true&pdf=true)',
39
+ 'pdf_files\\RCW-69-36.pdf': '[Washington Caustic Poison Act of 1929](https://app.leg.wa.gov/rcw/default.aspx?cite=69.36&full=true&pdf=true)',
40
+ 'pdf_files\\RCW-69-38.pdf': '[Poisons - Sales and Manufacturing](https://app.leg.wa.gov/rcw/default.aspx?cite=69.38&full=true&pdf=true)',
41
+ 'pdf_files\\RCW-69-40.pdf': '[Poisons and Dangerous Drugs](https://app.leg.wa.gov/rcw/default.aspx?cite=69.40&full=true&pdf=true)',
42
+ 'pdf_files\\RCW-69-41.pdf': '[Legend Drugs . . . Prescription Drugs](https://app.leg.wa.gov/rcw/default.aspx?cite=69.41&full=true&pdf=true)',
43
+ 'pdf_files\\RCW-69-43.pdf': '[Precursor Drugs](https://app.leg.wa.gov/rcw/default.aspx?cite=69.43&full=true&pdf=true)',
44
+ 'pdf_files\\RCW-69-45.pdf': '[Drug Samples](https://app.leg.wa.gov/rcw/default.aspx?cite=69.45&full=true&pdf=true)',
45
+ 'pdf_files\\RCW-69-48.pdf': '[Drug Take-Back Program\nSecure Medication Return webpage](https://app.leg.wa.gov/rcw/default.aspx?cite=69.48&full=true&pdf=true)',
46
+ 'pdf_files\\RCW-69-50.pdf': '[Uniform Controlled Substances Act](https://app.leg.wa.gov/rcw/default.aspx?cite=69.50&full=true&pdf=true)',
47
+ 'pdf_files\\RCW-69-51.pdf': '[Controlled Substances Therapeutic Research Act](https://app.leg.wa.gov/rcw/default.aspx?cite=69.51&full=true&pdf=true)',
48
+ 'pdf_files\\RCW-69-51A.pdf': '[Medical Cannabis](https://app.leg.wa.gov/rcw/default.aspx?cite=69.51A&full=true&pdf=true)',
49
+ 'pdf_files\\RCW-69-52.pdf': '[Imitation Controlled Substances](https://app.leg.wa.gov/rcw/default.aspx?cite=69.52&full=true&pdf=true)',
50
+ 'pdf_files\\RCW-69-53.pdf': '[Use of Buildings for Unlawful Drugs](https://app.leg.wa.gov/rcw/default.aspx?cite=69.53&full=true&pdf=true)',
51
+ 'pdf_files\\RCW-69-60.pdf': '[Over-the-Counter Medications - Imprinting](https://app.leg.wa.gov/rcw/default.aspx?cite=69.60&full=true&pdf=true)',
52
+ 'pdf_files\\RCW-69-70.pdf': '[Access to prescription drugs](https://app.leg.wa.gov/rcw/default.aspx?cite=69.70&full=true&pdf=true)',
53
+ 'pdf_files\\RCW-69-75.pdf': '[Dextromethorphan](https://app.leg.wa.gov/rcw/default.aspx?cite=69.75&full=true&pdf=true)',
54
+ 'pdf_files\\RCW-70-02.pdf': '[Medical Records-Health Care Information Access and Disclosure](https://app.leg.wa.gov/rcw/default.aspx?cite=70.02&full=true&pdf=true)',
55
+ 'pdf_files\\RCW-70-54.pdf': '[Miscellaneous Health and Safety Provisions\n\n70.54.400 Retail restroom access – Customers with medical conditions – Penalty\n\n\n70.54.440 Epinephrine autoinjectors – Prescribing to certain entities-training-Liability-incident reporting](https://app.leg.wa.gov/rcw/default.aspx?cite=70.54&full=true&pdf=true)',
56
+ 'pdf_files\\RCW-70-115.pdf': '[Drug Injection Devices](https://app.leg.wa.gov/rcw/default.aspx?cite=70.115&full=true&pdf=true)',
57
+ 'pdf_files\\RCW-70-225.pdf': '[Prescription Monitoring Program](https://app.leg.wa.gov/rcw/default.aspx?cite=70.225&full=true&pdf=true)',
58
+ 'pdf_files\\RCW-70-245.pdf': '[The Washington Death With Dignity Act](https://app.leg.wa.gov/rcw/default.aspx?cite=70.245&full=true&pdf=true)',
59
+ 'pdf_files\\RCW-74-34.pdf': '[Abuse of Vulnerable Adults](https://app.leg.wa.gov/rcw/default.aspx?cite=74.34&full=true&pdf=true)',
60
+ 'pdf_files\\WAC-246-338.pdf': '[Medical Test Site Rules](https://app.leg.wa.gov/wac/default.aspx?cite=246-338&full=true&pdf=true)',
61
+ 'pdf_files\\WAC-246-320.pdf': '[Hospital Licensing Regulations](https://app.leg.wa.gov/wac/default.aspx?cite=246-320&full=true&pdf=true)',
62
+ 'pdf_files\\RCW-70-41.pdf': '[Hospital Licensing and Regulation](https://app.leg.wa.gov/rcw/default.aspx?cite=70.41&full=true&pdf=true)',
63
+ 'pdf_files\\RCW-70-42.pdf': '[Medical Test Sites](https://app.leg.wa.gov/rcw/default.aspx?cite=70.42&full=true&pdf=true)',
64
+ 'pdf_files\\WAC-246-240.pdf': '[Medical Use of Radioactive Material](https://app.leg.wa.gov/wac/default.aspx?cite=246-240&full=true&pdf=true)',
65
+ 'pdf_files\\WAC-246-221.pdf': '[Radiation Protection Standards](https://app.leg.wa.gov/wac/default.aspx?cite=246-221&full=true&pdf=true)',
66
+ 'pdf_files\\RCW-18-71.pdf': '[Physicians](https://app.leg.wa.gov/rcw/default.aspx?cite=18.71&full=true&pdf=true)',
67
+ 'pdf_files\\RCW-18-71A.pdf': '[Physician Assistants](https://app.leg.wa.gov/rcw/default.aspx?cite=18.71A&full=true&pdf=true)',
68
+ 'pdf_files\\RCW-18-79.pdf': '[Nursing Care](https://app.leg.wa.gov/rcw/default.aspx?cite=18.79&full=true&pdf=true)',
69
+ 'pdf_files\\RCW-18-84.pdf': '[Radiologic Technologies](https://app.leg.wa.gov/rcw/default.aspx?cite=18.84&full=true&pdf=true)',
70
+ 'pdf_files\\RCW-18-370.pdf': '[Medical Assistants](https://app.leg.wa.gov/rcw/default.aspx?cite=18.370&full=true&pdf=true)'}
71
 
72
  with st.container():
73
  st.title("Hospital Regulation Chat")
 
75
  with st.sidebar:
76
  st.subheader("Find regulations for hospitals in the state of Washington.")
77
  st.markdown("""
78
+ We look into these sources to find top ten most relevant excerpts:
79
  - [CMS State Operations Manual Appendix A](https://www.cms.gov/regulations-and-guidance/guidance/manuals/downloads/som107ap_a_hospitals.pdf)
80
+ - [Pharmacists](https://app.leg.wa.gov/rcw/default.aspx?cite=18.64&full=true&pdf=true)
81
+ - [Pharmacy Assistants](https://app.leg.wa.gov/rcw/default.aspx?cite=18.64A&full=true&pdf=true)
82
+ - [Regulation of Health Professions—Uniform Disciplinary Act](https://app.leg.wa.gov/rcw/default.aspx?cite=18.130&full=true&pdf=true)
83
+ - [Abuse of Children and Adult Dependent Persons](https://app.leg.wa.gov/rcw/default.aspx?cite=26.44.030&full=true&pdf=true)
84
+ - [Administrative Procedures Act](https://app.leg.wa.gov/rcw/default.aspx?cite=34.05&full=true&pdf=true)
85
+ - [Public Disclosure](https://app.leg.wa.gov/rcw/default.aspx?cite=42.56&full=true&pdf=true)
86
+ - [Department of Health](https://app.leg.wa.gov/rcw/default.aspx?cite=43.70&full=true&pdf=true)
87
+ - [Uniform Food, Drug and Cosmetic Act](https://app.leg.wa.gov/rcw/default.aspx?cite=69.04&full=true&pdf=true)
88
+ - [Washington Caustic Poison Act of 1929](https://app.leg.wa.gov/rcw/default.aspx?cite=69.36&full=true&pdf=true)
89
+ - [Poisons - Sales and Manufacturing](https://app.leg.wa.gov/rcw/default.aspx?cite=69.38&full=true&pdf=true)
90
+ - [Poisons and Dangerous Drugs](https://app.leg.wa.gov/rcw/default.aspx?cite=69.40&full=true&pdf=true)
91
+ - [Legend Drugs . . . Prescription Drugs](https://app.leg.wa.gov/rcw/default.aspx?cite=69.41&full=true&pdf=true)
92
+ - [Precursor Drugs](https://app.leg.wa.gov/rcw/default.aspx?cite=69.43&full=true&pdf=true)
93
+ - [Drug Samples](https://app.leg.wa.gov/rcw/default.aspx?cite=69.45&full=true&pdf=true)
94
+ - [Drug Take-Back Program Secure Medication Return webpage](https://app.leg.wa.gov/rcw/default.aspx?cite=69.48&full=true&pdf=true)
95
+ - [Uniform Controlled Substances Act](https://app.leg.wa.gov/rcw/default.aspx?cite=69.50&full=true&pdf=true)
96
+ - [Controlled Substances Therapeutic Research Act](https://app.leg.wa.gov/rcw/default.aspx?cite=69.51&full=true&pdf=true)
97
+ - [Medical Cannabis](https://app.leg.wa.gov/rcw/default.aspx?cite=69.51A&full=true&pdf=true)
98
+ - [Imitation Controlled Substances](https://app.leg.wa.gov/rcw/default.aspx?cite=69.52&full=true&pdf=true)
99
+ - [Use of Buildings for Unlawful Drugs](https://app.leg.wa.gov/rcw/default.aspx?cite=69.53&full=true&pdf=true)
100
+ - [Over-the-Counter Medications - Imprinting](https://app.leg.wa.gov/rcw/default.aspx?cite=69.60&full=true&pdf=true)
101
+ - [Access to prescription drugs](https://app.leg.wa.gov/rcw/default.aspx?cite=69.70&full=true&pdf=true)
102
+ - [Dextromethorphan](https://app.leg.wa.gov/rcw/default.aspx?cite=69.75&full=true&pdf=true)
103
+ - [Medical Records-Health Care Information Access and Disclosure](https://app.leg.wa.gov/rcw/default.aspx?cite=70.02&full=true&pdf=true)
104
+ - [Miscellaneous Health and Safety Provisions 70.54.400 Retail restroom access – Customers with medical conditions – Penalty 70.54.440 Epinephrine autoinjectors – Prescribing to certain entities-training-Liability-incident reporting](https://app.leg.wa.gov/rcw/default.aspx?cite=70.54&full=true&pdf=true)
105
+ - [Drug Injection Devices](https://app.leg.wa.gov/rcw/default.aspx?cite=70.115&full=true&pdf=true)
106
+ - [Prescription Monitoring Program](https://app.leg.wa.gov/rcw/default.aspx?cite=70.225&full=true&pdf=true)
107
+ - [The Washington Death With Dignity Act](https://app.leg.wa.gov/rcw/default.aspx?cite=70.245&full=true&pdf=true)
108
+ - [Abuse of Vulnerable Adults](https://app.leg.wa.gov/rcw/default.aspx?cite=74.34&full=true&pdf=true)
109
+ - [Medical Test Site Rules](https://app.leg.wa.gov/wac/default.aspx?cite=246-338&full=true&pdf=true)
110
+ - [Hospital Licensing Regulations](https://app.leg.wa.gov/wac/default.aspx?cite=246-320&full=true&pdf=true)
111
+ - [Hospital Licensing and Regulation](https://app.leg.wa.gov/rcw/default.aspx?cite=70.41&full=true&pdf=true)
112
+ - [Medical Test Sites](https://app.leg.wa.gov/rcw/default.aspx?cite=70.42&full=true&pdf=true)
113
+ - [Medical Use of Radioactive Material](https://app.leg.wa.gov/wac/default.aspx?cite=246-240&full=true&pdf=true)
114
+ - [Radiation Protection Standards](https://app.leg.wa.gov/wac/default.aspx?cite=246-221&full=true&pdf=true)
115
+ - [Physicians](https://app.leg.wa.gov/rcw/default.aspx?cite=18.71&full=true&pdf=true)
116
+ - [Physician Assistants](https://app.leg.wa.gov/rcw/default.aspx?cite=18.71A&full=true&pdf=true)
117
+ - [Nursing Care](https://app.leg.wa.gov/rcw/default.aspx?cite=18.79&full=true&pdf=true)
118
+ - [Radiologic Technologies](https://app.leg.wa.gov/rcw/default.aspx?cite=18.84&full=true&pdf=true)
119
+ - [Medical Assistants](https://app.leg.wa.gov/rcw/default.aspx?cite=18.370&full=true&pdf=true)
120
  """) #, unsafe_allow_html=True)
121
  st.write("This is tool is meant to assist healthcare workers to the extent it can. Please note that the page numbers may be occasionally slightly off, use the matching excerpts to find the reference if this happens.")
122
 
 
130
 
131
  for i in range(n):
132
  with st.container():
133
+ page = str(answer['source_documents'][i].metadata['page'])
134
+ page_no = "#page=" + page + ")"
135
+ st.subheader(source_dictionary[answer['source_documents'][i].metadata['source']].replace(")",page_no))
136
+ page_no = "**Page: " + page + "**"
137
  st.markdown(page_no)
138
  st.write("...")
139
  st.write(answer['source_documents'][i].page_content)