Skip to content

Commit

Permalink
Fixes openemr#7707, openemr#7708 health snapshot, custom report (open…
Browse files Browse the repository at this point in the history
…emr#7709)

* Fixes openemr#7707, openemr#7708 health snapshot, custom report

Made it so the custom report foudn in patient_report.php uses twig and
also has a filter event for customizing the data that gets passed into
the report selection system.  This allows module writers to extend the
interface and add data or hide sections as needed.

Did the same thing with the health snapshot to allow pieces of the
snapshot to be overriden by twig templates.

This work was done to facilitate a module that wanted to have flags to
hide/show different parts of the reports and health snapshot as they
pilot test these areas with their patients.

Fixes openemr#7707
Fixes openemr#7708

* Fix code styles.

* Add copyright notice

* style fixes, escaping fixes
  • Loading branch information
adunsulag authored Sep 22, 2024
1 parent 55c96e7 commit 4d8d535
Show file tree
Hide file tree
Showing 25 changed files with 1,281 additions and 805 deletions.
2 changes: 2 additions & 0 deletions interface/patient_file/report/patient_report.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

/**
* Patient report
* TODO: Note that this file can be refactored to re-use shared code with the portal_patient_report.php file
* that file has been refactored to use twig templates and this file could be reworked to re-use much of that code
*
* @package OpenEMR
* @link http://www.open-emr.org
Expand Down
2 changes: 1 addition & 1 deletion interface/super/edit_globals.php
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ function checkBackgroundServices()
}
if ($fldtype == GlobalSetting::DATA_TYPE_HTML_DISPLAY_SECTION) {
// if the field is an html display box we want to take over the entire real estate so we will continue from here.
include_once 'templates/field_html_display_section.php';
include 'templates/field_html_display_section.php';
++$i; // make sure we advance the iterator here...
continue;
}
Expand Down
20 changes: 17 additions & 3 deletions portal/home.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@

use OpenEMR\Common\Csrf\CsrfUtils;
use OpenEMR\Common\Twig\TwigContainer;
use OpenEMR\Common\Logging\SystemLogger;
use OpenEMR\Events\PatientPortal\AppointmentFilterEvent;
use OpenEMR\Events\PatientReport\PatientReportFilterEvent;
use OpenEMR\Events\PatientPortal\RenderEvent;
use OpenEMR\Services\LogoService;
use OpenEMR\Services\Utils\TranslationService;
Expand Down Expand Up @@ -312,7 +314,14 @@ function buildNav($newcnt, $pid, $result): array
// Render Home Page
$twig = (new TwigContainer('', $GLOBALS['kernel']))->getTwig();
try {
echo $twig->render('portal/home.html.twig', [
$healthSnapshot = [
'immunizationRecords' => $immunRecords,
'patientID' => $pid
];
$patientReportEvent = new PatientReportFilterEvent();
$patientReportEvent->setDataElement('healthSnapshot', $healthSnapshot);
$filteredEvent = $GLOBALS['kernel']->getEventDispatcher()->dispatch($patientReportEvent, PatientReportFilterEvent::FILTER_PORTAL_HEALTHSNAPSHOT_TWIG_DATA);
$data = [
'user' => $user,
'whereto' => $_SESSION['whereto'] ?? null ?: ($whereto ?? '#quickstart-card'),
'result' => $result,
Expand Down Expand Up @@ -352,7 +361,7 @@ function buildNav($newcnt, $pid, $result): array
'styleArray' => $styleArray,
'ccdaOk' => $ccdaOk,
'allow_custom_report' => $GLOBALS['allow_custom_report'] ?? '0',
'immunRecords' => $immunRecords,
'healthSnapshot' => $filteredEvent->getDataElement('healthSnapshot'),
'languageDirection' => $_SESSION['language_direction'] ?? 'ltr',
'dateDisplayFormat' => $GLOBALS['date_display_format'],
'timezone' => $GLOBALS['gbl_time_zone'] ?? '',
Expand All @@ -363,8 +372,13 @@ function buildNav($newcnt, $pid, $result): array
'dashboardInjectCard' => RenderEvent::EVENT_DASHBOARD_INJECT_CARD,
'dashboardRenderScripts' => RenderEvent::EVENT_DASHBOARD_RENDER_SCRIPTS
]
]);
];

echo $twig->render('portal/home.html.twig', $data);
} catch (LoaderError | RuntimeError | SyntaxError $e) {
OpenEMR\Common\Session\SessionUtil::portalSessionCookieDestroy();
if ($e instanceof SyntaxError) {
(new SystemLogger())->error($e->getMessage(), ['file' => $e->getFile(), 'trace' => $e->getTraceAsString()]);
}
die(text($e->getMessage()));
}
Loading

0 comments on commit 4d8d535

Please sign in to comment.