dump db version
[openemr.git] / interface / weno / ajax_sample_code.php
blob7c1ddcc55cfb10241c76651dd08701a51a640d8b
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
13 require_once('../globals.php');
15 use OpenEMR\Core\Header;
18 <!DOCTYPE html>
19 <html>
20 <head>
21 <title><?php print xlt("Weno Sample Code") ?></title>
22 <?php Header::setupHeader(['jquery-ui', 'jquery-ui-sunny']); ?>
24 </head>
26 <body>
28 <h3><?php print xlt("Convert a JavaScript object into a JSON string, and send it to the server.") ?></h3>
30 <div id="confirm">
31 <br><br>
32 <input type='submit' id='confirm_btn' value='<?php print xla("Confirm") ?>' >
33 </div>
34 <div id="transmit">
35 <input type='submit' id='order' value='<?php print xla("Transmit Order") ?>' >
36 </div>
37 <div id="success"></div>
39 <script>
41 $(document).ready(function(){
44 $("#transmit").hide();
45 $("#confirm_btn").click(function(){
47 //build a process that will create the code below for transmit.
48 //each drug transmitted has to be separate
50 $("#transmit").show();
52 });
54 $('#order').click(function(){
55 $('#success').html("<i class="fa fa-refresh fa-spin fa-3x fa-fw"></i>");
56 var patient = { "patient": {
57 "lname" : "Ike",
58 "fname" : "Turner",
59 "street" : "123 Franklin Blvd",
60 "city" : "Chesapeake",
61 "postal" : 23323,
62 "DOB" : "1951-01-03",
63 "Sex" : "M"
64 }};
66 var provider = {"provider": {
67 "provlname" : "Mark",
68 "provfname" : "East",
69 "provnpi" : 1033137377,
70 "facilityphone" : 7573331212,
71 "facilityfax" : 7574441212,
72 "facilityname" : "East Cardiology",
73 "facilitystreet" : "127 Albert Dr.",
74 "facilitycity" : "Chesapeake",
75 "facilitystate" : "VA",
76 "facilityzip" : 23320,
77 "qualifier" : "D91539:C29729",
78 "wenoAccountId" : "111",
79 "wenoAccountPass" : "A80B97AB1A80B92084CB86DE61A1F82A6979990B",
80 "wenoClinicId" : "D91539:C29729"
81 }};
82 var pharmacy = {"pharmacy": {
83 "storename":"Test Direct Pharmacy",
84 "storenpi":321,
85 "pharmacy":1234567,
86 "pharmacyPhone":2109128143,
87 "pharmacyFax":5128525926
88 }};
90 var script = {"script": {
91 "drugName" : "tylonal ES TABS",
92 "drug_NDC" : 405012301,
93 "dateAdded" : "2017-02-02",
94 "quantity" : 50,
95 "refills" : 3,
96 "dateModified" : "2017-02-15",
97 "note" : "add not to pharmacy",
98 "take" : "once a day"
99 }};
102 var sendPatient = JSON.stringify(patient);
103 var sendProvider = JSON.stringify(provider);
104 var sendPharmacy = JSON.stringify(pharmacy);
105 var sendScript = JSON.stringify(script);
106 var send = '['+sendPatient+','+sendProvider+','+sendPharmacy+','+sendScript+']';
108 $.ajax({
109 type: 'POST',
110 dataType: 'JSON',
111 url: 'https://apa.openmedpractice.com/apa/interface/weno/receivingrx.php?',
112 data: {"scripts": send},
114 success: function(response){
115 console.log(response);
117 $('#success').html('<p>'+response+'</p>');
119 error: function(xhr, status, error){
120 console.log(xhr);
121 console.log(status);
122 console.log(error);
123 console.warn(xhr.responseText);
130 </script>
132 </body>
133 </html>