add lvo side

This commit is contained in:
Ross
2025-05-05 09:32:32 +01:00
parent ecb499426a
commit dc109c7fe6
+34 -7
View File
@@ -8,6 +8,7 @@ def report_stroke():
'haemorrhage': '',
'ischaemia': '',
'lvo': '',
'lvo_side': '', # Added for LVO side selection
'ica_disease': '',
'ica_side': '',
'quantify_stenosis': '',
@@ -25,7 +26,7 @@ def report_stroke():
formatted_text = (
f"There is evidence of intracranial haemorrhage: {answers['haemorrhage']} {custom_text['haemorrhage']}\n"
f"There is evidence of acute ischaemia: {answers['ischaemia']} {custom_text['ischaemia']}\n"
f"There is an intracranial LVO: {answers['lvo']} {custom_text['lvo']}\n"
f"There is an intracranial LVO: {answers['lvo']} {f'({answers["lvo_side"]})' if answers['lvo'] == 'YES' and answers['lvo_side'] else ''} {custom_text['lvo']}\n"
f"There is significant extracranial internal carotid artery disease: {answers['ica_disease']}\n"
)
if answers['ica_disease'] == 'YES':
@@ -42,6 +43,19 @@ def report_stroke():
"- Please discuss with a Vascular Radiologist and consider contemporaneous duplex imaging if the patient is a candidate for Carotid endarterectomy.\n"
)
result_box.value = formatted_text
highlight_unanswered_questions()
def highlight_unanswered_questions():
# Add a red border to the left of unanswered questions
haemorrhage_label.style('border-left: 4px solid red;' if not answers['haemorrhage'] else 'border-left: none;')
ischaemia_label.style('border-left: 4px solid red;' if not answers['ischaemia'] else 'border-left: none;')
lvo_label.style('border-left: 4px solid red;' if not answers['lvo'] else 'border-left: none;')
lvo_side_row.style('border-left: 4px solid red;' if answers['lvo'] == 'YES' and not answers['lvo_side'] else 'border-left: none;')
ica_disease_label.style('border-left: 4px solid red;' if not answers['ica_disease'] else 'border-left: none;')
ica_side_row.style('border-left: 4px solid red;' if answers['ica_disease'] == 'YES' and not answers['ica_side'] else 'border-left: none;')
quantify_stenosis_row.style('border-left: 4px solid red;' if answers['ica_disease'] == 'YES' and not answers['quantify_stenosis'] else 'border-left: none;')
left_stenosis_row.style('border-left: 4px solid red;' if answers['quantify_stenosis'] == 'YES' and not answers['left_stenosis'] else 'border-left: none;')
right_stenosis_row.style('border-left: 4px solid red;' if answers['quantify_stenosis'] == 'YES' and not answers['right_stenosis'] else 'border-left: none;')
def toggle_visibility(button, input_field):
input_field.visible = not input_field.visible
@@ -52,6 +66,7 @@ def report_stroke():
'haemorrhage': 'NO',
'ischaemia': 'NO',
'lvo': 'NO',
'lvo_side': '',
'ica_disease': 'NO',
'ica_side': '',
'quantify_stenosis': '',
@@ -62,6 +77,7 @@ def report_stroke():
haemorrhage_radio.value = 'NO'
ischaemia_radio.value = 'NO'
lvo_radio.value = 'NO'
lvo_side_row.visible = False
ica_disease_radio.value = 'NO'
ica_side_row.visible = False
quantify_stenosis_row.visible = False
@@ -73,7 +89,7 @@ def report_stroke():
ui.button('Normal', on_click=set_all_to_false).props('flat')
with ui.row():
ui.label('There is evidence of intracranial haemorrhage')
haemorrhage_label = ui.label('There is evidence of intracranial haemorrhage')
haemorrhage_radio = ui.radio(['YES', 'NO'], on_change=lambda e: (answers.update({'haemorrhage': e.value}), update_result())).props('inline')
custom_input_haemorrhage = ui.input('Custom text', on_change=lambda e: (custom_text.update({'haemorrhage': e.value}), update_result()))
custom_input_haemorrhage.visible = False
@@ -81,7 +97,7 @@ def report_stroke():
ui.tooltip('Add custom text for this option').on(toggle_button)
with ui.row():
ui.label('There is evidence of acute ischaemia')
ischaemia_label = ui.label('There is evidence of acute ischaemia')
ischaemia_radio = ui.radio(['YES', 'NO'], on_change=lambda e: (answers.update({'ischaemia': e.value}), update_result())).props('inline')
custom_input_ischaemia = ui.input('Custom text', on_change=lambda e: (custom_text.update({'ischaemia': e.value}), update_result()))
custom_input_ischaemia.visible = False
@@ -89,15 +105,25 @@ def report_stroke():
ui.tooltip('Add custom text for this option').on(toggle_button)
with ui.row():
ui.label('There is an intracranial LVO')
lvo_radio = ui.radio(['YES', 'NO'], on_change=lambda e: (answers.update({'lvo': e.value}), update_result())).props('inline')
lvo_label=ui.label('There is an intracranial LVO')
lvo_radio = ui.radio(['YES', 'NO'], on_change=lambda e: (answers.update({'lvo': e.value}), update_result(), toggle_lvo_side(e.value))).props('inline')
custom_input_lvo = ui.input('Custom text', on_change=lambda e: (custom_text.update({'lvo': e.value}), update_result()))
custom_input_lvo.visible = False
toggle_button = ui.button(icon='add', on_click=lambda: toggle_visibility(toggle_button, custom_input_lvo)).props('flat dense')
ui.tooltip('Add custom text for this option').on(toggle_button)
# Additional options for LVO side
def toggle_lvo_side(value):
lvo_side_row.visible = value == 'YES'
lvo_side_row = ui.row() # Create the row
lvo_side_row.visible = False # Set visibility to False
with lvo_side_row:
ui.label('Please indicate the side of the LVO')
ui.radio(['Left', 'Right'], on_change=lambda e: (answers.update({'lvo_side': e.value}), update_result())).props('inline')
with ui.row():
ui.label('There is significant extracranial internal carotid artery disease')
ica_disease_label = ui.label('There is significant extracranial internal carotid artery disease')
ica_disease_radio = ui.radio(['YES', 'NO'], on_change=lambda e: (answers.update({'ica_disease': e.value}), update_result(), toggle_ica_options(e.value))).props('inline')
# Additional options for ICA disease
@@ -141,4 +167,5 @@ def report_stroke():
def copy_to_clipboard():
ui.run_javascript(f'navigator.clipboard.writeText(`{result_box.value}`)')
ui.button('Copy to Clipboard', on_click=copy_to_clipboard).props('flat')
ui.button('Copy to Clipboard', on_click=copy_to_clipboard).props('flat')
highlight_unanswered_questions()