LBF custom template (nation notes) fancybox replace.
[openemr.git] / interface / eRx.php
blob49a83bf55ee33fbcd0da4592b1652104facfd166
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 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');
32 set_time_limit(0);
34 function array_key_exists_default($key, $search, $default = null)
36 if (array_key_exists($key, $search)) {
37 $value = $search[$key];
38 } else {
39 $value = $default;
42 return $value;
45 $eRxPage = new eRxPage(
46 new eRxXMLBuilder(
47 new eRxGlobals($GLOBALS),
48 new eRxStore
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);
59 <html>
60 <body>
61 <?php
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>
69 <ul>
70 <?php foreach ($missingExtensions as $missingExtension) {
71 echo '<li>'.text($missingExtension).'</li>';
72 } ?>
73 <ul>
74 <?php
75 } else {
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>
82 <ul>
83 <?php foreach ($messages['demographics'] as $message) {
84 echo '<li>'.text($message).'</li>';
85 } ?>
86 <ul>
87 <p><?php echo xlt('You will be automatically redirected to Demographics. You may make the necessary corrections and navigate to NewCrop again.'); ?></p>
88 <?php
90 ob_end_flush();
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; ?>);
97 </script>
98 <?php
99 } elseif (count($messages['empty']) > 0) {
101 <p><?php echo xlt('The following fields have to be filled to send a request.'); ?></p>
102 <ul>
103 <?php foreach ($messages['empty'] as $message) {
104 echo '<li>'.text($message).'</li>';
105 } ?>
106 <ul>
107 <?php
108 } else {
109 if (count($messages['warning']) > 0) {
111 <strong><?php echo xlt('Warning'); ?></strong>
112 <p><?php echo xlt('The following fields are empty.'); ?></p>
113 <ul>
114 <?php foreach ($messages['warning'] as $message) {
115 echo '<li>'.text($message).'</li>';
116 } ?>
117 <ul>
118 <p><strong><?php echo xlt('This will not prevent you from going to the e-Prescriptions site.'); ?></strong></p>
119 <?php
121 ob_end_flush();
122 $delay = (count($messages) * 2000) + 3000;
123 } else {
124 $delay = 1;
127 $xml = $eRxPage->getXML();
129 $errors = $eRxPage->checkError($xml);
131 if (count($errors) > 0) {
133 <strong><?php echo xlt('NewCrop call failed'); ?></strong>
134 <ul>
135 <?php foreach ($errors as $message) {
136 echo '<li>'.$message.'</li>';
137 } ?>
138 <ul>
139 <?php
140 } else {
141 $eRxPage->updatePatientData();
144 <script type="text/javascript">
145 <?php require($GLOBALS['srcdir'].'/restoreSession.php'); ?>
146 </script>
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; ?>">
150 </form>
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; ?>);
156 </script>
157 <?php
163 </body>
164 </html>