HealthVault and IronRuby sitting in a tree
Monday, 20 December 2010
If you take a look back at my previous articles on IronRuby, you’ll soon detect a running theme: IronRuby does pretty much everything you can do with traditional .NET development. I’m not even comfortable with the implication that IronRuby isn’t traditional .NET development – it’s just another language atop the CLR, like C#.
Over the past year, I’ve also become increasingly captivated by Microsoft’s health and fitness data storage platform, HealthVault. I’ve been using the HealthVault SDK extensively, but only today has the notion marrying it with IronRuby crossed my mind. To that end, consider the below example of IronRuby beginning a HealthVault application authorisation request in as many lines of code as there are dwarves in Snow White’s address book (that’s my unnecessarily poetic way of saying ‘seven’):
require 'System.Core'
require 'Microsoft.Health'
require 'Microsoft.Health.ItemTypes'
# Client applications are created on-the-fly as children of your 'Master' application ID
# The master application ID must exist in HealthVault, however.
client_id = System::Guid.new_guid
app_id = System::Guid.new("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX".to_clr_string)
# HealthClientApplication has no constructor, but the create method takes your two app IDs
# and URIs to the appropriate account and platform URLs for your region's HealthVault instance
app = Microsoft::Health::HealthClientApplication.create(client_id, app_id, System::Uri.new("https://account.healthvault-ppe.co.uk/"), System::Uri.new("https://platform.healthvault-ppe.co.uk/platform/"))
# Begin the authorisation process for your user
app.start_application_creation_process
Assuming you have been assigned a SODA-enabled application ID in the HealthVault Application Configuration Centre appropriate to your region (this example is set up to attach itself to the UK HealthVault platform), this snippet should begin the authorisation process for your user. It is up to you what happens with the session after that.
If you intend to take this concept beyond what has been demonstrated here – that is, yet another showcase of IronRuby taking arbitrary .NET assemblies and seamlessly working with them – then I advise you take a look at literature on the concept of master/child HealthVault application relationships required for the less-common SODA-based applications, and SODA applications themselves in regards to the platform.
This is probably also a great time to bring up the latest IronRuby release. As of a few months ago, version 1.1 has been the most recent. Although it is not yet officially ‘stable’, it does include Visual Studio 2010 support in the form of source highlighting for Ruby, templates and the same debugging workflow you’re used to with .NET development.