migrate old clinical notes form to clinic note (#4516)
[openemr.git] / contrib / forms / clinic_note / view.php
blob2467b3b6d661e04a94cd3cd2506d1ece8dea73bb
1 <?php
3 /**
4 * clinic_note view.php
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @author Daniel Ehrlich <daniel.ehrlich1@gmail.com>
11 * @copyright Copyright (c) 2005 Rod Roark <rod@sunsetsystems.com>
12 * @copyright Copyright (c) 2018-2021 Brady Miller <brady.g.miller@gmail.com>
13 * @copyright Copyright (c) 2018 Daniel Ehrlich <daniel.ehrlich1@gmail.com>
14 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
17 require_once("../../globals.php");
18 require_once("$srcdir/api.inc");
19 require_once("$srcdir/forms.inc");
21 use OpenEMR\Common\Csrf\CsrfUtils;
22 use OpenEMR\Core\Header;
24 $row = array();
26 if (! $encounter) { // comes from globals.php
27 die("Internal error: we do not seem to be in an encounter!");
30 function rbvalue($rbname)
32 $tmp = $_POST[$rbname];
33 if (! $tmp) {
34 $tmp = '0';
37 return "$tmp";
40 function cbvalue($cbname)
42 return $_POST[$cbname] ? '1' : '0';
45 function rbinput($name, $value, $desc, $colname)
47 global $row;
48 $ret = "<input type='radio' name='" . attr($name) . "' value='" . attr($value) . "'";
49 if ($row[$colname] == $value) {
50 $ret .= " checked";
53 $ret .= " />" . text($desc);
54 return $ret;
57 function rbcell($name, $value, $desc, $colname)
59 return "<td width='25%' nowrap>" . rbinput($name, $value, $desc, $colname) . "</td>\n";
62 function cbinput($name, $colname)
64 global $row;
65 $ret = "<input type='checkbox' name='" . attr($name) . "' value='1'";
66 if ($row[$colname]) {
67 $ret .= " checked";
70 $ret .= " />";
71 return $ret;
74 function cbcell($name, $desc, $colname)
76 return "<td width='25%' nowrap>" . cbinput($name, $colname) . text($desc) . "</td>\n";
79 $formid = $_GET['id'];
81 // If Save was clicked, save the info.
83 if (!empty($_POST['bn_save'])) {
84 $fu_timing = $_POST['fu_timing'];
85 if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) {
86 CsrfUtils::csrfNotVerified();
89 // If updating an existing form...
91 if ($formid) {
92 $query = "UPDATE form_clinic_note SET
93 history = ?,
94 examination = ?,
95 plan = ?,
96 followup_required = ?,
97 followup_timing = ?
98 WHERE id = ?";
100 sqlStatement($query, array($_POST['form_history'], $_POST['form_examination'], $_POST['form_plan'], rbvalue('fu_required'), $fu_timing, $formid));
101 } else { // If adding a new form...
102 $query = "INSERT INTO form_clinic_note ( " .
103 "history, examination, plan, followup_required, followup_timing
104 ) VALUES ( ?, ?, ?, ?, ? )";
106 $newid = sqlInsert($query, array($_POST['form_history'], $_POST['form_examination'], $_POST['form_plan'], rbvalue('fu_required'), $fu_timing));
107 addForm($encounter, "Clinic Note", $newid, "clinic_note", $pid, $userauthorized);
110 formHeader("Redirecting....");
111 formJump();
112 formFooter();
113 exit;
116 if ($formid) {
117 $row = sqlQuery("SELECT * FROM form_clinic_note WHERE " .
118 "id = ? AND activity = '1'", array($formid)) ;
121 <html>
122 <head>
123 <?php Header::setupHeader(); ?>
124 </head>
126 <body <?php echo $top_bg_line;?> topmargin="0" rightmargin="0" leftmargin="2"
127 bottommargin="0" marginwidth="2" marginheight="0">
128 <form method="post" action="<?php echo $rootdir ?>/forms/clinic_note/new.php?id=<?php echo attr_url($formid); ?>"
129 onsubmit="return top.restoreSession()">
130 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
132 <center>
135 <table border='1' width='95%'>
137 <tr bgcolor='#dddddd'>
138 <td colspan='2' align='center'><b><?php echo xlt("This Encounter"); ?></b></td>
139 </tr>
141 <tr>
142 <td width='5%' nowrap> <?php echo xlt("History"); ?> </td>
143 <td width='95%' nowrap>
144 <textarea name='form_history' rows='7' style='width:100%'><?php echo text($row['history']) ?></textarea>
145 </td>
146 </tr>
148 <tr>
149 <td nowrap> <?php echo xlt("Examination"); ?> </td>
150 <td nowrap>
151 <textarea name='form_examination' rows='7' style='width:100%'><?php echo text($row['examination']) ?></textarea>
152 </td>
153 </tr>
155 <tr>
156 <td nowrap> <?php echo xlt("Plan"); ?> </td>
157 <td nowrap>
158 <textarea name='form_plan' rows='7' style='width:100%'><?php echo text($row['plan']) ?></textarea>
159 </td>
160 </tr>
162 <tr>
163 <td nowrap><?php echo xlt("Follow Up"); ?></td>
164 <td nowrap>
165 <table width='100%'>
166 <tr>
167 <td width='5%' nowrap>
168 <?php echo rbinput('fu_required', '1', xl('Required in') . ':', 'followup_required') ?>
169 </td>
170 <td nowrap>
171 <input type='text' name='fu_timing' size='10' style='width:100%'
172 title='<?php echo xla("When to follow up"); ?>'
173 value='<?php echo attr($row['followup_timing']) ?>' />
174 </td>
175 </tr>
176 <tr>
177 <td colspan='2' nowrap>
178 <?php echo rbinput('fu_required', '2', xl('Pending investigation'), 'followup_required') ?>
179 </td>
180 </tr>
181 <tr>
182 <td colspan='2' nowrap>
183 <?php echo rbinput('fu_required', '0', xl('None required'), 'followup_required') ?>
184 </td>
185 </tr>
186 </table>
187 </td>
188 </tr>
190 </table>
193 <input type='submit' name='bn_save' value='<?php echo xla("Save"); ?>' />
194 &nbsp;
195 <input type='button' value='<?php echo xla("Cancel"); ?>' onclick="parent.closeTab(window.name, false)" />
196 </p>
198 </center>
200 </form>
201 </body>
202 </html>