Saturday, January 28, 2012

Making Love to Webkit

I just viewed Steven Wittens Acko.net and it is just awesome. You have to click here, to see the amazing stuff done with CSS 3D on the website. Don’t forget to click on the Load Scene, a little down in the post and then using the mouse to drag the scene. Classic Stuff!!

The site has used mrdoob’s JavaScript 3D library that also has some amazing examples to look at. It is very interesting to see how 3D in JavaScript is coming along in Webkit. People have been making Love to Webkit and it all looks so aesthetically pleasing and romantic…

Friday, January 27, 2012

NetCAT goodies

Some people might have followed on the blog that I had been participating in the NetbeansDSC00501 Community Acceptance Test (NetCAT) program for the 7.1 release. The release in my opinion is one of the most stable versions of Netbeans ever. This should be attributed to the co-operative effort between the developers, quality managers, community of testers and Jiri Kovalsky, who manages the NetCAT program.

There are some points for bugs, fixes, RFE, feedback, surveys etc. during the alpha and beta phase of the development and the NetCAT final tally for 7.1 is here. The best part in my opinion during this NetCAT release compared to earlier years was the quick bug fixes delivered by the Netbeans Engineering Team.

I also got some goodies for participating in NetCAT.

Thursday, January 26, 2012

Why REST with JSONP when you can CORS?

JSONP (JSON with padding) is a hack used by JavaScript developers by wrapping a JSON (JavaScript Object Notation) document within a function call. So, if the JSON document looked like {"givenName":"John", "familyName":"Smith"}, the JSONP for the same would be callback({"givenName":"John", "familyName":"Smith"}) (callback being the commonly used wrapper function). So, if you are familiar with JSONP, you will realize that it is used to make Cross-Domain calls where JSON is not accepted by the browsers if they come from another domain. Thus, AJAX requests across a different domain was not possible through JSON and hence using JSONP was the common hack.

The problem with using JSONP is that it is called as a JavaScript function response and hence CORS-supportyou will not be able to use it as normal HTTP calls. That means you would not be able to send HTTP headers and that can be a problem at many places. There are hacks to deal with the problem, but these are best described as hacks. Another limitation of the JSONP hack was that you could only make GET requests and nothing more. Hence to make a standard, W3C created the CORS (Cross-Origin Resource Sharing) standard which nearly all modern browsers support.

The main issue with using JSON or AJAX (XHR – XMLHttpRequest) across domain was that browsers would not be able to acknowledge if the response was malicious or in response to the request that they made. The same-origin-policy, prevented making cross-domain requests. Then came CORS, a technique by browsers to check the origin policy first and then accept responses. So a server that wants to allow getting any type of HTTP request from another domain would list the domain or * in its HTTP response header as follows:

Access-Control-Allow-Origin: *
Access-Control-Allow-Origin: http://example.com:8080 http://foo.example.com

This means that there is some modification to be done on the server-side resource to add these headers to the response. Another point to note is that it works with XHR requests as well as client errors (4xx) and server errors (5xx).

Excellent examples on how to use CORS can be found at HTML5Rocks. On the server-side of things, you can find resources to enable CORS.

In Tomcat for a Java web application, you can enable CORS using the CORS Filter library. Basically you copy the jar file into Tomcat lib or WEB-INF/lib of your application and then add filters in your application’s web.xml or tomcat’s global conf/web.xml. For a resource which requires Basic Authentication and Cookies can be configured as follows:

<filter>
<filter-name>CORS</filter-name>
    <filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
    <init-param>
     <param-name>cors.allowOrigin</param-name>
        <param-value>*</param-value>
    </init-param>
    <init-param>
     <param-name>cors.supportedMethods</param-name>
        <param-value>GET, POST, HEAD, PUT, DELETE</param-value>
    </init-param>
    <init-param>
     <param-name>cors.supportedHeaders</param-name>
        <param-value>Content-Type, Last-Modified</param-value>
    </init-param>
    <init-param>
        <param-name>cors.exposedHeaders</param-name>
        <param-value>Set-Cookie</param-value>
    </init-param>
    <init-param>
        <param-name>cors.supportsCredentials</param-name>
        <param-value>true</param-value>
    </init-param>
