4 * interface/eRx.php Redirect to NewCrop pages.
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');
25 function array_key_exists_default($key, $search, $default = null)
27 if (array_key_exists($key, $search)) {
28 $value = $search[$key];
36 $eRxPage = new eRxPage(
38 new eRxGlobals($GLOBALS),
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);
52 <title
><?php
echo xlt('New Crop'); ?
></title
>
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
>
64 <?php
foreach ($missingExtensions as $missingExtension) {
65 echo '<li>' . text($missingExtension) . '</li>';
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
>
77 <?php
foreach ($messages['demographics'] as $message) {
78 echo '<li>' . text($message) . '</li>';
81 <p
><?php
echo xlt('You will be automatically redirected to Demographics. You may make the necessary corrections and navigate to NewCrop again.'); ?
></p
>
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; ?
>);
93 } elseif (count($messages['empty']) > 0) {
95 <p
><?php
echo xlt('The following fields have to be filled to send a request.'); ?
></p
>
97 <?php
foreach ($messages['empty'] as $message) {
98 echo '<li>' . text($message) . '</li>';
103 if (count($messages['warning']) > 0) {
105 <strong
><?php
echo xlt('Warning'); ?
></strong
>
106 <p
><?php
echo xlt('The following fields are empty.'); ?
></p
>
108 <?php
foreach ($messages['warning'] as $message) {
109 echo '<li>' . text($message) . '</li>';
112 <p
><strong
><?php
echo xlt('This will not prevent you from going to the e-Prescriptions site.'); ?
></strong
></p
>
116 $delay = (count($messages) * 2000) +
3000;
121 $xml = $eRxPage->getXML();
123 $errors = $eRxPage->checkError($xml);
125 if (count($errors) > 0) {
127 <strong
><?php
echo xlt('NewCrop call failed'); ?
></strong
>
129 <?php
foreach ($errors as $message) {
130 echo '<li>' . text($message) . '</li>';
135 $eRxPage->updatePatientData();
139 <?php
require($GLOBALS['srcdir'] . '/restoreSession.php'); ?
>
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); ?>">
146 window
.setTimeout(function() {
147 document
.forms
[0].submit();
148 }, <?php
echo $delay; ?
>);