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