Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -99,7 +99,7 @@ select_style = """
|
|
| 99 |
mobile_style = {'font-size': f'{fpx}', 'padding': '40px'}
|
| 100 |
first_year = df['year'].nsmallest(2).iloc[-1]
|
| 101 |
|
| 102 |
-
col_options = ['ASC/LSIL', 'ASC-US/ASC-H ratio(%)','
|
| 103 |
column_changer = pn.widgets.Select(name='Select QA Parameter', options=col_options, styles = mobile_style, width = 400, height=150, margin = 0,stylesheets= [select_style])
|
| 104 |
year_slider = pn.widgets.Select(name='Select Year', value = int(df.year.max()),options=list(range(int(first_year), int(df.year.max())+1)), styles = mobile_style, width = 400, height=150, margin = 0,stylesheets= [select_style])
|
| 105 |
|
|
@@ -215,7 +215,7 @@ vertical_legend_indiv =vertical_legend_indiv.hide(axis='rows')
|
|
| 215 |
vertical_legend_indiv= pn.pane.DataFrame(vertical_legend_indiv, index= False)
|
| 216 |
vertical_legend_indiv= pn.Column("## Legend", vertical_legend_indiv)
|
| 217 |
|
| 218 |
-
zcol = [col_options[0],col_options[1],col_options[
|
| 219 |
zscore_base = df[zcol]
|
| 220 |
new_row = [0.75, 12.5, 1.5]
|
| 221 |
zscore_base.iloc[1] = new_row
|
|
@@ -255,8 +255,8 @@ def find_last_decreasing_element(lst):
|
|
| 255 |
return lst[i-1]
|
| 256 |
return lst[len(lst)-1]
|
| 257 |
def labres(column_changer):
|
| 258 |
-
lab_zscore = zscore_eval.get_group('
|
| 259 |
-
abs_results = df[df['people'] == '
|
| 260 |
|
| 261 |
|
| 262 |
asc_abn_outliers = zscore_df[(zscore_df['people'].str.contains('Cyto'))&(zscore_df['year']==int(df.year.max()))]
|
|
@@ -269,11 +269,11 @@ def labres(column_changer):
|
|
| 269 |
lab_comment_3= f"No outliers regarding {column_changer}"
|
| 270 |
lab_comment_4 = ""
|
| 271 |
if column_changer == col_options[1]:
|
| 272 |
-
avg_zscore = zscore_eval.get_group('
|
| 273 |
descript = f"**Description:** *ASC-US/ASC-H ratio literature reference value 90% / 10%. Given our average laboratory Z score of {avg_zscore:.2f} the attention threshold is at 65% / 35%.*<br><br>"
|
| 274 |
-
if column_changer == col_options[
|
| 275 |
descript = "**Description:** *Abnormal Rate represents the relative ratio of ASC, SIL and AGC diagnoses. Alterations ( Z Score: <-2) means a level of insecurity that requires attention.*<br><br>"
|
| 276 |
-
if column_changer == col_options[1] or column_changer == col_options[
|
| 277 |
|
| 278 |
lab_value = lab_zscore[column_changer].iloc[len(lab_zscore)-1]
|
| 279 |
|
|
@@ -336,35 +336,35 @@ def labres(column_changer):
|
|
| 336 |
lab_comment_5= ""
|
| 337 |
lab_comment_6= ""
|
| 338 |
# Thyroid Rate(%):
|
| 339 |
-
elif column_changer == col_options[2]:
|
| 340 |
-
descript = "**Description:** *Thyroid AUS Rate signifies the ratio of AUS (TBS 3) cytology reports. More than 15% requires attention.* <br><br>"
|
| 341 |
-
thyroid_value = abs_results[column_changer].iloc[len(abs_results)-1]
|
| 342 |
|
| 343 |
-
if thyroid_value < 10:
|
| 344 |
-
|
| 345 |
-
elif 10 < thyroid_value < 15:
|
| 346 |
-
|
| 347 |
-
else:
|
| 348 |
-
|
| 349 |
-
if (thyroid_value > 10) & (abs_results[column_changer].iloc[len(abs_results)-1] > abs_results[column_changer].iloc[len(abs_results)-2]):
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
else:
|
| 353 |
-
|
| 354 |
-
if (thy_outlier[column_changer] > 15).any():
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
lab_comment_5= ""
|
| 365 |
-
lab_comment_6= ""
|
| 366 |
# Referral Rate(%)
|
| 367 |
-
elif column_changer == col_options[
|
| 368 |
descript = "**Description:** *Referral Rate signifies the ratio the Cytologist consults cases. < 5 % and > 15% requires attention.*<br><br>"
|
| 369 |
referral_value = abs_results['Referral Rate(%)'].iloc[len(abs_results)-1]
|
| 370 |
|
|
@@ -420,7 +420,7 @@ inter_labres = pn.bind(labres, column_changer)
|
|
| 420 |
|
| 421 |
|
| 422 |
def lab_management(year_slider, column_changer):
|
| 423 |
-
scatterdata = df[(df.year == year_slider)&(df.people.str.contains('
|
| 424 |
ascending=False,key=natsort_keygen()).reset_index(drop=True)
|
| 425 |
ref = df[column_changer].iloc[0]
|
| 426 |
lab = scatterdata[column_changer].iloc[0]
|
|
@@ -474,19 +474,19 @@ def lab_management(year_slider, column_changer):
|
|
| 474 |
ascus_bg = (asc_us_goal.opts(color='#ACFFA0', alpha = 0.75)* asc_us_att.opts(color='#B34D93', alpha = 0.9)*\
|
| 475 |
asc_us_bdln.opts(color='#6AB35F', alpha = 0.75))
|
| 476 |
return (ascus_bg* ref_vline * lab_vline*scatter_plot).opts(shared_axes=False)
|
| 477 |
-
elif column_changer =='Thyroid AUS Rate(%)':
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
elif column_changer == 'Abnormal Rate(%)':
|
| 491 |
scatter_plot = scatterdata[scatterdata.people.str.contains('Cytol', na=False)].hvplot.scatter(x=column_changer, y='people', color='black', size=sdot_size,height= sheight,
|
| 492 |
xlim=(0,max_x_abn), xticks = [0,lab,ref,3, max_x_abn], grid=True, title=column_changer,
|
|
@@ -514,10 +514,10 @@ def lab_management(year_slider, column_changer):
|
|
| 514 |
return (ref_bg * lab_vline * scatter_plot).opts(toolbar='above', default_tools=[]).opts(shared_axes=False)
|
| 515 |
|
| 516 |
def add_no_cases_lab(year_slider):
|
| 517 |
-
scatterdata = df[(df.year == year_slider)&(df.people.str.contains('
|
| 518 |
gyncase_no = scatterdata['Number'].iloc[0]
|
| 519 |
-
thycase_no = scatterdata['ThyAC Number'].iloc[0]
|
| 520 |
-
return pn.pane.Markdown(f""" **
|
| 521 |
styles = {'font-size':fpx})
|
| 522 |
interactive_no_lab = pn.bind(add_no_cases_lab, year_slider)
|
| 523 |
interactive_func = pn.bind(lab_management, year_slider, column_changer)
|
|
@@ -590,7 +590,7 @@ def ascus_rate_overview_ct(ct_select):
|
|
| 590 |
last_year = ct_result['year'].iloc[-1]
|
| 591 |
second_last_result = ct_result['ASC-US/ASC-H ratio(%)'].iloc[-2]
|
| 592 |
second_last_year = ct_result['year'].iloc[-2]
|
| 593 |
-
avg_zscore = zscore_eval.get_group('
|
| 594 |
if 75 < last_result <= 100:
|
| 595 |
ct_comment = f"Your latest result from **{last_year}** is within the laboratory goal zone **{last_result:.0f}%/{(100-last_result):.0f}%**."
|
| 596 |
ct_comment_2 = ""
|
|
@@ -832,7 +832,7 @@ def ascus_rate_overview_cp(cp_select):
|
|
| 832 |
last_year = ct_result['year'].iloc[-1]
|
| 833 |
second_last_result = ct_result['ASC-US/ASC-H ratio(%)'].iloc[-2]
|
| 834 |
second_last_year = ct_result['year'].iloc[-2]
|
| 835 |
-
avg_zscore = zscore_eval.get_group('
|
| 836 |
if 75 < last_result <= 100:
|
| 837 |
ct_comment = f"Your latest result from **{last_year}** is within the laboratory goal zone **{last_result:.0f}%/{(100-last_result):.0f}%**."
|
| 838 |
ct_comment_2 = ""
|
|
@@ -908,47 +908,47 @@ inter_asclsil_cp = pn.bind(asclsil_rate_overview_cp, cp_select)
|
|
| 908 |
# In[57]:
|
| 909 |
|
| 910 |
|
| 911 |
-
def thyroid_rate_overview_cp(cp_select):
|
| 912 |
-
ct_result = df[df['people'] == cp_select][['Thyroid AUS Rate(%)','year']]
|
| 913 |
-
if ct_result['Thyroid AUS Rate(%)'].sum() > 0.0:
|
| 914 |
-
|
| 915 |
-
|
| 916 |
-
|
| 917 |
-
|
| 918 |
-
|
| 919 |
-
|
| 920 |
-
|
| 921 |
-
|
| 922 |
-
|
| 923 |
-
|
| 924 |
-
|
| 925 |
-
|
| 926 |
-
|
| 927 |
-
|
| 928 |
-
|
| 929 |
-
elif last_result > 15:
|
| 930 |
-
|
| 931 |
-
|
| 932 |
-
|
| 933 |
-
else:
|
| 934 |
-
|
| 935 |
-
|
| 936 |
-
|
| 937 |
-
|
| 938 |
-
|
| 939 |
-
|
| 940 |
-
|
| 941 |
-
|
| 942 |
-
|
| 943 |
-
|
| 944 |
-
|
| 945 |
-
|
| 946 |
-
|
| 947 |
-
else:
|
| 948 |
-
|
| 949 |
-
|
| 950 |
-
|
| 951 |
-
inter_thyroid_cp = pn.bind(thyroid_rate_overview_cp, cp_select)
|
| 952 |
# In[12]:
|
| 953 |
|
| 954 |
|
|
@@ -999,28 +999,28 @@ def update_scatter(year_slider,cp_select):
|
|
| 999 |
ascus_bg = (asc_us_goal.opts(color='#ACFFA0', alpha = 0.75)*asc_us_bdln.opts(color='#6AB35F', alpha = 0.9)*\
|
| 1000 |
asc_us_att.opts(color='#B34D93', alpha = 0.9))
|
| 1001 |
|
| 1002 |
-
if pd.isna(scatterdata['Thyroid AUS Rate(%)'].iloc[0]):
|
| 1003 |
-
|
| 1004 |
-
|
| 1005 |
-
else:
|
| 1006 |
-
|
| 1007 |
-
|
| 1008 |
-
|
| 1009 |
-
|
| 1010 |
-
|
| 1011 |
-
|
| 1012 |
-
|
| 1013 |
-
|
| 1014 |
-
|
| 1015 |
-
|
| 1016 |
-
|
| 1017 |
-
|
| 1018 |
-
|
| 1019 |
-
|
| 1020 |
-
|
| 1021 |
-
|
| 1022 |
-
|
| 1023 |
-
|
| 1024 |
|
| 1025 |
else:
|
| 1026 |
return pn.pane.Markdown("# N/A", styles={'font-size':'20px'})
|
|
@@ -1031,11 +1031,11 @@ def add_no_cases_cp(year_slider,cp_select):
|
|
| 1031 |
scatterdata = df[(df.year == year_slider)&(df['people'] == cp_select)]
|
| 1032 |
if len(scatterdata) > 0:
|
| 1033 |
case_no = scatterdata['Number'].iloc[0]
|
| 1034 |
-
if pd.isna(scatterdata['Thyroid AUS Rate(%)'].iloc[0]):
|
| 1035 |
-
|
| 1036 |
-
else:
|
| 1037 |
-
|
| 1038 |
-
|
| 1039 |
|
| 1040 |
|
| 1041 |
|
|
@@ -1048,7 +1048,7 @@ interactive_no_cp = pn.bind(add_no_cases_cp,year_slider,cp_select)
|
|
| 1048 |
cp_performance = pn.Tabs(('Performance results',pn.Column(pn.Row(cp_select,year_slider),interactive_no_cp,\
|
| 1049 |
pn.Row(pn.Column(pn.pane.Markdown("<br><br>"),vertical_legend_indiv),interactive_qa, height = 600 )\
|
| 1050 |
,pn.Column(pn.pane.Markdown("<br><br>"),modal_btn)))\
|
| 1051 |
-
,('Results overview',pn.Column(cp_select, inter_asclsil_cp, inter_ascus_cp
|
| 1052 |
|
| 1053 |
|
| 1054 |
|
|
@@ -1068,7 +1068,7 @@ cp_performance = pn.Tabs(('Performance results',pn.Column(pn.Row(cp_select,year_
|
|
| 1068 |
|
| 1069 |
|
| 1070 |
results = df[df['year'] != 2017]
|
| 1071 |
-
med_ref_distribution = pd.concat([results[results.people.str.contains('
|
| 1072 |
med_ref_distribution.loc[len(med_ref_distribution)] = {'ASC/LSIL':0.75,'ASC-US/ASC-H ratio(%)':12.5, 'Abnormal Rate(%)':1.5}
|
| 1073 |
|
| 1074 |
|
|
@@ -1110,7 +1110,7 @@ def hook_abnorm(plot, element):
|
|
| 1110 |
|
| 1111 |
|
| 1112 |
def add_norm_curves(column_changer,year_slider):
|
| 1113 |
-
if column_changer == '
|
| 1114 |
return None
|
| 1115 |
else:
|
| 1116 |
mu= med_ref_distribution.iloc[-2][column_changer]
|
|
|
|
| 99 |
mobile_style = {'font-size': f'{fpx}', 'padding': '40px'}
|
| 100 |
first_year = df['year'].nsmallest(2).iloc[-1]
|
| 101 |
|
| 102 |
+
col_options = ['ASC/LSIL', 'ASC-US/ASC-H ratio(%)','Abnormal Rate(%)','Referral Rate(%)']
|
| 103 |
column_changer = pn.widgets.Select(name='Select QA Parameter', options=col_options, styles = mobile_style, width = 400, height=150, margin = 0,stylesheets= [select_style])
|
| 104 |
year_slider = pn.widgets.Select(name='Select Year', value = int(df.year.max()),options=list(range(int(first_year), int(df.year.max())+1)), styles = mobile_style, width = 400, height=150, margin = 0,stylesheets= [select_style])
|
| 105 |
|
|
|
|
| 215 |
vertical_legend_indiv= pn.pane.DataFrame(vertical_legend_indiv, index= False)
|
| 216 |
vertical_legend_indiv= pn.Column("## Legend", vertical_legend_indiv)
|
| 217 |
|
| 218 |
+
zcol = [col_options[0],col_options[1],col_options[2]]
|
| 219 |
zscore_base = df[zcol]
|
| 220 |
new_row = [0.75, 12.5, 1.5]
|
| 221 |
zscore_base.iloc[1] = new_row
|
|
|
|
| 255 |
return lst[i-1]
|
| 256 |
return lst[len(lst)-1]
|
| 257 |
def labres(column_changer):
|
| 258 |
+
lab_zscore = zscore_eval.get_group('KGYC')
|
| 259 |
+
abs_results = df[df['people'] == 'KGYC']
|
| 260 |
|
| 261 |
|
| 262 |
asc_abn_outliers = zscore_df[(zscore_df['people'].str.contains('Cyto'))&(zscore_df['year']==int(df.year.max()))]
|
|
|
|
| 269 |
lab_comment_3= f"No outliers regarding {column_changer}"
|
| 270 |
lab_comment_4 = ""
|
| 271 |
if column_changer == col_options[1]:
|
| 272 |
+
avg_zscore = zscore_eval.get_group('KGYC')['ASC-US/ASC-H ratio(%)'].mean()
|
| 273 |
descript = f"**Description:** *ASC-US/ASC-H ratio literature reference value 90% / 10%. Given our average laboratory Z score of {avg_zscore:.2f} the attention threshold is at 65% / 35%.*<br><br>"
|
| 274 |
+
if column_changer == col_options[2]:
|
| 275 |
descript = "**Description:** *Abnormal Rate represents the relative ratio of ASC, SIL and AGC diagnoses. Alterations ( Z Score: <-2) means a level of insecurity that requires attention.*<br><br>"
|
| 276 |
+
if column_changer == col_options[1] or column_changer == col_options[2]:
|
| 277 |
|
| 278 |
lab_value = lab_zscore[column_changer].iloc[len(lab_zscore)-1]
|
| 279 |
|
|
|
|
| 336 |
lab_comment_5= ""
|
| 337 |
lab_comment_6= ""
|
| 338 |
# Thyroid Rate(%):
|
| 339 |
+
#elif column_changer == col_options[2]:
|
| 340 |
+
#descript = "**Description:** *Thyroid AUS Rate signifies the ratio of AUS (TBS 3) cytology reports. More than 15% requires attention.* <br><br>"
|
| 341 |
+
#thyroid_value = abs_results[column_changer].iloc[len(abs_results)-1]
|
| 342 |
|
| 343 |
+
#if thyroid_value < 10:
|
| 344 |
+
# lab_comment = f"Latest record of laboratory result is within laboratory goal zone. {thyroid_value:.2f}%"
|
| 345 |
+
#elif 10 < thyroid_value < 15:
|
| 346 |
+
# lab_comment = f"Latest record of laboratory result is in laboratory borderline zone. {thyroid_value:.2f}%"
|
| 347 |
+
#else:
|
| 348 |
+
# lab_comment = f"Latest laboratory result value is {thyroid_value:.2f}%, performance follow up and global laboratory practice revision is advised."
|
| 349 |
+
#if (thyroid_value > 10) & (abs_results[column_changer].iloc[len(abs_results)-1] > abs_results[column_changer].iloc[len(abs_results)-2]):
|
| 350 |
+
# increasing_tendency = find_values_more_than_previous(lab_zscore[column_changer].to_list())
|
| 351 |
+
# lab_comment_2 = f"with tendencious decrease in performance since year {increasing_tendency[0]+int(first_year)}."
|
| 352 |
+
#else:
|
| 353 |
+
# lab_comment_2 = "with no relevant tendency or no tendency at all in decrease of performance. "
|
| 354 |
+
#if (thy_outlier[column_changer] > 15).any():
|
| 355 |
+
# thy_outly = thy_outlier[thy_outlier[column_changer] > 15]['people'].to_list()
|
| 356 |
+
# lab_comment_3 = f"Outliers regarding {column_changer}: **{thy_outly}**,"
|
| 357 |
+
# for o in thy_outly:
|
| 358 |
+
# if (len(df.groupby(['people']).get_group(o))>1) & (df.groupby(['people']).get_group(o)[column_changer].iloc[len(df.groupby(['people']).get_group(o))-1] >= df.groupby(['people']).get_group(o)[column_changer].iloc[len(df.groupby(['people']).get_group(o))-2]):
|
| 359 |
+
# first_out = find_values_more_than_previous(df.groupby(['people']).get_group(o)[column_changer].to_list())
|
| 360 |
+
# if len(first_out) > 2:
|
| 361 |
+
# lab_comment_4.append(f"**{o}** with tendencious decrease since **{find_first_decrease_in_performance(first_out)+int(first_year)}**")
|
| 362 |
+
# else:
|
| 363 |
+
# lab_comment_4.append(f"**{o}** with tendencious decrease compared to last registered result in**{zscore_eval.get_group(o)['year'].iloc[first_out[0]]}**")
|
| 364 |
+
#lab_comment_5= ""
|
| 365 |
+
#lab_comment_6= ""
|
| 366 |
# Referral Rate(%)
|
| 367 |
+
elif column_changer == col_options[3]:
|
| 368 |
descript = "**Description:** *Referral Rate signifies the ratio the Cytologist consults cases. < 5 % and > 15% requires attention.*<br><br>"
|
| 369 |
referral_value = abs_results['Referral Rate(%)'].iloc[len(abs_results)-1]
|
| 370 |
|
|
|
|
| 420 |
|
| 421 |
|
| 422 |
def lab_management(year_slider, column_changer):
|
| 423 |
+
scatterdata = df[(df.year == year_slider)&(df.people.str.contains('KGYC|Cyto'))].sort_values(by="people", \
|
| 424 |
ascending=False,key=natsort_keygen()).reset_index(drop=True)
|
| 425 |
ref = df[column_changer].iloc[0]
|
| 426 |
lab = scatterdata[column_changer].iloc[0]
|
|
|
|
| 474 |
ascus_bg = (asc_us_goal.opts(color='#ACFFA0', alpha = 0.75)* asc_us_att.opts(color='#B34D93', alpha = 0.9)*\
|
| 475 |
asc_us_bdln.opts(color='#6AB35F', alpha = 0.75))
|
| 476 |
return (ascus_bg* ref_vline * lab_vline*scatter_plot).opts(shared_axes=False)
|
| 477 |
+
#elif column_changer =='Thyroid AUS Rate(%)':
|
| 478 |
+
# scatter_plot = scatterdata[scatterdata.people.str.contains('Cytop', na=False)].hvplot.scatter(x=column_changer, y='people', color='black', size=sdot_size,height= sheight,
|
| 479 |
+
# xlim=(0,30), xticks = [0,lab,10,15,30], grid=True, title=column_changer,
|
| 480 |
+
# xformatter='%.0f',ylabel='',xlabel='',tools = [hover_cp]).opts(fontsize = pl_title,fontscale=f_scale_lab,shared_axes=False,toolbar=None, default_tools = [])
|
| 481 |
+
#
|
| 482 |
+
# aus_goal = hv.VSpan(0, 10).opts(shared_axes=False,toolbar=None, default_tools = [])
|
| 483 |
+
# aus_bdln = hv.VSpan(10,15).opts(shared_axes=False,toolbar=None, default_tools = [])
|
| 484 |
+
# aus_att = hv.VSpan(15, 30).opts(shared_axes=False,toolbar=None, default_tools = [])
|
| 485 |
+
# aus_bg = (aus_goal.opts(color='#ACFFA0', alpha = 0.75)* aus_att.opts(color='#B34D93', alpha = 0.9)*\
|
| 486 |
+
# aus_bdln.opts(color='#6AB35F', alpha = 0.75))
|
| 487 |
+
#
|
| 488 |
+
# return (aus_bg* lab_vline * scatter_plot).opts(shared_axes=False)
|
| 489 |
+
#
|
| 490 |
elif column_changer == 'Abnormal Rate(%)':
|
| 491 |
scatter_plot = scatterdata[scatterdata.people.str.contains('Cytol', na=False)].hvplot.scatter(x=column_changer, y='people', color='black', size=sdot_size,height= sheight,
|
| 492 |
xlim=(0,max_x_abn), xticks = [0,lab,ref,3, max_x_abn], grid=True, title=column_changer,
|
|
|
|
| 514 |
return (ref_bg * lab_vline * scatter_plot).opts(toolbar='above', default_tools=[]).opts(shared_axes=False)
|
| 515 |
|
| 516 |
def add_no_cases_lab(year_slider):
|
| 517 |
+
scatterdata = df[(df.year == year_slider)&(df.people.str.contains('KGYC'))].sort_values(by='year').reset_index(drop=True)
|
| 518 |
gyncase_no = scatterdata['Number'].iloc[0]
|
| 519 |
+
#thycase_no = scatterdata['ThyAC Number'].iloc[0]
|
| 520 |
+
return pn.pane.Markdown(f""" **Case number: {gyncase_no}** """,
|
| 521 |
styles = {'font-size':fpx})
|
| 522 |
interactive_no_lab = pn.bind(add_no_cases_lab, year_slider)
|
| 523 |
interactive_func = pn.bind(lab_management, year_slider, column_changer)
|
|
|
|
| 590 |
last_year = ct_result['year'].iloc[-1]
|
| 591 |
second_last_result = ct_result['ASC-US/ASC-H ratio(%)'].iloc[-2]
|
| 592 |
second_last_year = ct_result['year'].iloc[-2]
|
| 593 |
+
avg_zscore = zscore_eval.get_group('KGYC')['ASC-US/ASC-H ratio(%)'].mean()
|
| 594 |
if 75 < last_result <= 100:
|
| 595 |
ct_comment = f"Your latest result from **{last_year}** is within the laboratory goal zone **{last_result:.0f}%/{(100-last_result):.0f}%**."
|
| 596 |
ct_comment_2 = ""
|
|
|
|
| 832 |
last_year = ct_result['year'].iloc[-1]
|
| 833 |
second_last_result = ct_result['ASC-US/ASC-H ratio(%)'].iloc[-2]
|
| 834 |
second_last_year = ct_result['year'].iloc[-2]
|
| 835 |
+
avg_zscore = zscore_eval.get_group('KGYC')['ASC-US/ASC-H ratio(%)'].mean()
|
| 836 |
if 75 < last_result <= 100:
|
| 837 |
ct_comment = f"Your latest result from **{last_year}** is within the laboratory goal zone **{last_result:.0f}%/{(100-last_result):.0f}%**."
|
| 838 |
ct_comment_2 = ""
|
|
|
|
| 908 |
# In[57]:
|
| 909 |
|
| 910 |
|
| 911 |
+
#def thyroid_rate_overview_cp(cp_select):
|
| 912 |
+
# ct_result = df[df['people'] == cp_select][['Thyroid AUS Rate(%)','year']]
|
| 913 |
+
# if ct_result['Thyroid AUS Rate(%)'].sum() > 0.0:
|
| 914 |
+
#
|
| 915 |
+
# if len(ct_result) > 1:
|
| 916 |
+
# last_result = ct_result['Thyroid AUS Rate(%)'].iloc[-1]
|
| 917 |
+
# second_last_result = ct_result['Thyroid AUS Rate(%)'].iloc[-2]
|
| 918 |
+
# last_year = ct_result['year'].iloc[-1]
|
| 919 |
+
# second_last_year = ct_result['year'].iloc[-2]
|
| 920 |
+
# if 0 < last_result < 10:
|
| 921 |
+
# ct_comment = f"Your latest result from **{last_year}** is within the laboratory goal zone **{last_result:.1f}%**."
|
| 922 |
+
# ct_comment_2 = ""
|
| 923 |
+
# elif 10 <last_result < 15:
|
| 924 |
+
# ct_comment = f"Your latest record from **{last_year}** is in the laboratory borderline zone **{last_result:.1f}%**."
|
| 925 |
+
# if last_result > second_last_result:
|
| 926 |
+
# ct_comment_2 = f"A decrease in the thyroid AUS ratio can be observed compared to your previous record **({second_last_result:.1f}%)** from **{second_last_year}**."
|
| 927 |
+
# else:
|
| 928 |
+
# ct_comment_2 =""
|
| 929 |
+
#elif last_result > 15:
|
| 930 |
+
# ct_comment = f"Your latest registered result from **{last_year}** is **{last_result:.1f}%**, your thyroid AUS ratio is too high. You use the AUS (TBS 3) category too much. "
|
| 931 |
+
# if last_result < second_last_result:
|
| 932 |
+
# ct_comment_2 = f"You performed better compared to your previous record **({second_last_result:.1f}%)** from **{second_last_year}**, but please consult with an experienced cytopathologist."
|
| 933 |
+
#else:
|
| 934 |
+
# ct_comment_2 = f"<br>Please consult with an experienced cytopathologist about your result since your thyroid AUS ratio worsened compared to your previous record **({second_last_result:.1f}%)** from **{second_last_year}**."
|
| 935 |
+
#
|
| 936 |
+
#
|
| 937 |
+
#
|
| 938 |
+
# return pn.pane.Markdown(f"""
|
| 939 |
+
# ## Thyroid AUS Rate(%) Overview:
|
| 940 |
+
# *Thyroid AUS Rate signifies the ratio of TBS 3 cytology reports. More than 15% requires attention.* <br><br>
|
| 941 |
+
# {ct_comment} {ct_comment_2}
|
| 942 |
+
# """, sizing_mode ="stretch_width", styles = {'font-size':fpx})
|
| 943 |
+
# else:
|
| 944 |
+
# return pn.pane.Markdown("""
|
| 945 |
+
# ## Not enough data to calculate parameters.
|
| 946 |
+
# """, styles = {'font-size':fpx})
|
| 947 |
+
#else:
|
| 948 |
+
# return pn.pane.Markdown("""
|
| 949 |
+
# ## Current cytopathologist doesn't examine thyroid FNA cases.
|
| 950 |
+
# """, styles = {'font-size':fpx})
|
| 951 |
+
#inter_thyroid_cp = pn.bind(thyroid_rate_overview_cp, cp_select)
|
| 952 |
# In[12]:
|
| 953 |
|
| 954 |
|
|
|
|
| 999 |
ascus_bg = (asc_us_goal.opts(color='#ACFFA0', alpha = 0.75)*asc_us_bdln.opts(color='#6AB35F', alpha = 0.9)*\
|
| 1000 |
asc_us_att.opts(color='#B34D93', alpha = 0.9))
|
| 1001 |
|
| 1002 |
+
#if pd.isna(scatterdata['Thyroid AUS Rate(%)'].iloc[0]):
|
| 1003 |
+
# return ((asclsil_bg* ref_lsil_vline * lab_lsil_vline * scatter_lsil).opts(toolbar='above') +\
|
| 1004 |
+
# (ascus_bg* ref_ascus_vline * lab_ascus_vline*scatter_ascus).opts(toolbar='above')).cols(1).opts(shared_axes=False)
|
| 1005 |
+
#else:
|
| 1006 |
+
# ref_aus = df['Thyroid AUS Rate(%)'].iloc[0]
|
| 1007 |
+
# lab_aus = labdata['Thyroid AUS Rate(%)'].iloc[0]
|
| 1008 |
+
# max_x_aus = labdata['Thyroid AUS Rate(%)'].max()
|
| 1009 |
+
# tooltips_aus = f"""<div><span style="font-size: {fpx};font-weight: bold">@{{Thyroid AUS Rate(%)}} </span></div>"""
|
| 1010 |
+
# hover_aus = HoverTool(tooltips=tooltips_aus)
|
| 1011 |
+
# scatter_aus = scatterdata.iloc[0:1].hvplot.scatter(x='Thyroid AUS Rate(%)', y='people', color='black', size=sdot_person,height= 160,
|
| 1012 |
+
# xlim=(0,30), xticks = [0,lab_aus,10,15,30], yaxis = 'bare',grid=True, title='Thyroid AUS Rate(%)',
|
| 1013 |
+
# xformatter='%.1f',xlabel ='', ylabel='', tools = [hover_aus]).opts(fontsize = pl_title,fontscale=f_scale, shared_axes=False,toolbar=None, default_tools = [])
|
| 1014 |
+
# lab_aus_vline = hv.VLine(x=lab_aus).opts(color='#5B91D1', line_dash ='dashed', alpha=1).opts(shared_axes=False,toolbar=None, default_tools = [])
|
| 1015 |
+
# aus_goal = hv.VSpan(0, 10).opts(shared_axes=False,toolbar=None, default_tools = [])
|
| 1016 |
+
# aus_bdln = hv.VSpan(10,15).opts(shared_axes=False,toolbar=None, default_tools = [])
|
| 1017 |
+
# aus_att = hv.VSpan(15, 30).opts(shared_axes=False,toolbar=None, default_tools = [])
|
| 1018 |
+
# aus_bg = (aus_goal.opts(color='#ACFFA0', alpha = 0.75)* aus_att.opts(color='#B34D93', alpha = 0.9)*\
|
| 1019 |
+
# aus_bdln.opts(color='#6AB35F', alpha = 0.75))
|
| 1020 |
+
|
| 1021 |
+
# return ((asclsil_bg* ref_lsil_vline * lab_lsil_vline * scatter_lsil).opts(toolbar='above') +\
|
| 1022 |
+
# (ascus_bg* ref_ascus_vline * lab_ascus_vline*scatter_ascus).opts(toolbar='above')+\
|
| 1023 |
+
# (aus_bg * lab_aus_vline * scatter_aus)).cols(1).opts(shared_axes=False)
|
| 1024 |
|
| 1025 |
else:
|
| 1026 |
return pn.pane.Markdown("# N/A", styles={'font-size':'20px'})
|
|
|
|
| 1031 |
scatterdata = df[(df.year == year_slider)&(df['people'] == cp_select)]
|
| 1032 |
if len(scatterdata) > 0:
|
| 1033 |
case_no = scatterdata['Number'].iloc[0]
|
| 1034 |
+
#if pd.isna(scatterdata['Thyroid AUS Rate(%)'].iloc[0]):
|
| 1035 |
+
# return pn.pane.Markdown(f'# Gyn Cases examined: {case_no}')
|
| 1036 |
+
#else:
|
| 1037 |
+
# ac_no =scatterdata['ThyAC Number'].iloc[0]
|
| 1038 |
+
return pn.pane.Markdown(f'# Gyn Cases examined: {case_no}')
|
| 1039 |
|
| 1040 |
|
| 1041 |
|
|
|
|
| 1048 |
cp_performance = pn.Tabs(('Performance results',pn.Column(pn.Row(cp_select,year_slider),interactive_no_cp,\
|
| 1049 |
pn.Row(pn.Column(pn.pane.Markdown("<br><br>"),vertical_legend_indiv),interactive_qa, height = 600 )\
|
| 1050 |
,pn.Column(pn.pane.Markdown("<br><br>"),modal_btn)))\
|
| 1051 |
+
,('Results overview',pn.Column(cp_select, inter_asclsil_cp, inter_ascus_cp)),styles = {'font-size': '20px'})
|
| 1052 |
|
| 1053 |
|
| 1054 |
|
|
|
|
| 1068 |
|
| 1069 |
|
| 1070 |
results = df[df['year'] != 2017]
|
| 1071 |
+
med_ref_distribution = pd.concat([results[results.people.str.contains('KGYC')],results.iloc[[0]] ])[['ASC/LSIL','ASC-US/ASC-H ratio(%)', 'Abnormal Rate(%)','Referral Rate(%)']]
|
| 1072 |
med_ref_distribution.loc[len(med_ref_distribution)] = {'ASC/LSIL':0.75,'ASC-US/ASC-H ratio(%)':12.5, 'Abnormal Rate(%)':1.5}
|
| 1073 |
|
| 1074 |
|
|
|
|
| 1110 |
|
| 1111 |
|
| 1112 |
def add_norm_curves(column_changer,year_slider):
|
| 1113 |
+
if column_changer == 'Referral Rate(%)':
|
| 1114 |
return None
|
| 1115 |
else:
|
| 1116 |
mu= med_ref_distribution.iloc[-2][column_changer]
|