Advertisement
Guest User

requesti

a guest
Jul 12th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $( document ).ready(function() {
  2.  
  3.     // authorization data
  4.     var username = "medrockweek1";
  5.     var password = "medrockweek1";
  6.    
  7.     // api query urls
  8.     var baseUrl = 'https://rest.ehrscape.com/rest/v1';
  9.     var queryUrl = baseUrl + '/query';
  10.    
  11.     function getSessionId() {
  12.        
  13.         var response = $.ajax({
  14.             type: "POST",
  15.             url: baseUrl + "/session?username=" + encodeURIComponent(username) +
  16.                     "&password=" + encodeURIComponent(password),
  17.             async: false
  18.         });
  19.         return response.responseJSON.sessionId;
  20.     }
  21.    
  22.     var sessionId = getSessionId();
  23.    
  24.     // console.log(sessionId);
  25.    
  26.     function getRequest(ehrId) {
  27.        
  28.         $.ajax({
  29.             url: baseUrl + "/view/" + ehrId + "/weight",
  30.             type: 'GET',
  31.             headers: {"Ehr-Session": sessionId},
  32.             success: function (data) {
  33.                 console.log(data);
  34.             }
  35.         });
  36.     }
  37.    
  38.     // test of our ehrid
  39.     getRequest("50bc1c98-8540-4d86-bbc7-813f7c55377e");
  40. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement