carisackc commited on
Commit
e6b122b
1 Parent(s): 042c4fe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -13
app.py CHANGED
@@ -46,23 +46,26 @@ st.markdown(
46
  )
47
  st.sidebar.markdown('Using transformer model')
48
 
49
- ## Loading in dataset
 
50
  df = pd.read_csv('shpi25nov.csv')
51
 
52
- #Loading in Admission chief Complaint and diagnosis
53
  df2 = pd.read_csv('cohort_cc_adm_diag.csv')
54
 
55
- #Loading in Dischare History
56
  df3 = pd.read_csv('cohort_past_history_12072022.csv')
57
 
58
- #combining both data into one
59
  df = pd.merge(df, df2, on=['HADM_ID','SUBJECT_ID'])
60
 
 
 
 
 
61
  df['HADM_ID'] = df['HADM_ID'].astype(str).apply(lambda x: x.replace('.0',''))
62
  df3['HADM_ID'] = df3['HADM_ID'].astype(str).apply(lambda x: x.replace('.0',''))
63
 
64
- del df2
65
-
66
  #Renaming column
67
  df.rename(columns={'SUBJECT_ID':'Patient_ID',
68
  'HADM_ID':'Admission_ID',
@@ -70,24 +73,25 @@ df.rename(columns={'SUBJECT_ID':'Patient_ID',
70
  'hpi_reference_summary':'Reference_text'}, inplace = True)
71
  df3.rename(columns={'SUBJECT_ID':'Patient_ID'}, inplace = True)
72
 
73
- #data.rename(columns={'gdp':'log(gdp)'}, inplace=True)
74
-
75
  #Filter selection
76
  st.sidebar.header("Search for Patient:")
77
 
 
78
  patientid = df['Patient_ID']
79
- patient = st.sidebar.selectbox('Select Patient ID:', patientid)
80
- admissionid = df['Admission_ID'].loc[df['Patient_ID'] == patient]
81
- HospitalAdmission = st.sidebar.selectbox(' ', admissionid)
82
- pastHistoryEpid = df3['HADM_ID'].loc[df3['Patient_ID'] == patient]
83
 
84
 
85
  # List of Model available
86
  model = st.sidebar.selectbox('Select Model', ('BertSummarizer','BertGPT2','t5seq2eq','t5','gensim','pysummarizer'))
87
 
 
88
  col3,col4 = st.columns(2)
89
  patientid = col3.write(f"Patient ID: {patient} ")
90
  admissionid =col4.write(f"Admission ID: {HospitalAdmission} ")
 
91
  runtext = ''
92
  inputNote ='Input note here:'
93
  # Query out relevant Clinical notes
@@ -147,6 +151,8 @@ with st.container():
147
  #st.date_input('Select Admission Date') # To replace with a dropdown filter instead
148
  #st.selectbox('Past Episodes',pastHistoryEp)
149
  pastHistory = st.selectbox(' ', pastHistoryEpid)
 
 
150
 
151
  ##========= END on Past History Tab =========
152
 
@@ -302,7 +308,11 @@ with col1:
302
  st.text_area('Reference text', str(reference_text), height=150)
303
  else:
304
  with st.expander('Full Discharge Summary'):
305
- st.write( str(original_text2))
 
 
 
 
306
  ##====== Storing the Diseases/Text
307
  table= {"Entity":[], "Class":[]}
308
  ent_bc = {}
 
46
  )
47
  st.sidebar.markdown('Using transformer model')
48
 
49
+ ## ======== Loading dataset ========
50
+ ## Loading in Admission Dataset
51
  df = pd.read_csv('shpi25nov.csv')
52
 
53
+ # Loading in Admission chief Complaint and diagnosis
54
  df2 = pd.read_csv('cohort_cc_adm_diag.csv')
55
 
56
+ # Loading in Dischare History
57
  df3 = pd.read_csv('cohort_past_history_12072022.csv')
58
 
59
+ # combining both data into one
60
  df = pd.merge(df, df2, on=['HADM_ID','SUBJECT_ID'])
61
 
62
+ # Deleting admission chief complaint and diagnosis after combining
63
+ del df2
64
+
65
+ # Remove decimal point from Admission ID
66
  df['HADM_ID'] = df['HADM_ID'].astype(str).apply(lambda x: x.replace('.0',''))
67
  df3['HADM_ID'] = df3['HADM_ID'].astype(str).apply(lambda x: x.replace('.0',''))
68
 
 
 
69
  #Renaming column
70
  df.rename(columns={'SUBJECT_ID':'Patient_ID',
71
  'HADM_ID':'Admission_ID',
 
73
  'hpi_reference_summary':'Reference_text'}, inplace = True)
74
  df3.rename(columns={'SUBJECT_ID':'Patient_ID'}, inplace = True)
75
 
 
 
76
  #Filter selection
77
  st.sidebar.header("Search for Patient:")
78
 
79
+ # ===== Initial filter for patient and admission id =====
80
  patientid = df['Patient_ID']
81
+ patient = st.sidebar.selectbox('Select Patient ID:', patientid) #Filter Patient
82
+ admissionid = df['Admission_ID'].loc[df['Patient_ID'] == patient] #Filter available Admission id for patient
83
+ HospitalAdmission = st.sidebar.selectbox(' ', admissionid)
84
+ pastHistoryEpid = df3['HADM_ID'].loc[df3['Patient_ID'] == patient] #Filter list of available Past History (for History tab)
85
 
86
 
87
  # List of Model available
88
  model = st.sidebar.selectbox('Select Model', ('BertSummarizer','BertGPT2','t5seq2eq','t5','gensim','pysummarizer'))
89
 
90
+ # ===== to display selected patient and admission id on main page
91
  col3,col4 = st.columns(2)
92
  patientid = col3.write(f"Patient ID: {patient} ")
93
  admissionid =col4.write(f"Admission ID: {HospitalAdmission} ")
94
+
95
  runtext = ''
96
  inputNote ='Input note here:'
97
  # Query out relevant Clinical notes
 
151
  #st.date_input('Select Admission Date') # To replace with a dropdown filter instead
152
  #st.selectbox('Past Episodes',pastHistoryEp)
153
  pastHistory = st.selectbox(' ', pastHistoryEpid)
154
+
155
+
156
 
157
  ##========= END on Past History Tab =========
158
 
 
308
  st.text_area('Reference text', str(reference_text), height=150)
309
  else:
310
  with st.expander('Full Discharge Summary'):
311
+ historyAdmission = df.query(
312
+ "Patient_ID == @patient & Admission_ID == @pastHistory"
313
+ )
314
+ fulldischargesummary = historyAdmission['TEXT'].values
315
+ st.write( str(fulldischargesummary))
316
  ##====== Storing the Diseases/Text
317
  table= {"Entity":[], "Class":[]}
318
  ent_bc = {}