revert composer from PR #5046 (#5058)
[openemr.git] / interface / patient_file / ccr_review_approve.php
blob044110c33a75892a9002c0e488a15a186a96a387
1 <?php
3 /**
4 * interface/patient_file/ccr_review_approve.php Approval screen for uploaded CCR XML.
6 * Approval screen for uploaded CCR XML.
8 * @package OpenEMR
9 * @link http://www.open-emr.org
10 * @author Eldho Chacko <eldho@zhservices.com>
11 * @author Ajil P M <ajilpm@zhservices.com>
12 * @copyright Copyright (c) 2013 Z&H Consultancy Services Private Limited <sam@zhservices.com>
13 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
16 require_once(dirname(__FILE__) . "/../globals.php");
17 require_once(dirname(__FILE__) . "/../../library/parse_patient_xml.php");
19 use OpenEMR\Common\Csrf\CsrfUtils;
20 use OpenEMR\Core\Header;
22 $patient_data = array(
23 'sex' => 'Sex',
24 'pubpid' => 'External ID',
25 'street' => 'Street',
26 'city' => 'City',
27 'state' => 'State',
28 'postal_code' => 'Postal Code',
31 if ($_POST["setval"] == 'approve') {
32 if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) {
33 CsrfUtils::csrfNotVerified();
36 insertApprovedData($_REQUEST);
37 $query = "UPDATE audit_master SET approval_status = '2' WHERE id=?";
38 sqlQuery($query, array($_REQUEST['amid']));
40 <html>
41 <head>
42 <title><?php echo xlt('CCR Review and Approve');?></title>
43 <?php Header::setupHeader(); ?>
44 </head>
45 <body class="body_top" >
46 <center><?php echo xlt('Approved Successfully'); ?></center>
47 </body>
48 </html>
49 <?php
50 exit;
51 } elseif ($_POST["setval"] == 'discard') {
52 if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) {
53 CsrfUtils::csrfNotVerified();
56 $query = "UPDATE audit_master SET approval_status = '3' WHERE id=?";
57 sqlQuery($query, array($_REQUEST['amid']));
59 <html>
60 <head>
61 <title><?php echo xlt('CCR Review and Approve');?></title>
62 <?php Header::setupHeader(); ?>
63 </head>
64 <body class="body_top" >
65 <center><?php echo xlt('Discarded'); ?></center>
66 </body>
67 </html>
68 <?php
69 exit;
72 if (!CsrfUtils::verifyCsrfToken($_GET["csrf_token_form"])) {
73 CsrfUtils::csrfNotVerified();
77 <html>
78 <head>
79 <title><?php echo xlt('CCR Review and Approve');?></title>
80 <?php Header::setupHeader(); ?>
81 <style>
83 table {
84 color: #000;
85 font: .85em/1.6em "Trebuchet MS",Verdana,sans-serif;
86 border-collapse: collapse;
87 margin: 0 auto;
88 border: 1px solid #CCC;
91 tbody th,td {
92 border-left: 0;
93 padding: 8px;
96 tbody {
97 background: #D4D4D4;
100 table table tbody tr {
101 background: #EEEEEE;
104 .alternate{
105 background-color: #C4C4C4;
108 </style>
109 <script>
111 function submit_form(val){
112 document.getElementById('setval').value = val;
113 top.restoreSession();
114 document.forms['approveform'].submit();
117 </script>
118 </head>
119 <body class="body_top" >
120 <center>
121 <p><b><?php echo xlt('CCR Patient Review');?></b></p>
122 </center>
123 <form method="post" name="approveform" "onsubmit='return top.restoreSession()'" >
124 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
125 <table border="0" width="90%;" >
126 <tr>
127 <td>
128 <u><?php echo xlt('Demographics'); ?></u>
129 </td>
130 </tr>
131 <tr>
132 <td>
133 <table border="0" width="95%" >
134 <tr>
135 <?php
136 $query_pd = sqlStatement("SELECT ad.id as adid, table_name, field_name, field_value FROM audit_master am JOIN audit_details ad ON ad.audit_master_id = am.id
137 WHERE am.id = ? AND ad.table_name = 'patient_data' ORDER BY ad.id", array($_REQUEST['amid']));
138 $i = 0;
139 while ($res_pd = sqlFetchArray($query_pd)) {
140 if ($res_pd['field_name'] != 'lname' && $res_pd['field_name'] != 'fname' && $res_pd['field_name'] != 'DOB') {
141 $i++;
142 $query_oldpd = sqlQuery("SELECT " . escape_sql_column_name($res_pd['field_name'], array("patient_data")) . " AS val FROM patient_data WHERE pid = ?", array($_REQUEST['pid']));
143 if ($res_pd['field_name'] == 'sex') {
144 echo "<td>" . ($patient_data[$res_pd['field_name']] ? text($patient_data[$res_pd['field_name']]) : text($res_pd['field_name'])) . "</td>" .
145 "<td><select name='" . attr($res_pd['table_name']) . "-" . attr($res_pd['field_name']) . "' style='width:150px;' >" .
146 "<option value='Male' " . ($res_pd['field_value'] == 'Male' ? 'selected' : '' ) . " >" . xlt('Male') . "</option>" .
147 "<option value='Female' " . ($res_pd['field_value'] == 'Female' ? 'selected' : '' ) . " >" . xlt('Female') . "</option></select>" .
148 "<span style='color:red;padding-left:25px;' >" . text($query_oldpd['val']) . "</span></td>" .
149 "<td><select name='" . attr($res_pd['table_name']) . "-" . attr($res_pd['field_name']) . "-sel'>" .
150 "<option value='ignore' >" . xlt('Ignore') . "</option> " .
151 "<option value='update' >" . xlt('Update') . "</option></select></td>";
152 } else {
153 echo "<td>" . ($patient_data[$res_pd['field_name']] ? text($patient_data[$res_pd['field_name']]) : text($res_pd['field_name'])) . "</td>" .
154 "<td><input type='text' name='" . attr($res_pd['table_name']) . "-" . attr($res_pd['field_name']) . "' value='" . attr($res_pd['field_value']) . "' >" .
155 "<span style='color:red;padding-left:25px;' >" . text($query_oldpd['val']) . "</span></td>" .
156 "<td><select name='" . attr($res_pd['table_name']) . "-" . attr($res_pd['field_name']) . "-sel' >" .
157 "<option value='ignore' >" . xlt('Ignore') . "</option><option value='update' >" . xlt('Update') . "</option></select></td>";
160 if ($i % 2 == 0) {
161 if ($i % 4 == 2) {
162 echo "</tr><tr class='alternate' >";
163 } else {
164 echo "</tr><tr>";
166 } else {
167 echo "<td>&nbsp;&nbsp;&nbsp;</td>";
172 </tr>
173 </table>
174 </td>
175 </tr>
176 <tr>
177 <td>
178 &nbsp;
179 </td>
180 </tr>
181 <tr>
182 <td>
183 <u><?php echo xlt('Problems'); ?></u>
184 </td>
185 </tr>
186 <tr>
187 <td>
188 <table border="0" width="95%" >
189 <tr>
190 <?php
191 $query_existing_prob = sqlStatement("SELECT * FROM lists WHERE pid = ? AND TYPE = 'medical_problem'", array($_REQUEST['pid']));
192 $result = array();
193 while ($res_existing_prob = sqlFetchArray($query_existing_prob)) {
194 array_push($result, $res_existing_prob);
197 $aud_res = createAuditArray($_REQUEST['amid'], 'lists1');
198 while ($res_existing_prob = array_shift($result)) {
199 if ($res_existing_prob['activity'] == 1) {
200 $activity = 'Active';
201 } else {
202 $activity = 'Inactive';
205 $set = 0;
206 $cnt = 0;
207 foreach ($aud_res['lists1'] as $k => $v) {
208 $cnt++;
209 if ($cnt % 2 == 0) {
210 $class = 'alternate';
211 } else {
212 $class = '';
215 if (in_array($res_existing_prob['diagnosis'], $aud_res['lists1'][$k])) {
216 $set = 1;
217 echo "<tr class='" . attr($class) . "' ><td>" . xlt('Title') . "</td><td><input type='text' name='lists1-title[]' value='' ></td>" .
218 "<td>" . xlt('Code') . "</td>" .
219 "<td><input type='text' name='lists1-diagnosis[]' value='" . attr($aud_res['lists1'][$k]['diagnosis']) . "' >" .
220 "<input type='hidden' name='lists1-old-diagnosis[]' value='" . attr($res_existing_prob['diagnosis']) . "' ></td>" .
221 "<td>" . xlt('Status') . "</td><td><input type='text' name='lists1-activity[]' value='" . attr($activity) . "' ></td>" .
222 "<td rowspan='2' ><select name='lists1-sel[]'><option value='ignore' >" . xlt('Ignore') . "</option>" .
223 "<option value='update' >" . xlt('Update') . "</option></select></td></tr>" .
224 "<tr style='color:red' ><td>&nbsp;</td><td>" . text($res_existing_prob['title']) . "</td><td>&nbsp;</td>" .
225 "<td>" . text($res_existing_prob['diagnosis']) . "</td>" .
226 "<td>&nbsp;</td><td>" . xlt($activity) . "</td>";
227 unset($aud_res['lists1'][$k]);
231 if ($set == 0) {
232 echo "<tr><td>" . xlt('Title') . "</td><td>" . text($res_existing_prob['title']) . "</td>" .
233 "<td>" . xlt('Code') . "</td><td>" . text($res_existing_prob['diagnosis']) . "</td>" .
234 "<td>" . xlt('Status') . "</td><td>" . xlt($activity) . "</td><td>&nbsp;</td>";
237 echo "</tr>";
240 foreach ($aud_res['lists1'] as $key => $val) {
241 if ($val['activity'] == 1) {
242 $activity = 'Active';
243 } else {
244 $activity = 'Inactive';
247 echo "<tr><td>" . xlt('Title') . "</td><td><input type='text' name='lists1-title[]' value='' ></td>" .
248 "<td>" . xlt('Code') . "</td><td><input type='text' name='lists1-diagnosis[]' value='" . attr($val['diagnosis']) . "' ></td>" .
249 "<td>" . xlt('Status') . "</td><td><input type='text' name='lists1-activity[]' value='" . attr($activity) . "' ></td>" .
250 "<td><select name='lists1-sel[]'><option value='ignore' >" . xlt('Ignore') . "</option>" .
251 "<option value='insert' >" . xlt('Insert') . "</option></select></td></tr>";
254 </tr>
255 </table>
256 </td>
257 </tr>
258 <tr>
259 <td>
260 &nbsp;
261 </td>
262 </tr>
263 <tr>
264 <td>
265 <u><?php echo xlt('Allergy'); ?></u>
266 </td>
267 </tr>
268 <tr>
269 <td>
270 <table border="0" width="95%" >
271 <tr>
272 <?php
273 $query_existing_alerts = sqlStatement("SELECT * FROM lists WHERE pid = ? AND TYPE = 'allergy'", array($_REQUEST['pid']));
274 $result = array();
275 while ($res_existing_alerts = sqlFetchArray($query_existing_alerts)) {
276 array_push($result, $res_existing_alerts);
279 $aud_res = createAuditArray($_REQUEST['amid'], 'lists2');
280 while ($res_existing_alerts = array_shift($result)) {
281 if ($res_existing_alerts['activity'] == 1) {
282 $activity = 'Active';
283 } else {
284 $activity = 'Inactive';
287 echo "<tr><td>" . xlt('Title') . "</td><td>" . text($res_existing_alerts['title']) . "</td>" .
288 "<td>" . xlt('Date Time') . "</td><td>" . text($res_existing_alerts['date']) . "</td>" .
289 "<td>" . xlt('Diagnosis') . "</td><td>" . text($res_existing_alerts['diagnosis']) . "</td>" .
290 "<td>" . xlt('Reaction') . "</td><td>" . text($res_existing_alerts['reaction']) . "</td><td>&nbsp;</td></tr>";
293 foreach ($aud_res['lists2'] as $key => $val) {
294 if ($val['activity'] == 1) {
295 $activity = 'Active';
296 } else {
297 $activity = 'Inactive';
300 echo "<tr><td>" . xlt('Title') . "</td><td><input type='text' name='lists2-title[]' value='" . attr($val['title']) . "' ></td>" .
301 "<td>" . xlt('Date Time') . "</td><td><input type='text' name='lists2-date[]' value='" . attr($val['date']) . "' ></td>" .
302 "<td>" . xlt('Diagnosis') . "</td><td><input type='text' name='lists2-diagnosis[]' value='" . attr($val['diagnosis']) . "' ></td>" .
303 "<td>" . xlt('Reaction') . "</td><td><input type='text' name='lists2-reaction[]' value='" . attr($val['reaction']) . "' ></td>" .
304 "<td><select name='lists2-sel[]'><option value='ignore' >" . xlt('Ignore') . "</option>" .
305 "<option value='insert' >" . xlt('Insert') . "</option></select></td>" .
306 "<input type='hidden' name='lists2-type[]' value='" . attr($val['type']) . "' ></tr>";
309 </tr>
310 </table>
311 </td>
312 </tr>
313 <tr>
314 <td>
315 &nbsp;
316 </td>
317 </tr>
318 <tr>
319 <td>
320 <u><?php echo xlt('Medications'); ?></u>
321 </td>
322 </tr>
323 <tr>
324 <td>
325 <table border="0" width="95%" >
326 <tr>
327 <?php
328 $query_existing_medications = sqlStatement("SELECT * FROM prescriptions WHERE patient_id = ?", array($_REQUEST['pid']));
329 $result = array();
330 while ($res_existing_medications = sqlFetchArray($query_existing_medications)) {
331 array_push($result, $res_existing_medications);
334 $aud_res = createAuditArray($_REQUEST['amid'], 'prescriptions');
335 while ($res_existing_medications = array_shift($result)) {
336 if ($res_existing_medications['active'] == 1) {
337 $activity = 'Active';
338 } else {
339 $activity = 'Inactive';
342 echo "<tr><td>" . xlt('Name') . "</td><td>" . text($res_existing_medications['drug']) . "</td>" .
343 "<td>" . xlt('Date') . "</td><td>" . text($res_existing_medications['date_added']) . "</td>" .
344 "<td>" . xlt('Status') . "</td><td>" . xlt($activity) . "</td><td rowspan='2' >&nbsp;</td></tr><tr><td>" . xlt('Form') . "</td>" .
345 "<td>" . text($res_existing_medications['form']) . "&nbsp;&nbsp;&nbsp;" . xlt('Strength') . "&nbsp;&nbsp;&nbsp;" . text($res_existing_medications['size']) . "</td>" .
346 "<td>" . xlt('Quantity') . "</td><td>" . text($res_existing_medications['quantity']) . "</td>" .
347 "<td>" . xlt('Refills') . "</td><td>" . text($res_existing_medications['refills']) . "</td></tr>";
350 foreach ($aud_res['prescriptions'] as $key => $val) {
351 if ($val['active'] == 1) {
352 $activity = 'Active';
353 } else {
354 $activity = 'Inactive';
357 echo "<tr><td>" . xlt('Name') . "</td><td><input type='text' name='prescriptions-drug[]' value='" . attr($val['drug']) . "' ></td>" .
358 "<td>" . xlt('Date') . "</td><td><input type='text' name='prescriptions-date_added[]' value='" . attr($val['date_added']) . "' ></td>" .
359 "<td>" . xlt('Status') . "</td><td><input type='text' name='prescriptions-active[]' value='" . attr($activity) . "' ></td><td rowspan='2' >" .
360 "<select name='prescriptions-sel[]'><option value='ignore' >" . xlt('Ignore') . "</option>" .
361 "<option value='insert' >" . xlt('Insert') . "</option></select></td></tr><tr><td>" . xlt('Form') . "</td>" .
362 "<td><input type='text' size='8' name='prescriptions-form[]' value='" . attr($val['form']) . "' >" .
363 "&nbsp;&nbsp;&nbsp;" . xlt('Strength') . "&nbsp;&nbsp;&nbsp;<input type='text' size='7' name='prescriptions-size[]' value='" . attr($val['size']) . "' ></td>" .
364 "<td>" . xlt('Quantity') . "</td><td><input type='text' name='prescriptions-quantity[]' value='" . attr($val['quantity']) . "' ></td>" .
365 "<td>" . xlt('Refills') . "</td><td><input type='text' name='prescriptions-refills[]' value='" . attr($val['refills']) . "' ></td></tr>";
368 </tr>
369 </table>
370 </td>
371 </tr>
372 <tr>
373 <td>
374 &nbsp;
375 </td>
376 </tr>
377 <tr>
378 <td>
379 <u><?php echo xlt('Immunizations'); ?></u>
380 </td>
381 </tr>
382 <tr>
383 <td>
384 <table border="0" width="95%" >
385 <tr>
386 <?php
387 $query_existing_immunizations = sqlStatement("SELECT * FROM immunizations WHERE patient_id = ? AND added_erroneously = 0", array($_REQUEST['pid']));
388 $result = array();
389 while ($res_existing_immunizations = sqlFetchArray($query_existing_immunizations)) {
390 array_push($result, $res_existing_immunizations);
393 $aud_res = createAuditArray($_REQUEST['amid'], 'immunizations');
394 while ($res_existing_immunizations = array_shift($result)) {
395 echo "<tr><td>" . xlt('Administered Date') . "</td>" .
396 "<td>" . text($res_existing_immunizations['administered_date']) . "</td>" .
397 "<td>" . xlt('Note') . "</td><td>" . text($res_existing_immunizations['note']) . "</td>" .
398 "<td>&nbsp;</td></tr>";
401 foreach ($aud_res['immunizations'] as $key => $val) {
402 echo "<tr><td>" . xlt('Administered Date') . "</td>" .
403 "<td><input type='text' name='immunizations-administered_date[]' value='" . attr($val['administered_date']) . "' ></td>" .
404 "<td>" . xlt('Note') . "</td><td><input type='text' name='immunizations-note[]' value='" . attr($val['note']) . "' ></td>" .
405 "<td><select name='immunizations-sel[]'><option value='ignore' >" . xlt('Ignore') . "</option>" .
406 "<option value='insert' >" . xlt('Insert') . "</option></select></td></tr>";
409 </tr>
410 </table>
411 </td>
412 </tr>
413 <tr>
414 <td>
415 &nbsp;
416 </td>
417 </tr>
418 <tr>
419 <td>
420 <u><?php echo xlt('Lab Results'); ?></u>
421 </td>
422 </tr>
423 <tr>
424 <td>
425 <table border="0" width="95%" >
426 <tr>
427 <?php
428 $query_existing_lab_results = sqlStatement("SELECT * FROM procedure_order AS po LEFT JOIN procedure_order_code AS poc
429 ON poc.procedure_order_id = po.procedure_order_id LEFT JOIN procedure_report AS pr ON pr.procedure_order_id = po.procedure_order_id
430 LEFT JOIN procedure_result AS prs ON prs.procedure_report_id = pr.procedure_report_id WHERE patient_id = ?", array($_REQUEST['pid']));
431 $result = array();
432 while ($res_existing_lab_results = sqlFetchArray($query_existing_lab_results)) {
433 array_push($result, $res_existing_lab_results);
436 $aud_res = createAuditArray($_REQUEST['amid'], 'procedure_result,procedure_type');
437 while ($res_existing_lab_results = array_shift($result)) {
438 echo "<tr><td>" . xlt('Name') . "</td>" .
439 "<td>" . text($res_existing_lab_results['result_text']) . "</td>" .
440 "<td>" . xlt('Date') . "</td><td>" . text($res_existing_lab_results['date_ordered']) . "</td>" .
441 "<td>" . xlt('Result') . "</td><td>" . text($res_existing_lab_results['result']) . "</td>" .
442 "<td>" . xlt('Abnormal') . "</td><td>" . text($res_existing_lab_results['abnormal']) . "</td>" .
443 "<td>&nbsp;</td></tr>";
446 foreach ($aud_res['procedure_result,procedure_type'] as $key => $val) {
447 echo "<tr><td>" . xlt('Name') . "</td>" .
448 "<td><input type='text' name='procedure_type-name[]' value='" . attr($val['name']) . "' ></td>" .
449 "<td>" . xlt('Date') . "</td><td><input type='text' name='procedure_result-date[]' value='" . attr($val['date']) . "' ></td>" .
450 "<td>" . xlt('Result') . "</td><td><input type='text' name='procedure_result-result[]' value='" . attr($val['result']) . "' ></td>" .
451 "<td>" . xlt('Abnormal') . "</td><td><input type='text' name='procedure_result-abnormal[]' value='" . attr($val['abnormal']) . "' ></td>" .
452 "<td><select name='procedure_result-sel[]'><option value='ignore' >" . xlt('Ignore') . "</option>" .
453 "<option value='insert' >" . xlt('Insert') . "</option></select></td></tr>";
456 </tr>
457 </table>
458 </td>
459 </tr>
460 <tr>
461 <td align="center" >
462 <input type="button" name="approve" value="<?php echo xla('Approve'); ?>" onclick="top.restoreSession();submit_form('approve');" >
463 <input type="button" name="discard" value="<?php echo xla('Discard'); ?>" onclick="top.restoreSession();submit_form('discard');" >
464 <?php
465 $aud_res = createAuditArray($_REQUEST['amid'], 'documents');
467 <input type="hidden" name="doc_id" id="doc_id" value="<?php echo attr($aud_res['documents']['']['id']); ?>" >
468 <input type="hidden" name="setval" id="setval" value="" >
469 </td>
470 </tr>
471 </table>
472 </form>
473 </body>
474 </html>