1. Sean Summers
  2. HealthVault-jython

Commits

Sean Summers  committed 7fdbfa1

Create works, but delete does not

  • Participants
  • Branches default

Comments (0)

Files changed (12)

File .hgignore

View file
+syntax: glob
+
+keystore
+*.class
+*.log
+*SNAPSHOT*

File HealthVault/__init__.py

View file
+__all__ = ['connection', 'request']
+
+from connection import Connection
+import request
+

File HealthVault/config.py

View file
+
+HV_URL = 'https://platform.healthvault-ppe.com/platform/wildcat.ashx'
+SHELL_URL = 'https://account.healthvault-ppe.com'
+CONNECT_URL = 'https://account.healthvault-ppe.com/patientwelcome.aspx?packageId='
+
+weightmeasurement = '3d34d87e-7fc1-4153-800f-f56592cb0d17'
+heightmeasurement = '40750a6a-89b2-455c-bd8d-b420a4cb500b'
+cholesterolProfile = '796c186f-b874-471c-8468-3eeff73bf66e'
+

File HealthVault/connection.py

View file
+import config
+import util
+
+class Connection:
+    ''' HealthVault Connection object '''
+
+    def __init__(s, appId, keyPassword, keyFilename = '/keystore', keyAlias = 'java-wildcat', url = config.HV_URL):
+	s.url = url
+	s.appId = appId
+        s.keyStore = util.setup_keyStore(keyFilename, keyAlias, keyPassword)
+        s.authenticator = util.setup_authenticator(s.keyStore, s.appId)
+        s.transport = util.setup_transport(s.url)
+        s.connection = util.setup_connection(s.transport, s.authenticator)
+
+    def connect(s):
+        s.connection.authenticate()
+
+    def request(s, aRequest):
+        request = util.setup_request(s.connection)
+        return request.makeRequest(aRequest)
+

File HealthVault/request.py

View file
+''' implemented requests '''
+
+def createConnect(externalId, friendlyName, question, answer):
+    from com.microsoft.hsg.methods.jaxb.createconnectrequest.request import CreateConnectRequestRequest
+    request = CreateConnectRequestRequest()
+    request.externalId = externalId
+    request.friendlyName = friendlyName
+    request.question = question
+    request.answer = answer
+    return request
+
+def deleteConnect(externalId):
+    from com.microsoft.hsg.methods.jaxb.deletependingconnectrequest.request import DeletePendingConnectPackageRequest
+    request = DeletePendingConnectPackageRequest()
+    request.externalId = externalId
+    return request

File HealthVault/util.py

View file
+''' setup functions '''
+
+from config import *
+
+def setup_keyStore(filename, alias, password):
+    from com.microsoft.hsg import DefaultPrivateKeyStore
+    keyStore = DefaultPrivateKeyStore()
+    keyStore.filename = filename
+    keyStore.alias = alias
+    keyStore.password = password
+    return keyStore
+
+def setup_authenticator(keyStore, appId):
+    from com.microsoft.hsg import ApplicationAuthenticator, DefaultSharedSecret
+    authenticator = ApplicationAuthenticator()
+    authenticator.sharedSecretGenerator = DefaultSharedSecret()
+    authenticator.keyStore = keyStore
+    authenticator.appId = appId
+    return authenticator
+
+def setup_transport(url = HV_URL):
+    from com.microsoft.hsg import URLConnectionTransport
+    import java.net.URL
+    transport = URLConnectionTransport()
+    transport.url = java.net.URL(url)
+    return transport
+
+def setup_connection(transport, authenticator):
+    from com.microsoft.hsg import Connection
+    connection = Connection()
+    connection.transport = transport
+    connection.authenticator = authenticator
+    return connection
+
+def setup_request(connection):
+    from com.microsoft.hsg.methods.jaxb import SimpleRequestTemplate
+    return SimpleRequestTemplate(connection)

File README

View file
+Prerequisites:
+ - Application Id from HealthVault Developer Center [https://config.healthvault-ppe.com/Default.aspx]
+ - working jython installation [http://www.jython.org/]
+ - Everything else set up as per the HealthVault Java Library [http://healthvaultjavalib.codeplex.com/], especially certs [http://healthvaultjavalib.codeplex.com/wikipage?title=Certs%20to%20use]
+
+

File lib/commons-codec-1.6.jar

Binary file added.

File lib/hv-jaxb-1.3.1.jar

Binary file added.

File lib/hv-sdk-1.3.1.jar

Binary file added.

File lib/log4j-1.2.15.jar

Binary file added.

File run.sh

View file
+#! /bin/sh
+
+export CLASSPATH=./cfg:"$(ls lib/* | xargs | tr ' ' ':')":${CLASSPATH}
+
+jython $@
+