4 * interface/patient_file/ccr_review_approve.php Approval screen for uploaded CCR XML.
6 * Approval screen for uploaded CCR XML.
9 * @link http://www.open-emr.org
10 * @author Eldho Chacko <eldho@zhservices.com>
11 * @author Ajil P M <ajilpm@zhservices.com>
12 * @copyright Copyright (c) 2013 Z&H Consultancy Services Private Limited <sam@zhservices.com>
13 * @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
;
20 use OpenEMR\Core\Header
;
22 $patient_data = array(
24 'pubpid' => 'External ID',
28 'postal_code' => 'Postal Code',
31 if ($_POST["setval"] == 'approve') {
32 if (!CsrfUtils
::verifyCsrfToken($_POST["csrf_token_form"])) {
33 CsrfUtils
::csrfNotVerified();
36 insertApprovedData($_REQUEST);
37 $query = "UPDATE audit_master SET approval_status = '2' WHERE id=?";
38 sqlQuery($query, array($_REQUEST['amid']));
42 <title
><?php
echo xlt('CCR Review and Approve');?
></title
>
43 <?php Header
::setupHeader(); ?
>
45 <body
class="body_top" >
46 <center
><?php
echo xlt('Approved Successfully'); ?
></center
>
51 } elseif ($_POST["setval"] == 'discard') {
52 if (!CsrfUtils
::verifyCsrfToken($_POST["csrf_token_form"])) {
53 CsrfUtils
::csrfNotVerified();
56 $query = "UPDATE audit_master SET approval_status = '3' WHERE id=?";
57 sqlQuery($query, array($_REQUEST['amid']));
61 <title
><?php
echo xlt('CCR Review and Approve');?
></title
>
62 <?php Header
::setupHeader(); ?
>
64 <body
class="body_top" >
65 <center
><?php
echo xlt('Discarded'); ?
></center
>
72 if (!CsrfUtils
::verifyCsrfToken($_GET["csrf_token_form"])) {
73 CsrfUtils
::csrfNotVerified();
79 <title
><?php
echo xlt('CCR Review and Approve');?
></title
>
80 <?php Header
::setupHeader(); ?
>
85 font
: .85em
/1.6em
"Trebuchet MS",Verdana
,sans
-serif
;
86 border
-collapse
: collapse
;
88 border
: 1px solid
#CCC;
100 table table tbody tr
{
105 background
-color
: #C4C4C4;
111 function submit_form(val
){
112 document
.getElementById('setval').value
= val
;
113 top
.restoreSession();
114 document
.forms
['approveform'].submit();
119 <body
class="body_top" >
121 <p
><b
><?php
echo xlt('CCR Patient Review');?
></b
></p
>
123 <form method
="post" name
="approveform" "onsubmit='return top.restoreSession()'" >
124 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
125 <table border
="0" width
="90%;" >
128 <u
><?php
echo xlt('Demographics'); ?
></u
>
133 <table border
="0" width
="95%" >
136 $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
137 WHERE am.id = ? AND ad.table_name = 'patient_data' ORDER BY ad.id", array($_REQUEST['amid']));
139 while ($res_pd = sqlFetchArray($query_pd)) {
140 if ($res_pd['field_name'] != 'lname' && $res_pd['field_name'] != 'fname' && $res_pd['field_name'] != 'DOB') {
142 $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']));
143 if ($res_pd['field_name'] == 'sex') {
144 echo "<td>" . ($patient_data[$res_pd['field_name']] ?
text($patient_data[$res_pd['field_name']]) : text($res_pd['field_name'])) . "</td>" .
145 "<td><select name='" . attr($res_pd['table_name']) . "-" . attr($res_pd['field_name']) . "' style='width:150px;' >" .
146 "<option value='Male' " . ($res_pd['field_value'] == 'Male' ?
'selected' : '' ) . " >" . xlt('Male') . "</option>" .
147 "<option value='Female' " . ($res_pd['field_value'] == 'Female' ?
'selected' : '' ) . " >" . xlt('Female') . "</option></select>" .
148 "<span style='color:red;padding-left:25px;' >" . text($query_oldpd['val']) . "</span></td>" .
149 "<td><select name='" . attr($res_pd['table_name']) . "-" . attr($res_pd['field_name']) . "-sel'>" .
150 "<option value='ignore' >" . xlt('Ignore') . "</option> " .
151 "<option value='update' >" . xlt('Update') . "</option></select></td>";
153 echo "<td>" . ($patient_data[$res_pd['field_name']] ?
text($patient_data[$res_pd['field_name']]) : text($res_pd['field_name'])) . "</td>" .
154 "<td><input type='text' name='" . attr($res_pd['table_name']) . "-" . attr($res_pd['field_name']) . "' value='" . attr($res_pd['field_value']) . "' >" .
155 "<span style='color:red;padding-left:25px;' >" . text($query_oldpd['val']) . "</span></td>" .
156 "<td><select name='" . attr($res_pd['table_name']) . "-" . attr($res_pd['field_name']) . "-sel' >" .
157 "<option value='ignore' >" . xlt('Ignore') . "</option><option value='update' >" . xlt('Update') . "</option></select></td>";
162 echo "</tr><tr class='alternate' >";
167 echo "<td> </td>";
183 <u
><?php
echo xlt('Problems'); ?
></u
>
188 <table border
="0" width
="95%" >
191 $query_existing_prob = sqlStatement("SELECT * FROM lists WHERE pid = ? AND TYPE = 'medical_problem'", array($_REQUEST['pid']));
193 while ($res_existing_prob = sqlFetchArray($query_existing_prob)) {
194 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';
207 foreach ($aud_res['lists1'] as $k => $v) {
210 $class = 'alternate';
215 if (in_array($res_existing_prob['diagnosis'], $aud_res['lists1'][$k])) {
217 echo "<tr class='" . attr($class) . "' ><td>" . xlt('Title') . "</td><td><input type='text' name='lists1-title[]' value='' ></td>" .
218 "<td>" . xlt('Code') . "</td>" .
219 "<td><input type='text' name='lists1-diagnosis[]' value='" . attr($aud_res['lists1'][$k]['diagnosis']) . "' >" .
220 "<input type='hidden' name='lists1-old-diagnosis[]' value='" . attr($res_existing_prob['diagnosis']) . "' ></td>" .
221 "<td>" . xlt('Status') . "</td><td><input type='text' name='lists1-activity[]' value='" . attr($activity) . "' ></td>" .
222 "<td rowspan='2' ><select name='lists1-sel[]'><option value='ignore' >" . xlt('Ignore') . "</option>" .
223 "<option value='update' >" . xlt('Update') . "</option></select></td></tr>" .
224 "<tr style='color:red' ><td> </td><td>" . text($res_existing_prob['title']) . "</td><td> </td>" .
225 "<td>" . text($res_existing_prob['diagnosis']) . "</td>" .
226 "<td> </td><td>" . xlt($activity) . "</td>";
227 unset($aud_res['lists1'][$k]);
232 echo "<tr><td>" . xlt('Title') . "</td><td>" . text($res_existing_prob['title']) . "</td>" .
233 "<td>" . xlt('Code') . "</td><td>" . text($res_existing_prob['diagnosis']) . "</td>" .
234 "<td>" . xlt('Status') . "</td><td>" . xlt($activity) . "</td><td> </td>";
240 foreach ($aud_res['lists1'] as $key => $val) {
241 if ($val['activity'] == 1) {
242 $activity = 'Active';
244 $activity = 'Inactive';
247 echo "<tr><td>" . xlt('Title') . "</td><td><input type='text' name='lists1-title[]' value='' ></td>" .
248 "<td>" . xlt('Code') . "</td><td><input type='text' name='lists1-diagnosis[]' value='" . attr($val['diagnosis']) . "' ></td>" .
249 "<td>" . xlt('Status') . "</td><td><input type='text' name='lists1-activity[]' value='" . attr($activity) . "' ></td>" .
250 "<td><select name='lists1-sel[]'><option value='ignore' >" . xlt('Ignore') . "</option>" .
251 "<option value='insert' >" . xlt('Insert') . "</option></select></td></tr>";
265 <u
><?php
echo xlt('Allergy'); ?
></u
>
270 <table border
="0" width
="95%" >
273 $query_existing_alerts = sqlStatement("SELECT * FROM lists WHERE pid = ? AND TYPE = 'allergy'", array($_REQUEST['pid']));
275 while ($res_existing_alerts = sqlFetchArray($query_existing_alerts)) {
276 array_push($result, $res_existing_alerts);
279 $aud_res = createAuditArray($_REQUEST['amid'], 'lists2');
280 while ($res_existing_alerts = array_shift($result)) {
281 if ($res_existing_alerts['activity'] == 1) {
282 $activity = 'Active';
284 $activity = 'Inactive';
287 echo "<tr><td>" . xlt('Title') . "</td><td>" . text($res_existing_alerts['title']) . "</td>" .
288 "<td>" . xlt('Date Time') . "</td><td>" . text($res_existing_alerts['date']) . "</td>" .
289 "<td>" . xlt('Diagnosis') . "</td><td>" . text($res_existing_alerts['diagnosis']) . "</td>" .
290 "<td>" . xlt('Reaction') . "</td><td>" . text($res_existing_alerts['reaction']) . "</td><td> </td></tr>";
293 foreach ($aud_res['lists2'] as $key => $val) {
294 if ($val['activity'] == 1) {
295 $activity = 'Active';
297 $activity = 'Inactive';
300 echo "<tr><td>" . xlt('Title') . "</td><td><input type='text' name='lists2-title[]' value='" . attr($val['title']) . "' ></td>" .
301 "<td>" . xlt('Date Time') . "</td><td><input type='text' name='lists2-date[]' value='" . attr($val['date']) . "' ></td>" .
302 "<td>" . xlt('Diagnosis') . "</td><td><input type='text' name='lists2-diagnosis[]' value='" . attr($val['diagnosis']) . "' ></td>" .
303 "<td>" . xlt('Reaction') . "</td><td><input type='text' name='lists2-reaction[]' value='" . attr($val['reaction']) . "' ></td>" .
304 "<td><select name='lists2-sel[]'><option value='ignore' >" . xlt('Ignore') . "</option>" .
305 "<option value='insert' >" . xlt('Insert') . "</option></select></td>" .
306 "<input type='hidden' name='lists2-type[]' value='" . attr($val['type']) . "' ></tr>";
320 <u
><?php
echo xlt('Medications'); ?
></u
>
325 <table border
="0" width
="95%" >
328 $query_existing_medications = sqlStatement("SELECT * FROM prescriptions WHERE patient_id = ?", array($_REQUEST['pid']));
330 while ($res_existing_medications = sqlFetchArray($query_existing_medications)) {
331 array_push($result, $res_existing_medications);
334 $aud_res = createAuditArray($_REQUEST['amid'], 'prescriptions');
335 while ($res_existing_medications = array_shift($result)) {
336 if ($res_existing_medications['active'] == 1) {
337 $activity = 'Active';
339 $activity = 'Inactive';
342 echo "<tr><td>" . xlt('Name') . "</td><td>" . text($res_existing_medications['drug']) . "</td>" .
343 "<td>" . xlt('Date') . "</td><td>" . text($res_existing_medications['date_added']) . "</td>" .
344 "<td>" . xlt('Status') . "</td><td>" . xlt($activity) . "</td><td rowspan='2' > </td></tr><tr><td>" . xlt('Form') . "</td>" .
345 "<td>" . text($res_existing_medications['form']) . " " . xlt('Strength') . " " . text($res_existing_medications['size']) . "</td>" .
346 "<td>" . xlt('Quantity') . "</td><td>" . text($res_existing_medications['quantity']) . "</td>" .
347 "<td>" . xlt('Refills') . "</td><td>" . text($res_existing_medications['refills']) . "</td></tr>";
350 foreach ($aud_res['prescriptions'] as $key => $val) {
351 if ($val['active'] == 1) {
352 $activity = 'Active';
354 $activity = 'Inactive';
357 echo "<tr><td>" . xlt('Name') . "</td><td><input type='text' name='prescriptions-drug[]' value='" . attr($val['drug']) . "' ></td>" .
358 "<td>" . xlt('Date') . "</td><td><input type='text' name='prescriptions-date_added[]' value='" . attr($val['date_added']) . "' ></td>" .
359 "<td>" . xlt('Status') . "</td><td><input type='text' name='prescriptions-active[]' value='" . attr($activity) . "' ></td><td rowspan='2' >" .
360 "<select name='prescriptions-sel[]'><option value='ignore' >" . xlt('Ignore') . "</option>" .
361 "<option value='insert' >" . xlt('Insert') . "</option></select></td></tr><tr><td>" . xlt('Form') . "</td>" .
362 "<td><input type='text' size='8' name='prescriptions-form[]' value='" . attr($val['form']) . "' >" .
363 " " . xlt('Strength') . " <input type='text' size='7' name='prescriptions-size[]' value='" . attr($val['size']) . "' ></td>" .
364 "<td>" . xlt('Quantity') . "</td><td><input type='text' name='prescriptions-quantity[]' value='" . attr($val['quantity']) . "' ></td>" .
365 "<td>" . xlt('Refills') . "</td><td><input type='text' name='prescriptions-refills[]' value='" . attr($val['refills']) . "' ></td></tr>";
379 <u
><?php
echo xlt('Immunizations'); ?
></u
>
384 <table border
="0" width
="95%" >
387 $query_existing_immunizations = sqlStatement("SELECT * FROM immunizations WHERE patient_id = ? AND added_erroneously = 0", array($_REQUEST['pid']));
389 while ($res_existing_immunizations = sqlFetchArray($query_existing_immunizations)) {
390 array_push($result, $res_existing_immunizations);
393 $aud_res = createAuditArray($_REQUEST['amid'], 'immunizations');
394 while ($res_existing_immunizations = array_shift($result)) {
395 echo "<tr><td>" . xlt('Administered Date') . "</td>" .
396 "<td>" . text($res_existing_immunizations['administered_date']) . "</td>" .
397 "<td>" . xlt('Note') . "</td><td>" . text($res_existing_immunizations['note']) . "</td>" .
398 "<td> </td></tr>";
401 foreach ($aud_res['immunizations'] as $key => $val) {
402 echo "<tr><td>" . xlt('Administered Date') . "</td>" .
403 "<td><input type='text' name='immunizations-administered_date[]' value='" . attr($val['administered_date']) . "' ></td>" .
404 "<td>" . xlt('Note') . "</td><td><input type='text' name='immunizations-note[]' value='" . attr($val['note']) . "' ></td>" .
405 "<td><select name='immunizations-sel[]'><option value='ignore' >" . xlt('Ignore') . "</option>" .
406 "<option value='insert' >" . xlt('Insert') . "</option></select></td></tr>";
420 <u
><?php
echo xlt('Lab Results'); ?
></u
>
425 <table border
="0" width
="95%" >
428 $query_existing_lab_results = sqlStatement("SELECT * FROM procedure_order AS po LEFT JOIN procedure_order_code AS poc
429 ON poc.procedure_order_id = po.procedure_order_id LEFT JOIN procedure_report AS pr ON pr.procedure_order_id = po.procedure_order_id
430 LEFT JOIN procedure_result AS prs ON prs.procedure_report_id = pr.procedure_report_id WHERE patient_id = ?", array($_REQUEST['pid']));
432 while ($res_existing_lab_results = sqlFetchArray($query_existing_lab_results)) {
433 array_push($result, $res_existing_lab_results);
436 $aud_res = createAuditArray($_REQUEST['amid'], 'procedure_result,procedure_type');
437 while ($res_existing_lab_results = array_shift($result)) {
438 echo "<tr><td>" . xlt('Name') . "</td>" .
439 "<td>" . text($res_existing_lab_results['result_text']) . "</td>" .
440 "<td>" . xlt('Date') . "</td><td>" . text($res_existing_lab_results['date_ordered']) . "</td>" .
441 "<td>" . xlt('Result') . "</td><td>" . text($res_existing_lab_results['result']) . "</td>" .
442 "<td>" . xlt('Abnormal') . "</td><td>" . text($res_existing_lab_results['abnormal']) . "</td>" .
443 "<td> </td></tr>";
446 foreach ($aud_res['procedure_result,procedure_type'] as $key => $val) {
447 echo "<tr><td>" . xlt('Name') . "</td>" .
448 "<td><input type='text' name='procedure_type-name[]' value='" . attr($val['name']) . "' ></td>" .
449 "<td>" . xlt('Date') . "</td><td><input type='text' name='procedure_result-date[]' value='" . attr($val['date']) . "' ></td>" .
450 "<td>" . xlt('Result') . "</td><td><input type='text' name='procedure_result-result[]' value='" . attr($val['result']) . "' ></td>" .
451 "<td>" . xlt('Abnormal') . "</td><td><input type='text' name='procedure_result-abnormal[]' value='" . attr($val['abnormal']) . "' ></td>" .
452 "<td><select name='procedure_result-sel[]'><option value='ignore' >" . xlt('Ignore') . "</option>" .
453 "<option value='insert' >" . xlt('Insert') . "</option></select></td></tr>";
462 <input type
="button" name
="approve" value
="<?php echo xla('Approve'); ?>" onclick
="top.restoreSession();submit_form('approve');" >
463 <input type
="button" name
="discard" value
="<?php echo xla('Discard'); ?>" onclick
="top.restoreSession();submit_form('discard');" >
465 $aud_res = createAuditArray($_REQUEST['amid'], 'documents');
467 <input type
="hidden" name
="doc_id" id
="doc_id" value
="<?php echo attr($aud_res['documents']['']['id']); ?>" >
468 <input type
="hidden" name
="setval" id
="setval" value
="" >