* @author Brady Miller * @copyright Copyright (c) 2016-2022 Jerry Padgett * @copyright Copyright (c) 2019 Brady Miller * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3 */ require_once("../interface/globals.php"); use OpenEMR\Common\Acl\AclMain; use OpenEMR\Common\Csrf\CsrfUtils; use OpenEMR\Core\Header; use OpenEMR\Services\DocumentTemplates\DocumentTemplateService; if (!(isset($GLOBALS['portal_onsite_two_enable'])) || !($GLOBALS['portal_onsite_two_enable'])) { echo xlt('Patient Portal is turned off'); exit; } $authUploadTemplates = AclMain::aclCheckCore('admin', 'forms'); $templateService = new DocumentTemplateService(); $from_demo_pid = $_GET['from_demo_pid'] ?? '0'; $patient = $_REQUEST['selected_patients'] ?? null; $patient = $patient ?: ($_REQUEST['upload_pid'] ?? 0); $category = $_REQUEST['template_category'] ?? ''; $category_list = $templateService->fetchDefaultCategories(); $profile_list = $templateService->fetchDefaultProfiles(); $group_list = $templateService->fetchDefaultGroups(); $none_message = xlt("Nothing to show for current actions."); ?> <?php echo xlt('Portal'); ?> | <?php echo xlt('Templates'); ?>


' id="repository-collapse"> getTemplateListByCategory($category, -1); } else { $templates = $templateService->getTemplateListAllCategories(-1); } echo "\n"; echo "\n"; echo "\n" . "" . '' . "" . "" . "" . "\n"; echo "\n"; echo "\n"; foreach ($templates as $cat => $files) { if (empty($cat)) { $cat = xlt('General'); } foreach ($files as $file) { $template_id = $file['id']; $this_cat = $file['category']; $notify_flag = false; $select_cat_options = '\n"; foreach ($category_list as $option_category) { if (stripos($option_category['option_id'], 'repository') !== false) { continue; } if ($this_cat === $option_category['option_id']) { $select_cat_options .= "\n"; } else { $select_cat_options .= "\n"; } } echo ""; if ($file['mime'] == 'application/pdf') { $this_cat = xlt('PDF Document'); $notify_flag = true; echo ''; echo ""; } else { echo ""; echo ''; } echo '"; echo ""; echo ""; echo ""; ?> \n"; } echo "\n"; echo "
" . xlt('Send') . "' . xlt('Category') . '" . xlt("Template Actions") . "" . xlt("Size") . "" . xlt("Last Modified") . "
' . '*' . '" . $this_cat . " Id: " . attr($template_id) . "' . ''; if ($authUploadTemplates) { echo ''; } echo "" . text($file['size']) . "" . text(date('m/d/Y H:i:s', strtotime($file['modified_date']))) . "
' . $none_message . "
\n"; ?>
\n"; echo '' . xlt('Profiles in Portal') . ""; echo "\n"; echo "\n" . "" . xlt('Active') . "" . '' . xlt('Profile') . '' . '' . xlt('Assigned Templates') . '' . '' . xlt('Assigned Groups') . '' . "\n"; echo "\n"; foreach ($profile_list as $profile => $profiles) { $template_list = ''; $group_list_text = ''; $group_items_list = $templateService->getPatientGroupsByProfile($profile); $profile_items_list = $templateService->getTemplateListByProfile($profile); if (empty($profile_items_list)) { continue; } $total = 0; foreach ($profile_items_list as $key => $files) { $total += count($files ?? []); foreach ($files as $file) { if (is_array($file)) { $template_list .= $file['template_name'] . ', '; } } } $template_list = substr($template_list, 0, -2); $profile_esc = attr($profile); foreach ($group_items_list as $key => $groups) { foreach ($groups as $group) { if (is_array($group)) { $group_list_text .= $group_list[$group['member_of']]['title'] . ', '; } } } $group_list_text = substr($group_list_text, 0, -2); $send = 'send'; if (!empty($group_list_text)) { $send = 'send_profile'; } echo ''; $is_checked = ''; if ((int)$templateService->fetchProfileStatus($profiles['option_id']) === 1) { $is_checked = 'checked'; } echo ""; echo '' . text($profiles['title']) . ''; echo '' . text($template_list) . ''; echo '' . text($group_list_text) . ''; echo ''; } if (empty($profile_list)) { echo '' . $none_message . "\n"; } echo "\n"; echo "\n"; ?>