</filter>
<filter-mapping>
        <filter-name>CORS</filter-name>
        <servlet-name>MyServlet</servlet-name>
</filter-mapping>

Instructions for Cookies in Safari can be challenge. A nice post to workaround can be found here.

Wednesday, January 25, 2012

Difference between iPad2’s Safari and Desktop Safari

Since we are targeting the Raxa EMR for JSS for Webkit-based browser, it is important that the team understands the subtle differences between the Desktop shipped Safari and the version of Safari shipped for iPad2. The differences with Chrome are quite a few, so I won’t list those here.

Following are some of the differences to remember:

  • No Flash support
  • Safari iPad does not support position:fixed in CSS
  • Safari iPad creates link for 10-digit numbers automatically
  • Safari iPad does not allow scrolling over textareas and iframes
  • Safari iPad has issues with CSS Animations that cause flickering. Use JavaScript animation or hacks in CSS -webkit-backface-visibility:none; and -webkit-perspective:1000;
  • Safari iPad greys the upload button

Things have been improving compared to the first iPad and iPad2 and the differences are minimizing.

Saturday, January 7, 2012

EMR at JSS Bilaspur – In pursuit of happyness

Over the last 3yrs, I have travelled across the world and looked at 100+ health facilities of different scales. My last encounter with a health facility in rural Bilaspur was very different. Having looked at systems of practice in a variety of health facilities including subcenters, private clinics, primary health centers, community health centers, district hospitals, tertiary hospitals and super-specialty hospitals, each of these places have different characteristics. What makes Jan Swasthya Sahyog (JSS), situated in rural Bilaspur in Chattisgarh special is the motivation levels among all the staff at the health facility. This includes clinicians, nurses, technicians and computer operators… And the motivation of these people stems from the fact that they still believe in care, rather than just providing health services. I use “still” because in my worldview of health facilities, most often I see people missing out on the “care” from the notion of health-care.

My visit to JSS was for volunteer work that I have been doing over the last few months to see an Electronic Medical Record (EMR) system to be setup at JSS. Over 100 volunteers across the world have come together in this pursuit to build an EMR system that is easy to use, suited to low-resource settings and can help improve work of the providers as well as help provide better services to patients. JSS was founded 15yrs back by post-graduates doctors of All India Institute of Medical Sciences (AIIMS), India’s most prestigious medical school and hospital to provide healthcare to people who are deprived from it because of poverty, neglect and lack of development. And when I visited JSS on Christmas 2011, I could see the savior work done by JSS for the many people who come from far-flung places because they are treated with dignity and care.

The EMR system broadly from interviews and discussions with some doctors, nurses, other staff and my interpretation of the context needs to do the following:

  1. Help to improve efficiency in use of resources and providing patient care
  2. Help to maintain correct medical practices through validations
  3. Help to understand who, what, why is being treated at JSS

EMRs or for that matter any computerization process advertises many-fold benefits. Technology is most often considered the silver bullet that will solve all problems. From my experience this is rarely the case. So these 3 points might provide a guiding path to decisions that we make in the design of the EMR. In the design of the EMR, just like JSS we have to put “care” at the forefront of our efforts rather than technology prowess. Thus, this system is envisaged to be a point-of-care systems where providers will look up records and use the system to provide “care”.

The other very unique thing about JSS is that is it rooted in the locale of the context. Having seen other health facilities setup by “change-makers-coming-from-the-outside”, JSS is uniquely very much part of the context. This is one of the reasons I see why people come from more than 100kms away to JSS for treatment. People view JSS as locals and one among their own. This is one aspect that I think the EMR system should incorporate. It should embody in itself the locale. By locale, I mean the local practices, language, usability… among other things.

I would say we have some lofty goals for the EMR. One that the project lead calls as “Linux of EMRs”, but in my opinion even if we achieve more humble ends, like not causing burden to providers and patients that would make me happy. It is this pursuit that drives me to work towards this cause. I call it a pursuit because I realize this is not something that is a stagnant phenomenon. It will change with every small change that we make. Every morning it is this pursuit of happyness that drives me to understand what an EMR system would be of use at JSS.