4 * interface/eRx.php Redirect to NewCrop pages.
6 * Copyright (C) 2011 ZMG LLC <sam@zhservices.com>
8 * LICENSE: This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 3 of the License, or (at your option) any
11 * later version. This program is distributed in the hope that it will be
12 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
14 * Public License for more details. You should have received a copy of the GNU
15 * General Public License along with this program.
16 * If not, see <http://opensource.org/licenses/gpl-license.php>.
20 * @author Eldho Chacko <eldho@zhservices.com>
21 * @author Vinish K <vinish@zhservices.com>
22 * @author Sam Likins <sam.likins@wsi-services.com>
23 * @link http://www.open-emr.org
26 $sanitize_all_escapes = true; //SANITIZE ALL ESCAPES
28 $fake_register_globals = false; //STOP FAKE REGISTER GLOBALS
30 require_once(__DIR__
.'/globals.php');
31 require_once($GLOBALS['fileroot'].'/interface/eRxGlobals.php');
32 require_once($GLOBALS['fileroot'].'/interface/eRxStore.php');
33 require_once($GLOBALS['fileroot'].'/interface/eRxXMLBuilder.php');
34 require_once($GLOBALS['fileroot'].'/interface/eRxPage.php');
38 function array_key_exists_default($key, $search, $default = null) {
39 if(array_key_exists($key, $search)) {
40 $value = $search[$key];
48 $eRxPage = new eRxPage(
50 new eRxGlobals($GLOBALS),
55 $eRxPage->setAuthUserId(array_key_exists_default('authUserID', $_SESSION))
56 ->setDestination(array_key_exists_default('page', $_REQUEST))
57 ->setPatientId(array_key_exists_default('pid', $GLOBALS))
58 ->setPrescriptionIds(array_key_exists_default('id', $_REQUEST))
59 ->setPrescriptionCount(60);
66 $missingExtensions = $eRxPage->checkForMissingExtensions();
68 if(count($missingExtensions) > 0) {
71 <strong
><?php
echo xlt('Error'); ?
>:</strong
>
72 <p
><?php
echo xlt('Please contact your systems administrator, the following component(s) are required but are missing.'); ?
></p
>
74 <?php
foreach($missingExtensions as $missingExtension) { echo '<li>'.text($missingExtension).'</li>'; } ?
>
80 $messages = $eRxPage->buildXML();
82 if(count($messages['demographics']) > 0) {
85 <strong
><?php
echo xlt('Warning'); ?
>:</strong
>
86 <p
><?php
echo xlt('The following fields have to be filled to send a request.'); ?
></p
>
88 <?php
foreach($messages['demographics'] as $message) { echo '<li>'.text($message).'</li>'; } ?
>
90 <p
><?php
echo xlt('You will be automatically redirected to Demographics. You may make the necessary corrections and navigate to NewCrop again.'); ?
></p
>
96 <script type
="text/javascript">
97 window
.setTimeout(function() {
98 window
.location
= "<?php echo $GLOBALS['webroot']; ?>/interface/patient_file/summary/demographics_full.php";
99 }, <?php
echo (count($messages) * 2000) +
3000; ?
>);
103 } elseif(count($messages['empty']) > 0) {
106 <p
><?php
echo xlt('The following fields have to be filled to send a request.'); ?
></p
>
108 <?php
foreach($messages['empty'] as $message) { echo '<li>'.text($message).'</li>'; } ?
>
114 if(count($messages['warning']) > 0) {
117 <strong
><?php
echo xlt('Warning'); ?
></strong
>
118 <p
><?php
echo xlt('The following fields are empty.'); ?
></p
>
120 <?php
foreach($messages['warning'] as $message) { echo '<li>'.text($message).'</li>'; } ?
>
122 <p
><strong
><?php
echo xlt('This will not prevent you from going to the e-Prescriptions site.'); ?
></strong
></p
>
126 $delay = (count($messages) * 2000) +
3000;
131 $xml = $eRxPage->getXML();
133 $errors = $eRxPage->checkError($xml);
135 if(count($errors) > 0) {
138 <strong
><?php
echo xlt('NewCrop call failed'); ?
></strong
>
140 <?php
foreach($errors as $message) { echo '<li>'.$message.'</li>'; } ?
>
146 $eRxPage->updatePatientData();
149 <script type
="text/javascript">
150 <?php
require($GLOBALS['srcdir'].'/restoreSession.php'); ?
>
152 <form name
="info" method
="post" action
="<?php echo $GLOBALS['erx_newcrop_path']; ?>" onsubmit
="return top.restoreSession()">
153 <input type
="submit" style
="display:none">
154 <input type
="hidden" id
="RxInput" name
="RxInput" value
="<?php echo $xml; ?>">
156 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-3-2/index.js"></script
>
157 <script type
="text/javascript">
158 window
.setTimeout(function() {
159 document
.forms
[0].submit();
160 }, <?php
echo $delay; ?
>);