Spaces:
Build error
Build error
Update app.py
Browse files
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 |
-
|
| 165 |
elif model == "t5seq2eq":
|
| 166 |
-
|
| 167 |
-
|
| 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 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
#
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 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 |
-
|
| 345 |
-
st.
|
| 346 |
-
st.markdown('
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
|
|
|
|
|
|
| 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 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
|
|
|
| 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)
|