Tuesday, September 30, 2008

The ABCs of Google Health Data API

Recently, I have been involved in a small project to aggregate medications from various Personal Health Records (PHR), including Google Health.

The documentation for the Google Data APIs Client Library and the Health Data API is quite complete and extensive. But it can be also be quite complex for someone who want to develop quickly a prototype or just test a proof of concept using these APIs.

Since I was going to develop my project in Java, I first downloaded he most recent GData Java Client Library (version 1.22 with samples - 6.8 MB).

The sample code can be used out of the box for a simple stand-alone java testing program.

I did import the sample code and the library in my IDE (eclipse) and just changed the credentials (sample.credentials.username and sample.credentials.password) in gdata/java/build-samples/build.properties using my google health account login and password.

To run the Google Health sample program, at the prompt under ./gdata/java just run: ant -f build-samples.xml sample.health.run
The next step for me was to reuse the sample code to develop a web application (I am creating small Liferay JSP based portlets).

Google offers two platforms for the developers to test their applications:
For my small web project I initially tested my code against H9, as recommended by Google.
The main reason is because the authentication with H9 is more simple than with Google Health production.

The application I wanted to build is supposed to connect to various PHRs (ICW LifeSensor, Microsoft Health Vault and Google Health/H9) and retrieve the medication lists. For Google I don't need to enter a login and password in my web application since I am going to use Google AuthSub mechanism:



By clicking on the Google 'connect' button, I am redirected to the Google AuthSub web site:

     <input id="btn_connect_google" name="Disconnect" type="submit"
         value="Connect" onClick="connectToGoogle();return false;"/>

Here is the Javascript function I use for URL redirection:

     function connectToGoogle() { 
       if (btn_connect_google.value == "Connect") {
          window.location.href = googleAuthSubURL.value;
       }
       else {
          btn_connect_google.value = "Connect"; 
       }
     }
I construct the AuthSub URL in advance in my JSP java code:
public String getGoogleAuthSubURL(HttpServletRequest request) {
     
       gh9s = new H9Service("ICW-H9Medications-1.0");

       String nextUrl = "http://localhost:8080/sample/hello.jsp";
       String scope = "https://www.google.com/h9/feeds/";
     
       boolean secure = false;
       boolean session = true;
    
       String authSubLink = AuthSubUtil.getRequestUrl(nextUrl, scope, secure, session);
       authSubLink += "&permission=1";
       authSubLink = authSubLink.replaceFirst("/accounts/AuthSubRequest", "/h9/authsub");
     
      return authSubLink;
   }
I store the URL in an hidden field:

   <input type=hidden id="googleAuthSubURL" value="<%= getGoogleAuthSubURL(request) %>" >

You can refer to the Google Data API and Google Health API, including security settings for AuthSub Request and application identification (for logging purpose).

I am redirected to the Google AuthSub WebSite where I can choose which H9 account I want to use.




Then I am redirected back to my original application, with a single use token associated to the request. I can then parse the request and extract the token that I exchange for the token session:
  http://localhost:8080/sample/hello.jsp?token=1%2FBtOEh.....lsYenOFQ&permission=1
  if (gh9s != null)  {        
      try {
        
         // Extract Single Use Token for the session
         String queryString = request.getQueryString();
                  if (queryString != null) {
           
                      String singleUseToken = AuthSubUtil.getTokenFromReply(queryString);
                 
                      if (singleUseToken != null) {
                        String sessionToken = AuthSubUtil.exchangeForSessionToken(URLDecoder.decode(singleUseToken, "UTF-8"), null);
                        gh9s.setAuthSubToken(sessionToken);
                        System.out.println("Google SetAuthSubToken");
                          
                        URL profile_url = new URL(PROFILE_DEFAULT_PATH);
                        System.out.println("Google ProfileURL:"+profile_url);
                        gh_feed = gh9s.getFeed(profile_url, ProfileFeed.class);
               
                        createReferences(gh_feed.getEntries());
                      }
                  }
            } catch (AuthenticationException e) {
                throw new RuntimeException(e);
            } catch (IOException e) {
                throw new RuntimeException(e);
            } catch (ServiceException e) {
                throw new RuntimeException(e);
            }
        }

