Add CCS study tools and case reporting
This commit is contained in:
@@ -14,17 +14,24 @@ var status: Label
|
||||
var timer: Timer
|
||||
var end_button: Button
|
||||
var time_row: HBoxContainer
|
||||
var report_dialog: Control
|
||||
var report_button: Button
|
||||
var workspace: HSplitContainer
|
||||
|
||||
func _ready() -> void:
|
||||
set_anchors_preset(Control.PRESET_FULL_RECT); add_theme_constant_override("separation", 8)
|
||||
var top := HBoxContainer.new(); add_child(top)
|
||||
var top := HBoxContainer.new(); top.add_theme_constant_override("separation", 8); add_child(top)
|
||||
heading = Label.new(); heading.size_flags_horizontal = Control.SIZE_EXPAND_FILL; Style.set_label(heading, 25, Style.TEXT); top.add_child(heading)
|
||||
clock = Label.new(); Style.set_label(clock, 18, Style.AMBER); top.add_child(clock)
|
||||
var columns := HSplitContainer.new(); columns.size_flags_vertical = Control.SIZE_EXPAND_FILL; columns.split_offset = 850; add_child(columns)
|
||||
var chart_panel := VBoxContainer.new(); chart_panel.custom_minimum_size.x = 500; columns.add_child(chart_panel)
|
||||
summary = RichTextLabel.new(); summary.bbcode_enabled = true; summary.custom_minimum_size.y = 160; chart_panel.add_child(summary)
|
||||
chart = RichTextLabel.new(); chart.bbcode_enabled = true; chart.size_flags_vertical = Control.SIZE_EXPAND_FILL; chart_panel.add_child(chart)
|
||||
var clerk_scroll := ScrollContainer.new(); clerk_scroll.custom_minimum_size.x = 430; columns.add_child(clerk_scroll)
|
||||
var smaller := Button.new(); smaller.text = "A-"; smaller.tooltip_text = "Decrease text size"; smaller.pressed.connect(_zoom.bind(-CCSService.TEXT_SCALE_STEP)); top.add_child(smaller)
|
||||
var larger := Button.new(); larger.text = "A+"; larger.tooltip_text = "Increase text size"; larger.pressed.connect(_zoom.bind(CCSService.TEXT_SCALE_STEP)); top.add_child(larger)
|
||||
var clear_highlights := Button.new(); clear_highlights.text = "Clear"; clear_highlights.tooltip_text = "Clear highlights"; clear_highlights.pressed.connect(_clear_highlights); top.add_child(clear_highlights)
|
||||
report_button = Button.new(); report_button.text = "Report"; report_button.tooltip_text = "Report CCS case"; report_button.pressed.connect(_report); top.add_child(report_button)
|
||||
workspace = HSplitContainer.new(); workspace.size_flags_vertical = Control.SIZE_EXPAND_FILL; workspace.split_offset = 850; add_child(workspace)
|
||||
var chart_panel := VBoxContainer.new(); chart_panel.custom_minimum_size.x = 500; workspace.add_child(chart_panel)
|
||||
summary = RichTextLabel.new(); summary.bbcode_enabled = true; summary.selection_enabled = true; summary.custom_minimum_size.y = 160; summary.set_meta("ccs_region", "summary"); summary.gui_input.connect(_text_input.bind(summary)); chart_panel.add_child(summary)
|
||||
chart = RichTextLabel.new(); chart.bbcode_enabled = true; chart.selection_enabled = true; chart.size_flags_vertical = Control.SIZE_EXPAND_FILL; chart.set_meta("ccs_region", "chart"); chart.gui_input.connect(_text_input.bind(chart)); chart_panel.add_child(chart)
|
||||
var clerk_scroll := ScrollContainer.new(); clerk_scroll.custom_minimum_size.x = 430; workspace.add_child(clerk_scroll)
|
||||
var clerk := VBoxContainer.new(); clerk.size_flags_horizontal = Control.SIZE_EXPAND_FILL; clerk.add_theme_constant_override("separation", 8); clerk_scroll.add_child(clerk)
|
||||
var order_title := Label.new(); order_title.text = "Order Clerk"; Style.set_label(order_title, 21, Style.CYAN); clerk.add_child(order_title)
|
||||
search = LineEdit.new(); search.placeholder_text = "Search tests, treatments, and procedures"; search.text_submitted.connect(func(_value): CCSService.search_orders(search.text)); clerk.add_child(search)
|
||||
@@ -45,6 +52,8 @@ func _ready() -> void:
|
||||
CCSService.attempt_changed.connect(_render)
|
||||
CCSService.orders_changed.connect(_render_search)
|
||||
CCSService.request_failed.connect(func(message: String): status.text = message)
|
||||
CCSService.report_submitted.connect(_report_submitted)
|
||||
report_dialog = preload("res://scripts/ui/ccs_report_dialog.gd").new(); add_child(report_dialog)
|
||||
|
||||
func on_show(payload: Variant = null) -> void:
|
||||
status.text = ""
|
||||
@@ -57,9 +66,8 @@ func _render() -> void:
|
||||
var attempt: Dictionary = CCSService.attempt
|
||||
if attempt.is_empty(): return
|
||||
if str(attempt.get("state", "")) == "completed": main.show_screen("ccs_review", attempt); return
|
||||
heading.text = "%s | %s" % [attempt.get("caseTitle", "CCS case"), str(attempt.get("location", "")).capitalize()]
|
||||
summary.text = "[b]%s[/b]\n%s\n\n[b]Vitals[/b] %s" % [attempt.get("patientSummary", ""), attempt.get("reasonForEncounter", ""), _vitals_text(attempt.get("vitals", {}))]
|
||||
chart.text = "[b]History[/b]\n%s\n\n[b]Appearance[/b]\n%s\n\n[b]Chart[/b]\n%s" % [attempt.get("history", ""), attempt.get("appearance", ""), _chart_text(attempt.get("chart", []))]
|
||||
heading.text = "CCS Case | %s" % str(attempt.get("location", "")).capitalize()
|
||||
_render_study_text()
|
||||
_clear(orders)
|
||||
for code in attempt.get("activeOrderCodes", []):
|
||||
var row := HBoxContainer.new(); orders.add_child(row)
|
||||
@@ -74,12 +82,14 @@ func _render() -> void:
|
||||
end_button.text = "Submit final orders" if str(attempt.get("state", "")) == "final_orders" else "End case"
|
||||
time_row.visible = str(attempt.get("state", "")) == "active"
|
||||
if str(attempt.get("state", "")) == "final_orders": status.text = "Case-end instructions: finalize or cancel orders, then submit."
|
||||
_apply_text_scale()
|
||||
|
||||
func _render_search() -> void:
|
||||
_clear(search_results)
|
||||
for order in CCSService.orders:
|
||||
var button := Button.new(); button.text = "%s (%s)" % [order.get("canonicalName", ""), order.get("category", "")]; button.alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
button.pressed.connect(_place_order.bind(str(order.get("code", "")))); search_results.add_child(button)
|
||||
_scale_controls(search_results)
|
||||
|
||||
func _place_order(code: String) -> void:
|
||||
CCSService.send_command("order", code); search.text = ""; CCSService.orders = []; _render_search()
|
||||
@@ -109,3 +119,52 @@ func _chart_text(entries: Array) -> String:
|
||||
var lines: Array[String] = []
|
||||
for entry in entries: lines.append("T+%d [%s] %s" % [entry.get("simulatedMinute", 0), entry.get("category", "note"), entry.get("text", "")])
|
||||
return "\n\n".join(lines)
|
||||
|
||||
func _summary_plain() -> String:
|
||||
var attempt := CCSService.attempt
|
||||
return "%s\n%s\n\nVitals %s" % [attempt.get("patientSummary", ""), attempt.get("reasonForEncounter", ""), _vitals_text(attempt.get("vitals", {}))]
|
||||
|
||||
func _chart_plain() -> String:
|
||||
var attempt := CCSService.attempt
|
||||
return "History\n%s\n\nAppearance\n%s\n\nChart\n%s" % [attempt.get("history", ""), attempt.get("appearance", ""), _chart_text(attempt.get("chart", []))]
|
||||
|
||||
func _render_study_text() -> void:
|
||||
var id := str(CCSService.attempt.get("id", ""))
|
||||
summary.text = CCSService.highlighted_text(id, "summary", _summary_plain())
|
||||
chart.text = CCSService.highlighted_text(id, "chart", _chart_plain())
|
||||
|
||||
func _text_input(event: InputEvent, label: RichTextLabel) -> void:
|
||||
var mouse := event as InputEventMouseButton
|
||||
if mouse != null and mouse.button_index == MOUSE_BUTTON_LEFT and not mouse.pressed:
|
||||
call_deferred("_commit_selection", label)
|
||||
|
||||
func _commit_selection(label: RichTextLabel) -> void:
|
||||
var selected := label.get_selected_text().strip_edges()
|
||||
if selected.is_empty(): return
|
||||
var start := label.get_selection_from(); var end := label.get_selection_to()
|
||||
CCSService.toggle_highlight(str(CCSService.attempt.get("id", "")), str(label.get_meta("ccs_region", "")), mini(start, end), maxi(start, end))
|
||||
label.deselect(); _render_study_text()
|
||||
|
||||
func _zoom(delta: float) -> void:
|
||||
CCSService.adjust_text_scale(delta); _apply_text_scale()
|
||||
|
||||
func _apply_text_scale() -> void:
|
||||
var size := int(round(18.0 * CCSService.text_scale))
|
||||
for label in [summary, chart]:
|
||||
label.add_theme_font_size_override("normal_font_size", size); label.add_theme_font_size_override("bold_font_size", size)
|
||||
_scale_controls(workspace)
|
||||
|
||||
func _scale_controls(node: Node) -> void:
|
||||
if node is Label or node is Button or node is LineEdit:
|
||||
if not node.has_meta("ccs_base_font_size"): node.set_meta("ccs_base_font_size", node.get_theme_font_size("font_size"))
|
||||
node.add_theme_font_size_override("font_size", int(round(float(node.get_meta("ccs_base_font_size")) * CCSService.text_scale)))
|
||||
for child in node.get_children(): _scale_controls(child)
|
||||
|
||||
func _clear_highlights() -> void:
|
||||
CCSService.clear_highlights(str(CCSService.attempt.get("id", ""))); _render_study_text()
|
||||
|
||||
func _report() -> void:
|
||||
report_dialog.show_for(str(CCSService.attempt.get("id", "")))
|
||||
|
||||
func _report_submitted(_id: String) -> void:
|
||||
Style.style_chip(report_button, Style.RED); report_button.tooltip_text = "Report submitted; report another issue"
|
||||
|
||||
Reference in New Issue
Block a user