added some fields
[openemr.git] / contrib / forms / scanned_notes / new.php
blobb70fbe3509758139b4a5d97e5b3673cb57dcbd18
1 <?php
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.
7 //
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 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");
26 $row = array();
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 = "$webserver_root/documents/$pid/encounters";
35 // If Save was clicked, save the info.
37 if ($_POST['bn_save']) {
39 // If updating an existing form...
41 if ($formid) {
42 $query = "UPDATE form_scanned_notes SET " .
43 "notes = '" . $_POST['form_notes'] . "' " .
44 "WHERE id = '$formid'";
45 sqlStatement($query);
48 // If adding a new form...
50 else {
51 $query = "INSERT INTO form_scanned_notes ( " .
52 "notes " .
53 ") VALUES ( " .
54 "'" . $_POST['form_notes'] . "' " .
55 ")";
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 $tmp_name = $_FILES['form_image']['tmp_name'];
72 // $cmd = "convert '$tmp_name' '$imagepath'"; // default density is 72 dpi
73 $cmd = "convert -density 96 '$tmp_name' '$imagepath'";
74 $tmp0 = exec($cmd, $tmp1, $tmp2);
75 if ($tmp2) die("\"$cmd\" returned $tmp2: $tmp0");
78 // formHeader("Redirecting....");
79 // formJump();
80 // formFooter();
81 // exit;
84 $imagepath = "$imagedir/${encounter}_$formid.jpg";
85 $imageurl = "$web_root/documents/$pid/encounters/${encounter}_$formid.jpg";
87 if ($formid) {
88 $row = sqlQuery("SELECT * FROM form_scanned_notes WHERE " .
89 "id = '$formid' AND activity = '1'");
90 $formrow = sqlQuery("SELECT id FROM forms WHERE " .
91 "form_id = '$formid' AND formdir = 'scanned_notes'");
94 <html>
95 <head>
96 <link rel=stylesheet href="<?echo $css_header;?>" type="text/css">
97 <style type="text/css">
98 body { font-family:sans-serif; font-size:10pt; font-weight:normal }
99 .dehead { color:#000000; font-family:sans-serif; font-size:10pt; font-weight:bold }
100 .detail { color:#000000; font-family:sans-serif; font-size:10pt; font-weight:normal }
101 </style>
102 <script type="text/javascript" src="../../../library/dialog.js"></script>
104 <script language='JavaScript'>
106 function newEvt() {
107 dlgopen('../../main/calendar/add_edit_event.php?patientid=<? echo $pid ?>',
108 '_blank', 550, 270);
109 return false;
112 // Process click on Delete button.
113 function deleteme() {
114 dlgopen('../../patient_file/deleter.php?formid=<?php echo $formrow['id'] ?>', '_blank', 500, 450);
115 return false;
118 // Called by the deleteme.php window on a successful delete.
119 function imdeleted() {
120 location = '<?php echo "$rootdir/patient_file/encounter/patient_encounter.php" ?>';
123 </script>
125 </head>
127 <body <?echo $top_bg_line;?> topmargin="0" rightmargin="0" leftmargin="2"
128 bottommargin="0" marginwidth="2" marginheight="0">
130 <form method="post" enctype="multipart/form-data"
131 action="<? echo $rootdir ?>/forms/scanned_notes/new.php?id=<? echo $formid ?>">
133 <center>
136 <table border='1' width='95%'>
138 <tr bgcolor='#dddddd' class='dehead'>
139 <td colspan='2' align='center'>Scanned Encounter Notes</td>
140 </tr>
142 <tr>
143 <td width='5%' class='dehead' nowrap>&nbsp;Comments&nbsp;</td>
144 <td width='95%' class='detail' nowrap>
145 <textarea name='form_notes' rows='4' style='width:100%'><? echo $row['notes'] ?></textarea>
146 </td>
147 </tr>
149 <tr>
150 <td class='dehead' nowrap>&nbsp;Document&nbsp;</td>
151 <td class='detail' nowrap>
152 <?php
153 if ($formid && is_file($imagepath)) {
154 echo " <img src='$imageurl' />\n";
157 <p>&nbsp;
158 <?php xl('Upload this file:','e') ?>
159 <input type="hidden" name="MAX_FILE_SIZE" value="12000000" />
160 <input name="form_image" type="file" />
161 <br />&nbsp;</p>
162 </td>
163 </tr>
165 </table>
168 <input type='submit' name='bn_save' value='Save' />
169 &nbsp;
170 <input type='button' value='Add Appointment' onclick='newEvt()' />
171 &nbsp;
172 <input type='button' value='Back' onclick="location='<? echo "$rootdir/patient_file/encounter/patient_encounter.php" ?>'" />
173 <?php if ($formrow['id'] && acl_check('admin', 'super')) { ?>
174 &nbsp;
175 <input type='button' value='Delete' onclick='deleteme()' style='color:red' />
176 <?php } ?>
177 </p>
179 </center>
181 </form>
182 </body>
183 </html>