Fully responsive globals.php with vertical menu (#2460)
[openemr.git] / interface / weno / confirm.php
blob9fcddf8c877cc27957b1a999bd5f4104f3411474
1 <?php
2 /**
3 * weno rx confirm
5 * @package OpenEMR
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();
34 <html>
35 <head>
36 <?php Header::setupHeader(['jquery-ui', 'jquery-ui-sunny']); ?>
39 <style>
40 footer {
41 padding: 0.5em;
42 font-size: 0.5em;
44 clear: left;
45 text-align: center;
46 top: 200px;
48 </style>
49 </head>
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">
56 <thead>
57 <th class='text-center'><?php print xlt("Drug"); ?></th>
58 <th class='text-center'><?php print xlt("Quantity"); ?></th>
59 </thead>
60 <?php
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'];
71 </table>
72 </div>
73 <?php if (empty($drug)) {
74 echo "<br> <p class='text-danger'><strong> ".xlt("No prescriptions selected"). "</strong></p>";
75 exit;
78 <div id="fields">
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">
82 <?php
83 if (!$patientPharmacy['name']) {
84 print "<b>".xlt("Please set pharmacy in patient\'s chart!")."</b><br> <br>";
85 } else {
86 print text($patientPharmacy['name']);
88 ?><br> <br>
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>
94 <br><br>
95 <input type='submit' id='confirm_btn' value='<?php print xla("Approve Order"); ?>' >
96 </div>
98 <div id="transmit" hidden>
99 <br><br>
100 <input type='submit' id='order' value='<?php print xla("Transmit Order"); ?>' >
101 </div>
102 <div id="success"></div>
103 </div>
105 <script type="text/javascript">
108 $(function(){
111 var toTran = <?php echo json_encode($drug); ?>; //pass php array to jquery script
112 var jsonArray = [];
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')) {
121 pharm_Id;
124 if($('#mailOrder').is(':checked')) {
126 pharm_Id;
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
147 $.ajax({
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){
156 console.log(xhr);
157 console.log(status);
158 console.log(error);
159 console.warn(xhr.responseText);
162 }); //end of
163 }); //end of confirm button
165 //Transmit order(s)
166 $('#order').click(function() {
167 $('#success').html("<i class='fa fa-refresh fa-spin fa-3x fa-fw'></i>");
168 var request = [];
169 var responses = [];
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) {
174 request.push(
175 $.ajax({
176 type: 'POST',
177 dataType: 'JSON',
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) {
185 console.log(xhr);
186 console.log(status);
187 console.log(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
212 </script>
213 <br>
214 <br>
215 <br>
217 <footer>
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>
219 </footer>
220 </body>
221 </html>