6 * @link http://www.open-emr.org
7 * @author Sherwin Gaddis <sherwingaddis@gmail.com>
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2016-2017 Sherwin Gaddis <sherwingaddis@gmail.com>
10 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once('../globals.php');
16 require_once("$srcdir/patient.inc");
18 use OpenEMR\Core\Header
;
19 use OpenEMR\Rx\Weno\TransmitData
;
21 $date = date("Y-m-d");
22 $pid = $GLOBALS['pid'];
23 $uid = $_SESSION['authUserID']; //username of the person for this session
25 $tData = new TransmitData();
27 $send = $tData->getDrugList($pid, $date);
28 $provider = $tData->getProviderFacility($uid);
29 $patientPharmacy = $tData->patientPharmacyInfo($pid);
30 $mailOrder = $tData->mailOrderPharmacy();
36 <?php Header
::setupHeader(['jquery-ui', 'jquery-ui-sunny']); ?
>
51 <body
class="body_top">
53 <h2
><?php
print xlt("Prescription Transmit Review"); ?
></h2
>
54 <div
class="table-responsive text-center" style
="margin-left:10%;width:75%;">
55 <table
class="table table-condensed table-striped">
57 <th
class='text-center'><?php
print xlt("Drug"); ?
></th
>
58 <th
class='text-center'><?php
print xlt("Quantity"); ?
></th
>
61 //List drugs to be sent
63 $drug = array(); //list of records that need to updated with pharmacy information
64 while ($list = sqlFetchArray($send)) {
65 print "<tr class='text-center'><td>". text($list['drug']) . " </td><td> " . text($list['quantity']) . "</td></tr>";
66 $drug[] = $list['id'];
73 <?php
if (empty($drug)) {
74 echo "<br> <p class='text-danger'><strong> ".xlt("No prescriptions selected"). "</strong></p>";
79 <h3
><?php
echo xlt("Select Pharmacy"); ?
></h3
>
80 <?php
echo xlt("Patient Default"); ?
> <br
>
81 <input type
= 'radio' name
= "pharmacy" id
= 'patientPharmacy' value
="<?php print attr($patientPharmacy['pharmacy_id']) ?>" checked
="checked">
83 if (!$patientPharmacy['name']) {
84 print "<b>".xlt("Please set pharmacy in patient\'s chart!")."</b><br> <br>";
86 print text($patientPharmacy['name']);
90 <?php
print xlt("Mail Order") ?
> <br
>
91 <input type
= 'radio' name
= 'pharmacy' id
= 'mailOrder' value
= "<?php print attr($mailOrder['id']) ?>"><?php
print "CCS Medical 14255 49th Street, North, Clearwater, FL 33762 <br>" ?
>
93 <div id
="confirm" show
>
95 <input type
='submit' id
='confirm_btn' value
='<?php print xla("Approve Order"); ?>' >
98 <div id
="transmit" hidden
>
100 <input type
='submit' id
='order' value
='<?php print xla("Transmit Order"); ?>' >
102 <div id
="success"></div
>
105 <script type
="text/javascript">
111 var toTran
= <?php
echo json_encode($drug); ?
>; //pass php array to jquery script
114 //Updates the order with the pharmacy information
115 $
("#confirm_btn").click(function(){
117 var pharm_Id
= $
("input[name='pharmacy']:checked").val();
119 if($
('#patientPharmacy').is(':checked')) {
124 if($
('#mailOrder').is(':checked')) {
129 //Shows the transmit button after selecting approved
130 $
("#transmit").toggle();
131 //Hide the approve button after selection
132 $
("#confirm").toggle();
134 //this is to set the pharmacy for the presciption(s)
135 $
.ajax({ url
: 'markTx.php?arr=' +
encodeURIComponent(pharm_Id
) +
',' +
encodeURIComponent(toTran
) +
'&csrf_token_form=' +
<?php
echo js_url(collectCsrfToken()); ?
> });
137 //Makes the returned ajax call a global variable
138 function getReturnJson(x
){
139 //to process multiple prescriptions.
140 jsonArray
.push(returnedJson
= x
);
144 //loop through the prescription to create json code on fly
145 $
.each(toTran
, function( index
, value
) {
146 //this is to create the json script to be transmitted
148 //feeds the json generator
149 url
: 'jsonScript.php?getJson=' +
encodeURIComponent(pharm_Id
) +
',' +
encodeURIComponent(value
) +
'&csrf_token_form=' +
<?php
echo js_url(collectCsrfToken()); ?
>,
151 success
: function(response
){
152 console
.log(response
);
153 getReturnJson(response
);
155 error
: function(xhr
, status
, error
){
159 console
.warn(xhr
.responseText
);
163 }); //end of confirm button
166 $
('#order').click(function() {
167 $
('#success').html("<i class='fa fa-refresh fa-spin fa-3x fa-fw'></i>");
170 // Lets not talk to user here because most likely won't make to user anyway.
171 // So we'll batch the ajax calls with an apply and promise so everyone is happy.
172 // This isn't foolproof so look here if not batching large json requests.
173 $
.each(jsonArray
, function(index
, value
) {
178 url
: 'https://apa.openmedpractice.com/apa/interface/weno/receivingrx.php?',
179 data
: {"scripts": value
},
181 success
: function (response
) {
182 responses
.push(response
);
184 error
: function (xhr
, status
, error
) {
188 console
.warn(xhr
.responseText
);
190 }) //end of ajax push
192 }); // end of each loop
194 $
("#transmit").toggle(); // turn off xmit button for spinner
196 // here we apply actual weno server requests and I've been promised
197 // a done event to present results to user in one shot.
198 $
.when
.apply(null, request
).done(function() {
199 // all done with our requests, lets announce what weno says.
200 var announce
= <?php
echo xlj("Send Complete - Prescription(s) Return Status");?
>;
201 $
('#success').html('<p><h4 class="bg-info">' + announce +
'</h4></p>');
202 $
.each(responses
, function (index
, response
) {
203 console
.log('result: ' + response
);
204 $
('#success').append('<p>' + response +
'</p>');
208 }); // That's it for click event.
210 }); //end of doc ready
218 <p
><?php
print xlt("Open Med Practice and its suppliers use their commercially reasonable efforts to provide the most current and complete data available to them concerning prescription histories, drug interactions and formularies, patient allergies and other factors, but by your use of this service you acknowledge that (1) the completeness and accuracy of such data depends upon the completeness and accuracy with which it is entered into connected electronic databases by physicians, physician’s offices, pharmaceutical benefits managers, electronic medical records firms, and other network participants, (2) such data is subject to error or omission in input, storage or retrieval, transmission and display, technical disruption, power or service outages, or other interruptions in electronic communication, any or all of which may be beyond the control of Open Med Practice and its suppliers, and (3) some information may be unavailable due to regulatory, contractual, privacy or other legal restrictions. You are responsible to use your clinical judgment at all times in rendering medical service and advice."); ?
></p
>