carisackc commited on
Commit
d1a9c9f
·
1 Parent(s): 4f828cb

Update pages/2_Daily Narrative.py

Browse files
Files changed (1) hide show
  1. pages/2_Daily Narrative.py +40 -5
pages/2_Daily Narrative.py CHANGED
@@ -8,6 +8,34 @@ import spacy
8
  from spacy import displacy
9
  import en_ner_bc5cdr_md
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  # Store the initial value of widgets in session state
12
  if "visibility" not in st.session_state:
13
  st.session_state.visibility = "visible"
@@ -65,18 +93,25 @@ patientid = col3.write(f"Patient ID: {patient} ")
65
  admissionid =col4.write(f"Admission ID: {HospitalAdmission} ")
66
 
67
 
 
68
  ##========= Buttons to the 4 tabs ========
69
  col1, col2, col3, col4 = st.columns(4)
70
  with col1:
71
  # st.button('Admission')
72
- st.button("🏥 Admission")
 
 
73
  with col2:
74
- st.button('📆Daily Narrative')
 
 
75
  with col3:
76
- st.button('Discharge Plan')
 
77
  with col4:
78
- st.button('📝Social Notes')
79
-
 
80
 
81
  # Query out relevant Clinical notes
82
  original_text = df.query(
 
8
  from spacy import displacy
9
  import en_ner_bc5cdr_md
10
 
11
+ from streamlit.components.v1 import html
12
+
13
+ def nav_page(page_name, timeout_secs=3):
14
+ nav_script = """
15
+ <script type="text/javascript">
16
+ function attempt_nav_page(page_name, start_time, timeout_secs) {
17
+ var links = window.parent.document.getElementsByTagName("a");
18
+ for (var i = 0; i < links.length; i++) {
19
+ if (links[i].href.toLowerCase().endsWith("/" + page_name.toLowerCase())) {
20
+ links[i].click();
21
+ return;
22
+ }
23
+ }
24
+ var elasped = new Date() - start_time;
25
+ if (elasped < timeout_secs * 1000) {
26
+ setTimeout(attempt_nav_page, 100, page_name, start_time, timeout_secs);
27
+ } else {
28
+ alert("Unable to navigate to page '" + page_name + "' after " + timeout_secs + " second(s).");
29
+ }
30
+ }
31
+ window.addEventListener("load", function() {
32
+ attempt_nav_page("%s", new Date(), %d);
33
+ });
34
+ </script>
35
+ """ % (page_name, timeout_secs)
36
+ html(nav_script)
37
+
38
+
39
  # Store the initial value of widgets in session state
40
  if "visibility" not in st.session_state:
41
  st.session_state.visibility = "visible"
 
93
  admissionid =col4.write(f"Admission ID: {HospitalAdmission} ")
94
 
95
 
96
+
97
  ##========= Buttons to the 4 tabs ========
98
  col1, col2, col3, col4 = st.columns(4)
99
  with col1:
100
  # st.button('Admission')
101
+ if st.button("🏥 Admission"):
102
+ nav_page('Admission')
103
+
104
  with col2:
105
+ if st.button('📆Daily Narrative'):
106
+ nav_page('Daily Narrative')
107
+
108
  with col3:
109
+ if st.button('Discharge Plan'):
110
+ nav_pages('Discharge Plan')
111
  with col4:
112
+ if st.button('📝Social Notes'):
113
+ nav_page('Social Notes')
114
+
115
 
116
  # Query out relevant Clinical notes
117
  original_text = df.query(