# Extending OpenEMR OpenEMR is the clinical EMR in the Med-SEAL stack. This page explains the supported extension points and how to make customisations without breaking the upstream update path. --- ## Extension Philosophy Med-SEAL follows OpenEMR's official customisation model: - **Custom modules** -- placed in `openemr/interface/modules/custom_modules/` - **Custom SQL patches** -- placed in `openemr/sql_upgrade.php` additions - **Configuration overrides** -- via `openemr/sites/default/` - **Hooks and events** -- via OpenEMR's `EventDispatcher` Avoid modifying core OpenEMR PHP files directly. Instead, use the override and hook system so your changes survive OpenEMR version upgrades. --- ## Project Layout Custom OpenEMR files in Med-SEAL live under: ``` openemr/ ├── interface/ │ └── modules/ │ └── custom_modules/ │ └── medseal/ # Med-SEAL custom module ├── sites/ │ └── default/ │ └── sqlconf.php # DB config (auto-generated) └── library/ └── medseal/ # Shared Med-SEAL PHP utilities ``` --- ## Adding a Custom Module 1. Create a directory: `openemr/interface/modules/custom_modules/my_module/` 2. Add the module entry point: `my_module/index.php` 3. Register the module in `openemr/interface/modules/custom_modules/my_module/info.php`: ```php 'my_module', 'name' => 'My Module', 'version' => '1.0.0', 'description' => 'Custom extension for Med-SEAL', 'acl_req' => array('patients', 'auth_med'), ); ``` 4. Activate the module in OpenEMR Admin: **Admin > Modules > Manage Modules**. --- ## Using the OpenEMR EventDispatcher OpenEMR fires events at key points in the clinical workflow. Subscribe to them from your module: ```php addListener(RenderEvent::EVENT_SECTION_LIST_RENDER_AFTER, function (RenderEvent $event) { echo '