Highway to PSR2
[openemr.git] / interface / patient_file / ccr_review_approve.php
blobfc2e0e8412cff27a87ba2c5990492ef725d5259b
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 * Copyright (C) 2013 Z&H Consultancy Services Private Limited <sam@zhservices.com>
9 * LICENSE: This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 3
12 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
20 * @package OpenEMR
21 * @author Eldho Chacko <eldho@zhservices.com>
22 * @author Ajil P M <ajilpm@zhservices.com>
23 * @link http://www.open-emr.org
28 require_once(dirname(__FILE__) . "/../globals.php");
29 require_once(dirname(__FILE__) . "/../../library/parse_patient_xml.php");
31 $patient_data = array(
32 'sex' => 'Sex',
33 'pubpid' => 'External ID',
34 'street' => 'Street',
35 'city' => 'City',
36 'state' => 'State',
37 'postal_code' => 'Postal Code',
40 if ($_POST["setval"] == 'approve') {
41 insertApprovedData($_REQUEST);
42 $query = "UPDATE audit_master SET approval_status = '2' WHERE id=?";
43 sqlQuery($query, array($_REQUEST['amid']));
45 <html>
46 <head>
47 <title><?php echo xlt('CCR Review and Approve');?></title>
48 <link rel="stylesheet" href="<?php echo $css_header; ?>" type="text/css" >
49 </head>
50 <body class="body_top" >
51 <center><?php echo xlt('Approved Successfully'); ?></center>
52 </body>
53 </html>
54 <?php
55 exit;
56 } elseif ($_POST["setval"] == 'discard') {
57 $query = "UPDATE audit_master SET approval_status = '3' WHERE id=?";
58 sqlQuery($query, array($_REQUEST['amid']));
60 <html>
61 <head>
62 <title><?php echo xlt('CCR Review and Approve');?></title>
63 <link rel="stylesheet" href="<?php echo $css_header; ?>" type="text/css" >
64 </head>
65 <body class="body_top" >
66 <center><?php echo xlt('Discarded'); ?></center>
67 </body>
68 </html>
69 <?php
70 exit;
74 <html>
75 <head>
76 <title><?php echo xlt('CCR Review and Approve');?></title>
77 <link rel="stylesheet" href="<?php echo $css_header; ?>" type="text/css" >
78 <style>
80 table {
81 color: #000;
82 font: .85em/1.6em "Trebuchet MS",Verdana,sans-serif;
83 border-collapse: collapse;
84 margin: 0 auto;
85 border: 1px solid #CCC;
88 tbody th,td {
89 border-left: 0;
90 padding: 8px;
93 tbody {
94 background: #D4D4D4;
97 table table tbody tr {
98 background: #EEEEEE;
101 .alternate{
102 background-color: #C4C4C4;
105 </style>
106 <script type="text/javascript" >
108 function submit_form(val){
109 document.getElementById('setval').value = val;
110 top.restoreSession();
111 document.forms['approveform'].submit();
114 </script>
115 </head>
116 <body class="body_top" >
117 <center>
118 <p><b><?php echo xlt('CCR Patient Review');?></b></p>
119 </center>
120 <form method="post" name="approveform" "onsubmit='return top.restoreSession()'" >
121 <table border="0" width="90%;" >
122 <tr>
123 <td>
124 <u><?php echo xlt('Demographics'); ?></u>
125 </td>
126 </tr>
127 <tr>
128 <td>
129 <table border="0" width="95%" >
130 <tr>
131 <?php
132 $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
133 WHERE am.id = ? AND ad.table_name = 'patient_data' ORDER BY ad.id", array($_REQUEST['amid']));
134 $i = 0;
135 while ($res_pd = sqlFetchArray($query_pd)) {
136 if ($res_pd['field_name'] != 'lname' && $res_pd['field_name'] != 'fname' && $res_pd['field_name'] != 'DOB') {
137 $i++;
138 $query_oldpd = sqlQuery("SELECT ".$res_pd['field_name']." AS val FROM patient_data WHERE pid = ?", array($_REQUEST['pid']));
139 if ($res_pd['field_name'] == 'sex') {
140 echo "<td>" . ($patient_data[$res_pd['field_name']] ? text($patient_data[$res_pd['field_name']]): text($res_pd['field_name'])) . "</td>" .
141 "<td><select name='" . $res_pd['table_name'] . "-" . $res_pd['field_name'] . "' style='width:150px;' >" .
142 "<option value='Male' " . ($res_pd['field_value'] == 'Male' ? 'selected' : '' ) . " >" . xlt('Male') . "</option>" .
143 "<option value='Female' ".($res_pd['field_value'] == 'Female' ? 'selected' : '' )." >".xlt('Female')."</option></select>" .
144 "<span style='color:red;padding-left:25px;' >" . text($query_oldpd['val']) . "</span></td>" .
145 "<td><select name='" . $res_pd['table_name'] . "-" . $res_pd['field_name'] . "-sel'>" .
146 "<option value='ignore' >" . xlt('Ignore') . "</option> " .
147 "<option value='update' >" . xlt('Update') . "</option></select></td>";
148 } else {
149 echo "<td>" . ($patient_data[$res_pd['field_name']] ? text($patient_data[$res_pd['field_name']]): text($res_pd['field_name'])) . "</td>" .
150 "<td><input type='text' name='" . $res_pd['table_name'] . "-" . $res_pd['field_name'] . "' value='" . attr($res_pd['field_value']) . "' >" .
151 "<span style='color:red;padding-left:25px;' >" . text($query_oldpd['val']) . "</span></td>" .
152 "<td><select name='" . $res_pd['table_name'] . "-" . $res_pd['field_name'] . "-sel' >" .
153 "<option value='ignore' >" . xlt('Ignore') . "</option><option value='update' >" . xlt('Update') . "</option></select></td>";
156 if ($i%2 == 0) {
157 if ($i%4 == 2) {
158 echo "</tr><tr class='alternate' >";
159 } else {
160 echo "</tr><tr>";
162 } else {
163 echo "<td>&nbsp;&nbsp;&nbsp;</td>";
168 </tr>
169 </table>
170 </td>
171 </tr>
172 <tr>
173 <td>
174 &nbsp;
175 </td>
176 </tr>
177 <tr>
178 <td>
179 <u><?php echo xlt('Problems'); ?></u>
180 </td>
181 </tr>
182 <tr>
183 <td>
184 <table border="0" width="95%" >
185 <tr>
186 <?php
187 $query_existing_prob = sqlStatement("SELECT * FROM lists WHERE pid = ? AND TYPE = 'medical_problem'", array($_REQUEST['pid']));
188 $result = array();
189 while ($res_existing_prob = sqlFetchArray($query_existing_prob)) {
190 array_push($result, $res_existing_prob);
193 $aud_res = createAuditArray($_REQUEST['amid'], 'lists1');
194 while ($res_existing_prob = array_shift($result)) {
195 if ($res_existing_prob['activity'] == 1) {
196 $activity = 'Active';
197 } else {
198 $activity = 'Inactive';
201 $set = 0;
202 $cnt = 0;
203 foreach ($aud_res['lists1'] as $k => $v) {
204 $cnt++;
205 if ($cnt%2 == 0) {
206 $class = 'alternate';
207 } else {
208 $class = '';
211 if (in_array($res_existing_prob['diagnosis'], $aud_res['lists1'][$k])) {
212 $set = 1;
213 echo "<tr class='$class' ><td>" . xlt('Title') . "</td><td><input type='text' name='lists1-title[]' value='' ></td>" .
214 "<td>" . xlt('Code') . "</td>" .
215 "<td><input type='text' name='lists1-diagnosis[]' value='" . attr($aud_res['lists1'][$k]['diagnosis']) . "' >" .
216 "<input type='hidden' name='lists1-old-diagnosis[]' value='" . attr($res_existing_prob['diagnosis']) . "' ></td>" .
217 "<td>" . xlt('Status') . "</td><td><input type='text' name='lists1-activity[]' value='" . $activity . "' ></td>" .
218 "<td rowspan='2' ><select name='lists1-sel[]'><option value='ignore' >" . xlt('Ignore') . "</option>" .
219 "<option value='update' >" . xlt('Update') . "</option></select></td></tr>" .
220 "<tr style='color:red' ><td>&nbsp;</td><td>" . text($res_existing_prob['title']) . "</td><td>&nbsp;</td>" .
221 "<td>" . text($res_existing_prob['diagnosis']) . "</td>" .
222 "<td>&nbsp;</td><td>" . xlt($activity) . "</td>";
223 unset($aud_res['lists1'][$k]);
227 if ($set == 0) {
228 echo "<tr><td>" . xlt('Title') . "</td><td>" . text($res_existing_prob['title']) . "</td>" .
229 "<td>" . xlt('Code') . "</td><td>" . text($res_existing_prob['diagnosis']) . "</td>" .
230 "<td>" . xlt('Status') . "</td><td>" . xlt($activity) . "</td><td>&nbsp;</td>";
233 echo "</tr>";
236 foreach ($aud_res['lists1'] as $key => $val) {
237 if ($val['activity'] == 1) {
238 $activity = 'Active';
239 } else {
240 $activity = 'Inactive';
243 echo "<tr><td>" . xlt('Title') . "</td><td><input type='text' name='lists1-title[]' value='' ></td>" .
244 "<td>" . xlt('Code') . "</td><td><input type='text' name='lists1-diagnosis[]' value='" . attr($val['diagnosis']) . "' ></td>" .
245 "<td>" . xlt('Status') . "</td><td><input type='text' name='lists1-activity[]' value='" . $activity . "' ></td>" .
246 "<td><select name='lists1-sel[]'><option value='ignore' >" . xlt('Ignore') . "</option>" .
247 "<option value='insert' >" . xlt('Insert') . "</option></select></td></tr>";
250 </tr>
251 </table>
252 </td>
253 </tr>
254 <tr>
255 <td>
256 &nbsp;
257 </td>
258 </tr>
259 <tr>
260 <td>
261 <u><?php echo xlt('Allergy'); ?></u>
262 </td>
263 </tr>
264 <tr>
265 <td>
266 <table border="0" width="95%" >
267 <tr>
268 <?php
269 $query_existing_alerts = sqlStatement("SELECT * FROM lists WHERE pid = ? AND TYPE = 'allergy'", array($_REQUEST['pid']));
270 $result = array();
271 while ($res_existing_alerts = sqlFetchArray($query_existing_alerts)) {
272 array_push($result, $res_existing_alerts);
275 $aud_res = createAuditArray($_REQUEST['amid'], 'lists2');
276 while ($res_existing_alerts = array_shift($result)) {
277 if ($res_existing_alerts['activity'] == 1) {
278 $activity = 'Active';
279 } else {
280 $activity = 'Inactive';
283 echo "<tr><td>" . xlt('Title') . "</td><td>" . text($res_existing_alerts['title']) . "</td>" .
284 "<td>" . xlt('Date Time') . "</td><td>" . text($res_existing_alerts['date']) . "</td>" .
285 "<td>" . xlt('Diagnosis') . "</td><td>" . text($res_existing_alerts['diagnosis']) . "</td>" .
286 "<td>" . xlt('Reaction') . "</td><td>" . text($res_existing_alerts['reaction']) . "</td><td>&nbsp;</td></tr>";
289 foreach ($aud_res['lists2'] as $key => $val) {
290 if ($val['activity'] == 1) {
291 $activity = 'Active';
292 } else {
293 $activity = 'Inactive';
296 echo "<tr><td>" . xlt('Title') . "</td><td><input type='text' name='lists2-title[]' value='" . attr($val['title']) . "' ></td>" .
297 "<td>" . xlt('Date Time') . "</td><td><input type='text' name='lists2-date[]' value='" . attr($val['date']) . "' ></td>" .
298 "<td>" . xlt('Diagnosis') . "</td><td><input type='text' name='lists2-diagnosis[]' value='" . attr($val['diagnosis']) . "' ></td>" .
299 "<td>" . xlt('Reaction') . "</td><td><input type='text' name='lists2-reaction[]' value='" . attr($val['reaction']) . "' ></td>" .
300 "<td><select name='lists2-sel[]'><option value='ignore' >" . xlt('Ignore') . "</option>" .
301 "<option value='insert' >" . xlt('Insert') . "</option></select></td>" .
302 "<input type='hidden' name='lists2-type[]' value='" . attr($val['type']) . "' ></tr>";
305 </tr>
306 </table>
307 </td>
308 </tr>
309 <tr>
310 <td>
311 &nbsp;
312 </td>
313 </tr>
314 <tr>
315 <td>
316 <u><?php echo xlt('Medications'); ?></u>
317 </td>
318 </tr>
319 <tr>
320 <td>
321 <table border="0" width="95%" >
322 <tr>
323 <?php
324 $query_existing_medications = sqlStatement("SELECT * FROM prescriptions WHERE patient_id = ?", array($_REQUEST['pid']));
325 $result = array();
326 while ($res_existing_medications = sqlFetchArray($query_existing_medications)) {
327 array_push($result, $res_existing_medications);
330 $aud_res = createAuditArray($_REQUEST['amid'], 'prescriptions');
331 while ($res_existing_medications = array_shift($result)) {
332 if ($res_existing_medications['active'] == 1) {
333 $activity = 'Active';
334 } else {
335 $activity = 'Inactive';
338 echo "<tr><td>" . xlt('Name') . "</td><td>" . text($res_existing_medications['drug']) . "</td>" .
339 "<td>" . xlt('Date') . "</td><td>" . text($res_existing_medications['date_added']) . "</td>" .
340 "<td>" . xlt('Status') . "</td><td>" . xlt($activity) . "</td><td rowspan='2' >&nbsp;</td></tr><tr><td>" . xlt('Form') . "</td>" .
341 "<td>" . text($res_existing_medications['form'])."&nbsp;&nbsp;&nbsp;" . xlt('Strength') . "&nbsp;&nbsp;&nbsp;" . text($res_existing_medications['size']) . "</td>" .
342 "<td>" . xlt('Quantity')."</td><td>" . text($res_existing_medications['quantity']) . "</td>" .
343 "<td>" . xlt('Refills') . "</td><td>" . text($res_existing_medications['refills']) . "</td></tr>";
346 foreach ($aud_res['prescriptions'] as $key => $val) {
347 if ($val['active'] == 1) {
348 $activity = 'Active';
349 } else {
350 $activity = 'Inactive';
353 echo "<tr><td>" . xlt('Name') . "</td><td><input type='text' name='prescriptions-drug[]' value='" . attr($val['drug']) . "' ></td>" .
354 "<td>" . xlt('Date') . "</td><td><input type='text' name='prescriptions-date_added[]' value='" . attr($val['date_added']) . "' ></td>" .
355 "<td>" . xlt('Status') . "</td><td><input type='text' name='prescriptions-active[]' value='" . $activity . "' ></td><td rowspan='2' >" .
356 "<select name='prescriptions-sel[]'><option value='ignore' >" . xlt('Ignore') . "</option>" .
357 "<option value='insert' >" . xlt('Insert') . "</option></select></td></tr><tr><td>" . xlt('Form') . "</td>" .
358 "<td><input type='text' size='8' name='prescriptions-form[]' value='" . attr($val['form']) . "' >" .
359 "&nbsp;&nbsp;&nbsp;" . xlt('Strength') . "&nbsp;&nbsp;&nbsp;<input type='text' size='7' name='prescriptions-size[]' value='" . attr($val['size']) . "' ></td>" .
360 "<td>" . xlt('Quantity') . "</td><td><input type='text' name='prescriptions-quantity[]' value='" . attr($val['quantity']) . "' ></td>" .
361 "<td>" . xlt('Refills') . "</td><td><input type='text' name='prescriptions-refills[]' value='" . attr($val['refills']) . "' ></td></tr>";
364 </tr>
365 </table>
366 </td>
367 </tr>
368 <tr>
369 <td>
370 &nbsp;
371 </td>
372 </tr>
373 <tr>
374 <td>
375 <u><?php echo xlt('Immunizations'); ?></u>
376 </td>
377 </tr>
378 <tr>
379 <td>
380 <table border="0" width="95%" >
381 <tr>
382 <?php
383 $query_existing_immunizations = sqlStatement("SELECT * FROM immunizations WHERE patient_id = ? AND added_erroneously = 0", array($_REQUEST['pid']));
384 $result = array();
385 while ($res_existing_immunizations = sqlFetchArray($query_existing_immunizations)) {
386 array_push($result, $res_existing_immunizations);
389 $aud_res = createAuditArray($_REQUEST['amid'], 'immunizations');
390 while ($res_existing_immunizations = array_shift($result)) {
391 echo "<tr><td>" . xlt('Administered Date') . "</td>" .
392 "<td>" . text($res_existing_immunizations['administered_date']) . "</td>" .
393 "<td>" . xlt('Note') . "</td><td>" . text($res_existing_immunizations['note']) . "</td>" .
394 "<td>&nbsp;</td></tr>";
397 foreach ($aud_res['immunizations'] as $key => $val) {
398 echo "<tr><td>" . xlt('Administered Date') . "</td>" .
399 "<td><input type='text' name='immunizations-administered_date[]' value='" . attr($val['administered_date']) . "' ></td>" .
400 "<td>" . xlt('Note') . "</td><td><input type='text' name='immunizations-note[]' value='" . attr($val['note']) . "' ></td>" .
401 "<td><select name='immunizations-sel[]'><option value='ignore' >" . xlt('Ignore') . "</option>" .
402 "<option value='insert' >" . xlt('Insert') . "</option></select></td></tr>";
405 </tr>
406 </table>
407 </td>
408 </tr>
409 <tr>
410 <td>
411 &nbsp;
412 </td>
413 </tr>
414 <tr>
415 <td>
416 <u><?php echo xlt('Lab Results'); ?></u>
417 </td>
418 </tr>
419 <tr>
420 <td>
421 <table border="0" width="95%" >
422 <tr>
423 <?php
424 $query_existing_lab_results = sqlStatement("SELECT * FROM procedure_order AS po LEFT JOIN procedure_order_code AS poc
425 ON poc.procedure_order_id = po.procedure_order_id LEFT JOIN procedure_report AS pr ON pr.procedure_order_id = po.procedure_order_id
426 LEFT JOIN procedure_result AS prs ON prs.procedure_report_id = pr.procedure_report_id WHERE patient_id = ?", array($_REQUEST['pid']));
427 $result = array();
428 while ($res_existing_lab_results = sqlFetchArray($query_existing_lab_results)) {
429 array_push($result, $res_existing_lab_results);
432 $aud_res = createAuditArray($_REQUEST['amid'], 'procedure_result,procedure_type');
433 while ($res_existing_lab_results = array_shift($result)) {
434 echo "<tr><td>" . xlt('Name') . "</td>" .
435 "<td>" . text($res_existing_lab_results['result_text']) . "</td>" .
436 "<td>" . xlt('Date') . "</td><td>" . text($res_existing_lab_results['date_ordered']) . "</td>" .
437 "<td>" . xlt('Result') . "</td><td>" . text($res_existing_lab_results['result']) . "</td>" .
438 "<td>" . xlt('Abnormal') . "</td><td>" . text($res_existing_lab_results['abnormal']) . "</td>" .
439 "<td>&nbsp;</td></tr>";
442 foreach ($aud_res['procedure_result,procedure_type'] as $key => $val) {
443 echo "<tr><td>" . xlt('Name') . "</td>" .
444 "<td><input type='text' name='procedure_type-name[]' value='" . attr($val['name']) . "' ></td>" .
445 "<td>" . xlt('Date') . "</td><td><input type='text' name='procedure_result-date[]' value='" . attr($val['date']) . "' ></td>" .
446 "<td>" . xlt('Result') . "</td><td><input type='text' name='procedure_result-result[]' value='" . attr($val['result']) . "' ></td>" .
447 "<td>" . xlt('Abnormal') . "</td><td><input type='text' name='procedure_result-abnormal[]' value='" . attr($val['abnormal']) . "' ></td>" .
448 "<td><select name='procedure_result-sel[]'><option value='ignore' >" . xlt('Ignore') . "</option>" .
449 "<option value='insert' >" . xlt('Insert') . "</option></select></td></tr>";
452 </tr>
453 </table>
454 </td>
455 </tr>
456 <tr>
457 <td align="center" >
458 <input type="button" name="approve" value="<?php echo xlt('Approve'); ?>" onclick="top.restoreSession();submit_form('approve');" >
459 <input type="button" name="discard" value="<?php echo xlt('Discard'); ?>" onclick="top.restoreSession();submit_form('discard');" >
460 <?php
461 $aud_res = createAuditArray($_REQUEST['amid'], 'documents');
463 <input type="hidden" name="doc_id" id="doc_id" value="<?php echo $aud_res['documents']['']['id']; ?>" >
464 <input type="hidden" name="setval" id="setval" value="" >
465 </td>
466 </tr>
467 </table>
468 </form>
469 </body>
470 </html>