A Django site.
June 27, 2008
» Barcode Fun With OpenMRS

The Registration Module is supposed to generate Barcode images that will be printed on stickers and given to patients on their ID cards. This will help easier logo  identification of patients and quicker patient registration. For this purpose, we use the “Patient Identifier” to create barcodes. The “Patient Identifier” is hopefully unique and will help create bug-free barcodes.

Barcodes have a lot of different standards like Code39, Code128, UPC-A, UPC-E etc. Each of these standards were designed for a specific industry and application. And the Registration Module should support different standards so that it can be easy for the implementers of OpenMRS to choose any standard that they want. Thus, began my journey to find a way to generate customizable and easy barcodes.

Having just finished with the commit for the barcode generation in my registration module, I am extremely happy to say that Barcode Generation through the Registration Module is very easy. Still have to implement a print dialog box, but then the way to generate barcode is done through a pre-built servlet... I used an open-source barcode library called Barcode4j, which can generate barcodes in a variety of standards as well as image formats.

Barcode4j is an excellent library and after comparing about 15 different barcode libraries, I found it to be the most easy-to-use and extensible. Barcode4j already provides a Java Servlet which needs to be passed different parameters and it generates the barcode image “just-like-that”. The only thing I had to do was create a mapping for the servlet in the modules “config.xml”.

And that was it... Those nice black lines were shown on screen beside the patient search results. Now I needed to see if the barcodes are accurate and working. I took a printout of the image and scanned it through the barcode scanner. Hurray!! It worked!! And thus I realized that the servlet was accurately creating barcodes. Now moving onto creating a nice AJAX print dialog and probably some useful UI for creating identity cards.

June 23, 2008
» Review: openSuSE 11.0

On the 19th of June 2008, openSuSE 11.0 was released and I was very excited about the new release because my experience with openSuSE 10.3 has been very good and I have been following the development of openSuSE 11.0 closely. In the meantime, I have tried Ubuntu 8.04, Kubuntu, Fedora 9, openSolaris 2008.05, but somehow I’ve been coming back to openSuSE 10.3 because of some or the other nagging problem with the other distros...

Download

I downloaded openSuSE 11.0 the moment it was released and I have to say that the release was very professionally co-ordinated. There were launch events all around the globe where people received their openSUSE 11.0 DVDs and with the counter running all the time, everyone knew when to get their download managers ready. The mirrors were fast and the torrents seemed to have enough seeders. I finished the 4.3GB DVD iso by 20th morning (IST) in just about 4hrs time. There is also a single Live CD KDE iso, GNOME iso as well as a MiniCD (71 MB) for Network installation...

Installation: Image-based Deployment and Sleek

The openSuSE site has a nice installation guide with screenshots and it doesn’t make sense for me to go through the same thing again. But two things are special in openSuSE 11.0 that are worth mention. The first is that they have a gorgeous installation GUI, the best looking installation for any operating system ever!! Its easy to install and intuitive. The second the use of image deployment for the installation of GNOME. This really speeds up the installation if you are just using the basic GNOME-based setup. I generally prefer KDE, but for the test I installed the GNOME and it was fast... really really fast! I was shown the GNOME desktop with all the preferred software installed in straight 15 minutes. That’s faster than any other distro that I’ve ever installed. It was an amazing experience to see such a fast installation!

SuSE11-ImageDeploy

Like previous version, openSuSE 11.0 comes with a variety of useful non-opensource software like flashplayer, java 1.6.0_u6, fonts, Adobe reader 8, etc. Along with these I also installed Jdk6 update 10 (the awesome new Java Plugin), Mono, Netbeans 6.1, GlassFish for my OpenMRS performance test... KDE 4.0 is also there as a separate choice of GUI when installing along with KDE 3.5.9, GNOME 2.22. Since I have never been able to stably run KDE 4.0 and have always switched back to KDE 3.5, I thought I’d try KDE 4.0 in openSUSE 11.0

