3 * interface/patient_file/ccr_review_approve.php Approval screen for uploaded CCR XML.
5 * Approval screen for uploaded CCR XML.
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(
23 'pubpid' => 'External ID',
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']));
41 <title
><?php
echo xlt('CCR Review and Approve');?
></title
>
42 <link rel
="stylesheet" href
="<?php echo $css_header; ?>" type
="text/css" >
44 <body
class="body_top" >
45 <center
><?php
echo xlt('Approved Successfully'); ?
></center
>
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']));
60 <title
><?php
echo xlt('CCR Review and Approve');?
></title
>
61 <link rel
="stylesheet" href
="<?php echo $css_header; ?>" type
="text/css" >
63 <body
class="body_top" >
64 <center
><?php
echo xlt('Discarded'); ?
></center
>
71 if (!CsrfUtils
::verifyCsrfToken($_GET["csrf_token_form"])) {
72 CsrfUtils
::csrfNotVerified();
78 <title
><?php
echo xlt('CCR Review and Approve');?
></title
>
79 <link rel
="stylesheet" href
="<?php echo $css_header; ?>" type
="text/css" >
84 font
: .85em
/1.6em
"Trebuchet MS",Verdana
,sans
-serif
;
85 border
-collapse
: collapse
;
87 border
: 1px solid
#CCC;
99 table table tbody tr
{
104 background
-color
: #C4C4C4;
108 <script type
="text/javascript" >
110 function submit_form(val
){
111 document
.getElementById('setval').value
= val
;
112 top
.restoreSession();
113 document
.forms
['approveform'].submit();
118 <body
class="body_top" >
120 <p
><b
><?php
echo xlt('CCR Patient Review');?
></b
></p
>
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%;" >
127 <u
><?php
echo xlt('Demographics'); ?
></u
>
132 <table border
="0" width
="95%" >
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']));
138 while ($res_pd = sqlFetchArray($query_pd)) {
139 if ($res_pd['field_name'] != 'lname' && $res_pd['field_name'] != 'fname' && $res_pd['field_name'] != 'DOB') {
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>";
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>";
161 echo "</tr><tr class='alternate' >";
166 echo "<td> </td>";
182 <u
><?php
echo xlt('Problems'); ?
></u
>
187 <table border
="0" width
="95%" >
190 $query_existing_prob = sqlStatement("SELECT * FROM lists WHERE pid = ? AND TYPE = 'medical_problem'", array($_REQUEST['pid']));
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';
201 $activity = 'Inactive';
206 foreach ($aud_res['lists1'] as $k => $v) {
209 $class = 'alternate';
214 if (in_array($res_existing_prob['diagnosis'], $aud_res['lists1'][$k])) {
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> </td><td>" . text($res_existing_prob['title']) . "</td><td> </td>" .
224 "<td>" . text($res_existing_prob['diagnosis']) . "</td>" .
225 "<td> </td><td>" . xlt($activity) . "</td>";
226 unset($aud_res['lists1'][$k]);
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> </td>";
239 foreach ($aud_res['lists1'] as $key => $val) {
240 if ($val['activity'] == 1) {
241 $activity = 'Active';
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>";
264 <u
><?php
echo xlt('Allergy'); ?
></u
>
269 <table border
="0" width
="95%" >
272 $query_existing_alerts = sqlStatement("SELECT * FROM lists WHERE pid = ? AND TYPE = 'allergy'", array($_REQUEST['pid']));
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';
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> </td></tr>";
292 foreach ($aud_res['lists2'] as $key => $val) {
293 if ($val['activity'] == 1) {
294 $activity = 'Active';
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>";
319 <u
><?php
echo xlt('Medications'); ?
></u
>
324 <table border
="0" width
="95%" >
327 $query_existing_medications = sqlStatement("SELECT * FROM prescriptions WHERE patient_id = ?", array($_REQUEST['pid']));
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';
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' > </td></tr><tr><td>" . xlt('Form') . "</td>" .
344 "<td>" . text($res_existing_medications['form'])." " . xlt('Strength') . " " . 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';
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 " " . xlt('Strength') . " <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>";
378 <u
><?php
echo xlt('Immunizations'); ?
></u
>
383 <table border
="0" width
="95%" >
386 $query_existing_immunizations = sqlStatement("SELECT * FROM immunizations WHERE patient_id = ? AND added_erroneously = 0", array($_REQUEST['pid']));
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> </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>";
419 <u
><?php
echo xlt('Lab Results'); ?
></u
>
424 <table border
="0" width
="95%" >
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']));
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> </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>";
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');" >
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
="" >