For my portlet version (Liferay), I just had to replace the definition of the current URL:
   String singleUseToken = AuthSubUtil.getTokenFromReply(getCurrentURL(request).getQuery());

   private URL getCurrentURL(HttpServletRequest request) {
    try {
       return(new URL(request.getScheme(), request.getServerName(), request.getServerPort(), request.getAttribute("CURRENT_URL").toString())); 
    } catch (MalformedURLException e) {
    throw new RuntimeException(e);
    }
   }
The next step is to obtain medication entries by parsing the Google CCR data feed:

  private void createReferences(List entries) { 
     if (entries != null) {
        for (ProfileEntry entry : entries) {
           System.out.println("Google CCR:"+entry.getContinuityOfCareRecord().getXmlBlob().getBlob());
                 GoogleCCRWrapper ccrWrapper = getDomRepresentation(entry);
                 if (ccrWrapper.containsMedications()) 
                    medication_list.add(ccrWrapper.getMedication());
                    source_list.add(SRC_GOOGLE_HEALTH);
         }
      }
   }

The GoogleCCRWrapper java class parses the CCRg XML data feed:

    public GoogleCCRWrapper(String xml) {
        DocumentBuilder builder = null;
        try {
            builder = documentBuilderFactory.newDocumentBuilder();
        } catch (ParserConfigurationException e) {
            throw new RuntimeException("Error creating DocumentBuilder.", e);
        }
        
        try {
            document = builder.parse(new ByteArrayInputStream(xml.getBytes()));
        } catch (SAXException e) {
            throw new RuntimeException("Error parsing XML.", e);
        } catch (IOException e) {
            throw new RuntimeException("Error parsing XML.", e);
        }
    }
public boolean containsMedications() {
        return document.getElementsByTagName("Medications").getLength() > 0;
    }

    public String getMedication() {   
     Element e = getElementFromDocument("Medications");
     e = getElement(e, "Medication");
     e = getElement(e, "Product"); 
     e = getElement(e, "ProductName");
     e = getElement(e, "Text"); 
     return getText(e);
    }

Here is the resulting portlet (Google Health and Lifesensor Medications):

Friday, August 29, 2008

Liferay Portal : My first impressions



My company ICW creates Health Care web applications and solutions.

We have a need to create reusable components that can be bundled into highly customizable and personalized web applications. Our stack uses Java Enterprise and Web 2.0 technologies, so we naturally turned to the open source Liferay Portal.

This was my first experience with Liferay. By looking at the features, it seems that this portal solution had a lot of things we were looking for:
  • A well recognized open source product (1.5 million downloads, 6000+ registered participants ...)
  • A business-friendly MIT License
  • Compatibility with all major servers, databases and operating systems (we are using Tomcat, Oracle, Windows for development and Linux for production).
  • Compatibility with our stack (J2E) and light container (Spring).
  • An easy way to create new skins and branding
  • An integrated content management system
  • Highly secure platform (especially important for Health Care applications)
Installing Liferay (version 5.1.0) was a little bit longer than expected (>1 GB), but after this, it went pretty smoothly besides minor MySQL configuration issues. This installation included all the source code of Liferay (I did not have to customize the code initially, but it seems nice to have all the source code available in case ...).

I did create a specific project for our need - a portal version of our Personal Health Record (PHR) - call phr-portal-assembly (see screen shot on the left):

I liked the fact that the runtime portion of the portal is contained inside the project: bundles/tomcat/ (although this takes a lot of space if you have several projects).

To be up and running, you just have to start MySQL and Tomcat and open a browser at http://localhost:8080/web/guest/home (I am using Firefox).

I find it easy to create new plugins (portlets and themes). You just have to open a prompt under the liferay-plugins-sdk-5.1.0/portlets or liferay-plugins-sdk-5.1.0/themes directory and use the command:

create new_portlet_name new_portlet_title and
create new_theme_name new_theme_title

I was then able to start to modify my portlet skeletons (by modifying the default view.JSP file under docroot) and redeploy them (without having to restart tomcat!) by using the ant deploy command. Easy and efficient!

For the themes, I was a little bit different: The style sheet changes/differences is specified under the docroot/_diffs and the new theme is built by adding the differences to the default classic look and feel.

