CCR Import, made changes per comments in github.
[openemr.git] / interface / patient_file / ccr_review_approve.php
blobce86df1099f7771b6e0c61b709d4c94fd009c4a5
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
26 //SANITIZE ALL ESCAPES
27 $sanitize_all_escapes=true;
30 //STOP FAKE REGISTER GLOBALS
31 $fake_register_globals=false;
34 require_once(dirname(__FILE__) . "/../globals.php");
35 require_once(dirname(__FILE__) . "/../../library/parse_patient_xml.php");
37 $patient_data = array(
38 'sex' => 'Sex',
39 'pubpid' => 'External ID',
40 'street' => 'Street',
41 'city' => 'City',
42 'state' => 'State',
43 'postal_code' => 'Postal Code',
46 if($_POST["setval"] == 'approve'){
47 insertApprovedData($_REQUEST);
48 $query = "UPDATE audit_master SET approval_status = '2' WHERE id=?";
49 sqlQuery($query,array($_REQUEST['amid']));
51 <html>
52 <head>
53 <title><?php echo xlt('CCR Review and Approve');?></title>
54 <link rel="stylesheet" href="<?php echo $css_header; ?>" type="text/css" >
55 </head>
56 <body class="body_top" >
57 <center><?php echo xlt('Approved Successfully'); ?></center>
58 </body>
59 </html>
60 <?php
61 exit;
62 }elseif($_POST["setval"] == 'discard'){
63 $query = "UPDATE audit_master SET approval_status = '3' WHERE id=?";
64 sqlQuery($query,array($_REQUEST['amid']));
66 <html>
67 <head>
68 <title><?php echo xlt('CCR Review and Approve');?></title>
69 <link rel="stylesheet" href="<?php echo $css_header; ?>" type="text/css" >
70 </head>
71 <body class="body_top" >
72 <center><?php echo xlt('Discarded'); ?></center>
73 </body>
74 </html>
75 <?php
76 exit;
80 <html>
81 <head>
82 <title><?php echo xlt('CCR Review and Approve');?></title>
83 <link rel="stylesheet" href="<?php echo $css_header; ?>" type="text/css" >
84 <style>
86 table {
87 color: #000;
88 font: .85em/1.6em "Trebuchet MS",Verdana,sans-serif;
89 border-collapse: collapse;
90 margin: 0 auto;
91 border: 1px solid #CCC;
94 tbody th,td {
95 border-left: 0;
96 padding: 8px;
99 tbody {
100 background: #D4D4D4;
103 table table tbody tr {
104 background: #EEEEEE;
107 .alternate{
108 background-color: #C4C4C4;
111 </style>
112 <script type="text/javascript" >
114 function submit_form(val){
115 document.getElementById('setval').value = val;
116 top.restoreSession();
117 document.forms['approveform'].submit();
120 </script>
121 </head>
122 <body class="body_top" >
123 <center>
124 <p><b><?php echo xlt('CCR Patient Review');?></b></p>
125 </center>
126 <form method="post" name="approveform" "onsubmit='return top.restoreSession()'" >
127 <table border="0" width="90%;" >
128 <tr>
129 <td>
130 <u><?php echo xlt('Demographics'); ?></u>
131 </td>
132 </tr>
133 <tr>
134 <td>
135 <table border="0" width="95%" >
136 <tr>
137 <?php
138 $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
139 WHERE am.id = ? AND ad.table_name = 'patient_data' ORDER BY ad.id",array($_REQUEST['amid']));
140 $i = 0;
141 while($res_pd = sqlFetchArray($query_pd)){
142 if($res_pd['field_name'] != 'lname' && $res_pd['field_name'] != 'fname' && $res_pd['field_name'] != 'DOB'){
143 $i++;
144 $query_oldpd = sqlQuery("SELECT ".$res_pd['field_name']." AS val FROM patient_data WHERE pid = ?",array($_REQUEST['pid']));
145 if($res_pd['field_name'] == 'sex'){
146 echo "<td>" . ($patient_data[$res_pd['field_name']] ? text($patient_data[$res_pd['field_name']]): text($res_pd['field_name'])) . "</td>" .
147 "<td><select name='" . $res_pd['table_name'] . "-" . $res_pd['field_name'] . "' style='width:150px;' >" .
148 "<option value='Male' " . ($res_pd['field_value'] == 'Male' ? 'selected' : '' ) . " >" . xlt('Male') . "</option>" .
149 "<option value='Female' ".($res_pd['field_value'] == 'Female' ? 'selected' : '' )." >".xlt('Female')."</option></select>" .
150 "<span style='color:red;padding-left:25px;' >" . text($query_oldpd['val']) . "</span></td>" .
151 "<td><select name='" . $res_pd['table_name'] . "-" . $res_pd['field_name'] . "-sel'>" .
152 "<option value='ignore' >" . xlt('Ignore') . "</option> " .
153 "<option value='update' >" . xlt('Update') . "</option></select></td>";
154 }else{
155 echo "<td>" . ($patient_data[$res_pd['field_name']] ? text($patient_data[$res_pd['field_name']]): text($res_pd['field_name'])) . "</td>" .
156 "<td><input type='text' name='" . $res_pd['table_name'] . "-" . $res_pd['field_name'] . "' value='" . attr($res_pd['field_value']) . "' >" .
157 "<span style='color:red;padding-left:25px;' >" . text($query_oldpd['val']) . "</span></td>" .
158 "<td><select name='" . $res_pd['table_name'] . "-" . $res_pd['field_name'] . "-sel' >" .
159 "<option value='ignore' >" . xlt('Ignore') . "</option><option value='update' >" . xlt('Update') . "</option></select></td>";
161 if($i%2 == 0){
162 if($i%4 == 2){
163 echo "</tr><tr class='alternate' >";
164 }else{
165 echo "</tr><tr>";
167 }else{
168 echo "<td>&nbsp;&nbsp;&nbsp;</td>";
173 </tr>
174 </table>
175 </td>
176 </tr>
177 <tr>
178 <td>
179 &nbsp;
180 </td>
181 </tr>
182 <tr>
183 <td>
184 <u><?php echo xlt('Problems'); ?></u>
185 </td>
186 </tr>
187 <tr>
188 <td>
189 <table border="0" width="95%" >
190 <tr>
191 <?php
192 $query_existing_prob = sqlStatement("SELECT * FROM lists WHERE pid = ? AND TYPE = 'medical_problem'",array($_REQUEST['pid']));
193 $result = array();
194 while($res_existing_prob = sqlFetchArray($query_existing_prob)){
195 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';
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 = '';
213 if(in_array($res_existing_prob['diagnosis'],$aud_res['lists1'][$k])){
214 $set = 1;
215 echo "<tr class='$class' ><td>" . xlt('Title') . "</td><td><input type='text' name='lists1-title[]' value='' ></td>" .
216 "<td>" . xlt('Code') . "</td>" .
217 "<td><input type='text' name='lists1-diagnosis[]' value='" . attr($aud_res['lists1'][$k]['diagnosis']) . "' >" .
218 "<input type='hidden' name='lists1-old-diagnosis[]' value='" . attr($res_existing_prob['diagnosis']) . "' ></td>" .
219 "<td>" . xlt('Status') . "</td><td><input type='text' name='lists1-activity[]' value='" . $activity . "' ></td>" .
220 "<td rowspan='2' ><select name='lists1-sel[]'><option value='ignore' >" . xlt('Ignore') . "</option>" .
221 "<option value='update' >" . xlt('Update') . "</option></select></td></tr>" .
222 "<tr style='color:red' ><td>&nbsp;</td><td>" . text($res_existing_prob['title']) . "</td><td>&nbsp;</td>" .
223 "<td>" . text($res_existing_prob['diagnosis']) . "</td>" .
224 "<td>&nbsp;</td><td>" . xlt($activity) . "</td>";
225 unset($aud_res['lists1'][$k]);
228 if($set == 0){
229 echo "<tr><td>" . xlt('Title') . "</td><td>" . text($res_existing_prob['title']) . "</td>" .
230 "<td>" . xlt('Code') . "</td><td>" . text($res_existing_prob['diagnosis']) . "</td>" .
231 "<td>" . xlt('Status') . "</td><td>" . xlt($activity) . "</td><td>&nbsp;</td>";
233 echo "</tr>";
235 foreach($aud_res['lists1'] as $key=>$val){
236 if($val['activity'] == 1){
237 $activity = 'Active';
238 }else{
239 $activity = 'Inactive';
241 echo "<tr><td>" . xlt('Title') . "</td><td><input type='text' name='lists1-title[]' value='' ></td>" .
242 "<td>" . xlt('Code') . "</td><td><input type='text' name='lists1-diagnosis[]' value='" . attr($val['diagnosis']) . "' ></td>" .
243 "<td>" . xlt('Status') . "</td><td><input type='text' name='lists1-activity[]' value='" . $activity . "' ></td>" .
244 "<td><select name='lists1-sel[]'><option value='ignore' >" . xlt('Ignore') . "</option>" .
245 "<option value='insert' >" . xlt('Insert') . "</option></select></td></tr>";
248 </tr>
249 </table>
250 </td>
251 </tr>
252 <tr>
253 <td>
254 &nbsp;
255 </td>
256 </tr>
257 <tr>
258 <td>
259 <u><?php echo xlt('Allergy'); ?></u>
260 </td>
261 </tr>
262 <tr>
263 <td>
264 <table border="0" width="95%" >
265 <tr>
266 <?php
267 $query_existing_alerts = sqlStatement("SELECT * FROM lists WHERE pid = ? AND TYPE = 'allergy'",array($_REQUEST['pid']));
268 $result = array();
269 while($res_existing_alerts = sqlFetchArray($query_existing_alerts)){
270 array_push($result,$res_existing_alerts);
272 $aud_res = createAuditArray($_REQUEST['amid'],'lists2');
273 while($res_existing_alerts = array_shift($result)){
274 if($res_existing_alerts['activity'] == 1){
275 $activity = 'Active';
276 }else{
277 $activity = 'Inactive';
279 echo "<tr><td>" . xlt('Title') . "</td><td>" . text($res_existing_alerts['title']) . "</td>" .
280 "<td>" . xlt('Date Time') . "</td><td>" . text($res_existing_alerts['date']) . "</td>" .
281 "<td>" . xlt('Diagnosis') . "</td><td>" . text($res_existing_alerts['diagnosis']) . "</td>" .
282 "<td>" . xlt('Reaction') . "</td><td>" . text($res_existing_alerts['reaction']) . "</td><td>&nbsp;</td></tr>";
284 foreach($aud_res['lists2'] as $key=>$val){
285 if($val['activity'] == 1){
286 $activity = 'Active';
287 }else{
288 $activity = 'Inactive';
290 echo "<tr><td>" . xlt('Title') . "</td><td><input type='text' name='lists2-title[]' value='" . attr($val['title']) . "' ></td>" .
291 "<td>" . xlt('Date Time') . "</td><td><input type='text' name='lists2-date[]' value='" . attr($val['date']) . "' ></td>" .
292 "<td>" . xlt('Diagnosis') . "</td><td><input type='text' name='lists2-diagnosis[]' value='" . attr($val['diagnosis']) . "' ></td>" .
293 "<td>" . xlt('Reaction') . "</td><td><input type='text' name='lists2-reaction[]' value='" . attr($val['reaction']) . "' ></td>" .
294 "<td><select name='lists2-sel[]'><option value='ignore' >" . xlt('Ignore') . "</option>" .
295 "<option value='insert' >" . xlt('Insert') . "</option></select></td>" .
296 "<input type='hidden' name='lists2-type[]' value='" . attr($val['type']) . "' ></tr>";
299 </tr>
300 </table>
301 </td>
302 </tr>
303 <tr>
304 <td>
305 &nbsp;
306 </td>
307 </tr>
308 <tr>
309 <td>
310 <u><?php echo xlt('Medications'); ?></u>
311 </td>
312 </tr>
313 <tr>
314 <td>
315 <table border="0" width="95%" >
316 <tr>
317 <?php
318 $query_existing_medications = sqlStatement("SELECT * FROM prescriptions WHERE patient_id = ?",array($_REQUEST['pid']));
319 $result = array();
320 while($res_existing_medications = sqlFetchArray($query_existing_medications)){
321 array_push($result,$res_existing_medications);
323 $aud_res = createAuditArray($_REQUEST['amid'],'prescriptions');
324 while($res_existing_medications = array_shift($result)){
325 if($res_existing_medications['active'] == 1){
326 $activity = 'Active';
327 }else{
328 $activity = 'Inactive';
330 echo "<tr><td>" . xlt('Name') . "</td><td>" . text($res_existing_medications['drug']) . "</td>" .
331 "<td>" . xlt('Date') . "</td><td>" . text($res_existing_medications['date_added']) . "</td>" .
332 "<td>" . xlt('Status') . "</td><td>" . xlt($activity) . "</td><td rowspan='2' >&nbsp;</td></tr><tr><td>" . xlt('Form') . "</td>" .
333 "<td>" . text($res_existing_medications['form'])."&nbsp;&nbsp;&nbsp;" . xlt('Strength') . "&nbsp;&nbsp;&nbsp;" . text($res_existing_medications['size']) . "</td>" .
334 "<td>" . xlt('Quantity')."</td><td>" . text($res_existing_medications['quantity']) . "</td>" .
335 "<td>" . xlt('Refills') . "</td><td>" . text($res_existing_medications['refills']) . "</td></tr>";
337 foreach($aud_res['prescriptions'] as $key=>$val){
338 if($val['active'] == 1){
339 $activity = 'Active';
340 }else{
341 $activity = 'Inactive';
343 echo "<tr><td>" . xlt('Name') . "</td><td><input type='text' name='prescriptions-drug[]' value='" . attr($val['drug']) . "' ></td>" .
344 "<td>" . xlt('Date') . "</td><td><input type='text' name='prescriptions-date_added[]' value='" . attr($val['date_added']) . "' ></td>" .
345 "<td>" . xlt('Status') . "</td><td><input type='text' name='prescriptions-active[]' value='" . $activity . "' ></td><td rowspan='2' >" .
346 "<select name='prescriptions-sel[]'><option value='ignore' >" . xlt('Ignore') . "</option>" .
347 "<option value='insert' >" . xlt('Insert') . "</option></select></td></tr><tr><td>" . xlt('Form') . "</td>" .
348 "<td><input type='text' size='8' name='prescriptions-form[]' value='" . attr($val['form']) . "' >" .
349 "&nbsp;&nbsp;&nbsp;" . xlt('Strength') . "&nbsp;&nbsp;&nbsp;<input type='text' size='7' name='prescriptions-size[]' value='" . attr($val['size']) . "' ></td>" .
350 "<td>" . xlt('Quantity') . "</td><td><input type='text' name='prescriptions-quantity[]' value='" . attr($val['quantity']) . "' ></td>" .
351 "<td>" . xlt('Refills') . "</td><td><input type='text' name='prescriptions-refills[]' value='" . attr($val['refills']) . "' ></td></tr>";
354 </tr>
355 </table>
356 </td>
357 </tr>
358 <tr>
359 <td>
360 &nbsp;
361 </td>
362 </tr>
363 <tr>
364 <td>
365 <u><?php echo xlt('Immunizations'); ?></u>
366 </td>
367 </tr>
368 <tr>
369 <td>
370 <table border="0" width="95%" >
371 <tr>
372 <?php
373 $query_existing_immunizations = sqlStatement("SELECT * FROM immunizations WHERE patient_id = ?",array($_REQUEST['pid']));
374 $result = array();
375 while($res_existing_immunizations = sqlFetchArray($query_existing_immunizations)){
376 array_push($result,$res_existing_immunizations);
378 $aud_res = createAuditArray($_REQUEST['amid'],'immunizations');
379 while($res_existing_immunizations = array_shift($result)){
380 echo "<tr><td>" . xlt('Administered Date') . "</td>" .
381 "<td>" . text($res_existing_immunizations['administered_date']) . "</td>" .
382 "<td>" . xlt('Note') . "</td><td>" . text($res_existing_immunizations['note']) . "</td>" .
383 "<td>&nbsp;</td></tr>";
385 foreach($aud_res['immunizations'] as $key=>$val){
386 echo "<tr><td>" . xlt('Administered Date') . "</td>" .
387 "<td><input type='text' name='immunizations-administered_date[]' value='" . attr($val['administered_date']) . "' ></td>" .
388 "<td>" . xlt('Note') . "</td><td><input type='text' name='immunizations-note[]' value='" . attr($val['note']) . "' ></td>" .
389 "<td><select name='immunizations-sel[]'><option value='ignore' >" . xlt('Ignore') . "</option>" .
390 "<option value='insert' >" . xlt('Insert') . "</option></select></td></tr>";
393 </tr>
394 </table>
395 </td>
396 </tr>
397 <tr>
398 <td>
399 &nbsp;
400 </td>
401 </tr>
402 <tr>
403 <td>
404 <u><?php echo xlt('Lab Results'); ?></u>
405 </td>
406 </tr>
407 <tr>
408 <td>
409 <table border="0" width="95%" >
410 <tr>
411 <?php
412 $query_existing_lab_results = sqlStatement("SELECT * FROM procedure_order AS po LEFT JOIN procedure_order_code AS poc
413 ON poc.procedure_order_id = po.procedure_order_id LEFT JOIN procedure_report AS pr ON pr.procedure_order_id = po.procedure_order_id
414 LEFT JOIN procedure_result AS prs ON prs.procedure_report_id = pr.procedure_report_id WHERE patient_id = ?",array($_REQUEST['pid']));
415 $result = array();
416 while($res_existing_lab_results = sqlFetchArray($query_existing_lab_results)){
417 array_push($result,$res_existing_lab_results);
419 $aud_res = createAuditArray($_REQUEST['amid'],'procedure_result,procedure_type');
420 while($res_existing_lab_results = array_shift($result)){
421 echo "<tr><td>" . xlt('Name') . "</td>" .
422 "<td>" . text($res_existing_lab_results['result_text']) . "</td>" .
423 "<td>" . xlt('Date') . "</td><td>" . text($res_existing_lab_results['date_ordered']) . "</td>" .
424 "<td>" . xlt('Result') . "</td><td>" . text($res_existing_lab_results['result']) . "</td>" .
425 "<td>" . xlt('Abnormal') . "</td><td>" . text($res_existing_lab_results['abnormal']) . "</td>" .
426 "<td>&nbsp;</td></tr>";
428 foreach($aud_res['procedure_result,procedure_type'] as $key=>$val){
429 echo "<tr><td>" . xlt('Name') . "</td>" .
430 "<td><input type='text' name='procedure_type-name[]' value='" . attr($val['name']) . "' ></td>" .
431 "<td>" . xlt('Date') . "</td><td><input type='text' name='procedure_result-date[]' value='" . attr($val['date']) . "' ></td>" .
432 "<td>" . xlt('Result') . "</td><td><input type='text' name='procedure_result-result[]' value='" . attr($val['result']) . "' ></td>" .
433 "<td>" . xlt('Abnormal') . "</td><td><input type='text' name='procedure_result-abnormal[]' value='" . attr($val['abnormal']) . "' ></td>" .
434 "<td><select name='procedure_result-sel[]'><option value='ignore' >" . xlt('Ignore') . "</option>" .
435 "<option value='insert' >" . xlt('Insert') . "</option></select></td></tr>";
438 </tr>
439 </table>
440 </td>
441 </tr>
442 <tr>
443 <td align="center" >
444 <input type="button" name="approve" value="<?php echo xlt('Approve'); ?>" onclick="top.restoreSession();submit_form('approve');" >
445 <input type="button" name="discard" value="<?php echo xlt('Discard'); ?>" onclick="top.restoreSession();submit_form('discard');" >
446 <?php
447 $aud_res = createAuditArray($_REQUEST['amid'],'documents');
449 <input type="hidden" name="doc_id" id="doc_id" value="<?php echo $aud_res['documents']['']['id']; ?>" >
450 <input type="hidden" name="setval" id="setval" value="" >
451 </td>
452 </tr>
453 </table>
454 </form>
455 </body>
456 </html>