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)
36 if (array_key_exists($key, $search)) {
37 $value = $search[$key];
45 $eRxPage = new eRxPage(
47 new eRxGlobals($GLOBALS),
52 $eRxPage->setAuthUserId(array_key_exists_default('authUserID', $_SESSION))
53 ->setDestination(array_key_exists_default('page', $_REQUEST))
54 ->setPatientId(array_key_exists_default('pid', $GLOBALS))
55 ->setPrescriptionIds(array_key_exists_default('id', $_REQUEST))
56 ->setPrescriptionCount(60);
63 $missingExtensions = $eRxPage->checkForMissingExtensions();
65 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) {
71 echo '<li>'.text($missingExtension).'</li>';
76 $messages = $eRxPage->buildXML();
78 if (count($messages['demographics']) > 0) {
80 <strong
><?php
echo xlt('Warning'); ?
>:</strong
>
81 <p
><?php
echo xlt('The following fields have to be filled to send a request.'); ?
></p
>
83 <?php
foreach ($messages['demographics'] as $message) {
84 echo '<li>'.text($message).'</li>';
87 <p
><?php
echo xlt('You will be automatically redirected to Demographics. You may make the necessary corrections and navigate to NewCrop again.'); ?
></p
>
93 <script type
="text/javascript">
94 window
.setTimeout(function() {
95 window
.location
= "<?php echo $GLOBALS['webroot']; ?>/interface/patient_file/summary/demographics_full.php";
96 }, <?php
echo (count($messages) * 2000) +
3000; ?
>);
99 } elseif (count($messages['empty']) > 0) {
101 <p
><?php
echo xlt('The following fields have to be filled to send a request.'); ?
></p
>
103 <?php
foreach ($messages['empty'] as $message) {
104 echo '<li>'.text($message).'</li>';
109 if (count($messages['warning']) > 0) {
111 <strong
><?php
echo xlt('Warning'); ?
></strong
>
112 <p
><?php
echo xlt('The following fields are empty.'); ?
></p
>
114 <?php
foreach ($messages['warning'] as $message) {
115 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) {
133 <strong
><?php
echo xlt('NewCrop call failed'); ?
></strong
>
135 <?php
foreach ($errors as $message) {
136 echo '<li>'.$message.'</li>';
141 $eRxPage->updatePatientData();
144 <script type
="text/javascript">
145 <?php
require($GLOBALS['srcdir'].'/restoreSession.php'); ?
>
147 <form name
="info" method
="post" action
="<?php echo $GLOBALS['erx_newcrop_path']; ?>" onsubmit
="return top.restoreSession()">
148 <input type
="submit" style
="display:none">
149 <input type
="hidden" id
="RxInput" name
="RxInput" value
="<?php echo $xml; ?>">
151 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-3-2/index.js"></script
>
152 <script type
="text/javascript">
153 window
.setTimeout(function() {
154 document
.forms
[0].submit();
155 }, <?php
echo $delay; ?
>);