@adunsulag Thanks for the forms module loader. I was hoping you could help flesh out the implementation. I brought in the code changes from
In my bootstrap file.
namespace Juggernaut\Module\WoundCare;
use OpenEMR\Core\Kernel;
use OpenEMR\Events\Encounter\EncounterMenuEvent;
use OpenEMR\Events\Encounter\LoadEncounterFormFilterEvent;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class Bootstrap
{
/**
* @var EventDispatcherInterface The object responsible for sending and subscribing to events through the OpenEMR system
*/
private $eventDispatcher;
private ?Kernel $kernel;
public function __construct(EventDispatcher $dispatcher, ?Kernel $kernel = null)
{
if (empty($kernel)) {
$kernel = new Kernel();
}
$this->eventDispatcher = $dispatcher;
$this->kernel = $kernel;
}
public function subscribeToEvents(): void
{
$this->registerMenuItems();
$this->registerFormFilters();
}
public function registerMenuItems(): void
{
/**
* @var EventDispatcherInterface $eventDispatcher
* @var array $module
* @global $eventDispatcher @see ModulesApplication::loadCustomModule
* @global $module @see ModulesApplication::loadCustomModule
*/
$this->eventDispatcher->addListener(EncounterMenuEvent::MENU_RENDER, [$this, 'addHealthScribeEncItem']);
}
public function registerFormFilters(): void
{
$this->eventDispatcher->addListener(LoadEncounterFormFilterEvent::EVENT_NAME, [$this, 'addWoundCareAssistant']);
}
public function addHealthScribeEncItem(EncounterMenuEvent $event): EncounterMenuEvent
{
$menu = $event->getMenuData();
$menu['WC AI Agent'] = [
'children' => [
[
'state' => 1,
'directory' => 'oe-module-wound-care',
'id' => 41,
'unpackaged' => 1,
'date' => '2023-03-01 00:00:00',
'priority' => 13,
'aco_spec' => 'encounters|coding',
'LBF' => '',
'displayText' => 'Assistant',
]
],
];
$event->setMenuData($menu);
return $event;
}
public function addWoundCareAssistant(LoadEncounterFormFilterEvent $event): LoadEncounterFormFilterEvent
{
$event->setFormName('oe-module-wound-care');
$event->setPageName('new.php');
return $event;
}
}
When I click on the assistant button. I get a blank page. I took a step back and dumped the Loader.
// AI GENERATED CODE: HEADER END
$filteredEvent = $GLOBALS['kernel']->getEventDispatcher()->dispatch($event, LoadEncounterFormFilterEvent::EVENT_NAME);
echo "<pre>";
var_dump($filteredEvent); die;
This is the result of the dump
object(OpenEMR\Events\Encounter\LoadEncounterFormFilterEvent)#588 (4) {
["formName":"OpenEMR\Events\Encounter\LoadEncounterFormFilterEvent":private]=>
string(20) "oe-module-wound-care"
["dir":"OpenEMR\Events\Encounter\LoadEncounterFormFilterEvent":private]=>
string(62) "/var/www/html/openemr702/interface/forms/oe-module-wound-care/"
["pageName":"OpenEMR\Events\Encounter\LoadEncounterFormFilterEvent":private]=>
string(7) "new.php"
["pid":"OpenEMR\Events\Encounter\LoadEncounterFormFilterEvent":private]=>
uninitialized(?int)
["encounter":"OpenEMR\Events\Encounter\LoadEncounterFormFilterEvent":private]=>
uninitialized(?int)
["isLBF":"OpenEMR\Events\Encounter\LoadEncounterFormFilterEvent":private]=>
bool(false)
}
This is looking in the wrong place “/var/www/html/openemr702/interface/forms/oe-module-wound-care/”
Please let me know where I am going in the wrong direction. What is $page for? This seems incomplete as it does don’t account for the module directory even though it is kinda does in the LoadEncounterFormFilterEvent. Why is called a filter and not a selector or just drop the word filter. Filter is confusing to me. What am I filter? Filter means trying to get rid of something, to me.