bug fix bundle (#2018)
[openemr.git] / interface / eRx.php
blob33f90176302ed8400c5ac74696ba2f609442f2a5
1 <?php
2 /**
3 * interface/eRx.php Redirect to NewCrop pages.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Eldho Chacko <eldho@zhservices.com>
8 * @author Vinish K <vinish@zhservices.com>
9 * @author Sam Likins <sam.likins@wsi-services.com>
10 * @author Brady Miller <brady.g.miller@gmail.com>
11 * @copyright Copyright (c) 2011 ZMG LLC <sam@zhservices.com>
12 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
13 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
17 require_once(__DIR__.'/globals.php');
18 require_once($GLOBALS['fileroot'].'/interface/eRxGlobals.php');
19 require_once($GLOBALS['fileroot'].'/interface/eRxStore.php');
20 require_once($GLOBALS['fileroot'].'/interface/eRxXMLBuilder.php');
21 require_once($GLOBALS['fileroot'].'/interface/eRxPage.php');
23 set_time_limit(0);
25 function array_key_exists_default($key, $search, $default = null)
27 if (array_key_exists($key, $search)) {
28 $value = $search[$key];
29 } else {
30 $value = $default;
33 return $value;
36 $eRxPage = new eRxPage(
37 new eRxXMLBuilder(
38 new eRxGlobals($GLOBALS),
39 new eRxStore
43 $eRxPage->setAuthUserId(array_key_exists_default('authUserID', $_SESSION))
44 ->setDestination(array_key_exists_default('page', $_REQUEST))
45 ->setPatientId(array_key_exists_default('pid', $GLOBALS))
46 ->setPrescriptionIds(array_key_exists_default('id', $_REQUEST))
47 ->setPrescriptionCount(60);
50 <html>
51 <body>
52 <?php
54 $missingExtensions = $eRxPage->checkForMissingExtensions();
56 if (count($missingExtensions) > 0) {
58 <strong><?php echo xlt('Error'); ?>:</strong>
59 <p><?php echo xlt('Please contact your systems administrator, the following component(s) are required but are missing.'); ?></p>
60 <ul>
61 <?php foreach ($missingExtensions as $missingExtension) {
62 echo '<li>'.text($missingExtension).'</li>';
63 } ?>
64 <ul>
65 <?php
66 } else {
67 $messages = $eRxPage->buildXML();
69 if (count($messages['demographics']) > 0) {
71 <strong><?php echo xlt('Warning'); ?>:</strong>
72 <p><?php echo xlt('The following fields have to be filled to send a request.'); ?></p>
73 <ul>
74 <?php foreach ($messages['demographics'] as $message) {
75 echo '<li>'.text($message).'</li>';
76 } ?>
77 <ul>
78 <p><?php echo xlt('You will be automatically redirected to Demographics. You may make the necessary corrections and navigate to NewCrop again.'); ?></p>
79 <?php
81 ob_end_flush();
84 <script type="text/javascript">
85 window.setTimeout(function() {
86 window.location = "<?php echo $GLOBALS['webroot']; ?>/interface/patient_file/summary/demographics_full.php";
87 }, <?php echo (count($messages) * 2000) + 3000; ?>);
88 </script>
89 <?php
90 } elseif (count($messages['empty']) > 0) {
92 <p><?php echo xlt('The following fields have to be filled to send a request.'); ?></p>
93 <ul>
94 <?php foreach ($messages['empty'] as $message) {
95 echo '<li>'.text($message).'</li>';
96 } ?>
97 <ul>
98 <?php
99 } else {
100 if (count($messages['warning']) > 0) {
102 <strong><?php echo xlt('Warning'); ?></strong>
103 <p><?php echo xlt('The following fields are empty.'); ?></p>
104 <ul>
105 <?php foreach ($messages['warning'] as $message) {
106 echo '<li>'.text($message).'</li>';
107 } ?>
108 <ul>
109 <p><strong><?php echo xlt('This will not prevent you from going to the e-Prescriptions site.'); ?></strong></p>
110 <?php
112 ob_end_flush();
113 $delay = (count($messages) * 2000) + 3000;
114 } else {
115 $delay = 1;
118 $xml = $eRxPage->getXML();
120 $errors = $eRxPage->checkError($xml);
122 if (count($errors) > 0) {
124 <strong><?php echo xlt('NewCrop call failed'); ?></strong>
125 <ul>
126 <?php foreach ($errors as $message) {
127 echo '<li>'.text($message).'</li>';
128 } ?>
129 <ul>
130 <?php
131 } else {
132 $eRxPage->updatePatientData();
135 <script type="text/javascript">
136 <?php require($GLOBALS['srcdir'].'/restoreSession.php'); ?>
137 </script>
138 <form name="info" method="post" action="<?php echo $GLOBALS['erx_newcrop_path']; ?>" onsubmit="return top.restoreSession()">
139 <input type="submit" style="display:none">
140 <input type="hidden" id="RxInput" name="RxInput" value="<?php echo attr($xml); ?>">
141 </form>
142 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-1-3-2/jquery.js"></script>
143 <script type="text/javascript">
144 window.setTimeout(function() {
145 document.forms[0].submit();
146 }, <?php echo $delay; ?>);
147 </script>
148 <?php
154 </body>
155 </html>