Becoming familiar with the portal application itself was not too complicated. Especially with version 5.1.0 which can give admin rights to any type of users, so I was able to customize my portal page without having to log a as an administrator.

To make the border/chrome disappear, I just had to click on the look-and-feel icon.








This opens a new window where I had to uncheck 'Show Borders' and refresh the browser.






After this, I had to uncheck the 'Toggle Edit Controls' check box.

The resulting portal had the same look and feel as our initial PHR, but was now highly customizable.I did some also some quick tests with different layouts and themes that was provided by one of my colleague with fast and good and results. We also did some tests encapsulating an existing Flex based application and some widgets with great success.

Overall my first impression of Liferay portal is a very positive one.

I am now looking forward to tackle the re-factoring of our existing products with this technology (we are using JSF, Ajax and Flex as front-end technology)!







Sunday, July 6, 2008

IEEE HealthCom 2008

  • The Tenth IEEE International Conference on e-Health Networking, Applications & Services (IEEE HealthCom 2008) takes place from 7th July to 9th July 2008 in Singapore (BioPolis - Matrix building 4th floor).
    • 130 attendees. 50% from oversea.
    • papers: 40% acceptance rate
  • Below are my notes of the presentations/sessions I have attended:

Keynote: A Road to Disease Prevention through Telemedecine and e-Health - Prof. Luis Kun Ph.D. FAIMBE, FIEEE.

  • Very interesting presentation on various topics: Interoperability and Globalization!
  • Interoperability is needed not only in Technology, but also in Process and People.
    • Dimension of time in CPR: Very often patient Dental, Mental health, Behavioral, Immunization, Prenatal, Labor and Delivery, Family postmortem related information is often not available at the hospital which increase medical errors.
    • We need single PHRs throughout the lives of the individuals (e.g. Dod and VA administration do not have access to non-military information sources).
    • Longitudinal Health Record (LHR) and intelligent Data WareHouses will be able to acquire and store multi-modality medical Data, fuse it into clinical records, along with laboratory, anatomical pathology, pharmacy, imaging and bio-molecular data, importing data from existing EHR.
    • However, privacy, confidentiality and ethical issues remain.
    • Prof Kun also mentionned the HRBA (Health Record Banking Alliance), a way to promote community repositories of electronic health records - in competition with Goolge Health & MS Health Vault private initiatives?
    • Mobile interoperability: we need better wireless devices integration through standards.
    • More use of micro-systems body worn, implanted mobile systems and location based systems.
    • Chronobiology and chronotherapeutics: taking in consideration the time when you take drugs can be very important.
    • PHRs should be compatible across countries (to take into account he health history of immigrants for example).
  • Globalization We are more interdependent that we think, thus increasing health risks, war, pollution:
    • Populations size and migration increase.
    • Food is imported/exported from more and more countries.
    • Global dust cloud across continents can help transmit diseases.

Session: Geriatrics and Eldercare : a lot of various sensors and methods are used automatically to track behavior.

  • IC Tag Monitoring System Identifies an Unusual Pattern of Toilet use by Patient with Vascular Dementia - (Japan - Hospital Chubu region)
    • Tags are put on the shoulder of the patients with patches.
    • Technology is used to complement training of personnel provides more precise real time monitoring, especially at night-time.
    • Allow statistical studies when merged with demographic and other health related data.
    • Discover specific unusual behavior patterns - e.g. a patient can walk up to 10 km per day, or up to 150 times per day to the toilet (non incontinent patient).
    • Future work will involve combination of tracking staff activities with patient activities.
  • Automatic detection of Activities of Daily living from detecting and classifying electrical events on the residential power line - Norbet Noury - (university of Grenoble)
    • Goal tracking: tracking systems, used to trigger alarms.
    • Watteco : a detector placed in the main electrical supply board to detect instantaneous signatures.
    • Issues: non automatic learning system: setup has to be done manually.
    • Use different weight for various appliances.
    • Issues: need to take into account seasonal variations
    • Activities tracking:
      • feeding, grooming, toilets, day vs night activities
  • Smart Wireless Continence Management System for Elderly with Dementia.
    • use sensor / wetness detection / placed in diapers (cost $50 per sensor -reusable).
    • plan to use RFID as well
    • care giver alerted through LED, Buzzer, 3D /GUI and SMS alerts.
  • Eating Activity Primitives Detection - a step towards ADL recognition.
    • basic safety, daily living and social interactions
      • person location
      • use of potential harmful objects
    • Combination of sensors: motion detecting PIS, pressure, accelerometer, RFID.
  • Approaches and Principles of Fall Detection for Elderly and Patient.
    • 4 types of falls: from sleeping, from sitting, from walking or standing, from standing on ladder, stool.
    • Devices
      • Wearable devices (postures, motion) - e.g. walking sticks
      • Camera based (inactivity detection, body shapec change, 3D head motion)
      • Ambiance devices (presence, posture)

