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 $GLOBALS_REF = $GLOBALS;
37 $eRxPage = new eRxPage(
39 new eRxGlobals($GLOBALS_REF),
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);
53 <title
><?php
echo xlt('New Crop'); ?
></title
>
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
>
65 <?php
foreach ($missingExtensions as $missingExtension) {
66 echo '<li>' . text($missingExtension) . '</li>';
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
>
78 <?php
foreach ($messages['demographics'] as $message) {
79 echo '<li>' . text($message) . '</li>';
82 <p
><?php
echo xlt('You will be automatically redirected to Demographics. You may make the necessary corrections and navigate to NewCrop again.'); ?
></p
>
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; ?
>);
94 } elseif (count($messages['empty']) > 0) {
96 <p
><?php
echo xlt('The following fields have to be filled to send a request.'); ?
></p
>
98 <?php
foreach ($messages['empty'] as $message) {
99 echo '<li>' . text($message) . '</li>';
104 if (count($messages['warning']) > 0) {
106 <strong
><?php
echo xlt('Warning'); ?
></strong
>
107 <p
><?php
echo xlt('The following fields are empty.'); ?
></p
>
109 <?php
foreach ($messages['warning'] as $message) {
110 echo '<li>' . text($message) . '</li>';
113 <p
><strong
><?php
echo xlt('This will not prevent you from going to the e-Prescriptions site.'); ?
></strong
></p
>
117 $delay = (count($messages) * 2000) +
3000;
122 $xml = $eRxPage->getXML();
124 $errors = $eRxPage->checkError($xml);
126 if (count($errors) > 0) {
128 <strong
><?php
echo xlt('NewCrop call failed'); ?
></strong
>
130 <?php
foreach ($errors as $message) {
131 echo '<li>' . text($message) . '</li>';
136 $eRxPage->updatePatientData();
140 <?php
require($GLOBALS['srcdir'] . '/restoreSession.php'); ?
>
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); ?>">
147 window
.setTimeout(function() {
148 document
.forms
[0].submit();
149 }, <?php
echo $delay; ?
>);