bug fix march continued (#1921)
[openemr.git] / contrib / forms / clinical_notes / new.php
blob79929d3cb5dcab722a3ca62ed88735ceab2fb043
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) 2005 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 require_once("../../globals.php");
22 require_once("$srcdir/api.inc");
23 require_once("$srcdir/forms.inc");
25 $row = array();
27 if (! $encounter) { // comes from globals.php
28 die("Internal error: we do not seem to be in an encounter!");
31 function rbvalue($rbname)
33 $tmp = $_POST[$rbname];
34 if (! $tmp) {
35 $tmp = '0';
38 return "$tmp";
41 function cbvalue($cbname)
43 return $_POST[$cbname] ? '1' : '0';
46 function rbinput($name, $value, $desc, $colname)
48 global $row;
49 $ret = "<input type='radio' name='" . attr($name) . "' value='" . attr($value) . "'";
50 if ($row[$colname] == $value) {
51 $ret .= " checked";
54 $ret .= " />" . text($desc);
55 return $ret;
58 function rbcell($name, $value, $desc, $colname)
60 return "<td width='25%' nowrap>" . rbinput($name, $value, $desc, $colname) . "</td>\n";
63 function cbinput($name, $colname)
65 global $row;
66 $ret = "<input type='checkbox' name='" . attr($name) . "' value='1'";
67 if ($row[$colname]) {
68 $ret .= " checked";
71 $ret .= " />";
72 return $ret;
75 function cbcell($name, $desc, $colname)
77 return "<td width='25%' nowrap>" . cbinput($name, $colname) . "$desc</td>\n";
80 $formid = $_GET['id'];
82 // If Save was clicked, save the info.
84 if ($_POST['bn_save']) {
85 $fu_timing = $_POST['fu_timing'];
86 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
87 csrfNotVerified();
90 // If updating an existing form...
92 if ($formid) {
93 $query = "UPDATE form_clinical_notes SET
94 history = ?,
95 examination = ?,
96 plan = ?,
97 followup_required = ?,
98 followup_timing = ?,
99 // outcome = ? rbvalue('outcome')
100 // destination = ? rbvalue('destination')
101 WHERE id = ?";
103 sqlStatement($query, array($_POST['form_history'], $_POST['form_examination'], $_POST['form_plan'], rbvalue('fu_required'), $fu_timing, $formid));
104 } // If adding a new form...
106 else {
107 $query = "INSERT INTO form_clinical_notes ( " .
108 "history, examination, plan, followup_required, followup_timing
109 ) VALUES ( ?, ?, ?, ?, ? )";
111 $newid = sqlInsert($query, array($_POST['form_history'], $_POST['form_examination'], $_POST['form_plan'], rbvalue('fu_required'), $fu_timing));
112 addForm($encounter, "Clinical Notes", $newid, "clinical_notes", $pid, $userauthorized);
115 formHeader("Redirecting....");
116 formJump();
117 formFooter();
118 exit;
121 if ($formid) {
122 $row = sqlQuery("SELECT * FROM form_clinical_notes WHERE " .
123 "id = ? AND activity = '1'", array($formid));
126 <html>
127 <head>
128 <?php html_header_show();?>
129 <link rel=stylesheet href="<?php echo $css_header;?>" type="text/css">
130 <script language="JavaScript">
131 </script>
132 </head>
134 <body <?php echo $top_bg_line;?> topmargin="0" rightmargin="0" leftmargin="2"
135 bottommargin="0" marginwidth="2" marginheight="0">
136 <form method="post" action="<?php echo $rootdir ?>/forms/clinical_notes/new.php?id=<?php echo attr($formid) ?>"
137 onsubmit="return top.restoreSession()">
138 <input type="hidden" name="csrf_token_form" value="<?php echo attr(collectCsrfToken()); ?>" />
140 <center>
143 <table border='1' width='95%'>
145 <tr bgcolor='#dddddd'>
146 <td colspan='2' align='center'><b>This Encounter</b></td>
147 </tr>
149 <tr>
150 <td width='5%' nowrap> History </td>
151 <td width='95%' nowrap>
152 <textarea name='form_history' rows='7' style='width:100%'><?php echo text($row['history']) ?></textarea>
153 </td>
154 </tr>
156 <tr>
157 <td nowrap> Examination </td>
158 <td nowrap>
159 <textarea name='form_examination' rows='7' style='width:100%'><?php echo text($row['examination']) ?></textarea>
160 </td>
161 </tr>
163 <tr>
164 <td nowrap> Plan </td>
165 <td nowrap>
166 <textarea name='form_plan' rows='7' style='width:100%'><?php echo text($row['plan']) ?></textarea>
167 </td>
168 </tr>
170 <tr>
171 <td nowrap>Follow Up</td>
172 <td nowrap>
173 <table width='100%'>
174 <tr>
175 <td width='5%' nowrap>
176 <?php echo rbinput('fu_required', '1', 'Required in:', 'followup_required') ?>
177 </td>
178 <td nowrap>
179 <input type='text' name='fu_timing' size='10' style='width:100%'
180 title='When to follow up'
181 value='<?php echo attr($row['followup_timing']) ?>' />
182 </td>
183 </tr>
184 <tr>
185 <td colspan='2' nowrap>
186 <?php echo rbinput('fu_required', '2', 'Pending investigation', 'followup_required') ?>
187 </td>
188 </tr>
189 <tr>
190 <td colspan='2' nowrap>
191 <?php echo rbinput('fu_required', '0', 'None required', 'followup_required') ?>
192 </td>
193 </tr>
194 </table>
195 </td>
196 </tr>
198 <!--
200 <tr bgcolor='#dddddd'>
201 <td colspan='2' align='center'><b>Final Discharge</b></td>
202 </tr>
204 <tr>
205 <td nowrap>Outcome</td>
206 <td nowrap>
207 <table width='100%'>
208 <tr>
209 <?php // echo rbcell('outcome', '1', 'Resolved' , 'outcome') ?>
210 <?php // echo rbcell('outcome', '2', 'Improved' , 'outcome') ?>
211 <?php // echo rbcell('outcome', '3', 'Status Quo', 'outcome') ?>
212 <?php // echo rbcell('outcome', '4', 'Worse' , 'outcome') ?>
213 </tr>
214 </table>
215 </td>
216 </tr>
218 <tr>
219 <td nowrap>Destination</td>
220 <td nowrap>
221 <table width='100%'>
222 <tr>
223 <?php // echo rbcell('destination', '1', 'GP' , 'destination') ?>
224 <?php // echo rbcell('destination', '2', 'Hospital Specialist', 'destination') ?>
225 <td width='25%'>&nbsp;</td>
226 <td width='25%'>&nbsp;</td>
227 </tr>
228 </table>
229 </td>
230 </tr>
234 </table>
237 <input type='submit' name='bn_save' value='Save' />
238 &nbsp;
239 <input type='button' value='Cancel' onclick="parent.closeTab(window.name, false)" />
240 </p>
242 </center>
244 </form>
245 </body>
246 </html>