SuSE11-KDE4

I was pleasantly surprised that KDE 4.0 “just worked”. I had my first KDE 4.0 crash after 1.5 hrs of use whereas earlier it was before 20 min that the SigEnv or Segmentation Fault would throw up. I still didn’t want any crashes and hence I’m back to using KDE 3.5.9. But KDE 4 is really coming good!

As soon as I finished installing, everyone at home wanted me to record the Euro 2008 matches and soon I needed VLC to be installed. I went to videolan.org/vlc and clicked on the SuSE link... and I was greeted with a 1-Click Install button.

SuSE11-VLC-1Click

This was one of the really awesome openSUSE things that was first brought in openSUSE 10.3 and has been improved in openSuSE 11.0. I clicked on it and the installation was finished really quickly.

Improved Installation with YaST

That’s when I realized the most important update to openSuSE 11.0 which is the improved speed of YaST. No other distro has such an easy administration tool where nearly everything can be administered. And in openSuSE 11.0 everything in the YaST module just works. RPM installation is fast and adding community repositories is easy. I am a big fan of apt-get in Ubuntu, but openSUSE 11.0 software installation is just as easy now...

SuSE11-CommunityRepo2 SuSE11-CommunityRepo1

Every piece of hardware worked

I have lots of hardware, old and new on which I often install and test different distros, Windows, OSx86 etc. openSuSE worked with every bit of hardware that was thrown at it out of the box. Every distro struggled with the UMTS 3G card on a laptop, but surprisingly openSuSE 11.0 made it work. Few other distros had trouble with the legacy Nvidia Quadro GoGL card on another laptop, but openSuSE 11.0 worked... Old printers, USB devices, Firewire everything worked. Even the Barcode Reader with PS2-USB converter worked on the USB port which wouldn’t work on Ubuntu 8.04 or other newer distros.

The only change was that on my desktop Intel DG965RY board the surround sound wasn’t working. I followed the Audio Troubleshooting doc, added the model=dell-3stack and all my speakers started trumpeting!

Compiz-Fusion and the Bling

Last time I was not happy with the stability of Compiz-Fusion on openSuSE 10.3. For Ubuntu 8.04, Compiz-Fusion worked well and so I knew it was something to do with the new kernel module driver on my system. With openSuSE 11.0, Compiz-Fusion works perfectly and is able to show all its features. A nice little configuration screen helps manage the amount of effects that you wish to enable. I personally don’t enable effects, but its a good show-off to make people standup and appreciate open-source beauty.

SuSE11-Compiz SuSE11-Sphere

Other features and improvements

  • Linux kernel 2.6.25
  • glibc 2.8
  • GCC 4.3
  • 200 other new features

Conclusion

You can’t miss the ease of use and the sleek looks that openSuSE 11.0 brings to the desktop. Its the perfect distro for a new user coming to linux. For the old pros, openSUSE 11.0 is fast and brings in ease of administration and software installation. Novell support is pretty good for big organizations that can buy a boxed product from them. Xen is my favorite for virtualization and it has good integration and management in YaST. But the strength and momentum of openSUSE is definitely in the desktop space. Earlier, openSuSE lacked the community backing that Ubuntu has generated in a short timespan, but with new initiatives and better responses at openSuSE forums, the openSuSE community and grown leaps and bounds. openSuSE 11.0 has grown from strength to strength and is one of the best ways to give competition to Windows on the desktop!

Other screenshots

gnome-desktop The GNOME Desktop KDE-desktop The KDE Desktop
Cube-atlantis Compiz-Fusion Cube Atlantis Plugin Animation-burn Compiz-Fusion Burn Animation

June 16, 2008
» Improving Java Web Performance With C/C++

