Skip to content

Commit

Permalink
feat: Group attendance display encounter (openemr#7128) (openemr#7394)
Browse files Browse the repository at this point in the history
* expected at least 8 spaces, found 4

* adding attendance to encounter summary page

* PSR fixes

* fixing translation

Co-authored-by: Sherwin Gaddis <sherwingaddis@gmail.com>
  • Loading branch information
adunsulag and juggernautsei committed Apr 23, 2024
1 parent 0186814 commit ab177a6
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 14 deletions.
21 changes: 21 additions & 0 deletions interface/forms/group_attendance/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function participant_insertions($form_id, $therapy_group, $group_encounter_data,
*/
function insert_into_tgpa_table($form_id, $pid, $participantData)
{

$sql_for_table_tgpa = "INSERT INTO therapy_groups_participant_attendance (form_id, pid, meeting_patient_comment, meeting_patient_status) " .
"VALUES(?,?,?,?);";
sqlStatement($sql_for_table_tgpa, array($form_id, $pid, $participantData['comment'], $participantData['status']));
Expand Down Expand Up @@ -152,6 +153,19 @@ function get_appt_data($encounter_id)
return $result;
}

function getGroupAttendance($form_id): array
{
$participants_sql = "SELECT tgpa.*, p.fname, p.lname " .
"FROM therapy_groups_participant_attendance as tgpa " .
"JOIN patient_data as p ON tgpa.pid = p.id " .
"WHERE tgpa.form_id = ?;";
$result = sqlStatement($participants_sql, array($form_id));
$participants = array();
while ($p = sqlFetchArray($result)) {
$participants[] = $p;
}
return $participants;
}
/**
* Gets group encounter data
* @param $encounter_id
Expand All @@ -177,6 +191,13 @@ function if_to_create_for_patient($status)
return $to_create;
}

function getAttendanceStatus($status)
{
$sql = 'SELECT title FROM list_options WHERE list_id = \'attendstat\' AND option_id = ?';
$result = sqlQuery($sql, array($status));
return $result['title'];
}

/**
* Returns the number after the greatest id number in the table
* @param $table
Expand Down
9 changes: 1 addition & 8 deletions interface/forms/group_attendance/new.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,7 @@


if ($form_id) {//If editing a form or the form already exists (inwhich case will automatically go into edit mode for existing form)
$participants_sql = "SELECT tgpa.*, p.fname, p.lname " .
"FROM therapy_groups_participant_attendance as tgpa " .
"JOIN patient_data as p ON tgpa.pid = p.id " .
"WHERE tgpa.form_id = ?;";
$result = sqlStatement($participants_sql, array($form_id));
while ($p = sqlFetchArray($result)) {
$participants[] = $p;
}
$participants = getGroupAttendance($form_id);
} else {//new form
$participants = getParticipants($therapy_group, true);
}
Expand Down
38 changes: 35 additions & 3 deletions interface/forms/group_attendance/report.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@
require_once(__DIR__ . "/../../globals.php");
require_once($GLOBALS["srcdir"] . "/api.inc.php");
require_once("{$GLOBALS['srcdir']}/group.inc.php");

require_once("functions.php");
function group_attendance_report($pid, $encounter, $cols, $id)
{

global $therapy_group;

$encounter = $_SESSION["encounter"];
$sql = "SELECT * FROM `form_group_attendance` WHERE id=? AND group_id = ? AND encounter_id = ?";
$res = sqlStatement($sql, array($id,$therapy_group, $_SESSION["encounter"]));
$res = sqlStatement($sql, array($id,$therapy_group, $encounter));
$form_data = sqlFetchArray($res);
$group_data = getGroup($therapy_group);
$group_name = $group_data['group_name'];
$result = get_form_id_of_existing_attendance_form($encounter, $therapy_group);

$form_id = $result['form_id'];
$participants = getGroupAttendance($form_id);
if ($form_data) { ?>
<table class="table table-bordered w-100">
<tr class="text-center">
Expand All @@ -38,6 +41,35 @@ function group_attendance_report($pid, $encounter, $cols, $id)
<td><span class='text'><?php echo text($group_name); ?></span></td>
</tr>
</table>
<table class="table table-bordered w-100">
<tr>
<td><span class='font-weight-bold'><?php echo xlt('Participant'); ?></span></td>
<td><span class='font-weight-bold'><?php echo xlt('Status'); ?></span></td>
<td><span class='font-weight-bold'><?php echo xlt('Comments'); ?></span></td>
</tr>
<?php
if ($participants) {
foreach ($participants as $participant) {
$name = $participant['lname'] . ', ' . $participant['fname'];
$attnStatus = getAttendanceStatus($participant['meeting_patient_status'])
?>
<tr>
<td><span class='text'><?php echo text($name); ?></span></td>
<td><span class='text'><?php echo text(xl_list_label($attnStatus)); ?></span></td>
<td width="65%"><span
class='text'><?php echo text($participant['meeting_patient_comment']); ?></span></td>
</tr>
<?php
}
} else {
?>
<tr>
<td colspan="3"><span class='text'><?php echo xlt('No participants'); ?></span></td>
</tr>
<?php
}
?>
</table>
<?php
}
}
Expand Down
6 changes: 3 additions & 3 deletions interface/reports/collections_report.php
Original file line number Diff line number Diff line change
Expand Up @@ -1082,9 +1082,9 @@ function checkAll(checked) {
<th>&nbsp;<?php echo xlt('Act Date')?></th>
<?php } ?>
<?php } ?>
<th align="right"><?php echo xlt('Charge') ?>&nbsp;</th>
<th align="right"><?php echo xlt('Adjust') ?>&nbsp;</th>
<th align="right"><?php echo xlt('Paid') ?>&nbsp;</th>
<th align="right"><?php echo xlt('Charge') ?>&nbsp;</th>
<th align="right"><?php echo xlt('Adjust') ?>&nbsp;</th>
<th align="right"><?php echo xlt('Paid') ?>&nbsp;</th>
<?php
// Generate aging headers if appropriate, else balance header.
if ($form_age_cols) {
Expand Down

0 comments on commit ab177a6

Please sign in to comment.