Entries from July 2008 ↓

Whats your “editor” personality

Emacs? Vi? Visual Studio? TextMate?? Whats your favorite editor?

I started with Emacs and got to a point where I could write some elisp to work with a new language, but it just was too heavy weight and more often seemed to be bloat and cruft than necessary. Then I moved to Microsoft and gradually my editor became Visual Studio (and Notepad). It happened that way since it turned out to be a common denominator, and Visual Studio has amazing intellisense~

However more of late I have think vi (especially Vim) is a great tool. Since i work a lot with Non Microsoft programming language Vi seems to be the just right choice and it lean and mean!! Yep i do kick myself for not defecting to this camp earlier in my education.

Very recently @ OSCON i got in conversation with _those_ mac guys who love TextMate. It really interesting how TextMate has put the realm of XML declaration for a language as powerful as Context free grammer, and CSS with all the design and color gu – in to the editor world. It has an amazing community managed code / snippet repository which folks can use to share code with one another…!

Zemanta Pixie

OSCON 2008

I will be partially attending OSCON 2008 in Portland, next week. If you are around and want to say hi feel free to holler or message or leave a comment here. This is my first time to OSCON and I have heard great things about it and i’m looking forward to the state of onion. Microsoft is one of the Diamond sponsors -  Sam Ramji is talking about Open Source Heros and John Lam is delving in to IronRuby. This will be an oppurtunity for us at HealthVault to evaluate and see how we can move the state of art of our Java, Ruby and PHP libraries by interacting with the opensource community and discover possible way to enhance our open-ness.

OSCON 2008

Creating a HealthVault Child Application

If your application is a master application, you can programmatically create child application in the HealthVault environment. This implies that you have the ability to provision the child application. This is particularly desirable in the patientconnect scenario.

So here are the steps to do this, highlighting the gotchas:

  1. Create an OfflineWebApplicationConnection, you don’t need a PersonId for this it can be Guid.Empty
  2. Make a template ApplicationInfo object
  3. Read the public key you want to associate with this application and use the GetRawCertData method to add it to the ApplicationInfo object
  4. Read the image you want to associate with this child application and add it to ApplicationInfo
  5. Since a child application is an offline application it doesn’t really need a action url, so instead of this you are suppose to provide the contents for PrivacyStatement and TermsOfUse of this application (with content type text) by setting the appropriate ApplicationInfo properties
  6. Add the rules for datatypes this child application will use. The best way to do this is individually add a rule for each type accessed.
  7. Viola, fire it up to the HealthVault environment – using the AddApplication method!

Update: Below is a prototype sample, you will need to add paths to appropriate files.

/// 
/// Summary description for CreateChildApplication
/// 
public class CreateChildApplication
{
    public static void CreateApplication()
    {
        // Create an offline connection, we use an empty Guid as personId
        // There is a bug to create a constructor without requiring a guid
        // Use this only if you master application wants to do this in Offline mode
        OfflineWebApplicationConnection offlineConnection =
            new OfflineWebApplicationConnection(Guid.Empty);
        offlineConnection.Authenticate();

        // Setting up the application we want to create
        ApplicationInfo appInfo =
            new ApplicationInfo();
        appInfo.Name = "Cool child application";
        appInfo.AuthorizationReason =
            "Cool child application needs authorization to improve your health";
        appInfo.Description =
            "Cool child application can help you change our lifestyle";
        // get a base64 encoded logo
        appInfo.LargeLogo = new ApplicationBinaryConfiguration(
            pathTojpgOrGifOrPng, "image/gif");
        // base64 encoded public key for this application
        appInfo.PublicKeys.Add(
            GetPublicKeyFromPfxOrP12(fullPathToPfxOrP12OrCerFile));

        // You need to have PrivacyStatement + TermsOfUse or ActionUrl
        appInfo.PrivacyStatement = new ApplicationBinaryConfiguration(
        pathToPrivacyStatementTextFile, "text/plain");
        appInfo.TermsOfUse = new ApplicationBinaryConfiguration
            (pathToTermsOfUseTextFile, "text/plain");
        //actionUrl
        //appInfo.ActionUrl = new Uri("http://localhost/redirect.aspx");

        // Create and add the rules individually
        List rules = new List();
        rules.Add((AuthorizationSetDefinition)(new TypeIdSetDefinition(Height.TypeId)));
        AuthorizationRule rule1 = new AuthorizationRule(
            HealthRecordItemPermissions.Read,
            rules,
            null);
        // Here we are setting up the child as an offline application
        appInfo.OfflineBaseAuthorizations.Add(rule1);

        // Add more rules, if needed

        // Lets make the child app!
        Provisioner.AddApplication(offlineConnection, appInfo);
    }

    private static byte[] GetPublicKeyFromPfxOrP12(string fullPathToCerFile)
    {
        X509Certificate cert = new X509Certificate(fullPathToCerFile);
        return cert.GetRawCertData();
    }
}