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>;.
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(
39 'pubpid' => 'External ID',
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']));
53 <title
><?php
echo xlt('CCR Review and Approve');?
></title
>
54 <link rel
="stylesheet" href
="<?php echo $css_header; ?>" type
="text/css" >
56 <body
class="body_top" >
57 <center
><?php
echo xlt('Approved Successfully'); ?
></center
>
62 }elseif($_POST["setval"] == 'discard'){
63 $query = "UPDATE audit_master SET approval_status = '3' WHERE id=?";
64 sqlQuery($query,array($_REQUEST['amid']));
68 <title
><?php
echo xlt('CCR Review and Approve');?
></title
>
69 <link rel
="stylesheet" href
="<?php echo $css_header; ?>" type
="text/css" >
71 <body
class="body_top" >
72 <center
><?php
echo xlt('Discarded'); ?
></center
>
82 <title
><?php
echo xlt('CCR Review and Approve');?
></title
>
83 <link rel
="stylesheet" href
="<?php echo $css_header; ?>" type
="text/css" >
88 font
: .85em
/1.6em
"Trebuchet MS",Verdana
,sans
-serif
;
89 border
-collapse
: collapse
;
91 border
: 1px solid
#CCC;
103 table table tbody tr
{
108 background
-color
: #C4C4C4;
112 <script type
="text/javascript" >
114 function submit_form(val
){
115 document
.getElementById('setval').value
= val
;
116 top
.restoreSession();
117 document
.forms
['approveform'].submit();
122 <body
class="body_top" >
124 <p
><b
><?php
echo xlt('CCR Patient Review');?
></b
></p
>
126 <form method
="post" name
="approveform" "onsubmit='return top.restoreSession()'" >
127 <table border
="0" width
="90%;" >
130 <u
><?php
echo xlt('Demographics'); ?
></u
>
135 <table border
="0" width
="95%" >
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']));
141 while($res_pd = sqlFetchArray($query_pd)){
142 if($res_pd['field_name'] != 'lname' && $res_pd['field_name'] != 'fname' && $res_pd['field_name'] != 'DOB'){
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>";
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>";
163 echo "</tr><tr class='alternate' >";
168 echo "<td> </td>";
184 <u
><?php
echo xlt('Problems'); ?
></u
>
189 <table border
="0" width
="95%" >
192 $query_existing_prob = sqlStatement("SELECT * FROM lists WHERE pid = ? AND TYPE = 'medical_problem'",array($_REQUEST['pid']));
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';
202 $activity = 'Inactive';
206 foreach($aud_res['lists1'] as $k=>$v){
209 $class = 'alternate';
213 if(in_array($res_existing_prob['diagnosis'],$aud_res['lists1'][$k])){
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> </td><td>" . text($res_existing_prob['title']) . "</td><td> </td>" .
223 "<td>" . text($res_existing_prob['diagnosis']) . "</td>" .
224 "<td> </td><td>" . xlt($activity) . "</td>";
225 unset($aud_res['lists1'][$k]);
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> </td>";
235 foreach($aud_res['lists1'] as $key=>$val){
236 if($val['activity'] == 1){
237 $activity = 'Active';
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>";
259 <u
><?php
echo xlt('Allergy'); ?
></u
>
264 <table border
="0" width
="95%" >
267 $query_existing_alerts = sqlStatement("SELECT * FROM lists WHERE pid = ? AND TYPE = 'allergy'",array($_REQUEST['pid']));
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';
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> </td></tr>";
284 foreach($aud_res['lists2'] as $key=>$val){
285 if($val['activity'] == 1){
286 $activity = 'Active';
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>";
310 <u
><?php
echo xlt('Medications'); ?
></u
>
315 <table border
="0" width
="95%" >
318 $query_existing_medications = sqlStatement("SELECT * FROM prescriptions WHERE patient_id = ?",array($_REQUEST['pid']));
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';
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' > </td></tr><tr><td>" . xlt('Form') . "</td>" .
333 "<td>" . text($res_existing_medications['form'])." " . xlt('Strength') . " " . 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';
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 " " . xlt('Strength') . " <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>";
365 <u
><?php
echo xlt('Immunizations'); ?
></u
>
370 <table border
="0" width
="95%" >
373 $query_existing_immunizations = sqlStatement("SELECT * FROM immunizations WHERE patient_id = ? AND added_erroneously = 0",array($_REQUEST['pid']));
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> </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>";
404 <u
><?php
echo xlt('Lab Results'); ?
></u
>
409 <table border
="0" width
="95%" >
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']));
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> </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>";
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');" >
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
="" >