Hide dashboard card 2 (#7423)
[openemr.git] / interface / eRx.php
blobe252fdab2c54a211cceb84f23eed6ccfde30e549
1 <?php
3 /**
4 * interface/eRx.php Redirect to NewCrop pages.
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Eldho Chacko <eldho@zhservices.com>
9 * @author Vinish K <vinish@zhservices.com>
10 * @author Sam Likins <sam.likins@wsi-services.com>
11 * @author Brady Miller <brady.g.miller@gmail.com>
12 * @copyright Copyright (c) 2011 ZMG LLC <sam@zhservices.com>
13 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
14 * @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 $GLOBALS_REF = $GLOBALS;
37 $eRxPage = new eRxPage(
38 new eRxXMLBuilder(
39 new eRxGlobals($GLOBALS_REF),
40 new eRxStore()
44 $eRxPage->setAuthUserId(array_key_exists_default('authUserID', $_SESSION))
45 ->setDestination(array_key_exists_default('page', $_REQUEST))
46 ->setPatientId(array_key_exists_default('pid', $GLOBALS))
47 ->setPrescriptionIds(array_key_exists_default('id', $_REQUEST))
48 ->setPrescriptionCount(60);
51 <html>
52 <head>
53 <title><?php echo xlt('New Crop'); ?></title>
54 </head>
55 <body>
56 <?php
58 $missingExtensions = $eRxPage->checkForMissingExtensions();
60 if (count($missingExtensions) > 0) {
62 <strong><?php echo xlt('Error'); ?>:</strong>
63 <p><?php echo xlt('Please contact your systems administrator, the following component(s) are required but are missing.'); ?></p>
64 <ul>
65 <?php foreach ($missingExtensions as $missingExtension) {
66 echo '<li>' . text($missingExtension) . '</li>';
67 } ?>
68 <ul>
69 <?php
70 } else {
71 $messages = $eRxPage->buildXML();
73 if (count($messages['demographics']) > 0) {
75 <strong><?php echo xlt('Warning'); ?>:</strong>
76 <p><?php echo xlt('The following fields have to be filled to send a request.'); ?></p>
77 <ul>
78 <?php foreach ($messages['demographics'] as $message) {
79 echo '<li>' . text($message) . '</li>';
80 } ?>
81 <ul>
82 <p><?php echo xlt('You will be automatically redirected to Demographics. You may make the necessary corrections and navigate to NewCrop again.'); ?></p>
83 <?php
85 ob_end_flush();
88 <script>
89 window.setTimeout(function() {
90 window.location = "<?php echo $GLOBALS['webroot']; ?>/interface/patient_file/summary/demographics_full.php";
91 }, <?php echo (count($messages) * 2000) + 3000; ?>);
92 </script>
93 <?php
94 } elseif (count($messages['empty']) > 0) {
96 <p><?php echo xlt('The following fields have to be filled to send a request.'); ?></p>
97 <ul>
98 <?php foreach ($messages['empty'] as $message) {
99 echo '<li>' . text($message) . '</li>';
100 } ?>
101 <ul>
102 <?php
103 } else {
104 if (count($messages['warning']) > 0) {
106 <strong><?php echo xlt('Warning'); ?></strong>
107 <p><?php echo xlt('The following fields are empty.'); ?></p>
108 <ul>
109 <?php foreach ($messages['warning'] as $message) {
110 echo '<li>' . text($message) . '</li>';
111 } ?>
112 <ul>
113 <p><strong><?php echo xlt('This will not prevent you from going to the e-Prescriptions site.'); ?></strong></p>
114 <?php
116 ob_end_flush();
117 $delay = (count($messages) * 2000) + 3000;
118 } else {
119 $delay = 1;
122 $xml = $eRxPage->getXML();
124 $errors = $eRxPage->checkError($xml);
126 if (count($errors) > 0) {
128 <strong><?php echo xlt('NewCrop call failed'); ?></strong>
129 <ul>
130 <?php foreach ($errors as $message) {
131 echo '<li>' . text($message) . '</li>';
132 } ?>
133 <ul>
134 <?php
135 } else {
136 $eRxPage->updatePatientData();
139 <script>
140 <?php require($GLOBALS['srcdir'] . '/restoreSession.php'); ?>
141 </script>
142 <form name="info" method="post" action="<?php echo $GLOBALS['erx_newcrop_path']; ?>" onsubmit="return top.restoreSession()">
143 <input type="submit" style="display:none">
144 <input type="hidden" id="RxInput" name="RxInput" value="<?php echo attr($xml); ?>">
145 </form>
146 <script>
147 window.setTimeout(function() {
148 document.forms[0].submit();
149 }, <?php echo $delay; ?>);
150 </script>
151 <?php
157 </body>
158 </html>