Skip to content

Commit

Permalink
fix: broken patient menu dashboard links prior auth module (openemr#7849
Browse files Browse the repository at this point in the history
)
  • Loading branch information
stephenwaite authored Nov 30, 2024
1 parent 92341b9 commit 3298e34
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use OpenEMR\Common\Acl\AclMain;
use OpenEMR\Menu\MenuEvent;
use OpenEMR\Menu\PatientMenuEvent;
use OpenEMR\Menu\PatientMenuRole;
use OpenEMR\Events\PatientDemographics\RenderEvent;
use OpenEMR\Common\Csrf\CsrfUtils;
use Symfony\Component\EventDispatcher\Event;
Expand Down Expand Up @@ -50,6 +51,7 @@ function oe_module_priorauth_patient_menu_item(PatientMenuEvent $menuEvent)
{
$menu = file_get_contents(__DIR__ . '/public/patient_menu/custom_patient_menu.json');
$menu_parsed = json_decode($menu);
$menu_parsed = (new PatientMenuRole())->setPatientMenuUrl($menu_parsed);
$menuEvent->setMenu($menu_parsed);
return $menuEvent;
}
Expand Down
34 changes: 21 additions & 13 deletions src/Menu/PatientMenuRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,8 @@ public function getMenu()
if (!$menu_parsed) {
die("\nJSON ERROR: " . json_last_error());
}
//to make the url absolute to web root and to account for external urls i.e. those beginning with http or https
foreach ($menu_parsed as $menu_obj) {
if (property_exists($menu_obj, 'url')) {
$menu_obj -> url = $this->getAbsoluteWebRoot($menu_obj -> url);
}
if (!empty($menu_obj->children)) {
foreach ($menu_obj->children as $menu_obj) {
if (property_exists($menu_obj, 'url')) {
$menu_obj -> url = $this->getAbsoluteWebRoot($menu_obj -> url);
}
}
}
}

$menu_parsed = $this->setPatientMenuUrl($menu_parsed);

// Parse the menu JSON and build the menu. Also, tell the EventDispatcher about the event
// so that 3rd party modules may modify the menu items
Expand Down Expand Up @@ -244,4 +233,23 @@ private function getAbsoluteWebRoot($rel_url)
}
return $rel_url;
}

public function setPatientMenuUrl($menu_parsed)
{
//to make the url absolute to web root and to account for external urls i.e. those beginning with http or https
foreach ($menu_parsed as $menu_obj) {
if (property_exists($menu_obj, 'url')) {
$menu_obj->url = $this->getAbsoluteWebRoot($menu_obj->url);
}
if (!empty($menu_obj->children)) {
foreach ($menu_obj->children as $menu_obj) {
if (property_exists($menu_obj, 'url')) {
$menu_obj->url = $this->getAbsoluteWebRoot($menu_obj->url);
}
}
}
}

return $menu_parsed;
}
}

0 comments on commit 3298e34

Please sign in to comment.