* @author Brady Miller * @copyright Copyright (c) 2017-2018 Brady Miller * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3 */ require_once("../../globals.php"); $srcdir = \OpenEMR\Core\OEGlobalsBag::getInstance()->getSrcDir(); $session = \OpenEMR\Common\Session\SessionWrapperFactory::getInstance()->getActiveSession(); $pid = $session->get('pid', 0); $userauthorized = $session->get('userauthorized', 0); require_once($srcdir . "/options.inc.php"); use OpenEMR\Common\Acl\AccessDeniedHelper; use OpenEMR\Common\Acl\AclMain; use OpenEMR\Common\Csrf\CsrfUtils; use OpenEMR\Common\Database\QueryUtils; use OpenEMR\Core\Header; use OpenEMR\Core\OEGlobalsBag; use OpenEMR\OeUI\OemrUI; /** @var string $date_init */ $date_init = OEGlobalsBag::getInstance()->get('date_init', ''); // This can come from the URL if it's an Add. $title = empty($_REQUEST['title']) ? 'LBTref' : $_REQUEST['title']; $form_id = $title; // Plugin support. $fname = OEGlobalsBag::getInstance()->get('OE_SITE_DIR') . "/LBF/" . convert_safe_file_dir_name($form_id) . ".plugin.php"; if (file_exists($fname)) { include_once($fname); } $transid = empty($_REQUEST['transid']) ? 0 : $_REQUEST['transid'] + 0; $mode = empty($_POST['mode' ]) ? '' : $_POST['mode' ]; // $inmode = $_GET['inmode']; $body_onload_code = ""; // Transaction read/write surface; align the permission check with the // `patients/trans` ACO. Writes additionally require `write` (or `addonly` // when inserting a new form). $aclReturn = $mode ? ['write', 'addonly'] : ''; if (!AclMain::aclCheckCore('patients', 'trans', '', $aclReturn)) { AccessDeniedHelper::denyWithTemplate("ACL check failed for patients/trans: Transactions", xl("Transactions")); } // Bind the request `transid` to the open chart. `$pid` is the session-scoped // chart id (switching the chart goes through the normal demographics path). $sessionPidInt = is_numeric($pid) ? (int) $pid : 0; if ($transid > 0) { $owner = QueryUtils::querySingleRow("SELECT pid FROM transactions WHERE id = ?", [$transid]); $ownerPid = is_array($owner) && isset($owner['pid']) && is_numeric($owner['pid']) ? (int) $owner['pid'] : 0; // transactions.pid is nullable; a NULL-owned row with no open chart // would otherwise normalize to 0 === 0 and pass the match. Require // both sides to be positive before comparing. if ($sessionPidInt <= 0 || $ownerPid <= 0 || $ownerPid !== $sessionPidInt) { AccessDeniedHelper::deny('add_transaction: transid does not belong to the open chart'); } } // Load array of properties for this layout and its groups. $grparr = []; getLayoutProperties($form_id, $grparr); if ($mode) { CsrfUtils::checkCsrfInput(INPUT_POST, dieOnFail: true); $sets = "title = ?, user = ?, groupname = ?, authorized = ?, date = NOW()"; $sqlBindArray = [$form_id, $session->get('authUser'), $session->get('authProvider'), $userauthorized]; if ($transid) { array_push($sqlBindArray, $transid); sqlStatement("UPDATE transactions SET $sets WHERE id = ?", $sqlBindArray); } else { array_push($sqlBindArray, $pid); $sets .= ", pid = ?"; $newid = sqlInsert("INSERT INTO transactions SET $sets", $sqlBindArray); } $fres = sqlStatement("SELECT * FROM layout_options " . "WHERE form_id = ? AND uor > 0 AND field_id != '' " . "ORDER BY group_id, seq", [$form_id]); while ($frow = sqlFetchArray($fres)) { $data_type = $frow['data_type']; $field_id = $frow['field_id']; $value = get_layout_form_value($frow); if ($transid) { // existing form if ($value === '') { $query = "DELETE FROM lbt_data WHERE " . "form_id = ? AND field_id = ?"; sqlStatement($query, [$transid, $field_id]); } else { $query = "REPLACE INTO lbt_data SET field_value = ?, " . "form_id = ?, field_id = ?"; sqlStatement($query, [$value, $transid, $field_id]); } } else { // new form if ($value !== '') { sqlStatement( "INSERT INTO lbt_data " . "( form_id, field_id, field_value ) VALUES ( ?, ?, ? )", [$newid, $field_id, $value] ); } } } if (!$transid) { $transid = $newid; } // Set the AMC sent records flag if (!(empty($_POST['send_sum_flag']))) { // add the sent records flag processAmcCall('send_sum_amc', true, 'add', $pid, 'transactions', $transid); if (!(empty($_POST['send_sum_elec_flag']))) { processAmcCall('send_sum_elec_amc', true, 'add', $pid, 'transactions', $transid); } else { processAmcCall('send_sum_elec_amc', true, 'remove', $pid, 'transactions', $transid); } if (!(empty($_POST['send_sum_amc_confirmed']))) { processAmcCall('send_sum_amc_confirmed', true, 'add', $pid, 'transactions', $transid); } else { processAmcCall('send_sum_amc_confirmed', true, 'remove', $pid, 'transactions', $transid); } } else { // remove the sent records flags processAmcCall('send_sum_amc', true, 'remove', $pid, 'transactions', $transid); processAmcCall('send_sum_elec_amc', true, 'remove', $pid, 'transactions', $transid); processAmcCall('send_sum_amc_confirmed', true, 'remove', $pid, 'transactions', $transid); } $body_onload_code = "javascript:location.href='transactions.php';"; } $CPR = 4; // cells per row function transaction_end_cell(): void { global $item_count, $cell_count; if ($item_count > 0) { echo ""; $item_count = 0; } } function transaction_end_row(): void { global $cell_count, $CPR; transaction_end_cell(); if ($cell_count > 0) { for (; $cell_count < $CPR; ++$cell_count) { echo ""; } echo "\n"; $cell_count = 0; } } function transaction_end_group(): void { global $last_group; if (strlen((string) $last_group) > 0) { transaction_end_row(); echo " \n"; echo "\n"; } } // If we are editing a transaction, get its ID and data. $trow = $transid ? getTransById($transid) : []; ?> <?php echo xlt('Add/Edit Patient Transaction'); ?> xl('Add/Edit Patient Transaction'), 'include_patient_name' => true, 'expandable' => false, 'expandable_files' => [],//all file names need suffix _xpd 'action' => "back",//conceal, reveal, search, reset, link or back 'action_title' => "", 'action_href' => "transactions.php",//only for actions - reset, link and back 'show_help_icon' => true, 'help_file_name' => "add_edit_transactions_dashboard_help.php" ]; $oemr_ui = new OemrUI($arrOeUiSettings); ?>
getProjectDir() . "/interface/patient_file/summary/dashboard_header.php"); ?>


