The Third Reminders email bug fix - contributed by arnabnaha
[openemr.git] / interface / patient_file / summary / pnotes.php
blobe8e34d229ab76dba2e5e611863875ca0af51a9b1
1 <?php
3 //SANITIZE ALL ESCAPES
4 $sanitize_all_escapes=true;
5 //
7 //STOP FAKE REGISTER GLOBALS
8 $fake_register_globals=false;
9 //
11 require_once("../../globals.php");
12 require_once("$srcdir/pnotes.inc");
13 require_once("$srcdir/acl.inc");
14 require_once("$srcdir/patient.inc");
15 require_once("$srcdir/options.inc.php");
16 require_once("$srcdir/classes/Document.class.php");
18 // form parameter docid can be passed to restrict the display to a document.
19 $docid = empty($_REQUEST['docid']) ? 0 : 0 + $_REQUEST['docid'];
21 <html>
22 <head>
23 <?php html_header_show();?>
25 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script>
26 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
28 </head>
29 <body class="body_bottom">
31 <?php
32 $thisauth = acl_check('patients', 'notes');
33 if ($thisauth) {
34 $tmp = getPatientData($pid, "squad");
35 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad']))
36 $thisauth = 0;
38 if (!$thisauth) {
39 echo "<p>(" . htmlspecialchars( xl('Notes not authorized'), ENT_NOQUOTES) . ")</p>\n";
40 echo "</body>\n</html>\n";
41 exit();
45 <div id='pnotes'>
47 <?php if ( acl_check('patients', 'notes','',array('write','addonly') )): ?>
49 <?php if ($GLOBALS['concurrent_layout']) { ?>
50 <a href="pnotes_full.php?docid=<?php echo htmlspecialchars( $docid, ENT_QUOTES); ?>" onclick="top.restoreSession()">
51 <?php } else { ?>
52 <a href="pnotes_full.php?docid=<?php echo htmlspecialchars( $docid, ENT_QUOTES); ?>" target="Main" onclick="top.restoreSession()">
53 <?php } ?>
55 <span class="title"><?php echo htmlspecialchars( xl('Notes'), ENT_NOQUOTES); ?>
56 <?php
57 if ($docid) {
58 echo " " . htmlspecialchars( xl("linked to document"), ENT_NOQUOTES) . " ";
59 $d = new Document($docid);
60 echo $d->get_url_file();
63 </span>
64 <span class=more><?php echo htmlspecialchars( $tmore, ENT_NOQUOTES);?></span>
65 </a>
66 <?php endif; ?>
68 <br>
70 <table>
72 <?php
73 //display all of the notes for the day, as well as others that are active from previous dates, up to a certain number, $N
74 $N = 15;
76 // Get the billing note if there is one.
77 $billing_note = "";
78 $colorbeg = "";
79 $colorend = "";
80 $sql = "select genericname2, genericval2 " .
81 "from patient_data where pid = ? limit 1";
82 $resnote = sqlQuery($sql, array($pid) );
83 if($resnote && $resnote['genericname2'] == 'Billing') {
84 $billing_note = $resnote['genericval2'];
85 $colorbeg = "<span style='color:red'>";
86 $colorend = "</span>";
89 //Display what the patient owes
90 $balance = get_patient_balance($pid);
91 if ($balance != "0") {
92 $formatted = sprintf((xl('$').'%01.2f'), $balance);
93 echo " <tr class='text billing'>\n";
94 echo " <td>" . $colorbeg . htmlspecialchars( xl('Balance Due'), ENT_NOQUOTES) .
95 $colorend . "</td><td>" . $colorbeg .
96 htmlspecialchars( $formatted, ENT_NOQUOTES) . $colorend."</td>\n";
97 echo " </tr>\n";
100 if ($billing_note) {
101 echo " <tr class='text billing'>\n";
102 echo " <td>" . $colorbeg . htmlspecialchars( xl('Billing Note'), ENT_NOQUOTES) .
103 $colorend . "</td><td>" . $colorbeg .
104 htmlspecialchars( $billing_note, ENT_NOQUOTES) . $colorend . "</td>\n";
105 echo " </tr>\n";
108 //retrieve all active notes
109 $result = getPnotesByDate("", 1, "id,date,body,user,title,assigned_to",
110 $pid, "all", 0, '', $docid);
112 if ($result != null) {
113 $notes_count = 0;//number of notes so far displayed
114 foreach ($result as $iter) {
116 if ($notes_count >= $N) {
117 //we have more active notes to print, but we've reached our display maximum
118 echo " <tr>\n";
119 echo " <td colspan='3' align='center'>\n";
120 echo " <a ";
121 if (!$GLOBALS['concurrent_layout']) echo "target='Main' ";
122 echo "href='pnotes_full.php?active=1&docid=" .
123 htmlspecialchars( $docid, ENT_QUOTES) .
124 "' class='alert' onclick='top.restoreSession()'>";
125 echo htmlspecialchars( xl('Some notes were not displayed.','','',' '), ENT_NOQUOTES) .
126 htmlspecialchars( xl('Click here to view all.'), ENT_NOQUOTES) . "</a>\n";
127 echo " </td>\n";
128 echo " </tr>\n";
129 break;
132 $body = $iter['body'];
133 if (preg_match('/^\d\d\d\d-\d\d-\d\d \d\d\:\d\d /', $body)) {
134 $body = nl2br(htmlspecialchars( $body, ENT_NOQUOTES));
135 } else {
136 $body = htmlspecialchars( date('Y-m-d H:i', strtotime($iter['date'])), ENT_NOQUOTES) .
137 ' (' . htmlspecialchars( $iter['user'], ENT_NOQUOTES) . ') ' . nl2br(htmlspecialchars( $body, ENT_NOQUOTES));
140 echo " <tr class='text noterow' id='".htmlspecialchars( $iter['id'], ENT_QUOTES)."'>\n";
142 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
143 echo " <td valign='top' class='bold'>";
144 echo generate_display_field(array('data_type'=>'1','list_id'=>'note_type'), $iter['title']);
145 echo "</td>\n";
147 echo " <td valign='top'>$body</td>\n";
148 echo " </tr>\n";
150 $notes_count++;
155 </table>
157 </div> <!-- end pnotes -->
159 </body>
161 <script language="javascript">
162 // jQuery stuff to make the page a little easier to use
164 $(document).ready(function(){
165 $(".noterow").mouseover(function() { $(this).toggleClass("highlight"); });
166 $(".noterow").mouseout(function() { $(this).toggleClass("highlight"); });
167 $(".noterow").click(function() { EditNote(this); });
170 var EditNote = function(note) {
171 <?php if ( acl_check('patients', 'notes','',array('write','addonly') )): ?>
172 top.restoreSession();
173 <?php if (!$GLOBALS['concurrent_layout']): ?>
174 top.Main.location.href = "pnotes_full.php?docid=<?php echo $docid; ?>&noteid=" + note.id + "&active=1";
175 <?php else: ?>
176 location.href = "pnotes_full.php?docid=<?php echo $docid; ?>&noteid=" + note.id + "&active=1";
177 <?php endif; ?>
178 <?php else: ?>
179 // no-op
180 alert("<?php echo htmlspecialchars( xl('You do not have access to view/edit this note'), ENT_QUOTES); ?>");
181 <?php endif; ?>
184 </script>
186 </html>