3 * Encounter form for entering clinical data as a scanned document.
5 * Copyright (C) 2006-2013 Rod Roark <rod@sunsetsystems.com>
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 2
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>.
19 * @author Rod Roark <rod@sunsetsystems.com>
22 // NOTE: HTML escaping still needs to be done for this script.
24 require_once("../../globals.php");
25 require_once("$srcdir/api.inc");
26 require_once("$srcdir/forms.inc");
27 require_once("$srcdir/acl.inc");
31 if (! $encounter) { // comes from globals.php
32 die("Internal error: we do not seem to be in an encounter!");
35 $formid = $_GET['id'];
36 $imagedir = $GLOBALS['OE_SITE_DIR'] . "/documents/$pid/encounters";
38 // If Save was clicked, save the info.
40 if ($_POST['bn_save']) {
41 // If updating an existing form...
44 $query = "UPDATE form_scanned_notes SET notes = ? WHERE id = ?";
45 sqlStatement($query, array($_POST['form_notes'], $formid));
46 } // If adding a new form...
49 $query = "INSERT INTO form_scanned_notes (notes) VALUES (?)";
50 $formid = sqlInsert($query, array($_POST['form_notes']));
51 addForm($encounter, "Scanned Notes", $formid, "scanned_notes", $pid, $userauthorized);
54 $imagepath = "$imagedir/${encounter}_$formid.jpg";
56 // Upload new or replacement document.
57 // Always convert it to jpeg.
58 if ($_FILES['form_image']['size']) {
59 // If the patient's encounter image directory does not yet exist, create it.
60 if (! is_dir($imagedir)) {
61 $tmp0 = exec("mkdir -p '$imagedir'", $tmp1, $tmp2);
63 die("mkdir returned $tmp2: $tmp0");
66 exec("touch '$imagedir/index.html'");
69 // Remove any previous image files for this encounter and form ID.
70 for ($i = -1; true; ++
$i) {
71 $suffix = ($i < 0) ?
"" : "-$i";
72 $path = "$imagedir/${encounter}_$formid$suffix.jpg";
82 $tmp_name = $_FILES['form_image']['tmp_name'];
83 // default density is 72 dpi, we change to 96. And -append was removed
84 // to create a separate image file for each page.
85 $cmd = "convert -density 96 '$tmp_name' '$imagepath'";
86 $tmp0 = exec($cmd, $tmp1, $tmp2);
88 die("\"$cmd\" returned $tmp2: $tmp0");
92 // formHeader("Redirecting....");
98 $imagepath = "$imagedir/${encounter}_$formid.jpg";
99 $imageurl = "$web_root/sites/" . $_SESSION['site_id'] .
100 "/documents/$pid/encounters/${encounter}_$formid.jpg";
104 "SELECT * FROM form_scanned_notes WHERE " .
105 "id = ? AND activity = '1'",
109 "SELECT id FROM forms WHERE " .
110 "form_id = ? AND formdir = 'scanned_notes'",
117 <?php
html_header_show();?
>
118 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
119 <style type
="text/css">
120 .dehead
{ color
:#000000; font-family:sans-serif; font-size:10pt; font-weight:bold }
121 .detail
{ color
:#000000; font-family:sans-serif; font-size:10pt; font-weight:normal }
123 <script type
="text/javascript" src
="../../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
125 <script language
='JavaScript'>
128 dlgopen('../../main/calendar/add_edit_event.php?patientid=<?php echo $pid ?>',
133 // Process click on Delete button.
134 function deleteme() {
135 dlgopen('../../patient_file/deleter.php?formid=<?php echo $formrow['id
'] ?>', '_blank', 500, 450);
139 // Called by the deleteme.php window on a successful delete.
140 function imdeleted() {
141 top
.restoreSession();
142 location
= '<?php echo $GLOBALS['form_exit_url
']; ?>';
149 <body
class="body_top">
151 <form method
="post" enctype
="multipart/form-data"
152 action
="<?php echo $rootdir ?>/forms/scanned_notes/new.php?id=<?php echo $formid ?>"
153 onsubmit
="return top.restoreSession()">
158 <table border
='1' width
='95%'>
160 <tr bgcolor
='#dddddd' class='dehead'>
161 <td colspan
='2' align
='center'>Scanned Encounter Notes
</td
>
165 <td width
='5%' class='dehead' nowrap
> 
;Comments
 
;</td
>
166 <td width
='95%' class='detail' nowrap
>
167 <textarea name
='form_notes' rows
='4' style
='width:100%'><?php
echo $row['notes'] ?
></textarea
>
172 <td
class='dehead' nowrap
> 
;Document
 
;</td
>
173 <td
class='detail' nowrap
>
175 if ($formid && is_file($imagepath)) {
176 echo " <img src='$imageurl' />\n";
180 <?php
xl('Upload this file:', 'e') ?
>
181 <input type
="hidden" name
="MAX_FILE_SIZE" value
="12000000" />
182 <input name
="form_image" type
="file" />
190 <input type
='submit' name
='bn_save' value
='Save' />
192 <input type
='button' value
='Add Appointment' onclick
='newEvt()' />
194 <input type
='button' value
='Back' onclick
="top.restoreSession();location='<?php echo $GLOBALS['form_exit_url']; ?>'" />
195 <?php
if ($formrow['id'] && acl_check('admin', 'super')) { ?
>
197 <input type
='button' value
='Delete' onclick
='deleteme()' style
='color:red' />