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 require_once(__DIR__
.'/globals.php');
27 require_once($GLOBALS['fileroot'].'/interface/eRxGlobals.php');
28 require_once($GLOBALS['fileroot'].'/interface/eRxStore.php');
29 require_once($GLOBALS['fileroot'].'/interface/eRxXMLBuilder.php');
30 require_once($GLOBALS['fileroot'].'/interface/eRxPage.php');
34 function array_key_exists_default($key, $search, $default = null) {
35 if(array_key_exists($key, $search)) {
36 $value = $search[$key];
44 $eRxPage = new eRxPage(
46 new eRxGlobals($GLOBALS),
51 $eRxPage->setAuthUserId(array_key_exists_default('authUserID', $_SESSION))
52 ->setDestination(array_key_exists_default('page', $_REQUEST))
53 ->setPatientId(array_key_exists_default('pid', $GLOBALS))
54 ->setPrescriptionIds(array_key_exists_default('id', $_REQUEST))
55 ->setPrescriptionCount(60);
62 $missingExtensions = $eRxPage->checkForMissingExtensions();
64 if(count($missingExtensions) > 0) {
67 <strong
><?php
echo xlt('Error'); ?
>:</strong
>
68 <p
><?php
echo xlt('Please contact your systems administrator, the following component(s) are required but are missing.'); ?
></p
>
70 <?php
foreach($missingExtensions as $missingExtension) { echo '<li>'.text($missingExtension).'</li>'; } ?
>
76 $messages = $eRxPage->buildXML();
78 if(count($messages['demographics']) > 0) {
81 <strong
><?php
echo xlt('Warning'); ?
>:</strong
>
82 <p
><?php
echo xlt('The following fields have to be filled to send a request.'); ?
></p
>
84 <?php
foreach($messages['demographics'] as $message) { echo '<li>'.text($message).'</li>'; } ?
>
86 <p
><?php
echo xlt('You will be automatically redirected to Demographics. You may make the necessary corrections and navigate to NewCrop again.'); ?
></p
>
92 <script type
="text/javascript">
93 window
.setTimeout(function() {
94 window
.location
= "<?php echo $GLOBALS['webroot']; ?>/interface/patient_file/summary/demographics_full.php";
95 }, <?php
echo (count($messages) * 2000) +
3000; ?
>);
99 } elseif(count($messages['empty']) > 0) {
102 <p
><?php
echo xlt('The following fields have to be filled to send a request.'); ?
></p
>
104 <?php
foreach($messages['empty'] as $message) { echo '<li>'.text($message).'</li>'; } ?
>
110 if(count($messages['warning']) > 0) {
113 <strong
><?php
echo xlt('Warning'); ?
></strong
>
114 <p
><?php
echo xlt('The following fields are empty.'); ?
></p
>
116 <?php
foreach($messages['warning'] as $message) { echo '<li>'.text($message).'</li>'; } ?
>
118 <p
><strong
><?php
echo xlt('This will not prevent you from going to the e-Prescriptions site.'); ?
></strong
></p
>
122 $delay = (count($messages) * 2000) +
3000;
127 $xml = $eRxPage->getXML();
129 $errors = $eRxPage->checkError($xml);
131 if(count($errors) > 0) {
134 <strong
><?php
echo xlt('NewCrop call failed'); ?
></strong
>
136 <?php
foreach($errors as $message) { echo '<li>'.$message.'</li>'; } ?
>
142 $eRxPage->updatePatientData();
145 <script type
="text/javascript">
146 <?php
require($GLOBALS['srcdir'].'/restoreSession.php'); ?
>
148 <form name
="info" method
="post" action
="<?php echo $GLOBALS['erx_newcrop_path']; ?>" onsubmit
="return top.restoreSession()">
149 <input type
="submit" style
="display:none">
150 <input type
="hidden" id
="RxInput" name
="RxInput" value
="<?php echo $xml; ?>">
152 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-3-2/index.js"></script
>
153 <script type
="text/javascript">
154 window
.setTimeout(function() {
155 document
.forms
[0].submit();
156 }, <?php
echo $delay; ?
>);