carisackc commited on
Commit
68183e5
·
1 Parent(s): ee8b1e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -45
app.py CHANGED
@@ -66,6 +66,7 @@ df3['HADM_ID'] = df3['HADM_ID'].astype(str).apply(lambda x: x.replace('.0',''))
66
  df3['INDEX_HADM_ID'] = df3['INDEX_HADM_ID'].astype(str).apply(lambda x: x.replace('.0',''))
67
  df3["CHARTDATE_HADM_ID"] = df3["CHARTDATE"].astype(str) +' - '+ df3["HADM_ID"]
68
  df3["DIAGNOSIS"] = df3["DIAGNOSIS"].str.capitalize()
 
69
 
70
  df3["TEXT"] =df3["TEXT"].replace(r'\n',' \n ', regex=True)
71
 
@@ -139,6 +140,9 @@ with st.container():
139
  if btnPastHistory:
140
  inputNote = "Input History records"
141
 
 
 
 
142
  ##========= on Past History Tab =========
143
 
144
  with st.container():
@@ -152,20 +156,16 @@ with st.container():
152
  pastHistory = st.selectbox(' ', pastHistoryEpDate,on_change=None,)
153
 
154
  if btnPastHistory:
 
155
  st.write('Past History')
156
  historyAdmission = df3.query(
157
  "Patient_ID == @patient & CHARTDATE_HADM_ID == @pastHistory"
158
  )
159
- st.markdown('Admission Date: ' + historyAdmission['ADMITTIME'].values[0])
160
- st.markdown('Date of Discharge: ' + historyAdmission['DISCHTIME'].values[0])
161
- st.markdown('Days from current admission: ' + str(historyAdmission['days_from_index'].values[0]) +' days')
162
- st.markdown('Summary: ')
163
  if model == "BertSummarizer":
164
- st.markdown(str(historyAdmission['BertSummarizer'].values[0]))
165
  elif model == "t5seq2eq":
166
- st.markdown(str(historyAdmission['t5seq2eq'].values[0]))
167
- st.markdown('Diagnosis: ' + str(historyAdmission['DIAGNOSIS'].values[0]))
168
- st.markdown('Discharge Disposition: ' + str(historyAdmission['DISCHARGE_LOCATION'].values[0]))
169
  else:
170
  runtext =st.text_area(inputNote, str(original_text2), height=300)
171
 
@@ -315,46 +315,51 @@ def run_model(input_text):
315
 
316
  col1, col2 = st.columns([1,1])
317
 
318
- with col1:
319
- if not(btnPastHistory): #to not show summary and references text for Past History
320
- st.button('Summarize')
321
- run_model(runtext)
322
- #sentences=runtext.split('.')
323
- st.text_area('Reference text', str(reference_text), height=150)
324
- else:
325
- with st.expander('Full Discharge Summary'):
326
- #st.write("line 1 \n line 2 \n line 3")
327
- fulldischargesummary = historyAdmission['TEXT'].values[0]
328
- st.write(fulldischargesummary)
329
-
330
- ##====== Storing the Diseases/Text -No longer in use
331
- # table= {"Entity":[], "Class":[]}
332
- # ent_bc = {}
333
- # for x in doc.ents:
334
- # ent_bc[x.text] = x.label_
335
- # for key in ent_bc:
336
- # table["Entity"].append(key)
337
- # table["Class"].append(ent_bc[key])
338
- # trans_df = pd.DataFrame(table)
339
-
 
 
 
 
 
340
  # ===== Adding the Disease/Chemical into a list =====
341
  problem_entities = list(dedupe([t for t in doc0.ents if t.label_ == 'DISEASE']))
342
  medication_entities = list(dedupe([t for t in doc0.ents if t.label_ == 'CHEMICAL']))
343
-
344
- with col2:
345
- st.button('NER')
346
- st.markdown('**CHIEF COMPLAINT:**')
347
- st.write(str(AdmissionChiefCom)[1:-1])
348
- st.markdown('**ADMISSION DIAGNOSIS:**')
349
- st.markdown(str(diagnosis)[1:-1])
 
 
350
  st.markdown('**PROBLEM/ISSUE**')
351
- #st.markdown(problem_entities)
352
  st.markdown(f'<p style="background-color:PINK;color:#080808;font-size:16px;">{str(problem_entities)[1:-1]}</p>', unsafe_allow_html=True)
353
- #genEntities(trans_df, 'DISEASE')
354
  st.markdown('**MEDICATION**')
355
- st.markdown(f'<p style="background-color:orange;color:#080808;font-size:16px;">{str(medication_entities)[1:-1]}</p>', unsafe_allow_html=True)
356
- #genEntities(trans_df, 'CHEMICAL')
357
- #st.table(trans_df)
358
- st.markdown('**NER**')
359
- with st.expander("See NER Details"):
360
- st.markdown(ent_html, unsafe_allow_html=True)
 
66
  df3['INDEX_HADM_ID'] = df3['INDEX_HADM_ID'].astype(str).apply(lambda x: x.replace('.0',''))
