Skip to content
jmandel edited this page Mar 21, 2013 · 1 revision

Getting started in 2 minutes

The Scenario

Let's start with a simple app that will, on launch, fetch and log a patient's demographics.

Launching

Your app launches via OAuth2 implicit grant, with the following key parameters:

  • server: Query parameter containing the C-CDA Receiver URL
  • patient: Query parameter containing the in-context patient ID
  • access_token: Hash parameter containing an OAuth2 bearer token

Your app uses these parameters to construct an API call to the C-CDA Receiver. To help you parse these parameters and use them in your app, we provide a JavaScript client library:

<script src="smart-apps/public/common/smart.js"></script>

Issuing an API call

So to build an app that fetches and logs the current patient's demographics, we can just include the SMART client library (as well as jQuery to help issue AJAX calls), and then:

$.ajax({
  url: SMART.server + "/patients/"+SMART.patient,
  type: "GET",
  data: {
    access_token: SMART.auth.access_token
  },
  dataType:"json"
}).success(function(demographics){
  console.log(demographics);
});
Clone this wiki locally