forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eRx.php
158 lines (139 loc) · 4.97 KB
/
eRx.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
/**
* interface/eRx.php Redirect to NewCrop pages.
*
* @package OpenEMR
* @link http://www.open-emr.org
* @author Eldho Chacko <[email protected]>
* @author Vinish K <[email protected]>
* @author Sam Likins <[email protected]>
* @author Brady Miller <[email protected]>
* @copyright Copyright (c) 2011 ZMG LLC <[email protected]>
* @copyright Copyright (c) 2018 Brady Miller <[email protected]>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/
require_once(__DIR__ . '/globals.php');
require_once($GLOBALS['fileroot'] . '/interface/eRxGlobals.php');
require_once($GLOBALS['fileroot'] . '/interface/eRxStore.php');
require_once($GLOBALS['fileroot'] . '/interface/eRxXMLBuilder.php');
require_once($GLOBALS['fileroot'] . '/interface/eRxPage.php');
set_time_limit(0);
function array_key_exists_default($key, $search, $default = null)
{
if (array_key_exists($key, $search)) {
$value = $search[$key];
} else {
$value = $default;
}
return $value;
}
$GLOBALS_REF = $GLOBALS;
$eRxPage = new eRxPage(
new eRxXMLBuilder(
new eRxGlobals($GLOBALS_REF),
new eRxStore()
)
);
$eRxPage->setAuthUserId(array_key_exists_default('authUserID', $_SESSION))
->setDestination(array_key_exists_default('page', $_REQUEST))
->setPatientId(array_key_exists_default('pid', $GLOBALS))
->setPrescriptionIds(array_key_exists_default('id', $_REQUEST))
->setPrescriptionCount(60);
?>
<html>
<head>
<title><?php echo xlt('New Crop'); ?></title>
</head>
<body>
<?php
$missingExtensions = $eRxPage->checkForMissingExtensions();
if (count($missingExtensions) > 0) {
?>
<strong><?php echo xlt('Error'); ?>:</strong>
<p><?php echo xlt('Please contact your systems administrator, the following component(s) are required but are missing.'); ?></p>
<ul>
<?php foreach ($missingExtensions as $missingExtension) {
echo '<li>' . text($missingExtension) . '</li>';
} ?>
<ul>
<?php
} else {
$messages = $eRxPage->buildXML();
if (count($messages['demographics']) > 0) {
?>
<strong><?php echo xlt('Warning'); ?>:</strong>
<p><?php echo xlt('The following fields have to be filled to send a request.'); ?></p>
<ul>
<?php foreach ($messages['demographics'] as $message) {
echo '<li>' . text($message) . '</li>';
} ?>
<ul>
<p><?php echo xlt('You will be automatically redirected to Demographics. You may make the necessary corrections and navigate to NewCrop again.'); ?></p>
<?php
ob_end_flush();
?>
<script>
window.setTimeout(function() {
window.location = "<?php echo $GLOBALS['webroot']; ?>/interface/patient_file/summary/demographics_full.php";
}, <?php echo (count($messages) * 2000) + 3000; ?>);
</script>
<?php
} elseif (count($messages['empty']) > 0) {
?>
<p><?php echo xlt('The following fields have to be filled to send a request.'); ?></p>
<ul>
<?php foreach ($messages['empty'] as $message) {
echo '<li>' . text($message) . '</li>';
} ?>
<ul>
<?php
} else {
if (count($messages['warning']) > 0) {
?>
<strong><?php echo xlt('Warning'); ?></strong>
<p><?php echo xlt('The following fields are empty.'); ?></p>
<ul>
<?php foreach ($messages['warning'] as $message) {
echo '<li>' . text($message) . '</li>';
} ?>
<ul>
<p><strong><?php echo xlt('This will not prevent you from going to the e-Prescriptions site.'); ?></strong></p>
<?php
ob_end_flush();
$delay = (count($messages) * 2000) + 3000;
} else {
$delay = 1;
}
$xml = $eRxPage->getXML();
$errors = $eRxPage->checkError($xml);
if (count($errors) > 0) {
?>
<strong><?php echo xlt('NewCrop call failed'); ?></strong>
<ul>
<?php foreach ($errors as $message) {
echo '<li>' . text($message) . '</li>';
} ?>
<ul>
<?php
} else {
$eRxPage->updatePatientData();
?>
<script>
<?php require($GLOBALS['srcdir'] . '/restoreSession.php'); ?>
</script>
<form name="info" method="post" action="<?php echo $GLOBALS['erx_newcrop_path']; ?>" onsubmit="return top.restoreSession()">
<input type="submit" style="display:none">
<input type="hidden" id="RxInput" name="RxInput" value="<?php echo attr($xml); ?>">
</form>
<script>
window.setTimeout(function() {
document.forms[0].submit();
}, <?php echo $delay; ?>);
</script>
<?php
}
}
}
?>
</body>
</html>