From the very first day that I had been working on OpenMRS, I felt that OpenMRS ran a little slower than I expected. Probably the old OpenMRS demo server openmrs_logo adds to the slowness. Later, when we were discussing about how Hibernate sessions should be implemented in OpenMRS and Java Web Apps in general, I was again brought to think about OpenMRS performance.

Since OpenMRS community generally implements on Tomcat, my main aim was to improve performance of the servlet container. One simple way to improve performance, which I had heard of earlier was the use of Apache has the “Apache Portable Runtime” (APR) project with Native Libraries. The APR uses native libraries with JNI to improve the server performance on a specific platform. In short, Tomcat is given some local OS steroids and currently works on Windows and POSIX-based systems.

The APR library is somewhat an irony for 2 main reasons:

  • I’ve heard this argument that Tomcat runs faster than Apache in some benchmarks. These guys argue that Java is faster than C/C++ and hence Tomcat wins.
  • On the other hand, APR and Native Tomcat uses JNI code written in C/C++ to improve performance.

Either ways, I think generalizing the above statements isn’t correct and hence I went forward to see if APR does improve performance of our web application. I used Windows Vista and Tomcat 6.0.16 for the test and Windows is probably what most OpenMRS implementations use. You can download the native binaries for Windows from here & APR from here.  Add the extracted files to Path and place the tcnative-1.dll in APR’s bin folder.

And the first thing I observed tomcat started little faster and even OpenMRS initialized slightly faster.

 
Before
After
OpenMRS initialization 192ms 183ms
Tomcat Server Startup 12892ms 11449ms

But startup improvement is not all. We want to check how good the application is performing and Apache Benchmark (ab) is a good way to test static content, but isn’t very good at dynamic content... I wanted to use Faban after I remembered Scott Oak’s writeup from last year, but couldn’t find enough time for the testing with Faban...

Instead, I used JMeter which is a nice generalized test that replicates how a user interacts with the web application. You can send POST requests with parameters and also simulate your test plan, just like a normal web user would use your application. Here are some of the results on different OpenMRS pages with 10 concurrent requests and average of 3 runs on my dual core server:

 
Without APR
With APR
OpenMRS homepage 225.7ms/request 185.7ms/request
User Login 1464.2ms/request 1185.3ms/request
Find patient 95ms/request 80ms/request
Patient dashboard 2887.6ms/request 1984.3ms/request

My first observation was that the first run on the test completely sucks. The later runs improve performance drastically. This is because of tomcat 6 has good caching mechanism and was shown with or without APR. Another thing I observed was that beyond 500 concurrent users the application was crying and tomcat was hanging up. APR or no APR didn’t matter much... I’ve yet to analyze why it wouldn’t scale any further, but must be something related to Hibernate sessions. May be some experienced developer can look into these figures, perform some more specific benchmarks and improve scalability.

June 10, 2008
» Second Week For OpenMRS Coding

Last week was really a hectic time for me and hence haven’t found much time to code or blog. A close friend Debojit is in a new Idol-like reality show called “Jo Jeeta Wohi Superstar” and we are back in the publicity campaign like we were when last time he won Saregamapa Challenge 2005. The good thing is that I’m still writing code (to game the online voting), but not exactly for OpenMRS… But I did some work on OpenMRS and nearly had a deliverable basic patient search.

The patient search on my Registration Module has taught me a few important lessons. OpenMRS’s web application uses the Model-View-Controller (MVC) through Spring Framework. I have a controller which calls some methods from the OpenMRS API and retrieves patient information. Normally, the practice is to return values from the Controller to the View (JSP here) is through the use of a bean’s getter methods. This means that the Controller sets the Bean object with the values from the database and the View (i.e. JSP) page uses to the getter methods to get values.

But instead of a bean, I tried to return a double-dimensional array and got stuck with the following... I’m still wondering why I can’t access length variable of the array. Look at the code snippets below and may be I’ll get some hints from you!!

RegistrationController:

