chore: complete integration of flex-3.20 (alpine 3.20) into ci (#7538)
[openemr.git] / interface / patient_file / summary / print_amendments.php
blob2f73ec8296248f3ca0a987b78d1831c066ce6af3
1 <?php
3 /**
4 * Print Amendments
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Hema Bandaru <hemab@drcloudemr.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2014 Ensoftek
11 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once("../../globals.php");
16 require_once("$srcdir/options.inc.php");
18 use OpenEMR\Common\Acl\AclMain;
19 use OpenEMR\Common\Twig\TwigContainer;
20 use OpenEMR\Core\Header;
22 //ensure user has proper access
23 if (!AclMain::aclCheckCore('patients', 'amendment')) {
24 echo (new TwigContainer(null, $GLOBALS['kernel']))->getTwig()->render('core/unauthorized.html.twig', ['pageTitle' => xl("Amendment Print")]);
25 exit;
28 $amendments = $_REQUEST["ids"];
29 $amendments = rtrim($amendments, ",");
30 $amendmentsList = explode(",", $amendments);
32 $patientDetails = getPatientData($pid, "fname,lname");
33 $patientName = $patientDetails['lname'] . ", " . $patientDetails['fname'];
35 function printAmendment($amendmentID, $lastAmendment)
37 $query = "SELECT lo.title AS 'amendmentFrom', lo1.title AS 'amendmentStatus',a.* FROM amendments a
38 LEFT JOIN list_options lo ON a.amendment_by = lo.option_id AND lo.list_id = 'amendment_from' AND lo.activity = 1
39 LEFT JOIN list_options lo1 ON a.amendment_status = lo1.option_id AND lo1.list_id = 'amendment_status' AND lo1.activity = 1
40 WHERE a.amendment_id = ?";
41 $resultSet = sqlQuery($query, array($amendmentID));
42 echo "<table>";
43 echo "<tr class=text>";
44 echo "<td class=bold>" . xlt("Requested Date") . ":" . "</td>";
45 echo "<td>" . text(oeFormatShortDate($resultSet['amendment_date'])) . "</td>";
46 echo "</tr>";
48 echo "<tr class=text>";
49 echo "<td class=bold>" . xlt("Requested By") . ":" . "</td>";
50 echo "<td>" . generate_display_field(array('data_type' => '1','list_id' => 'amendment_from'), $resultSet['amendment_by']) . "</td>";
51 echo "</tr>";
53 echo "<tr class=text>";
54 echo "<td class=bold>" . xlt("Request Status") . ":" . "</td>";
55 echo "<td>" . generate_display_field(array('data_type' => '1','list_id' => 'amendment_status'), $resultSet['amendment_status']) . "</td>";
56 echo "</tr>";
58 echo "<tr class=text>";
59 echo "<td class=bold>" . xlt("Request Description") . ":" . "</td>";
60 echo "<td>" . text($resultSet['amendment_desc']) . "</td>";
61 echo "</tr>";
63 echo "</table>";
65 echo "<hr>";
66 echo "<span class='bold'>" . xlt("History") . "</span><br />";
67 $pageBreak = ( $lastAmendment ) ? "" : "page-break-after:always";
68 echo "<table border='1' cellspacing=0 cellpadding=3 style='width:75%;margin-top:10px;margin-bottom:20px;" . $pageBreak . "'>";
69 echo "<tr class='text bold'>";
70 echo "<th align=left style='width:10%'>" . xlt("Date") . "</th>";
71 echo "<th align=left style='width:20%'>" . xlt("By") . "</th>";
72 echo "<th align=left >" . xlt("Comments") . "</th>";
73 echo "</tr>";
75 $query = "SELECT u.fname,u.lname,ah.* FROM amendments_history ah INNER JOIN users u ON ah.created_by = u.id WHERE ah.amendment_id = ?";
76 $resultSet = sqlStatement($query, array($amendmentID));
77 while ($row = sqlFetchArray($resultSet)) {
78 echo "<tr class=text>";
79 $created_date = date('Y-m-d', strtotime($row['created_time']));
80 echo "<td>" . text(oeFormatShortDate($created_date)) . "</td>";
81 echo "<td>" . text($row['lname']) . ", " . text($row['fname']) . "</td>";
82 echo "<td>" . text($row['amendment_note']) . "</td>";
83 echo "</tr>";
86 echo "</table>";
90 <html>
91 <head>
92 <?php Header::setupHeader(); ?>
93 </head>
95 <body class="body_top">
96 <span class='title'><?php echo xlt("Amendments for") . " " . text($patientName); ?></span>
97 <p></p>
99 <?php
100 for ($i = 0; $i < count($amendmentsList); $i++) {
101 $lastAmendment = ( $i == count($amendmentsList) - 1 ) ? true : false;
102 printAmendment($amendmentsList[$i], $lastAmendment);
106 <script>
107 opener.top.printLogPrint(window);
108 </script>
110 </body>
112 </html>