Update X12_5010_837P.php (#2599)
[openemr.git] / interface / eRx.php
blobba5a75001d4ccfe45c60624954af476fc30077f1
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 <head>
52 <title><?php echo xlt('New Crop'); ?></title>
53 </head>
54 <body>
55 <?php
57 $missingExtensions = $eRxPage->checkForMissingExtensions();
59 if (count($missingExtensions) > 0) {
61 <strong><?php echo xlt('Error'); ?>:</strong>
62 <p><?php echo xlt('Please contact your systems administrator, the following component(s) are required but are missing.'); ?></p>
63 <ul>
64 <?php foreach ($missingExtensions as $missingExtension) {
65 echo '<li>'.text($missingExtension).'</li>';
66 } ?>
67 <ul>
68 <?php
69 } else {
70 $messages = $eRxPage->buildXML();
72 if (count($messages['demographics']) > 0) {
74 <strong><?php echo xlt('Warning'); ?>:</strong>
75 <p><?php echo xlt('The following fields have to be filled to send a request.'); ?></p>
76 <ul>
77 <?php foreach ($messages['demographics'] as $message) {
78 echo '<li>'.text($message).'</li>';
79 } ?>
80 <ul>
81 <p><?php echo xlt('You will be automatically redirected to Demographics. You may make the necessary corrections and navigate to NewCrop again.'); ?></p>
82 <?php
84 ob_end_flush();
87 <script type="text/javascript">
88 window.setTimeout(function() {
89 window.location = "<?php echo $GLOBALS['webroot']; ?>/interface/patient_file/summary/demographics_full.php";
90 }, <?php echo (count($messages) * 2000) + 3000; ?>);
91 </script>
92 <?php
93 } elseif (count($messages['empty']) > 0) {
95 <p><?php echo xlt('The following fields have to be filled to send a request.'); ?></p>
96 <ul>
97 <?php foreach ($messages['empty'] as $message) {
98 echo '<li>'.text($message).'</li>';
99 } ?>
100 <ul>
101 <?php
102 } else {
103 if (count($messages['warning']) > 0) {
105 <strong><?php echo xlt('Warning'); ?></strong>
106 <p><?php echo xlt('The following fields are empty.'); ?></p>
107 <ul>
108 <?php foreach ($messages['warning'] as $message) {
109 echo '<li>'.text($message).'</li>';
110 } ?>
111 <ul>
112 <p><strong><?php echo xlt('This will not prevent you from going to the e-Prescriptions site.'); ?></strong></p>
113 <?php
115 ob_end_flush();
116 $delay = (count($messages) * 2000) + 3000;
117 } else {
118 $delay = 1;
121 $xml = $eRxPage->getXML();
123 $errors = $eRxPage->checkError($xml);
125 if (count($errors) > 0) {
127 <strong><?php echo xlt('NewCrop call failed'); ?></strong>
128 <ul>
129 <?php foreach ($errors as $message) {
130 echo '<li>'.text($message).'</li>';
131 } ?>
132 <ul>
133 <?php
134 } else {
135 $eRxPage->updatePatientData();
138 <script type="text/javascript">
139 <?php require($GLOBALS['srcdir'].'/restoreSession.php'); ?>
140 </script>
141 <form name="info" method="post" action="<?php echo $GLOBALS['erx_newcrop_path']; ?>" onsubmit="return top.restoreSession()">
142 <input type="submit" style="display:none">
143 <input type="hidden" id="RxInput" name="RxInput" value="<?php echo attr($xml); ?>">
144 </form>
145 <script type="text/javascript">
146 window.setTimeout(function() {
147 document.forms[0].submit();
148 }, <?php echo $delay; ?>);
149 </script>
150 <?php
156 </body>
157 </html>