' id='template-collapse'> getTemplateListByCategory($category); } else { $templates = $templateService->getTemplateListAllCategories(); } echo "\n"; echo "\n"; echo "\n" . '' . '' . '' . '' . "\n"; echo "\n"; echo "\n"; foreach ($templates as $cat => $files) { if (empty($cat)) { $cat = xlt('General'); } foreach ($files as $file) { $template_id = $file['id']; echo ''; /*echo "";*/ echo ''; echo ''; echo ''; ?> \n"; } echo "\n"; echo "
' . xlt('Category') . '' . xlt('Template Actions') . '' . xlt('Size') . '' . xlt('Last Modified') . '
' . text(ucwords($cat)) . ''; echo ''; if ($authUploadTemplates) { echo ''; } echo '' . text($file['size']) . '' . text(date('m/d/Y H:i:s', strtotime($file['modified_date']))) . '
' . $none_message . "
\n"; ?>

' id="assigned_collapse"> getPortalAssignedTemplates(0, $category, false); } else {// Category selected so get all of them for pid's $patient_templates = $templateService->getTemplateCategoriesByPids($patient, $category); } echo "\n"; echo ""; $idcnt = 0; foreach ($patient_templates as $name => $templates) { $count = 0; $fetched_groups = $fetch_pid = null; foreach ($templates as $c => $t) { if (is_array($t)) { $fetch_pid = $t[0]['pid']; if (empty($fetched_groups)) { $fetched_groups = str_replace('|', ', ', $t[0]['patient_groups'] ?? ''); } $count += count($t); } } echo ""; echo "\n"; } if (empty($templates)) { echo '\n"; } echo "\n"; echo "
" . text($name) . " (" . text($count . ' ' . xl('Templates')) . ") in " . text($fetched_groups) . "
\n"; //echo ''; echo "\n"; echo "\n" . '' . '' . '\n"; echo "\n"; echo "\n"; foreach ($templates as $cat => $files) { if (empty($cat)) { $cat = xlt('General'); } foreach ($files as $file) { $template_id = $file['id']; $audit_status = array ( 'pid' => '', 'create_date' => ($file['profile_date'] ?: $file['modified_date']) ?? '', 'doc_type' => '', 'patient_signed_time' => '', 'authorize_signed_time' => '', 'patient_signed_status' => '', 'review_date' => '', 'denial_reason' => $file['status'] ?? '', 'file_name' => '', 'file_path' => '', ); $audit_status_fetch = $templateService->fetchTemplateStatus($file['pid'], $file['id']); if (is_array($audit_status_fetch)) { $audit_status = $audit_status_fetch; } $next_due = $templateService->showTemplateFromEvent($file, true); if ($next_due > 1) { if ($audit_status['denial_reason'] === 'In Review') { $audit_status['denial_reason'] = xl('Scheduled') . ' ' . xl('but Needs Review'); } else { $audit_status['denial_reason'] = xl('Scheduled'); } $next_due = date('m/d/Y', $next_due); } elseif ($next_due === 1 || ($next_due === true && $file['recurring'] ?? 0)) { $audit_status['denial_reason'] = xl('Recurring'); $next_due = xl('Active'); } elseif ($next_due === 0) { $audit_status['denial_reason'] = xl('Completed'); $next_due = xl('Inactive'); } elseif ($next_due === true && empty($file['recurring'] ?? 0)) { $next_due = xl('Active'); } echo ''; echo ''; echo '\n"; } echo ''; echo ''; echo ''; echo "\n"; } } echo "\n"; echo "
' . text($name) . '
' . xlt('Category') . '' . xlt('Profile') . '' . xlt('Template Actions') . '' . xlt('Status') . '' . xlt('Last Action') . '' . xlt('Next Due') . "
' . text(ucwords($cat)) . '' . text($profile_list[$file['profile']]['title'] ?? '') . '' . '\n"; if ($authUploadTemplates && empty($file['member_of']) && !empty($file['status'])) { echo '' . text($audit_status['denial_reason']) . '' . text(date('m/d/Y H:i:s', strtotime($audit_status['create_date']))) . '' . text($next_due) . '
' . xlt('Multi Select Patients or All Patients using toolbar Location') . "
\n"; ?>