<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Reviving The Health Revolution &#187; Python</title>
	<atom:link href="http://healthblog.vitraag.com/topics/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://healthblog.vitraag.com</link>
	<description>A view from inside the HealthVault</description>
	<lastBuildDate>Sun, 29 Aug 2010 15:54:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PutThings for OfflineAccess</title>
		<link>http://healthblog.vitraag.com/2008/08/putthings-for-offline-access/</link>
		<comments>http://healthblog.vitraag.com/2008/08/putthings-for-offline-access/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 16:46:57 +0000</pubDate>
		<dc:creator>vaibhavb</dc:creator>
				<category><![CDATA[HealthVault]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[RubyOnRails]]></category>

		<guid isPermaLink="false">http://healthblog.vitraag.com/?p=40</guid>
		<description><![CDATA[Folks trying to talk through raw xml layer with HealthVault have asked this a few times &#8211; so i thought I&#8217;ll put it up here, thanks to Rob for digging the XML.
The key to do a PutThings for an application in offline mode is the following snippet in the auth-session:

11111111-1111-1111-1111-111111111111

An application with OfflineAccess is ready [...]]]></description>
			<content:encoded><![CDATA[<p>Folks trying to talk through raw xml layer with <a href="http://en.wikipedia.org/wiki/Microsoft_HealthVault" title="Microsoft HealthVault" rel="wikipedia" class="zem_slink">HealthVault</a> have asked this a few times &#8211; so i thought I&#8217;ll put it up here, thanks to Rob for digging the XML.</p>
<p>The key to do a PutThings for an application in offline mode is the following snippet in the auth-session:</p>
<pre name="code" class="html"><offline-person-info>
<offline-person-id>11111111-1111-1111-1111-111111111111</offline-person-id>
</offline-person-info></pre>
<p>An application with OfflineAccess is ready to publish data in a users record once it successfully does the CreateAuthenticateSession call. Here is a sample PutThings call:</p>
<pre name="code" class="html"><wc-request:request xmlns:wc-request="urn:com.microsoft.wc.request">
<auth>
<hmac-data algname="HMACSHA1">Ax4hxwu+7BAkrH62g8tUvjNzpEQ=</hmac-data>
</auth>
<header>
<method>PutThings</method>
<method-version>1</method-version>
<record-id>22210250-3d35-4170-bffa-514e12e7f925</record-id>
<auth-session>
<auth-token>ASAAAEJsFrdImoBPhEuDFRUObCKOvcbsicri3tSAaYRo+dQIg1Rsl9/Au7pM2YYfTdN2z0VlRnz4G5iCaSjXIFQGiG98qmaKy8IMt63b1FMahGKC13JVjpBA7LOAvKgpOkv7GJm7xrUlEyQWwSL39dzMTcuiyLB12hugNYIBB9r8pYOJhlLcD/Y0lEDHMTH+XbqZXSdF0SAoq60OWEXkPhTeaKrN8fNq</auth-token>
<offline-person-info><offline-person-id>11111111-1111-1111-1111-111111111111</offline-person-id>
</offline-person-info>
<language>en</language>
<country>US</country>
<msg-time>2008-08-13T00:24:58.126-07:00</msg-time>
<msg-ttl>60</msg-ttl>
<version>0.0.0.1</version>
<info-hash>
<hash-data algname="SHA1">v08Nd7MFCdO8aDwIOFJvU/0TpWw=</hash-data>
</info-hash>
</auth-session>
<info>
<thing>
<type-id>3d34d87e-7fc1-4153-800f-f56592cb0d17</type-id>
<data-xml>
<weight>
<when><date><y>2008</y><m>8</m><d>13</d></date><time><h>0</h><m>24</m><s>58</s></time></when><value><kg>777</kg><display units="lb" units-code="lb">777</display></value>
</weight>
<common></common>
</data-xml>
</thing>
</info>
</header>

</wc-request:request></pre>
<div style="margin-top: 10px; height: 15px;" class="zemanta-pixie"><a class="zemanta-pixie-a" href="http://reblog.zemanta.com/zemified/7b7dc416-c01b-4627-9d38-76d92da8418c/" title="Zemified by Zemanta"><img style="border: medium none ; float: right;" class="zemanta-pixie-img" src="http://img.zemanta.com/reblog_e.png?x-id=7b7dc416-c01b-4627-9d38-76d92da8418c" alt="Reblog this post [with Zemanta]"></a></div>
<p>Related Article: <a href="http://healthblog.vitraag.com/2008/06/curious-about-whats-under-the-healthvault-sdks-hood/"> Whats Under the hood of HealthVault SDK</a></p>
]]></content:encoded>
			<wfw:commentRss>http://healthblog.vitraag.com/2008/08/putthings-for-offline-access/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Lighting it up!</title>
		<link>http://healthblog.vitraag.com/2008/06/lighting-it-up/</link>
		<comments>http://healthblog.vitraag.com/2008/06/lighting-it-up/#comments</comments>
		<pubDate>Mon, 02 Jun 2008 10:24:19 +0000</pubDate>
		<dc:creator>vaibhavb</dc:creator>
				<category><![CDATA[HealthVault]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[RubyOnRails]]></category>

		<guid isPermaLink="false">http://healthblog.vitraag.com/?p=34</guid>
		<description><![CDATA[Alrite now that you have the firewood (application auth token) and the firestarter (user auth token) how can we start the fire (get details user&#8217;s record).
Well first of all congratulations! most of the hard part is done!! Just a few more nitty gritty tricks though! In order to get the details about a user&#8217;s health [...]]]></description>
			<content:encoded><![CDATA[<p>Alrite now that you have the firewood (application auth token) and the firestarter (user auth token) how can we start the fire (get details user&#8217;s record).</p>
<p>Well first of all congratulations! most of the hard part is done!! Just a few more nitty gritty tricks though! In order to get the details about a user&#8217;s health record, you need to use a method <strong>GetPersonInfo</strong>.</p>
<p>The XML for GetPersonInfo look like this:</p>
<pre name="code" class="html">
<wc-request:request xmlns:wc-request="urn:com.microsoft.wc.request">
<auth>
  <hmac-data algName="HMACSHA1">da9WYaQGEoseAYDOhJv2cwNIEVg=</hmac-data>
</auth>
<header>
<method>GetPersonInfo</method>
<method-version>1</method-version>
<auth-session>
<auth-token>ASAAADNt1Jwbx85MgH9vkWzAINBxBWQFCtQ+osTzGw/I0Ty27OhKFCXUb83dxI5/M2mtGYymc1gKx6qwsWEtw31ZV/tyscJwmc5dNT2o2nYJcFTf1vfi/L4R5V68ckxFrd48Rz4jhU9Yg6lDhNTymCsJSDiVJCKLqKwcHcr/QSTsytRpVXBK7LpAVBicjC3OPGCEg4XE/UGwM7ZDAXlR4AR+emiHBaPOzSQD9iYMYxAyDBYZPde8N+rDv58zFw9pjDLJJIwvhXOOLahhFvX/n5DqwAb+BpdTlE19x5P/B67kKie/zDtEYWHEXHMhX+KNdvrxdm17l5pwt8JShIGimbXgAcZEFTiPVOW77mCgDxpc0U2ykcG7RVqXKTA3Gqt42OZf9aCuzq/J0wHOTLQvdx1ZYVOxo7+1TpMaW+13Fz5/jgOHR7hJZ/DPUIcKfCYdHS7phQ3r60nOReUl2qeq7rDvDmGQBWPjcCrT7CuQRSgZlyUpAav4DiFJtKh9U5DbJ5VW80dUAqcxamulklTxSR75Sb6v0X4T8B2zbfmVl+HtcupUIuz66Q==</auth-token>
<user-auth-token>ASAAAE57vlXwS8VDupO6/FSWlMZR+OL02JQyhWvlesegc/J6f7XGgJq4xRW1WIWc7ZXufY9U1cAFeQMDF9pAvmNG1/1KGlp7FFFBdrUMk7gJLPpdTYkQeDMdp8UXcXNht+U6hJzpI7plchQKvpBMFeBj1XMOC15fLXRyfRFpD3RaIF66awgUVw==</user-auth-token>
</auth-session>
<language>en</language>
<country>US</country>
<msg-time>2008-06-01T02:44:16.73Z</msg-time>
<msg-ttl>1800</msg-ttl>
<version>0.9.1712.2902</version>
<info-hash>
<hash-data algName="SHA1">1mWxpY+leClypXQzPvDBLFIBDpI=</hash-data>
</info-hash>
</header>
<info/>
</wc-request:request>
</pre>
<p>So now do we go about concoting the seemingly complicated xml above. Well we already have the token and wctoken from our previous CreateAuthenticatedSession and Shell -redirect. Use the token for the auth-token in line 9 and the wctoken as user-token in line 10.</p>
<p>Most of the elements in the header section are straight forward. The one to comment about is hash-data (line 18). The hash in this case is SHA-1 hash of the info section. Matter of fact our info section is empty so that make sure that the SHA-1 hash is done right. In ruby i do it the following way (using OpenSSL):</p>
<pre name="code" class="ruby">
  def self.doSha1(text)
    Base64.encode64(OpenSSL::Digest::SHA1.digest(text)).chomp
  end
</pre>
<p>Now the interesting part &#8211; whats this auth on line 2? Well auth is a HMAC of header (line 5-20) section. Remember we generated the shared secret in CreateAutheticatedSession method? Now use that secret to do a HMAC digest for the header. In ruby i do it the following way:</p>
<pre name="code" class="ruby">
  def self.doHmac(secret, payload)
    key = Base64.decode64(secret)
    hashmac = OpenSSL::HMAC.digest(OpenSSL::Digest::SHA1.new(key), key, payload)
    Base64.encode64(hashmac).chomp
  end
</pre>
<p>secret is the shared secret used for createauthenticationtoken.</p>
<p>Now the fun part,caveats:</p>
<ul>
<li>Don&#8217;t leave any white spaces between you xml tags. HealthVault behaves weird sometime when their is white space.</li>
<li>If you are getting an error saying code 3 (which implied invalid xml) and you are sure that your xml is correct, then most likely your auth section or your hash-data section are not proper. Which in turn implies that your HMAC-ing or SHA-1 hashing is a little off. The best way to actually resolve this is to first write tiny parts which make sure that the HMAC /SHA-1 is same for a known successfully call. You can get the xml for such a call from HealthVault SDK, the process is described <a href="http://healthblog.vitraag.com/2008/06/curious-about-whats-under-the-healthvault-sdks-hood/">here</a>. However for ease of testing i&#8217;m appending know good calls below.
</ul>
<p><strong>PLEASE NOTE</strong>: Remove all the white-space between tags before testing your crypto functions to match the result seen here. I have put the white space for readability.</p>
<p>CreateAuthenticatedSessionToken (for SharedSecret)</p>
<pre name="code" class="html">
<wc-request:request xmlns:wc-request="urn:com.microsoft.wc.request">
<header>
<method>CreateAuthenticatedSessionToken</method>
<method-version>1</method-version>
<app-id>05a059c9-c309-46af-9b86-b06d42510550</app-id>
<language>en</language>
<country>US</country>
<msg-time>2008-06-01T02:44:16.21Z</msg-time>
<msg-ttl>1800</msg-ttl>
<version>0.9.1712.2902</version>
</header>
<info>
<auth-info>
<app-id>05a059c9-c309-46af-9b86-b06d42510550</app-id>
<credential><appserver>
<sig digestMethod="SHA1" sigMethod="RSA-SHA1" thumbprint="50054D4FAEE16F69AAF66B7596ED30F9922B949E">b2uCbONZDGj8jDYhz3e5PcJfugPQTHOsOvpZ6kA9uG5XzQXV+EHtXtTDAbwHbFyNozC1uR7uZwgi44pfgw4NyQp8LO2PwI9E7pOx/Ho7+6siY41sjI5+frhq2fcj8iljpG8EK07WGDuf4JeFg5yc8IWjHHtUwabpdPVJWYLi18+Gk7AaFfCuM1iQwFbBSWWMyckCe3V48JaCZcNVcS/XuJJovFdsM9QnZ1CwrQaaBB/evf1u1YGM3fXpVeCjVWPXpHiu3WWVVsJ5aURtCzGvXJe9R7Gh10sYDSG6wC/CJvcBSJlRCpacA1qds2gcMCBwO+iDCPY3I15+FbM0E9D+Qw==</sig>
<content>
<app-id>05a059c9-c309-46af-9b86-b06d42510550</app-id>
<shared-secret><hmac-alg algName="HMACSHA1">RXziN4RDYIu89cu+cOp4POLhKUCSUb0sPsV9yaz8m6BfJxjpDNUBRUF5MU3OJMJ7DH0FPXg8HFuahbvSz1HxG1Q6MlahpHAmUkXNBJ0zcrKvcH3+NiS3qD26FkpLXsvzjNv/QSxwqRMpYnDhY11RkUkOvz2M2Ybg9H5aEe7RpfYCYwEAudpj05J2KEFMP2WO1Q6Kz8hjIhf2QdswgzvLueUQ2ajG8Al9DvpGWLKl4dGNqnY1/FUnJOZq/nPivTYHYOcH/qpC5euWIt7bU6hXRehAIC9IYTbHG32jLBoIxhM79Wtj2sRdn4j3SBk/QVqQNXyPrAgFIzmtR7CSaN393A==</hmac-alg>
</shared-secret></content>
</appserver></credential></auth-info></info></wc-request:request>
</pre>
<p>Successful GetPersonInfo using the above SharedSecret:</p>
<pre name="code" class="html">
<wc-request:request xmlns:wc-request="urn:com.microsoft.wc.request">
<auth><hmac-data algName="HMACSHA1">da9WYaQGEoseAYDOhJv2cwNIEVg=</hmac-data></auth>
<header><method>GetPersonInfo</method>
<method-version>1</method-version>
<auth-session>
<auth-token>ASAAADNt1Jwbx85MgH9vkWzAINBxBWQFCtQ+osTzGw/I0Ty27OhKFCXUb83dxI5/M2mtGYymc1gKx6qwsWEtw31ZV/tyscJwmc5dNT2o2nYJcFTf1vfi/L4R5V68ckxFrd48Rz4jhU9Yg6lDhNTymCsJSDiVJCKLqKwcHcr/QSTsytRpVXBK7LpAVBicjC3OPGCEg4XE/UGwM7ZDAXlR4AR+emiHBaPOzSQD9iYMYxAyDBYZPde8N+rDv58zFw9pjDLJJIwvhXOOLahhFvX/n5DqwAb+BpdTlE19x5P/B67kKie/zDtEYWHEXHMhX+KNdvrxdm17l5pwt8JShIGimbXgAcZEFTiPVOW77mCgDxpc0U2ykcG7RVqXKTA3Gqt42OZf9aCuzq/J0wHOTLQvdx1ZYVOxo7+1TpMaW+13Fz5/jgOHR7hJZ/DPUIcKfCYdHS7phQ3r60nOReUl2qeq7rDvDmGQBWPjcCrT7CuQRSgZlyUpAav4DiFJtKh9U5DbJ5VW80dUAqcxamulklTxSR75Sb6v0X4T8B2zbfmVl+HtcupUIuz66Q==</auth-token>
<user-auth-token>ASAAAE57vlXwS8VDupO6/FSWlMZR+OL02JQyhWvlesegc/J6f7XGgJq4xRW1WIWc7ZXufY9U1cAFeQMDF9pAvmNG1/1KGlp7FFFBdrUMk7gJLPpdTYkQeDMdp8UXcXNht+U6hJzpI7plchQKvpBMFeBj1XMOC15fLXRyfRFpD3RaIF66awgUVw==</user-auth-token>
</auth-session>
<language>en</language><country>US</country><msg-time>2008-06-01T02:44:16.73Z</msg-time>
<msg-ttl>1800</msg-ttl><version>0.9.1712.2902</version><info-hash><hash-data algName="SHA1">1mWxpY+leClypXQzPvDBLFIBDpI=</hash-data></info-hash>
</header>
<info />
</wc-request:request>
</pre>
<p>Sweet!!! you wanna check out th lighted application? Well its <a href="http://openhealthvault.vitraag.com">live&#8230;</a> (Please Note: it will prompt you yo sign in with HealthVault id, its still rough around edges and doesn&#8217;t deal with corner cases).</p>
<p>So lets see your LAMPR application lighted up soon.. </p>
<p>Next time: <a href="http://healthblog.vitraag.com/2008/08/putthings-for-offline-access/">How to do offline access and use PutThings </a></p>
]]></content:encoded>
			<wfw:commentRss>http://healthblog.vitraag.com/2008/06/lighting-it-up/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>OpenSSL and working with HealthVault</title>
		<link>http://healthblog.vitraag.com/2008/03/openssl-and-working-with-healthvault/</link>
		<comments>http://healthblog.vitraag.com/2008/03/openssl-and-working-with-healthvault/#comments</comments>
		<pubDate>Wed, 26 Mar 2008 01:42:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[RubyOnRails]]></category>

		<guid isPermaLink="false">http://www.healthblog.vitraag.com/?p=26</guid>
		<description><![CDATA[This is my first post in an N-series indulgence in trying to evaluate HealthVault to work with Ruby On Rails or Pythons DJango. As you know we HealthVault released a Java library &#8211; and it works in a platform independant fashion on most of platforms. I will attempt to outline some of the challenges here [...]]]></description>
			<content:encoded><![CDATA[<p>This is my first post in an N-series indulgence in trying to evaluate HealthVault to work with Ruby On Rails or Pythons DJango. As you know we HealthVault released a <a href="http://www.codeplex.com/HealthVaultJavaLib">Java library</a> &#8211; and it works in a platform independant fashion on most of platforms. I will attempt to outline some of the challenges here lets starting with -</p>
<p>Step 1: Authentication &amp; Authorization -</p>
<ul>
<li>Support for Crytography &#8211; RSA and Hash Method Authenticaion Code (SHA1/ SHA256)
<ul>
<li>The Java library comes with Sun&#8217;s implementation of the above <a href="http://java.sun.com/javase/technologies/security/">Java.Security</a>. However in LAMP/R world the only respectable alterative is <a href="http://www.openssl.org/">OpenSSL</a>.</li>
<li>While Java is everywhere but you might have to install your flavor of OpenSSL in addition to the web-framework. However having a robust framework makes rest of work easy.</li>
</ul>
</li>
<li>Exporting the private key from Windows generated pfx certificate to be used with one of the offerings.
<ul>
<li>While in theory it should just work but their are some format issues which will need to be dealt with getting key material to be used with the above option.</li>
</ul>
</li>
</ul>
<p>I&#8217;m going to try the Step 1 with Python &amp; OpenSSL and lets see where I go with it.</p>
<p>Next Part: <a href="http://healthblog.vitraag.com/2008/04/talking-to-the-public-methods-of-healthvault-platform/">Talking to the public methods of healthvault platform.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://healthblog.vitraag.com/2008/03/openssl-and-working-with-healthvault/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Querying HealthVault with &quot;Where&quot; clauses!</title>
		<link>http://healthblog.vitraag.com/2007/12/querying-healthvault-with-where-clauses/</link>
		<comments>http://healthblog.vitraag.com/2007/12/querying-healthvault-with-where-clauses/#comments</comments>
		<pubDate>Thu, 27 Dec 2007 04:20:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[HealthVault]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.healthblog.vitraag.com/?p=11</guid>
		<description><![CDATA[HealthVault give me all height measures greater than 1.7mOne can use the XPath attribute of the filter to do the specific queries on the healthvault search items.
Here is an example, which gives you all the height items greater than 1.7 m :

HealthRecordSearcher searcher = PersonInfo.SelectedRecord.CreateSearcher()
HealthRecordFilter filter = new HealthRecordFilter(typeID);
filter.XPath = "/thing/data-xml/height/value/m[.>=1.7]";
searcher.Filters.Add(filter);
HealthRecordItemCollection items = searcher.GetMatchingItems()[0];

Please note [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-size:130%;">HealthVault give me all height measures greater than 1.7m<br /></span><br />One can use the XPath attribute of the filter to do the specific queries on the healthvault search items.</p>
<p>Here is an example, which gives you all the height items greater than 1.7 m :</p>
<pre class="html" name="code">
HealthRecordSearcher searcher = PersonInfo.SelectedRecord.CreateSearcher()
HealthRecordFilter filter = new HealthRecordFilter(typeID);
filter.XPath = "/thing/data-xml/height/value/m[.>=1.7]";
searcher.Filters.Add(filter);
HealthRecordItemCollection items = searcher.GetMatchingItems()[0];
</pre>
<p>Please note that the XPath tag doesnot support recursive XPath queries.</p>
<p>Easiest way to construct the queries is first find the HealthRecordItem you want to filter, identify its XML via the GetItemXml() and then use that structure to construct your XPath query. The following is the Xml for Height -</p>
<pre class="html" name="code">
<thing>
<thing-id version-stamp="e1ef0593-53d1-4e67-9e52-dc32b7e0e99b">a891edda-48c3-4783-83d7-c3594a514739
</thing-id>
<type-id>40750a6a-89b2-455c-bd8d-b420a4cb500b</type-id>
<thing-state>Active</thing-state>  <eff-date>2007-12-26T19:43:14Z</eff-date>  <data-xml>    <height>      <when>        <date>          <y>2007</y>          <m>12</m>          <d>26</d>        </date>        <time>          <h>19</h>          <m>43</m>          <s>14</s>        </time>      </when>

<value>        <m>1.9405395758527</m>      </value>    </height>    <common />  </data-xml></thing>
</pre>
<p>Hope this helps, I&#8217;ll post more on this in case there is interest.</p>
<p><strong>Update: </strong> Eric wrote a tool to help with this, more details are <a href="http://blogs.msdn.com/ericgu/archive/2009/04/10/healthvault-xpath-explorer.aspx">here</a>.
	</div>
]]></content:encoded>
			<wfw:commentRss>http://healthblog.vitraag.com/2007/12/querying-healthvault-with-where-clauses/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
