* @copyright Copyright (c) 2022 Jerry Padgett * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3 */ require_once('./../../interface/globals.php'); require_once("$srcdir/patient.inc"); use OpenEMR\Core\Header; use OpenEMR\Services\DocumentTemplates\DocumentTemplateService; $templateService = new DocumentTemplateService(); $group_list = $templateService->fetchDefaultGroups(); $profile_list = $templateService->fetchDefaultProfiles(); $_POST['mode'] = $_POST['mode'] ?? null; if ($_POST['mode'] === 'save_profile_groups') { $groups = json_decode(($_POST['patient_groups'] ?? ''), true, 512, JSON_THROW_ON_ERROR); $work_ids = []; foreach ($groups as $group) { if (empty($group)) { continue; } foreach ($group as $item) { $work_ids[$item['profile']][] = $item; } } $rtn = $templateService->savePatientGroupsByProfile($work_ids); if ($rtn) { echo xlt('Groups successfully saved.'); } else { echo xlt('Error! Groups save failed. Check your Group lists.'); } exit; } if ($_POST['mode'] === 'save_groups') { $groups = json_decode(($_POST['groups'] ?? ''), true, 512, JSON_THROW_ON_ERROR); $master_ids = $work_ids = []; foreach ($groups as $group) { if (empty($group)) { continue; } foreach ($group as $item) { $work_ids[$item['id']][$item['group']][] = $item['group']; } } foreach ($work_ids as $id => $items) { $work_grps = []; foreach ($items as $grp => $item) { $work_grps[] = $grp; } $master_ids[$id] = implode('|', array_unique($work_grps)); } $rtn = $templateService->updateGroupsInPatients($master_ids); if ($rtn) { echo xlt('Groups successfully saved.'); } else { echo xlt('Error! Groups save failed. Check your Group lists.'); } exit; } if (!isset($_GET['render_group_assignments'])) { $info_msg = ''; $result = ''; if (!empty($_REQUEST['searchby']) && !empty($_REQUEST['searchparm'])) { $searchby = $_REQUEST['searchby']; $searchparm = trim($_REQUEST['searchparm'] ?? ''); if ($searchby == 'Last') { $result = getPatientLnames("$searchparm", 'pid, pubpid, lname, fname, mname, providerID, DOB'); } elseif ($searchby == 'Phone') { $result = getPatientPhone("$searchparm"); } elseif ($searchby == 'ID') { $result = getPatientId("$searchparm"); } elseif ($searchby == 'DOB') { $result = getPatientDOB(DateToYYYYMMDD($searchparm)); } elseif ($searchby == 'SSN') { $result = getPatientSSN("$searchparm"); } elseif ($searchby == 'Issues') { $result = $templateService->fetchPatientListByIssuesSearch("$searchparm"); } } else { $result = getPatientLnames("", 'pid, pubpid, lname, fname, mname, providerID, DOB'); } ?>

= 1000) : ?>
    " . '' . text($name) . '' . ' ' . xlt('Dob') . ': ' . '' . text(oeFormatShortDate($pt['DOB'])) . '' . ' ' . xlt('ID') . ': ' . '' . text($pt['pubpid']) . ''; if (!empty($searchby) && ($searchby === 'Issues')) { echo ' ' . xlt('Result') . ': ' . text($pt['title']) . ' ' . text($pt['diagnosis']); } echo '' . "\n"; } } ?>
getPatientsByAllGroups(); foreach ($group_list as $group => $groups) { $group_esc = attr($groups['option_id']); $groups_esc = attr($groups['option_id']); echo "
" . text($groups['title']) . "
\n"; echo "
    \n"; if (!empty($result[$groups['option_id']] ?? '')) { foreach ($result[$groups['option_id']] as $pt) { $name = $pt['lname'] . ', ' . $pt['fname'] . ' ' . $pt['mname']; $this_name = attr($name); $pt_pid = attr($pt['pid']); $groups_esc = attr($pt['patient_groups']); echo "
  • " . '' . text($name) . '' . ' ' . xlt('Dob') . ': ' . '' . text(oeFormatShortDate($pt['DOB'])) . '' . ' ' . xlt('ID') . ': ' . '' . text($pt['pubpid']) . '' . '
  • ' . "\n"; } } echo "
\n"; } // so list is responsive. echo "
\n"; ?>

getPatientsByAllGroups(); foreach ($group_list as $group => $groups) { $group_esc = attr($groups['option_id']); $groups_esc = attr($groups['option_id']); echo "
  • " . text($groups['title']) . "
  • \n"; echo "
      \n"; if (!empty($result[$groups['option_id']] ?? '')) { foreach ($result[$groups['option_id']] as $pt) { $name = $pt['lname'] . ', ' . $pt['fname'] . ' ' . $pt['mname']; $this_name = attr($name); $pt_pid = attr($pt['pid']); $groups_esc = attr($pt['patient_groups']); echo "
    • " . '' . text($name) . '' . ' ' . xlt('Dob') . ': ' . '' . text(oeFormatShortDate($pt['DOB'])) . '' . ' ' . xlt('ID') . ': ' . '' . text($pt['pubpid']) . '' . '
    • ' . "\n"; } } echo "
    \n"; } // so list is responsive. echo "
    \n"; ?>
    $profiles) { $profile_items_list = $templateService->getPatientGroupsByProfile($profile); $active = $templateService->getProfileActiveStatus($profile); $active_esc = attr($active); if (!empty($active)) { $active_text = '' . xlt('Active') . ''; } else { $active_text = ''; } $profile_esc = attr($profile); echo "
    " . $active_text . text($profiles['title']) . "
    \n"; echo "
      \n"; foreach ($profile_items_list as $grp_profile => $groups) { foreach ($groups as $group) { $group_esc = attr($group['member_of']); $title = $group_list[$group['member_of']]['title'] ?: $group['member_of']; echo "
    • " . text($title) . "
    • \n"; } } echo "
    \n"; } ?>