AMC changes for summary of care and CPOE, see note below:
[openemr.git] / interface / eRx.php
bloba9adb930b3b138cde1a6c9cb62aefe6b027ba759
1 <?php
3 /**
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>.
18 * @package OpenEMR
19 * @subpackage NewCrop
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');
36 set_time_limit(0);
38 function array_key_exists_default($key, $search, $default = null) {
39 if(array_key_exists($key, $search)) {
40 $value = $search[$key];
41 } else {
42 $value = $default;
45 return $value;
48 $eRxPage = new eRxPage(
49 new eRxXMLBuilder(
50 new eRxGlobals($GLOBALS),
51 new eRxStore
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);
62 <html>
63 <body>
64 <?php
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>
73 <ul>
74 <?php foreach($missingExtensions as $missingExtension) { echo '<li>'.text($missingExtension).'</li>'; } ?>
75 <ul>
76 <?php
78 } else {
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>
87 <ul>
88 <?php foreach($messages['demographics'] as $message) { echo '<li>'.text($message).'</li>'; } ?>
89 <ul>
90 <p><?php echo xlt('You will be automatically redirected to Demographics. You may make the necessary corrections and navigate to NewCrop again.'); ?></p>
91 <?php
93 ob_end_flush();
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; ?>);
100 </script>
101 <?php
103 } elseif(count($messages['empty']) > 0) {
106 <p><?php echo xlt('The following fields have to be filled to send a request.'); ?></p>
107 <ul>
108 <?php foreach($messages['empty'] as $message) { echo '<li>'.text($message).'</li>'; } ?>
109 <ul>
110 <?php
112 } else {
114 if(count($messages['warning']) > 0) {
117 <strong><?php echo xlt('Warning'); ?></strong>
118 <p><?php echo xlt('The following fields are empty.'); ?></p>
119 <ul>
120 <?php foreach($messages['warning'] as $message) { echo '<li>'.text($message).'</li>'; } ?>
121 <ul>
122 <p><strong><?php echo xlt('This will not prevent you from going to the e-Prescriptions site.'); ?></strong></p>
123 <?php
125 ob_end_flush();
126 $delay = (count($messages) * 2000) + 3000;
127 } else {
128 $delay = 1;
131 $xml = $eRxPage->getXML();
133 $errors = $eRxPage->checkError($xml);
135 if(count($errors) > 0) {
138 <strong><?php echo xlt('NewCrop call failed'); ?></strong>
139 <ul>
140 <?php foreach($errors as $message) { echo '<li>'.$message.'</li>'; } ?>
141 <ul>
142 <?php
144 } else {
146 $eRxPage->updatePatientData();
149 <script type="text/javascript">
150 <?php require($GLOBALS['srcdir'].'/restoreSession.php'); ?>
151 </script>
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; ?>">
155 </form>
156 <script type="text/javascript" src="../library/js/jquery.1.3.2.js"></script>
157 <script type="text/javascript">
158 window.setTimeout(function() {
159 document.forms[0].submit();
160 }, <?php echo $delay; ?>);
161 </script>
162 <?php
169 </body>
170 </html>