More complete support for activity flag in list_options table. (#274)
[openemr.git] / interface / patient_file / summary / print_amendments.php
blobc7df8d001ed564054269c57d1cf485e07435388a
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
23 //SANITIZE ALL ESCAPES
24 $sanitize_all_escapes=true;
27 //STOP FAKE REGISTER GLOBALS
28 $fake_register_globals=false;
31 include_once("../../globals.php");
32 include_once("$srcdir/sql.inc");
33 include_once("$srcdir/options.inc.php");
35 $amendments = $_REQUEST["ids"];
36 $amendments = rtrim($amendments,",");
37 $amendmentsList = explode(",",$amendments);
39 $patientDetails = getPatientData($pid,"fname,lname");
40 $patientName = $patientDetails['lname'] . ", " . $patientDetails['fname'];
42 function printAmendment($amendmentID,$lastAmendment) {
43 $query = "SELECT lo.title AS 'amendmentFrom', lo1.title AS 'amendmentStatus',a.* FROM amendments a
44 LEFT JOIN list_options lo ON a.amendment_by = lo.option_id AND lo.list_id = 'amendment_from' AND lo.activity = 1
45 LEFT JOIN list_options lo1 ON a.amendment_status = lo1.option_id AND lo1.list_id = 'amendment_status' AND lo1.activity = 1
46 WHERE a.amendment_id = ?";
47 $resultSet = sqlQuery($query,array($amendmentID));
48 echo "<table>";
49 echo "<tr class=text>";
50 echo "<td class=bold>" . xlt("Requested Date") . ":" . "</td>";
51 echo "<td>". oeFormatShortDate($resultSet['amendment_date']) . "</td>";
52 echo "</tr>";
54 echo "<tr class=text>";
55 echo "<td class=bold>" . xlt("Requested By") . ":" . "</td>";
56 echo "<td>". generate_display_field(array('data_type'=>'1','list_id'=>'amendment_from'),$resultSet['amendment_by']) . "</td>";
57 echo "</tr>";
59 echo "<tr class=text>";
60 echo "<td class=bold>" . xlt("Request Status") . ":" . "</td>";
61 echo "<td>". generate_display_field(array('data_type'=>'1','list_id'=>'amendment_status'),$resultSet['amendment_status']) . "</td>";
62 echo "</tr>";
64 echo "<tr class=text>";
65 echo "<td class=bold>" . xlt("Request Description") . ":" . "</td>";
66 echo "<td>". text($resultSet['amendment_desc']) . "</td>";
67 echo "</tr>";
69 echo "</table>";
71 echo "<hr>";
72 echo "<span class='bold'>" . xlt("History") . "</span><br>";
73 $pageBreak = ( $lastAmendment ) ? "" : "page-break-after:always";
74 echo "<table border='1' cellspacing=0 cellpadding=3 style='width:75%;margin-top:10px;margin-bottom:20px;" . $pageBreak . "'>";
75 echo "<tr class='text bold'>";
76 echo "<th align=left style='width:10%'>" . xlt("Date") . "</th>";
77 echo "<th align=left style='width:20%'>" . xlt("By") . "</th>";
78 echo "<th align=left >" . xlt("Comments") . "</th>";
79 echo "</tr>";
81 $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 = ?";
82 $resultSet = sqlStatement($query,array($amendmentID));
83 while( $row = sqlFetchArray($resultSet)) {
84 echo "<tr class=text>";
85 $created_date = date('Y-m-d', strtotime($row['created_time']));
86 echo "<td>" . oeFormatShortDate($created_date) . "</td>";
87 echo "<td>" . text($row['lname']) . ", " . text($row['fname']) . "</td>";
88 echo "<td>" . text($row['amendment_note']) . "</td>";
89 echo "</tr>";
91 echo "</table>";
96 <html>
97 <head>
98 <?php html_header_show();?>
100 <!-- supporting javascript code -->
101 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-1/index.js"></script>
102 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/textformat.js"></script>
103 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script>
106 <!-- page styles -->
107 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
109 </head>
111 <body class="body_top">
112 <span class='title'><?php echo xlt("Amendments for") . " " . text($patientName); ?></span>
113 <p></p>
115 <?php
116 for ( $i = 0 ; $i < count($amendmentsList) ; $i++ ) {
117 $lastAmendment = ( $i == count($amendmentsList) - 1 ) ? true : false;
118 printAmendment($amendmentsList[$i],$lastAmendment);
122 <script language='JavaScript'>
123 opener.top.printLogPrint(window);
124 </script>
126 </body>
128 </html>