Add graphical CCS orders and finalization
This commit is contained in:
@@ -5,7 +5,7 @@ const Style := preload("res://scripts/ui/ui_style.gd")
|
||||
const DOCTOR_SCENE := preload("res://scenes/ccs_cases_2/doctor_office.tscn")
|
||||
const DESIGN_SIZE := Vector2(1600.0, 900.0)
|
||||
const FOCUSED_INTERVIEW_CASE_ID := "ccs-gastro-duodenal-ulcer-office-001"
|
||||
const FOCUSED_INTERVIEW_REVISION := 3
|
||||
const FOCUSED_INTERVIEW_REVISION := 4
|
||||
|
||||
var main
|
||||
var stage_root: Control
|
||||
@@ -43,6 +43,8 @@ func _connect_service() -> void:
|
||||
CCSService.attempt_changed.connect(_on_attempt_changed)
|
||||
if not CCSService.request_failed.is_connected(_on_request_failed):
|
||||
CCSService.request_failed.connect(_on_request_failed)
|
||||
if not CCSService.orders_changed.is_connected(_on_orders_changed):
|
||||
CCSService.orders_changed.connect(_on_orders_changed)
|
||||
if not CCSService.attempt_abandoned.is_connected(_on_attempt_abandoned):
|
||||
CCSService.attempt_abandoned.connect(_on_attempt_abandoned)
|
||||
|
||||
@@ -97,10 +99,19 @@ func _on_attempt_changed() -> void:
|
||||
and current_view == "doctor_office":
|
||||
_refresh_exam_result(CCSService.attempt, completed_exam_code)
|
||||
return
|
||||
if completed_action in ["orders", "cancel_order", "advance", "enter_final_orders"] \
|
||||
and active_scene != null and current_view == "doctor_office":
|
||||
_refresh_case_workspace(CCSService.attempt)
|
||||
return
|
||||
_render_state()
|
||||
|
||||
|
||||
func _refresh_exam_result(attempt: Dictionary, exam_code: String) -> void:
|
||||
_refresh_case_workspace(attempt)
|
||||
active_scene.show_exam_result(attempt.get("chart", []), exam_code)
|
||||
|
||||
|
||||
func _refresh_case_workspace(attempt: Dictionary) -> void:
|
||||
active_scene.configure_presentation(
|
||||
attempt.get("graphicalPresentation", {}),
|
||||
str(attempt.get("simulatedStartUtc", "")),
|
||||
@@ -108,7 +119,7 @@ func _refresh_exam_result(attempt: Dictionary, exam_code: String) -> void:
|
||||
attempt.get("vitals", {}),
|
||||
str(attempt.get("medicalHistory", "")), attempt.get("chart", []))
|
||||
active_scene.configure_examinations(attempt.get("availableExams", []), attempt.get("chart", []))
|
||||
active_scene.show_exam_result(attempt.get("chart", []), exam_code)
|
||||
active_scene.configure_orders(attempt)
|
||||
|
||||
|
||||
func _render_state() -> void:
|
||||
@@ -128,7 +139,7 @@ func _render_state() -> void:
|
||||
|
||||
|
||||
func _render_attempt(attempt: Dictionary) -> void:
|
||||
if str(attempt.get("state", "")) != "active":
|
||||
if str(attempt.get("state", "")) not in ["active", "final_orders"]:
|
||||
_show_unsupported_attempt("This active case is not available in the graphical interview yet.")
|
||||
return
|
||||
var interview: Dictionary = attempt.get("interview", {})
|
||||
@@ -243,6 +254,11 @@ func _show_doctor_office(node: Dictionary, attempt: Dictionary = {}) -> void:
|
||||
active_scene.choice_selected.connect(_submit_dialogue_choice)
|
||||
active_scene.physical_exam_selected.connect(_submit_physical_exam)
|
||||
active_scene.physical_exam_finish_requested.connect(_finish_physical_examination)
|
||||
active_scene.order_search_requested.connect(_search_orders)
|
||||
active_scene.orders_submit_requested.connect(_submit_orders)
|
||||
active_scene.order_cancel_requested.connect(_cancel_order)
|
||||
active_scene.time_advance_requested.connect(_advance_time)
|
||||
active_scene.final_orders_submit_requested.connect(_submit_final_orders)
|
||||
active_scene.debrief_return_requested.connect(_return_to_cases)
|
||||
active_scene.debrief_repeat_requested.connect(_repeat_interview)
|
||||
selection_view.visible = false
|
||||
@@ -256,6 +272,7 @@ func _show_doctor_office(node: Dictionary, attempt: Dictionary = {}) -> void:
|
||||
str(attempt.get("medicalHistory", "")), attempt.get("chart", []))
|
||||
active_scene.configure_examinations(attempt.get("availableExams", []), attempt.get("chart", []))
|
||||
active_scene.configure_interview(node)
|
||||
active_scene.configure_orders(attempt)
|
||||
active_scene.set_choices_pending(not pending_action.is_empty())
|
||||
|
||||
|
||||
@@ -279,8 +296,52 @@ func _submit_physical_exam(exam_code: String) -> void:
|
||||
func _finish_physical_examination() -> void:
|
||||
if not pending_action.is_empty():
|
||||
return
|
||||
pending_action = "finishing_exam"
|
||||
pending_action = "enter_final_orders"
|
||||
active_scene.set_physical_exam_pending("finishing_case")
|
||||
CCSService.send_command("end_case")
|
||||
|
||||
|
||||
func _search_orders(query: String) -> void:
|
||||
CCSService.search_orders(query)
|
||||
|
||||
|
||||
func _on_orders_changed() -> void:
|
||||
if active_scene != null and active_scene.has_method("render_order_search"):
|
||||
active_scene.render_order_search(CCSService.orders)
|
||||
|
||||
|
||||
func _submit_orders(codes: Array) -> void:
|
||||
if not pending_action.is_empty() or codes.is_empty():
|
||||
return
|
||||
pending_action = "orders"
|
||||
active_scene.set_orders_pending(true, "Submitting orders...")
|
||||
var commands: Array = []
|
||||
for code in codes:
|
||||
commands.append({"type": "order", "code": str(code), "minutes": 0})
|
||||
CCSService.send_batch(commands)
|
||||
|
||||
|
||||
func _cancel_order(code: String) -> void:
|
||||
if not pending_action.is_empty() or code.is_empty():
|
||||
return
|
||||
pending_action = "cancel_order"
|
||||
active_scene.set_orders_pending(true, "Cancelling order...")
|
||||
CCSService.send_batch([{"type": "cancel_order", "code": code, "minutes": 0}])
|
||||
|
||||
|
||||
func _advance_time(minutes: int) -> void:
|
||||
if not pending_action.is_empty() or minutes <= 0:
|
||||
return
|
||||
pending_action = "advance"
|
||||
active_scene.set_orders_pending(true, "Obtaining results...")
|
||||
CCSService.send_command("advance", "", minutes)
|
||||
|
||||
|
||||
func _submit_final_orders() -> void:
|
||||
if not pending_action.is_empty():
|
||||
return
|
||||
pending_action = "submit_final_orders"
|
||||
active_scene.set_orders_pending(true, "Submitting final orders...")
|
||||
CCSService.send_command("exit_case")
|
||||
|
||||
|
||||
@@ -361,6 +422,8 @@ func _on_request_failed(message: String) -> void:
|
||||
active_scene.show_physical_exam_error(message)
|
||||
else:
|
||||
active_scene.set_choices_pending(false)
|
||||
if active_scene.has_method("set_orders_pending"):
|
||||
active_scene.set_orders_pending(false, message)
|
||||
else:
|
||||
status_label.text = message
|
||||
retry_button.visible = failed_action == "loading"
|
||||
|
||||
Reference in New Issue
Block a user