protected String[][] formBackingObject(HttpServletRequest request) throws Exception {
        String[][] searchedPatients = new String[0][0];
        if (request.getParameter("phrase") != null) {
            List<Patient> patients = Context.getPatientService().getPatients(request.getParameter("phrase"));
            searchedPatients = new String[patients.size()][8];
            for (int i = 0; i < patients.size(); i++) {
                searchedPatients [i][0] = (patients.get(i)).getPatientIdentifier().getIdentifier();
                searchedPatients [i][1] = (patients.get(i)).getGivenName();
                searchedPatients [i][2] = (patients.get(i)).getMiddleName();
                searchedPatients [i][3] = (patients.get(i)).getFamilyName();
                searchedPatients [i][4] = String.valueOf((patients.get(i)).getAge());
                searchedPatients [i][5] = (patients.get(i)).getGender();
                searchedPatients [i][6] = (patients.get(i)).getTribe().getName();
                searchedPatients [i][7] = (patients.get(i)).getBirthdate().toString(); 
        } 
        log.info("# of patients found: "+searchedPatients.length); 
        return searchedPatients;           
        }
        return searchedPatients; 
}

This String[][] called searchedPatients can be accessed as registrationForm according to my moduleApplicationContext mapping. But in my JSP page when I try to access the .length variable of the registration form there seems to be a problem.

registrationForm.jsp

<c:forEach var="row" begin="0" end="${registrationForm.length}">
    <tr>
        <td>${registrationForm[row][0]}</td>
        <td>${registrationForm[row][1]}</td>
        <td>${registrationForm[row][2]}</td>
        <td>${registrationForm[row][3]}</td>
        <td>${registrationForm[row][4]}</td>
        <td>${registrationForm[row][5]}</td>
        <td>${registrationForm[row][6]}</td>
        <td>${registrationForm[row][7]}</td>
    </tr>
    </c:forEach>

I get an error where the JSP page throws a NumberFormatException for “length” input. Now I was baffled why it was trying to take “length” as input string, when it should have taken the length of the array as its input.

Anyways, with the Bean the current patient search is working, but I have to get back to coding quickly and build a good UI, for which I’m using jQuery. With jQuery I plan to implement AJAX and also some simple but useful UI improvements. Next in-line is searching using the barcode reader and a lot more left to do… Hopefully, I’ll do more!!

May 30, 2008
» Barcode Scanner for OpenMRS

The work on the OpenMRS module continues and I have just got a little more excited because of the barcode scanner that I just purchased. The Barcode Scanner is required to test the working of the module, which will be able to identify patients based on barcodes present on patient identity cards. The Barcodes will help solve problems where patients don't give correct information leading to duplicate records for the same patient.

The Barcode Scanner that I purchased is Argox AS-8000, near-range CCD scanner. Detailed specification on the product can be found here. I tested the scanner and it was able to detect a variety of barcodes. Its a low-end CCD scanner, but it detected nearly every thing I put in front of it. Even round jars and bottle!! Brian advised me not to spend much and hence I brought this open-box one. So was in a hurry to test, coz they have just 3-day testing warranty on these stuff.

Screenshots of the Barcode Scanner:

Scanner-1

Scanner-2

The Barcode Scanner works just like a keyboard and when scanning, the OS feels someone typed in from the keyboard. The scanner works on the PS/2 port of the keyboard and not on the PS/2 port of the mouse. My keyboard is connected to the PS/2 port and hence probably I'll buy a USB converter which will enable me to connect the scanner to the USB port. The Barcode Scanner won't be required by me until I reach the end of the search routines of the registration module... I'm still stuck on getting multiple patients from a search query!!

May 28, 2008
» OpenMRS Registration Module Begins

The Google Summer of Code 2008 timeline shows that we start coding from 26th May and I've already started coding. Before the coding there was thislogo "Community Bonding Period", and I'm not sure if I've done bonding with my community members, but sure I've been talking with my mentor Brian... and he's really a cool guy! We talked a lot about technical as well as personal stuff. He invited me to this house virtually through Google Street View and it was really nice talking to him. I bonded with him well !!