Session: Knowledge Management and Ontology in HealthCare.
  • Design and implementation of a Knowledge-Based Applications in Specimen Collection
    • Tests collection by phlebotomy stations - tracking done via ATOM system
    • Barcode Lab Information System (LIS) based demographic and session ID labels are added to testing tubes/containers.
    • COW (Computer on Wheels) systems at point of care (used by doctor and phlebotomist).
    • Reduce the number of human errors dramatically.
    • Issue: multiple distributed systems can still lead to errors (e.g. if there has been delays in the production of the lab results).
  • An Ontology-Based Framework for Managing Semantic Interoperability Issues in e-Health (Singapore).
    • Need to decouple domain knowledge from underlying intelligent agent infrastructure.
    • Use ontology (explicit domain knowledge) used by multi-agent systems.
    • However, domain knowledge can be very complex.
    • Semantic interoperability is an issue in Health Care - same object for various terms e.g. Anemometer or Sphygmomanometer.
    • Context must be brought in.
    • Use of dialogs/predictions
    • Issues: multi-language interpretation
  • Management of Mobile Social ntework services for families with Developmental Delay Children (Taiwan)
  • Assessment of User Satisfaction with an Internet-Based Integrated Patient Education System for Diabetes Management.
    • different types of formats are used (e.g. text, powerpoint etc ...)
  • A Framework for Personalized HealthCare Service Recommendation (South Korea)
    • see Healthcare provider recommendation system (Bachus et al.) - US patent
    • However there is a need for personalization
    • HSRF provides personalized results.
    • Integrated with MUSS - Mobile U-Health Service Ststem (see Lee et al)
    • Health Status is a combination of Bio Signals & Symptoms
    • Health Vector is generated from patient information.
    • Heuristic calculates the distanced between users vectors and vectors of services
    • Use satisfaction / user feedback to refine the recommendations.
    • Technology use is JSP, AXIS, MYSQL

Session: Security and Privacy in HealthCare
  • A Web-Based Wireless Mobile System design of Security and Privacy Framework for ubiquituous HealthCare (u-HealthCare) - San Jose, CA
    • SSL, data encryption, Windows based solution
  • Secure WBAN Usng Rule-Based IDS with Biometrics and MAC Authentication - India
    • Use Wireless Sensor Networks (sink +sensor) for medical monitoring.
    • Take into account constraints in Sensor Network Security
    • Use strong public key Cryptography technology
    • Cost factor is the limitation
    • Denial of service are the type of attacks that are prevented
  • Privacy-preserving EHR linkage using pseudonyms identifiers.
    • Need to allow patient to keep certain linkages private (e.g. abortion, drug addiction clinics)
    • Need to link only records belonging to the same patient
    • Need to override privacy rules in emergencies?
Session: Discovery
  • Highly Interactive and User Friendly Web Application for People with Diabetes
  • Training Program for e-Health in Tokai University (Japan)
  • Ride Comfort Analysis Based on Tilting Train Simulator for e-Health Train (Korea)
  • Development of the Support System to Help Team Care for Home Care
  • Security and Privacy fro WiMoHS (Wireless Mobile Healthcare System)
  • A Case Report on a e-Learning for Health Initiative in the Philippines
  • Comparison and Optimization of Methods fro Intra-Disc Vascular Architecture Extraction

