2 //////////////////////////////////////////////////////////////////////
3 // ------------------ DO NOT MODIFY VIEW.PHP !!! ---------------------
4 // View.php is an exact duplicate of new.php. If you wish to make
5 // any changes, then change new.php and either (recommended) make
6 // view.php a symbolic link to new.php, or copy new.php to view.php.
8 // And if you check in a change to either module, be sure to check
9 // in the other (identical) module also.
11 // This nonsense will go away if we ever move to subversion.
12 //////////////////////////////////////////////////////////////////////
14 // Copyright (C) 2006-2010 Rod Roark <rod@sunsetsystems.com>
16 // This program is free software; you can redistribute it and/or
17 // modify it under the terms of the GNU General Public License
18 // as published by the Free Software Foundation; either version 2
19 // of the License, or (at your option) any later version.
21 include_once("../../globals.php");
22 include_once("$srcdir/api.inc");
23 include_once("$srcdir/forms.inc");
24 include_once("$srcdir/acl.inc");
28 if (! $encounter) { // comes from globals.php
29 die("Internal error: we do not seem to be in an encounter!");
32 $formid = $_GET['id'];
33 $imagedir = $GLOBALS['OE_SITE_DIR'] . "/documents/$pid/encounters";
35 // If Save was clicked, save the info.
37 if ($_POST['bn_save']) {
39 // If updating an existing form...
42 $query = "UPDATE form_scanned_notes SET " .
43 "notes = '" . $_POST['form_notes'] . "' " .
44 "WHERE id = '$formid'";
48 // If adding a new form...
51 $query = "INSERT INTO form_scanned_notes ( " .
54 "'" . $_POST['form_notes'] . "' " .
56 $formid = sqlInsert($query);
57 addForm($encounter, "Scanned Notes", $formid, "scanned_notes", $pid, $userauthorized);
60 $imagepath = "$imagedir/${encounter}_$formid.jpg";
62 // Upload new or replacement document.
63 // Always convert it to jpeg.
64 if ($_FILES['form_image']['size']) {
65 // If the patient's encounter image directory does not yet exist, create it.
66 if (! is_dir($imagedir)) {
67 $tmp0 = exec("mkdir -p '$imagedir'", $tmp1, $tmp2);
68 if ($tmp2) die("mkdir returned $tmp2: $tmp0");
69 exec("touch '$imagedir/index.html'");
71 // Remove any previous image files for this encounter and form ID.
72 for ($i = -1; true; ++
$i) {
73 $suffix = ($i < 0) ?
"" : "-$i";
74 $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);
87 if ($tmp2) die("\"$cmd\" returned $tmp2: $tmp0");
90 // formHeader("Redirecting....");
96 $imagepath = "$imagedir/${encounter}_$formid.jpg";
97 $imageurl = "$web_root/sites/" . $_SESSION['site_id'] .
98 "/documents/$pid/encounters/${encounter}_$formid.jpg";
101 $row = sqlQuery("SELECT * FROM form_scanned_notes WHERE " .
102 "id = '$formid' AND activity = '1'");
103 $formrow = sqlQuery("SELECT id FROM forms WHERE " .
104 "form_id = '$formid' AND formdir = 'scanned_notes'");
109 <?php
html_header_show();?
>
110 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
111 <style type
="text/css">
112 .dehead
{ color
:#000000; font-family:sans-serif; font-size:10pt; font-weight:bold }
113 .detail
{ color
:#000000; font-family:sans-serif; font-size:10pt; font-weight:normal }
115 <script type
="text/javascript" src
="../../../library/dialog.js"></script
>
117 <script language
='JavaScript'>
120 dlgopen('../../main/calendar/add_edit_event.php?patientid=<?php echo $pid ?>',
125 // Process click on Delete button.
126 function deleteme() {
127 dlgopen('../../patient_file/deleter.php?formid=<?php echo $formrow['id
'] ?>', '_blank', 500, 450);
131 // Called by the deleteme.php window on a successful delete.
132 function imdeleted() {
133 top
.restoreSession();
134 location
= '<?php echo $GLOBALS['form_exit_url
']; ?>';
141 <body
class="body_top">
143 <form method
="post" enctype
="multipart/form-data"
144 action
="<?php echo $rootdir ?>/forms/scanned_notes/new.php?id=<?php echo $formid ?>"
145 onsubmit
="return top.restoreSession()">
150 <table border
='1' width
='95%'>
152 <tr bgcolor
='#dddddd' class='dehead'>
153 <td colspan
='2' align
='center'>Scanned Encounter Notes
</td
>
157 <td width
='5%' class='dehead' nowrap
> 
;Comments
 
;</td
>
158 <td width
='95%' class='detail' nowrap
>
159 <textarea name
='form_notes' rows
='4' style
='width:100%'><?php
echo $row['notes'] ?
></textarea
>
164 <td
class='dehead' nowrap
> 
;Document
 
;</td
>
165 <td
class='detail' nowrap
>
167 if ($formid && is_file($imagepath)) {
168 echo " <img src='$imageurl' />\n";
172 <?php
xl('Upload this file:','e') ?
>
173 <input type
="hidden" name
="MAX_FILE_SIZE" value
="12000000" />
174 <input name
="form_image" type
="file" />
182 <input type
='submit' name
='bn_save' value
='Save' />
184 <input type
='button' value
='Add Appointment' onclick
='newEvt()' />
186 <input type
='button' value
='Back' onclick
="top.restoreSession();location='<?php echo $GLOBALS['form_exit_url']; ?>'" />
187 <?php
if ($formrow['id'] && acl_check('admin', 'super')) { ?
>
189 <input type
='button' value
='Delete' onclick
='deleteme()' style
='color:red' />