In the meantime, I have been pondering and working on the ideas for the OpenMRS Registration Module.  My Introductory post on OpenMRS showed a lot of interest from friends and got a lot of questions from colleagues. Thanks to r0bby, who told me on the IRC about SoC and talked about contributing to OpenMRS.

The work on the Registration Module has begun and I created the Registration Module documentation page. It is still incomplete on the UML diagrams, but is good enough to show the workflow through the Use-case. Brian and I have also worked on my project plan and have made a timeline that I need to follow. The timeline is a good motivator and will be putting that up on the project page as well. OpenMRS and open-source developers in general, advocate the idea of quick and early commits. OpenMRS shares the Story of FLOSS to make this idea stand out. I'm still trying to get into this mould of development, coz I mainly advocate the planning/design approach. You take twice as much time to design compared to code, but I need to get agile and work on the Bazaar way of open-source. More eyes... More interest and faster working deliverable!!

With this in mind, I tried to commit the basic module changed to registration module, but it gives me a 403 error:

Error: CHECKOUT of '/!svn/ver/4193/openmrs-modules/registration': 403 Forbidden (http://svn.openmrs.org)

I can login through the trac web page. So probably some issue with either my SVN client (TortoiseSVN) settings... or something on the SVN server side!!

April 25, 2008
» Summer With OpenMRS... & that Life is not FREE

I haven't blogged for a few days and I haven't been able to follow the tech news and follow-up on emails. But today, I feel a bit relaxed and probably have something to share. I haven't talked about myself on this blog, but today may be a little bit of philosophy and personal adventure will come through this post.

I had applied to the Google Summer of Code 2008 for a summer job and I will be working with OpenMRS. To all my students, now you have to believe I'm a student... and Moksh guys/gals I'm still your "MEAN" software architect ;-). Just that along with my services at Moksh, I'll also be contributing code to open-source, and consider this post to be an introduction to OpenMRS...

OpenMRS is a free, open-source, Medical Records System targeted towards developing countries and mainly implemented in HIV/AIDS health-care. You can read the Overview of OpenMRS and I think the OpenMRS community has already done a decent job at its own introduction. Instead, I will talk to you why I'm contributing to OpenMRS.

I realized pretty early in my life that "Humans fear death". Although death is the only sure thing about life, we often forget its quintessential for life. But probably its the fear for suffering that's more deathly than death itself. I wanted to be a doctor after I passed out of high-school, just for the sake of treating people and making them realize the beauty of life. I dropped out to prepare for the State Medical entrance exams and it was in this year of self-turmoil that I learnt from a spiritual guru that we can change lives only through what we loved in life. I realized then, that I've loved computers and programming all my life and that my karma couldn't have been more appropriate to hug my love for computers as tightly as I could. In the following years, I learnt new paradigms of programming, new languages and better ways to write code. I'm still learning and pray to God that the learning never ends...

With the same love, I hope to contribute code to OpenMRS, in a pursuit that it helps change lives. My summer job is to make a "General Registration Module" and you can read the details here. My mentor for this project is Brian McKown and hopefully I'll follow his guidelines and be useful to the OpenMRS community. And along with the fun of contributing, Google pays me $4500 + certificate + Google swag for the 3-months (i.e. if I complete the project successfully) and $500 to my mentor.

I don't think the project I'm doing at OpenMRS is a life-changing contribution by itself, but I hope its a beginning. If we all do our minuscule contribution to a social cause, it can really change lives. We have taken life and what life has given us so lightly that we don't respect it. Our skills may be completely different, but its the desire that can help. Although OpenMRS is FREE, life is not FREE. Give back something to the world, which has given you the skills.

I will be regularly writing about my OpenMRS Module and OpenMRS in general. Please look into the project, contribute and offer advice to me on the project.