Keynote: e-Health from the hands of Patients - Prof Yu-Chuang (Institute Biomedical Informatics, National Yang-Ming University Tapei).
  • H2H Exchange: Medical Information Exchange Center. Attempts to interconnect EHRs were not very sucessful. The main reason is that the providers were reluctant.
  • Could ATM machines be a model for Hospital-centric exchange? The problem is that hospitals are afraid to loose patients/customers (in the case of ATM machines, bank accounts are not transfered, whereas EHR transfer would be similar to full bank account transfer).
  • Patients should be the one who initiate the transferts: H2P2H exchange and the content of Health Record belongs to the patient.
  • Standard format?
  • Health Smart Card started in 2004 was a success however.
    • 23M Health Smart cards (non RSA card)
    • 100K Health professionals would would have RSA cards
    • issues:
      • too small for EHR (8KB)
      • patients do not have a reader for their card
  • TMT: Taiwan Electronic Medical Record Templates (2007-2011)
    • 70 templates, 24K data elements, 3 years.
    • A couple of days are necessary to map templates to hospital documents
    • Patient centric, initiated and own exchange (PIX).
    • XML based, signed , but not encrypted
    • Masking function available for the user to keep privacy
    • Patients will be able to use viewers at home to see their records (open source)
    • Data can be stored on USB disks or to Health Data Bank
    • 11 largest hospitals (27K beds) -
    • 2000 pilot patients
    • Would expand to 7M (30% of the population) in 5 years.
  • TET (Travelers Electronic Health Summary)
    • template-based approach
    • Endorsed by APEC, IMIA, EFMI, AMIA, APAMI
    • some degree if international interoperability
    • 88 data elements. Similar to CCR.
Session: e-Health
  • Assistive Care Loop with Electronic Maternity Record -D.B. Hoang - Univ. Sydney.
    • provide alert, notifications, advices (SMS, email)
  • A Framework for Assessing ICT Preparedness for e-Health Implementation
  • Information and Communications Technology Needs Assessment of Philippine Rural Health.
    • few people own laptops, but a lot of people have cell phones.
  • An Approach for E-Health System Assessing ICT Preparedness for e-Health Implementations.
  • An Empirical Analysis of Reduction of Medical Expenditures by the e-Health System: Further Results.
  • Challenging Interoperability and Bandwidth Issues in National e-Health Strategies by a Bottom-up Approach: Establishing a Performant IT Infrastructure Network in a Middle East . State Vienna University of Technology.

