quick minor path updates (#1968)
[openemr.git] / interface / weno / ajax_sample_code.php
blobb00deb22bd0740460f9a30b1ec668c648680888e
1 <?php
2 /**
3 * weno rx ajax sample code
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Sherwin Gaddis <sherwingaddis@gmail.com>
8 * @copyright Copyright (c) 2016-2017 Sherwin Gaddis <sherwingaddis@gmail.com>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
12 require_once('../globals.php');
13 use OpenEMR\Core\Header;
16 <!DOCTYPE html>
17 <html>
18 <head>
19 <title><?php print xlt("Weno Sample Code") ?></title>
20 <?php Header::setupHeader(['jquery-ui', 'jquery-ui-sunny']); ?>
22 </head>
24 <body>
26 <h3><?php print xlt("Convert a JavaScript object into a JSON string, and send it to the server.") ?></h3>
28 <div id="confirm">
29 <br><br>
30 <input type='submit' id='confirm_btn' value='<?php print xla("Confirm") ?>' >
31 </div>
32 <div id="transmit">
33 <input type='submit' id='order' value='<?php print xla("Transmit Order") ?>' >
34 </div>
35 <div id="success"></div>
37 <script>
39 $(document).ready(function(){
42 $("#transmit").hide();
43 $("#confirm_btn").click(function(){
45 //build a process that will create the code below for transmit.
46 //each drug transmitted has to be separate
48 $("#transmit").show();
50 });
52 $('#order').click(function(){
53 $('#success').html("<i class="fa fa-refresh fa-spin fa-3x fa-fw"></i>");
54 var patient = { "patient": {
55 "lname" : "Ike",
56 "fname" : "Turner",
57 "street" : "123 Franklin Blvd",
58 "city" : "Chesapeake",
59 "postal" : 23323,
60 "DOB" : "1951-01-03",
61 "Sex" : "M"
62 }};
64 var provider = {"provider": {
65 "provlname" : "Mark",
66 "provfname" : "East",
67 "provnpi" : 1033137377,
68 "facilityphone" : 7573331212,
69 "facilityfax" : 7574441212,
70 "facilityname" : "East Cardiology",
71 "facilitystreet" : "127 Albert Dr.",
72 "facilitycity" : "Chesapeake",
73 "facilitystate" : "VA",
74 "facilityzip" : 23320,
75 "qualifier" : "D91539:C29729",
76 "wenoAccountId" : "111",
77 "wenoAccountPass" : "A80B97AB1A80B92084CB86DE61A1F82A6979990B",
78 "wenoClinicId" : "D91539:C29729"
79 }};
80 var pharmacy = {"pharmacy": {
81 "storename":"Test Direct Pharmacy",
82 "storenpi":321,
83 "pharmacy":1234567,
84 "pharmacyPhone":2109128143,
85 "pharmacyFax":5128525926
86 }};
88 var script = {"script": {
89 "drugName" : "tylonal ES TABS",
90 "drug_NDC" : 405012301,
91 "dateAdded" : "2017-02-02",
92 "quantity" : 50,
93 "refills" : 3,
94 "dateModified" : "2017-02-15",
95 "note" : "add not to pharmacy",
96 "take" : "once a day"
97 }};
100 var sendPatient = JSON.stringify(patient);
101 var sendProvider = JSON.stringify(provider);
102 var sendPharmacy = JSON.stringify(pharmacy);
103 var sendScript = JSON.stringify(script);
104 var send = '['+sendPatient+','+sendProvider+','+sendPharmacy+','+sendScript+']';
106 $.ajax({
107 type: 'POST',
108 dataType: 'JSON',
109 url: 'https://apa.openmedpractice.com/apa/interface/weno/receivingrx.php?',
110 data: {"scripts": send},
112 success: function(response){
113 console.log(response);
115 $('#success').html('<p>'+response+'</p>');
117 error: function(xhr, status, error){
118 console.log(xhr);
119 console.log(status);
120 console.log(error);
121 console.warn(xhr.responseText);
128 </script>
130 </body>
131 </html>