67
  df3["CHARTDATE_HADM_ID"] = df3["CHARTDATE"].astype(str) +' - '+ df3["HADM_ID"]
68
  df3["DIAGNOSIS"] = df3["DIAGNOSIS"].str.capitalize()
69
+ df3["DISCHARGE_LOCATION"] = df3["DISCHARGE_LOCATION"].str.capitalize()
70
 
71
  df3["TEXT"] =df3["TEXT"].replace(r'\n',' \n ', regex=True)
72
 
 
140
  if btnPastHistory:
141
  inputNote = "Input History records"
142
 
143
+
144
+
145
+
146
  ##========= on Past History Tab =========
147
 
148
  with st.container():
 
156
  pastHistory = st.selectbox(' ', pastHistoryEpDate,on_change=None,)
157
 
158
  if btnPastHistory:
159
+
160
  st.write('Past History')
161
  historyAdmission = df3.query(
162
  "Patient_ID == @patient & CHARTDATE_HADM_ID == @pastHistory"
163
  )
 
 
 
 
164
  if model == "BertSummarizer":
165
+ runtext = historyAdmission['BertSummarizer'].values[0]
166
  elif model == "t5seq2eq":
167
+ runtext = historyAdmission['t5seq2eq'].values[0]
168
+
 
169
  else:
170
  runtext =st.text_area(inputNote, str(original_text2), height=300)
171
 
 
315
 
316
  col1, col2 = st.columns([1,1])
317
 
318
+ if not(btnPastHistory): #to not show summary and references text for Past History
319
+ with col1:
320
+ st.button('Summarize')
321
+ run_model(runtext)
322
+ #sentences=runtext.split('.')
323
+ st.text_area('Reference text', str(reference_text), height=150)
324
+ with col2:
325
+ st.button('NER')
326
+ # ===== Adding the Disease/Chemical into a list =====
327
+ problem_entities = list(dedupe([t for t in doc0.ents if t.label_ == 'DISEASE']))
328
+ medication_entities = list(dedupe([t for t in doc0.ents if t.label_ == 'CHEMICAL']))
329
+ st.markdown('**CHIEF COMPLAINT:**')
330
+ st.write(str(AdmissionChiefCom)[1:-1])
331
+ st.markdown('**ADMISSION DIAGNOSIS:**')
332
+ st.markdown(str(diagnosis)[1:-1])
333
+ st.markdown('**PROBLEM/ISSUE**')
334
+ #st.markdown(problem_entities)
335
+ st.markdown(f'<p style="background-color:PINK;color:#080808;font-size:16px;">{str(problem_entities)[1:-1]}</p>', unsafe_allow_html=True)
336
+ #genEntities(trans_df, 'DISEASE')
337
+ st.markdown('**MEDICATION**')
338
+ st.markdown(f'<p style="background-color:orange;color:#080808;font-size:16px;">{str(medication_entities)[1:-1]}</p>', unsafe_allow_html=True)
339
+ #genEntities(trans_df, 'CHEMICAL')
340
+ #st.table(trans_df)
341
+ st.markdown('**NER**')
342
+ with st.expander("See NER Details"):
343
+ st.markdown(ent_html, unsafe_allow_html=True)
344
+ else:
345
  # ===== Adding the Disease/Chemical into a list =====
346
  problem_entities = list(dedupe([t for t in doc0.ents if t.label_ == 'DISEASE']))
347
  medication_entities = list(dedupe([t for t in doc0.ents if t.label_ == 'CHEMICAL']))
348
+ st.markdown('Admission Date: ' + historyAdmission['ADMITTIME'].values[0])
349
+ st.markdown('Date of Discharge: ' + historyAdmission['DISCHTIME'].values[0])
350
+ st.markdown('Days from current admission: ' + str(historyAdmission['days_from_index'].values[0]) +' days')
351
+ st.markdown('Summary: ')
352
+ if model == "BertSummarizer":
353
+ st.markdown(str(historyAdmission['BertSummarizer'].values[0]))
354
+ elif model == "t5seq2eq":
355
+ st.markdown(str(historyAdmission['t5seq2eq'].values[0]))
356
+ st.markdown('Diagnosis: ' + str(historyAdmission['DIAGNOSIS'].values[0]))
357
  st.markdown('**PROBLEM/ISSUE**')
 
358
  st.markdown(f'<p style="background-color:PINK;color:#080808;font-size:16px;">{str(problem_entities)[1:-1]}</p>', unsafe_allow_html=True)
 
359
  st.markdown('**MEDICATION**')
360
+ st.markdown(f'<p style="background-color:orange;color:#080808;font-size:16px;">{str(medication_entities)[1:-1]}</p>', unsafe_allow_html=True)
361
+ st.markdown('Discharge Disposition: ' + str(historyAdmission['DISCHARGE_LOCATION'].values[0]))
362
+ with st.expander('Full Discharge Summary'):
363
+ #st.write("line 1 \n line 2 \n line 3")
364
+ fulldischargesummary = historyAdmission['TEXT'].values[0]
365
+ st.write(fulldischargesummary)