3 * interface/eRx.php Redirect to NewCrop pages.
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');
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);
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
>
61 <?php
foreach ($missingExtensions as $missingExtension) {
62 echo '<li>'.text($missingExtension).'</li>';
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
>
74 <?php
foreach ($messages['demographics'] as $message) {
75 echo '<li>'.text($message).'</li>';
78 <p
><?php
echo xlt('You will be automatically redirected to Demographics. You may make the necessary corrections and navigate to NewCrop again.'); ?
></p
>
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; ?
>);
90 } elseif (count($messages['empty']) > 0) {
92 <p
><?php
echo xlt('The following fields have to be filled to send a request.'); ?
></p
>
94 <?php
foreach ($messages['empty'] as $message) {
95 echo '<li>'.text($message).'</li>';
100 if (count($messages['warning']) > 0) {
102 <strong
><?php
echo xlt('Warning'); ?
></strong
>
103 <p
><?php
echo xlt('The following fields are empty.'); ?
></p
>
105 <?php
foreach ($messages['warning'] as $message) {
106 echo '<li>'.text($message).'</li>';
109 <p
><strong
><?php
echo xlt('This will not prevent you from going to the e-Prescriptions site.'); ?
></strong
></p
>
113 $delay = (count($messages) * 2000) +
3000;
118 $xml = $eRxPage->getXML();
120 $errors = $eRxPage->checkError($xml);
122 if (count($errors) > 0) {
124 <strong
><?php
echo xlt('NewCrop call failed'); ?
></strong
>
126 <?php
foreach ($errors as $message) {
127 echo '<li>'.text($message).'</li>';
132 $eRxPage->updatePatientData();
135 <script type
="text/javascript">
136 <?php
require($GLOBALS['srcdir'].'/restoreSession.php'); ?
>
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); ?>">
142 <script type
="text/javascript">
143 window
.setTimeout(function() {
144 document
.forms
[0].submit();
145 }, <?php
echo $delay; ?
>);