Session: Communication Technology in Mobile HealthCare
  • Power and Delay Aware Mobile Application Data Flow Adaptation: the Mobihealth System Case study - Kataryna Wac - University Geneva.
    • patient tele-monitoring services (cardiac sensor: HR, SpO2, pleth, 3 led ECG, alarm (128 Hz)
    • use 2.5/3G WLAN and bluetooth andTMSI box (NL)
    • started in 2001 with Vodafone (Mobihealth) - worked with mobihealth, vodafone and Myotel
    • in 205-06 (project HealthService24)
    • in 2004-08 : Freeband-awareness - location, time, standing status of the patient.
    • in 2008 - MobiHealth BV - Commercial application
    • in 2009 - Myotel project
    • study the optimization of the battery consumption (li-ion polymer 1490 mAh), match delay requirement to emergency/non emergency case.
    • Mobile device: Qtek 9090, Windows Mobile 203 (battery drain!)
    • WWLAN (802.11b) & WWAN-GPRS (class 10: 4+1/3+2 slots)
    • Appplication flow: 5-14 Bytes, 128 Hz, aggregation 1 sec of Data., compression (ZIP) 38-85%, TCI/IP end to end path. continuous 1.2, 1.5, 5.5 or .7.7 kbps or burst 5.5 or 7.7 kbps
  • A study on Intra-Body Communication for Personal HeathCare Monitoring System - Waseda University, Japan
    • use human body (skin and muscle) as signal transmission medium
    • use ECG (future plan to use other types of sensors)
    • use central hub
    • use 3-USB receiver Unit (USB2.0/1-1 12mbps
    • transmiter: Agilent E443B, receiver: tektronix WCAA230
    • 75 MHZ is found to be the optimal frequency for intra-Body human skin communication (electrostatic coupling model).
    • weather and sweating have small effects on the results.
  • A Platform for Personalized Mobile u-Health Application Design and Development - Korea
    • MUSS Mobile U-Health Service System (Application Platform) + Workbench
    • Application model i sbased on 5 phases (sensing, Questionaire, Data processing, Disease Management User feedback).
    • MUSS: 3 layers
      • Component : combine web services
      • Process : BPM engine
      • Application: Application Designer + scenario player are store in application portal
    • Application designer generates Application scenario in XML format for stand alone or web application.
      • Process consist of activities
    • the platform is written in Java
    • the client is written in C++ and C#
    • Heath Care specialist can create questionaires via the Questionaire composer.
    • Example: Stress Application
      • sensing: Bluetooth PPG sensor
      • questionaire: stress response inventory
    • Future work: application designer will use conditional and more complex workflow.

Monday, June 2, 2008

Google IO 2008

Keynote: Client, Connectivity, and the Cloud - Vic Gundotra, Vice President, Engineering
  • Historically access to computing and deployment of applications have not been easy
    • in the 50s & 60s Mainframe were powerful but not very accessible, deployment was easy (terminal were dumb)
    • in the 70s & 80s PCs were not powerful, but accessible, deployment were difficult (complex deployment on all clients)
    • since the 90s Internet made access to power and deployment easier, but there is sill some progress to be made
  • Google wants to move the internet forward by
    • making clouds more accessible (providing more power to web applications)
    • making clients (browsers) more powerful
    • keeping (internet) connectivity pervasive
  • Technologies offered by Google to achieve these 3 goals*
    • Google Web Toolkit *Version 1.5 available with support to Java 5* - The Google Web Toolkit (GWT) is an open source Java software development framework that helps you produce user-friendly AJAX applications. With GWT, you can use your favorite Java development tools to build AJAX applications without having to tackle the steep learning curve of JavaScript/CSS browser quirks. GWT has bee used to develop Google Health
    • YouTube Data API - Integrate YouTube videos into your website or application.
See other blog on this topic


Keynote: Imagination, Immediacy and Innovation... plus a little glimpse under the hood at Google
      Marissa Mayer, Vice President of Search and User Experience
  • Google focus on most popular Web Applications on the Web:
    • EMail
    • Social Networks
    • Blogs
    • News
    • Search
    • ...
  • "The simplest design is probably the best"
    • e.g. in Google Search, everytime a search query is done, it hits between 700-1000 Google servers. This involves load balancers, mixers, several search engines (image, blogs, books, news, videos, maps ...). The whole process takes 0.16 seconds. However the GUI still hides the complexity of the process and remains very simple. E.g. Use an unified logging/authentication/authorization system (eg. OAuth)
  • On User Usability
    • a lot of studies are done regularly with a lot of statistics gathered on very small changes on Google Applications. e.g. small changes such as the space between lines e.g. testing various background colors
    • performance remains one of the most important criteria for users
    • user want instant feedback (e.g. uploaded content should be available right away)
    • novice users become very quickly experts users (e.g. simple google search page to iGoogle portal).
    • It is therefore important to not spend too much effort to coach novice users and/or provide too much guidance (this could slow expert users)
    • experts users are those who will being more revenue
    • usability studies should target expert users
    • Google uses a mix of direct user feedbacks (such as emails), existing applications user studies (instrumentation + metrics) and testing new designs changes with controlled panels of
  • Use an Happiness Matrix for your products to measure user satisfaction
  • Use Design more as a Science than an Art
  • Try to think 10 years ahead- Goal: Aim at quantum leap (a good example is the iPhone)
  • Build on real flexible technologies
  • Be Scrappy. Revel in constraints. Google works in small groups and create quickly prototypes for testing and try to address very difficult problems that seem impossible to solve.
  • Imagination is a muscle : Do not hesitate to brain storm about crazy projects with your team even if you do not intend to make a product of it. Try to come up with solutions and mockups (at Google 50% of the product features come from 20% time given to Googlers to work on personal project).
  • On Google Health: We will never be able to have all the medical record information online, but Google hope to make a difference in this domain too.
  • On Future Directions for Google Applications and Services
    • All: Personalization
    • Search Engines:
      • search on Phones
      • search on Graphs
      • Location based search (GPS will be soon integrated by default in most cars and vehicles)
      • Take into account previous search to improve future searches.
See other blog on this topic