+ getTwig();
+
+ $allergy = (AclMain::aclCheckIssue('allergy') ? 1 : 0) && !in_array('card_allergies', $hiddenCards) ? 1 : 0;
+ $pl = (AclMain::aclCheckIssue('medical_problem') ? 1 : 0) && !in_array('card_medicalproblems', $hiddenCards) ? 1 : 0;
+ $meds = (AclMain::aclCheckIssue('medication') ? 1 : 0) && !in_array('card_medication', $hiddenCards) ? 1 : 0;
+ $rx = !$GLOBALS['disable_prescriptions'] && AclMain::aclCheckCore('patients', 'rx') && !in_array('card_prescriptions', $hiddenCards) ? 1 : 0;
+ $cards = max(1, ($allergy + $pl + $meds));
+ $col = "p-1 ";
+ $colInt = 12 / $cards;
+ $col .= "col-md-" . $colInt;
+
+ /**
+ * Helper function to return only issues with an outcome not equal to resolved
+ *
+ * @param array $i An array of issues
+ * @return array
+ */
+ function filterActiveIssues(array $i): array
+ {
+ return array_filter($i, function ($_i) {
+ return ($_i['outcome'] != 1) && (empty($_i['enddate']) || (strtotime($_i['enddate']) > strtotime('now')));
+ });
+ }
- $allergy = (AclMain::aclCheckIssue('allergy') ? 1 : 0) && !in_array('card_allergies', $hiddenCards) ? 1 : 0;
- $pl = (AclMain::aclCheckIssue('medical_problem') ? 1 : 0) && !in_array('card_medicalproblems', $hiddenCards) ? 1 : 0;
- $meds = (AclMain::aclCheckIssue('medication') ? 1 : 0) && !in_array('card_medication', $hiddenCards) ? 1 : 0;
- $rx = (!$GLOBALS['disable_prescriptions'] && AclMain::aclCheckCore('patients', 'rx')) ? 1 : 0;
- $cards = max(1, ($allergy + $pl + $meds));
- $col = "p-1 ";
- $colInt = 12 / $cards;
- $col .= "col-md-" . $colInt;
-
- /**
- * Helper function to return only issues with an outcome not equal to resolved
- *
- * @param array $i An array of issues
- * @return array
- */
- function filterActiveIssues(array $i): array
- {
- return array_filter($i, function ($_i) {
- return ($_i['outcome'] != 1) && (empty($_i['enddate']) || (strtotime($_i['enddate']) > strtotime('now')));
- });
- }
+ // ALLERGY CARD
+ if ($allergy === 1) {
+ $allergyService = new AllergyIntoleranceService();
+ $_rawAllergies = filterActiveIssues($allergyService->getAll(['lists.pid' => $pid])->getData());
+ $id = 'allergy_ps_expand';
+ $viewArgs = [
+ 'title' => xl('Allergies'),
+ 'card_container_class_list' => ['flex-fill', 'mx-1', 'card'],
+ 'id' => $id,
+ 'forceAlwaysOpen' => false,
+ 'initiallyCollapsed' => (getUserSetting($id) == 0) ? true : false,
+ 'linkMethod' => "javascript",
+ 'list' => $_rawAllergies,
+ 'listTouched' => (!empty(getListTouch($pid, 'allergy'))) ? true : false,
+ 'auth' => true,
+ 'btnLabel' => 'Edit',
+ 'btnLink' => "return load_location('{$GLOBALS['webroot']}/interface/patient_file/summary/stats_full.php?active=all&category=allergy')"
+ ];
+ echo "
";
+ echo $t->render('patient/card/allergies.html.twig', $viewArgs);
+ echo "
";
+ }
- // ALLERGY CARD
- if ($allergy === 1) {
- $allergyService = new AllergyIntoleranceService();
- $_rawAllergies = filterActiveIssues($allergyService->getAll(['lists.pid' => $pid])->getData());
- $id = 'allergy_ps_expand';
- $viewArgs = [
- 'title' => xl('Allergies'),
- 'card_container_class_list' => ['flex-fill', 'mx-1', 'card'],
- 'id' => $id,
- 'forceAlwaysOpen' => false,
- 'initiallyCollapsed' => (getUserSetting($id) == 0) ? true : false,
- 'linkMethod' => "javascript",
- 'list' => $_rawAllergies,
- 'listTouched' => (!empty(getListTouch($pid, 'allergy'))) ? true : false,
- 'auth' => true,
- 'btnLabel' => 'Edit',
- 'btnLink' => "return load_location('{$GLOBALS['webroot']}/interface/patient_file/summary/stats_full.php?active=all&category=allergy')"
- ];
- echo "
";
- echo $t->render('patient/card/allergies.html.twig', $viewArgs);
- echo "
";
- }
+ $patIssueService = new PatientIssuesService();
- $patIssueService = new PatientIssuesService();
+ // MEDICAL PROBLEMS CARD
+ if ($pl === 1) {
+ $_rawPL = $patIssueService->search(['lists.pid' => $pid, 'lists.type' => 'medical_problem'])->getData();
+ $id = 'medical_problem_ps_expand';
+ $viewArgs = [
+ 'title' => xl('Medical Problems'),
+ 'card_container_class_list' => ['flex-fill', 'mx-1', 'card'],
+ 'id' => $id,
+ 'forceAlwaysOpen' => false,
+ 'initiallyCollapsed' => (getUserSetting($id) == 0) ? true : false,
+ 'linkMethod' => "javascript",
+ 'list' => filterActiveIssues($_rawPL),
+ 'listTouched' => (!empty(getListTouch($pid, 'medical_problem'))) ? true : false,
+ 'auth' => true,
+ 'btnLabel' => 'Edit',
+ 'btnLink' => "return load_location('{$GLOBALS['webroot']}/interface/patient_file/summary/stats_full.php?active=all&category=medical_problem')"
+ ];
+ echo "
";
+ echo $t->render('patient/card/medical_problems.html.twig', $viewArgs);
+ echo "
";
+ }
- // MEDICAL PROBLEMS CARD
- if ($pl === 1) {
- $_rawPL = $patIssueService->search(['lists.pid' => $pid, 'lists.type' => 'medical_problem'])->getData();
- $id = 'medical_problem_ps_expand';
- $viewArgs = [
- 'title' => xl('Medical Problems'),
- 'card_container_class_list' => ['flex-fill', 'mx-1', 'card'],
- 'id' => $id,
- 'forceAlwaysOpen' => false,
- 'initiallyCollapsed' => (getUserSetting($id) == 0) ? true : false,
- 'linkMethod' => "javascript",
- 'list' => filterActiveIssues($_rawPL),
- 'listTouched' => (!empty(getListTouch($pid, 'medical_problem'))) ? true : false,
- 'auth' => true,
- 'btnLabel' => 'Edit',
- 'btnLink' => "return load_location('{$GLOBALS['webroot']}/interface/patient_file/summary/stats_full.php?active=all&category=medical_problem')"
- ];
- echo "
";
- echo $t->render('patient/card/medical_problems.html.twig', $viewArgs);
- echo "
";
- }
+ // MEDICATION CARD
+ if ($meds === 1) {
+ $_rawMedList = $patIssueService->search(['lists.pid' => $pid, 'lists.type' => 'medication'])->getData();
+ $id = 'medication_ps_expand';
+ $viewArgs = [
+ 'title' => xl('Medications'),
+ 'card_container_class_list' => ['flex-fill', 'mx-1', 'card'],
+ 'id' => $id,
+ 'forceAlwaysOpen' => false,
+ 'initiallyCollapsed' => (getUserSetting($id) == 0) ? true : false,
+ 'linkMethod' => "javascript",
+ 'list' => filterActiveIssues($_rawMedList),
+ 'listTouched' => (!empty(getListTouch($pid, 'medication'))) ? true : false,
+ 'auth' => true,
+ 'btnLabel' => 'Edit',
+ 'btnLink' => "return load_location('{$GLOBALS['webroot']}/interface/patient_file/summary/stats_full.php?active=all&category=medication')"
+ ];
+ echo "
";
+ echo $t->render('patient/card/medication.html.twig', $viewArgs);
+ echo "
";
+ }
- // MEDICATION CARD
- if ($meds === 1) {
- $_rawMedList = $patIssueService->search(['lists.pid' => $pid, 'lists.type' => 'medication'])->getData();
- $id = 'medication_ps_expand';
+ // Render the Prescriptions card if turned on
+ if ($rx === 1) :
+ if ($GLOBALS['erx_enable'] && $display_current_medications_below == 1) {
+ $sql = "SELECT * FROM prescriptions WHERE patient_id = ? AND active = '1'";
+ $res = sqlStatement($sql, [$pid]);
+
+ $rxArr = [];
+ while ($row = sqlFetchArray($res)) {
+ $row['unit'] = generate_display_field(array('data_type' => '1', 'list_id' => 'drug_units'), $row['unit']);
+ $row['form'] = generate_display_field(array('data_type' => '1', 'list_id' => 'drug_form'), $row['form']);
+ $row['route'] = generate_display_field(array('data_type' => '1', 'list_id' => 'drug_route'), $row['route']);
+ $row['interval'] = generate_display_field(array('data_type' => '1', 'list_id' => 'drug_interval'), $row['interval']);
+ $rxArr[] = $row;
+ }
+ $id = "current_prescriptions_ps_expand";
$viewArgs = [
- 'title' => xl('Medications'),
- 'card_container_class_list' => ['flex-fill', 'mx-1', 'card'],
+ 'title' => xl('Current Medications'),
'id' => $id,
'forceAlwaysOpen' => false,
'initiallyCollapsed' => (getUserSetting($id) == 0) ? true : false,
- 'linkMethod' => "javascript",
- 'list' => filterActiveIssues($_rawMedList),
- 'listTouched' => (!empty(getListTouch($pid, 'medication'))) ? true : false,
- 'auth' => true,
- 'btnLabel' => 'Edit',
- 'btnLink' => "return load_location('{$GLOBALS['webroot']}/interface/patient_file/summary/stats_full.php?active=all&category=medication')"
+ 'auth' => false,
+ 'rxList' => $rxArr,
];
- echo "
";
- echo $t->render('patient/card/medication.html.twig', $viewArgs);
- echo "
";
- }
-
- // Render the Prescriptions card if turned on
- if ($rx === 1) :
- if ($GLOBALS['erx_enable'] && $display_current_medications_below == 1) {
- $sql = "SELECT * FROM prescriptions WHERE patient_id = ? AND active = '1'";
- $res = sqlStatement($sql, [$pid]);
-
- $rxArr = [];
- while ($row = sqlFetchArray($res)) {
- $row['unit'] = generate_display_field(array('data_type' => '1', 'list_id' => 'drug_units'), $row['unit']);
- $row['form'] = generate_display_field(array('data_type' => '1', 'list_id' => 'drug_form'), $row['form']);
- $row['route'] = generate_display_field(array('data_type' => '1', 'list_id' => 'drug_route'), $row['route']);
- $row['interval'] = generate_display_field(array('data_type' => '1', 'list_id' => 'drug_interval'), $row['interval']);
- $rxArr[] = $row;
- }
- $id = "current_prescriptions_ps_expand";
- $viewArgs = [
- 'title' => xl('Current Medications'),
- 'id' => $id,
- 'forceAlwaysOpen' => false,
- 'initiallyCollapsed' => (getUserSetting($id) == 0) ? true : false,
- 'auth' => false,
- 'rxList' => $rxArr,
- ];
- echo $t->render('patient/card/erx.html.twig', $viewArgs);
- }
+ echo $t->render('patient/card/erx.html.twig', $viewArgs);
+ }
- $id = "prescriptions_ps_expand";
- $viewArgs = [
- 'title' => xl("Prescriptions"),
- 'card_container_class_list' => ['flex-fill', 'mx-1', 'card'],
- 'id' => $id,
- 'forceAlwaysOpen' => false,
- 'initiallyCollapsed' => (getUserSetting($id) == 0) ? true : false,
- 'btnLabel' => "Edit",
- 'auth' => AclMain::aclCheckCore('patients', 'rx', '', ['write', 'addonly']),
- ];
+ $id = "prescriptions_ps_expand";
+ $viewArgs = [
+ 'title' => xl("Prescriptions"),
+ 'card_container_class_list' => ['flex-fill', 'mx-1', 'card'],
+ 'id' => $id,
+ 'forceAlwaysOpen' => false,
+ 'initiallyCollapsed' => (getUserSetting($id) == 0) ? true : false,
+ 'btnLabel' => "Edit",
+ 'auth' => AclMain::aclCheckCore('patients', 'rx', '', ['write', 'addonly']),
+ ];
- if ($GLOBALS['erx_enable']) {
- $viewArgs['title'] = 'Prescription History';
- $viewArgs['btnLabel'] = 'Add';
- $viewArgs['btnLink'] = "{$GLOBALS['webroot']}/interface/eRx.php?page=compose";
- } else {
- $viewArgs['btnLink'] = "editScripts('{$GLOBALS['webroot']}/controller.php?prescription&list&id=" . attr_url($pid) . "')";
- $viewArgs['linkMethod'] = "javascript";
- $viewArgs['btnClass'] = "iframe";
- }
+ if ($GLOBALS['erx_enable']) {
+ $viewArgs['title'] = 'Prescription History';
+ $viewArgs['btnLabel'] = 'Add';
+ $viewArgs['btnLink'] = "{$GLOBALS['webroot']}/interface/eRx.php?page=compose";
+ } else {
+ $viewArgs['btnLink'] = "editScripts('{$GLOBALS['webroot']}/controller.php?prescription&list&id=" . attr_url($pid) . "')";
+ $viewArgs['linkMethod'] = "javascript";
+ $viewArgs['btnClass'] = "iframe";
+ }
- $cwd = getcwd();
- chdir("../../../");
- $c = new Controller();
- // This is a hacky way to get a Smarty template from the controller and injecting it into
- // a Twig template. This reduces the amount of refactoring that is required but ideally the
- // Smarty template should be upgraded to Twig
- ob_start();
- echo $c->act(['prescription' => '', 'fragment' => '', 'patient_id' => $pid]);
- $viewArgs['content'] = ob_get_contents();
- ob_end_clean();
-
- echo "
";
- echo $t->render('patient/card/rx.html.twig', $viewArgs); // render core prescription card
- echo "
";
- endif;
- ?>
-
+ $cwd = getcwd();
+ chdir("../../../");
+ $c = new Controller();
+ // This is a hacky way to get a Smarty template from the controller and injecting it into
+ // a Twig template. This reduces the amount of refactoring that is required but ideally the
+ // Smarty template should be upgraded to Twig
+ ob_start();
+ echo $c->act(['prescription' => '', 'fragment' => '', 'patient_id' => $pid]);
+ $viewArgs['content'] = ob_get_contents();
+ ob_end_clean();
+
+ echo "
";
+ echo $t->render('patient/card/rx.html.twig', $viewArgs); // render core prescription card
+ echo "