\n"; while ($ttrow = sqlFetchArray($ttres)) { $thisid = $ttrow['grp_form_id']; echo "\n"; } echo "\n"; ?>
getBoolean('enable_amc_prompting') && 'LBTref' == $form_id) { ?>

        
        
    0 " . "ORDER BY group_id, seq", [$form_id]); $last_group = ''; while ($frow = sqlFetchArray($fres)) { $this_group = $frow['group_id']; // Handle a data category (group) change. if (strcmp((string) $this_group, (string) $last_group) != 0) { $group_seq = substr((string) $this_group, 0, 1); $group_name = $grparr[$this_group]['grp_title']; $last_group = $this_group; if ($group_seq == 1) { echo "
  • "; } else { echo "
  • "; } echo "" . text(xl_layout_label($group_name)) . "
  • "; } } ?>
0 " . "ORDER BY group_id, seq", [$form_id]); $last_group = ''; $cell_count = 0; $item_count = 0; $display_style = 'block'; $condition_str = ''; while ($frow = sqlFetchArray($fres)) { $this_group = $frow['group_id']; $titlecols = $frow['titlecols']; $datacols = $frow['datacols']; $data_type = $frow['data_type']; $field_id = $frow['field_id']; $list_id = $frow['list_id']; // Accumulate action conditions into a JSON expression for the browser side. accumActionConditions($frow, $condition_str); $currvalue = ''; if (isset($trow[$field_id])) { $currvalue = $trow[$field_id]; } // Handle special-case default values. if (!$currvalue && !$transid && $form_id == 'LBTref') { if ($field_id == 'refer_date') { $currvalue = date('Y-m-d'); } } // Handle a data category (group) change. if (strcmp((string) $this_group, (string) $last_group) != 0) { transaction_end_group(); $group_seq = substr((string) $this_group, 0, 1); $group_name = $grparr[$this_group]['grp_title']; $last_group = $this_group; if ($group_seq == 1) { echo "
"; } else { echo "
"; } echo " \n"; $display_style = 'none'; } // Handle starting of a new row. if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) { transaction_end_row(); echo " "; } if ($item_count == 0 && $titlecols == 0) { $titlecols = 1; } // Handle starting of a new label cell. if ($titlecols > 0) { transaction_end_cell(); echo "
"; $cell_count += $titlecols; } ++$item_count; echo ""; // Modified 6-09 by BM - Translate if applicable if ($frow['title']) { echo (text(xl_layout_label($frow['title'])) . ":"); } else { echo " "; } echo ""; // Handle starting of a new data cell. if ($datacols > 0) { transaction_end_cell(); echo " 0) { echo " style='padding-left:5pt'"; } echo ">"; $cell_count += $datacols; } ++$item_count; generate_form_field($frow, $currvalue); echo ""; } transaction_end_group(); ?> getProjectDir() . "/library/options_listadd.inc.php"; ?> oeBelowContainerDiv();?>