Fitness FHIR API - Fitbit Implementation Template
home
System APIs abstract away the complexity of core systems of record from end user data, while providing downstream insulation from any interface changes or rationalization of those systems. This API provides an implementation best practice to expose fitness data via a set of RESTful FHIR services in RAML, making it easy to consume within an enterprise.
Accelerator for Healthcare
This FHIR implementation is one of many components included in Accelerator for Healthcare. It provides organizations with connectivity assets that accelerate project delivery in healthcare, including pre-built API designs and implementations that support core healthcare business processes.
Contact info@mulesoft.com for more information.
License Agreement
This template is subject to the conditions of the MuleSoft License Agreement. Review the terms of the license before downloading and using this template. You can use this template for free with the Mule Enterprise Edition, CloudHub, or as a trial in Anypoint Studio.
Use Case
As a FitBit user I want a microservice to access data from the FitBit system and transform them to FHIR standard.
Healthcare Fitbit to FHIR System API is part of the Healthcare Templates Solution. This template calls FitBit API to retrieve required data from the FitBit system and transforms them to JSON following the FHIR specification version 3.0.1 STU3.
Considerations
To make this template run, there are certain preconditions that must be considered. Failing to do so can lead to unexpected behavior of the template.
Use Anypoint Studio v7.1.4 and later and Mule Runtime 4.1.1 and later to run this template.
Register your Fitbit Application
Create a new developer app at http://dev.fitbit.com/ with the OAuth 2.0 Application Type “Server”. Note that you need to define the Callback URL too. This is important as you would need to set this URL in property fitbit.redirect.uri
.
Key parameters to note once you’ve registered your app is the OAuth 2.0 Client ID, the Client (Consumer) Secret, and the Redirect URI.
Run the Application
Access the Fitbit OAuth login from a web browser at:
This gets you to the login landing page where you fill in your email and password. After the successful log in you are redirected to the URL specified in the app at http://dev.fitbit.com/. You can notice the access code in the URL.
To register a patient to this Fitbit account you need to do create the request GET https://YOUR_APP_DOMAIN.cloudhub.io/Patient/{id}/register?code=YOUR_ACCESS_CODE
where {id} represents the Patient ID, who wants to authorize to Fitbit account and access code is the one obtained after login with Fitbit credentials.
Run it!
Simple steps to get Healthcare Fitbit to FHIR System API running.
Where to Download Anypoint Studio and the Mule Runtime
If you are new to Mule, download this software:
Note: Anypoint Studio requires JDK 8.
Import into Studio
In Studio, click the Exchange X icon in the upper left of the taskbar, log in with your Anypoint Platform credentials, search for the template, and click Open.
Run in Studio
After you import the Template into Anypoint Studio, to follow these steps to run it:
- Generate a keystore and set up the truststore (you can find a detailed description on how to do so in TLS Configuration).
- Locate the properties file
mule.dev.properties
, in src/main/resources. - Complete all the properties required as per the examples in "Properties to Configure".
- Right click your template project folder.
- Hover your mouse over Run As.
- Click Mule Application.
Run Stand Alone
Fill in all the properties in one of the property files, for example in mule.prod.properties and run your app with the corresponding environment variable to use it. To follow the example, use mule.env=prod
.
Run on CloudHub
When creating your application in CloudHub, you need to go to Manage Application > Properties to set all environment variables detailed in the "Properties to Configure" section.
Deploy on CloudHub
In Studio, right click your project name in Package Explorer and select Anypoint Platform > Deploy on CloudHub.
Properties to Configure
To use this template you need to configure properties either in a properties file or in CloudHub as Environment Variables. To run the MUnit tests, the configuration file is located in the mule.test.properties.
Application Properties
- https.port
8082
- token.refresh.poll.frequencyMinutes
30
token.refresh.poll.startDelayMinutes
2
keystore.location
keystore.jks
- keystore.password
password1234
- key.password
password1234
key.alias
alias
baseUri
baseUri.of.your.app/api/
Note: You should encode the fitbit.redirect.uri
api.fitbit.host
api.fitbit.com
- fitbit.redirect.uri
redirect.uri.defined.also.on.fitbit.side
- fitbit.client.id
12345
- fitbit.client.secret
fsd5fd45fs5d4f45sdf5d