Highway to PSR2
[openemr.git] / interface / patient_file / summary / print_amendments.php
blob2f02d535c7df00f706a270447e9451ca6f989818
1 <?php
2 /**
3 * Print Amendments
5 * Copyright (C) 2014 Ensoftek
7 * LICENSE: This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
18 * @package OpenEMR
19 * @author Hema Bandaru <hemab@drcloudemr.com>
20 * @link http://www.open-emr.org
25 include_once("../../globals.php");
26 include_once("$srcdir/options.inc.php");
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>". 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>" . 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>";
91 <html>
92 <head>
93 <?php html_header_show();?>
95 <!-- supporting javascript code -->
96 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-2/index.js"></script>
97 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/textformat.js"></script>
98 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
101 <!-- page styles -->
102 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
104 </head>
106 <body class="body_top">
107 <span class='title'><?php echo xlt("Amendments for") . " " . text($patientName); ?></span>
108 <p></p>
110 <?php
111 for ($i = 0; $i < count($amendmentsList); $i++) {
112 $lastAmendment = ( $i == count($amendmentsList) - 1 ) ? true : false;
113 printAmendment($amendmentsList[$i], $lastAmendment);
117 <script language='JavaScript'>
118 opener.top.printLogPrint(window);
119 </script>
121 </body>
123 </html>