From 19825519c9983e0bb81edd561b850333da1d894a Mon Sep 17 00:00:00 2001 From: Stephen Nielson Date: Fri, 11 Aug 2023 15:53:52 -0400 Subject: [PATCH] Fixes #6720 appointment dialog hooks (#6721) * Fixes #6720 appointment dialog hooks Made it so we can launch a smart app with a specific appointment context as well as hook into the appointment close dialog. Also added in an ehr-launch-client.php file so we can quickly do an ehr initiated app launch. * Add copyright headers * Fix styles --- interface/main/calendar/add_edit_event.php | 16 +++++ interface/smart/ehr-launch-client.php | 34 ++++++++++ .../SMARTSessionTokenContextBuilder.php | 4 ++ .../Appointments/AppointmentDialogCloseEvent.php | 48 +++++++++++++++ src/FHIR/SMART/SMARTLaunchToken.php | 30 ++++++++- src/FHIR/SMART/SmartLaunchController.php | 72 +++++++++++++++++++++- 6 files changed, 200 insertions(+), 4 deletions(-) create mode 100644 interface/smart/ehr-launch-client.php create mode 100644 src/Events/Appointments/AppointmentDialogCloseEvent.php diff --git a/interface/main/calendar/add_edit_event.php b/interface/main/calendar/add_edit_event.php index ff11dcb3c..5900aa44c 100644 --- a/interface/main/calendar/add_edit_event.php +++ b/interface/main/calendar/add_edit_event.php @@ -56,6 +56,8 @@ use OpenEMR\Common\Twig\TwigContainer; use OpenEMR\Core\Header; use OpenEMR\Events\Appointments\AppointmentSetEvent; use OpenEMR\Events\Appointments\AppointmentRenderEvent; +use OpenEMR\Events\Appointments\AppointmentDialogCloseEvent; +use OpenEMR\Common\Logging\SystemLogger; //Check access control if (!AclMain::aclCheckCore('patients', 'appt', '', array('write','wsome'))) { @@ -764,6 +766,20 @@ if (!empty($_POST['form_action']) && ($_POST['form_action'] == "save")) { } if (!empty($_POST['form_action'])) { + $closeEvent = new AppointmentDialogCloseEvent(); + $closeEvent->setDialogAction($_POST['form_action']); + $closeEventData = ['form_action' => $_POST['form_action']]; + if (isset($eid)) { + $closeEvent->setAppointmentId($eid); + } + $event = $GLOBALS['kernel']->getEventDispatcher()->dispatch($closeEvent, AppointmentDialogCloseEvent::EVENT_NAME); + // listeners can stop the window from closing if they want to add any additional workflow steps + // to the calendar appointment flow for their own workflow dialogs here they will need + // to implement the dialog closing and duplicate the logic of what happens here in this closing event. + if ($event->isPropagationStopped()) { + (new SystemLogger())->debug("add_edit_event.php: event propagation stopped before closing dialog, exiting"); + exit(); + } // Close this window and refresh the calendar (or the patient_tracker) display. echo "\n\n