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
28 require_once(dirname(__FILE__
) . "/../globals.php");
29 require_once(dirname(__FILE__
) . "/../../library/parse_patient_xml.php");
31 $patient_data = array(
33 'pubpid' => 'External ID',
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']));
47 <title
><?php
echo xlt('CCR Review and Approve');?
></title
>
48 <link rel
="stylesheet" href
="<?php echo $css_header; ?>" type
="text/css" >
50 <body
class="body_top" >
51 <center
><?php
echo xlt('Approved Successfully'); ?
></center
>
56 } elseif ($_POST["setval"] == 'discard') {
57 $query = "UPDATE audit_master SET approval_status = '3' WHERE id=?";
58 sqlQuery($query, array($_REQUEST['amid']));
62 <title
><?php
echo xlt('CCR Review and Approve');?
></title
>
63 <link rel
="stylesheet" href
="<?php echo $css_header; ?>" type
="text/css" >
65 <body
class="body_top" >
66 <center
><?php
echo xlt('Discarded'); ?
></center
>
76 <title
><?php
echo xlt('CCR Review and Approve');?
></title
>
77 <link rel
="stylesheet" href
="<?php echo $css_header; ?>" type
="text/css" >
82 font
: .85em
/1.6em
"Trebuchet MS",Verdana
,sans
-serif
;
83 border
-collapse
: collapse
;
85 border
: 1px solid
#CCC;
97 table table tbody tr
{
102 background
-color
: #C4C4C4;
106 <script type
="text/javascript" >
108 function submit_form(val
){
109 document
.getElementById('setval').value
= val
;
110 top
.restoreSession();
111 document
.forms
['approveform'].submit();
116 <body
class="body_top" >
118 <p
><b
><?php
echo xlt('CCR Patient Review');?
></b
></p
>
120 <form method
="post" name
="approveform" "onsubmit='return top.restoreSession()'" >
121 <table border
="0" width
="90%;" >
124 <u
><?php
echo xlt('Demographics'); ?
></u
>
129 <table border
="0" width
="95%" >
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']));
135 while ($res_pd = sqlFetchArray($query_pd)) {
136 if ($res_pd['field_name'] != 'lname' && $res_pd['field_name'] != 'fname' && $res_pd['field_name'] != 'DOB') {
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>";
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>";
158 echo "</tr><tr class='alternate' >";
163 echo "<td> </td>";
179 <u
><?php
echo xlt('Problems'); ?
></u
>
184 <table border
="0" width
="95%" >
187 $query_existing_prob = sqlStatement("SELECT * FROM lists WHERE pid = ? AND TYPE = 'medical_problem'", array($_REQUEST['pid']));
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';
198 $activity = 'Inactive';
203 foreach ($aud_res['lists1'] as $k => $v) {
206 $class = 'alternate';
211 if (in_array($res_existing_prob['diagnosis'], $aud_res['lists1'][$k])) {
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> </td><td>" . text($res_existing_prob['title']) . "</td><td> </td>" .
221 "<td>" . text($res_existing_prob['diagnosis']) . "</td>" .
222 "<td> </td><td>" . xlt($activity) . "</td>";
223 unset($aud_res['lists1'][$k]);
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> </td>";
236 foreach ($aud_res['lists1'] as $key => $val) {
237 if ($val['activity'] == 1) {
238 $activity = 'Active';
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>";
261 <u
><?php
echo xlt('Allergy'); ?
></u
>
266 <table border
="0" width
="95%" >
269 $query_existing_alerts = sqlStatement("SELECT * FROM lists WHERE pid = ? AND TYPE = 'allergy'", array($_REQUEST['pid']));
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';
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> </td></tr>";
289 foreach ($aud_res['lists2'] as $key => $val) {
290 if ($val['activity'] == 1) {
291 $activity = 'Active';
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>";
316 <u
><?php
echo xlt('Medications'); ?
></u
>
321 <table border
="0" width
="95%" >
324 $query_existing_medications = sqlStatement("SELECT * FROM prescriptions WHERE patient_id = ?", array($_REQUEST['pid']));
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';
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' > </td></tr><tr><td>" . xlt('Form') . "</td>" .
341 "<td>" . text($res_existing_medications['form'])." " . xlt('Strength') . " " . 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';
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 " " . xlt('Strength') . " <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>";
375 <u
><?php
echo xlt('Immunizations'); ?
></u
>
380 <table border
="0" width
="95%" >
383 $query_existing_immunizations = sqlStatement("SELECT * FROM immunizations WHERE patient_id = ? AND added_erroneously = 0", array($_REQUEST['pid']));
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> </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>";
416 <u
><?php
echo xlt('Lab Results'); ?
></u
>
421 <table border
="0" width
="95%" >
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']));
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> </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>";
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');" >
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
="" >