Thursday, September 18, 2008

Today, I completed the development of the Patient Portrait Module according to the proposal I have submitted and gotten approved by OpenMRS. The Patient Portrait Module comprises an image viewer that provides features for uploading an image, removing an image, and displaying the most recent image of a person in the patient dashboard. With the instruction of my mentor, ended up not including zooming-in and –out an image, and display all available images for a given person.

Before completing the project, I had to overcome recently the following two issues:

- For uploading an image, I wanted to use jQuery Form Plugin. The jQuery Form Plugin allows you to upgrade HTML forms to use AJAX, which is very simple. After adding the necessary code to the jsp file for uploading the image, everything seemed working fine. The image was being uploaded and saved in the database. However, after the upload process, a blank page was being displayed, which is not normal. After a lot of debugging and with the help of my mentor, I discovered that I did not handled properly the callback method showResponse(), which is responsible for displaying the image after uploading it. I needed to get back the obsId of the image and use it to display the image.

- In order to save the image in the database, I needed to create a Concept Complex for it. The Concept Complex is created in two parts. The first part is to add a global property in the confing.xml file of the module and give it a name. The second part is to use OpenMRS application to manually add the Concept Complex to the dictionary of concepts. Now, when I first created the Concept Complex called PERSONPORTRAIT, I did not add a handler for it. Later on, when I wanted to modify this concept to associate it with the handler, OpenMRS was throwing an exception saying that the concept already exists. Unsuccessful associating the concept with the handler, I created a second concept for the dictionary and associated it with the handler successful. I changed the name of global property in the config.xml file to the second name. After this changes, the upload picture stopped working. After hours of debugging I was not able to fix the problem and I asked my mentor for assistance. It turned out that, if you change the name of the global property in the code, it will not be automatically changed in OpenMRS. You need to manually change the name through the Global Properties Manager found in the Administrator page. This issue needs to be addressed by OpenMRS.

Monday, August 25, 2008

Implementation Phase

I have been very slow updating this blog. Since the last time I have updated it, I have made a lot of progress working on the project. I am event getting closer to completing the project.

The following are the two major issues I had to overcome in the last few weeks.

First, the initial approach for implementing the Person Portrait module, was to have a separate module that can be accessed through the OpenMRS Administration page. After consulting with my Mentor, David Thomas, he advised me to use a portlet to implement the Person Portrait support. In this way, it would be easier to use the portlet through various extension points in the OpenMRS system.
We decided to use the DWR package to implement the portlet. With DWR, it is very easy to communicate between a client and a server by allowing JavaScript in a browser to interact with Java on a server..

Second, after implementing the portlet using DWR, we realized that the DWR service does not support images upload. The problem is that openmrs is tied to an older version of DWR (1.1.3), which does not provide support for image upload. The new version (2.0) that supports image manipulations is in its beta version. The discussion on the OpenMRS developers forum about upgrading OpenMRS to this new version did not favor relaying on the beta version. Therefore, we decided to abandone the DWR and use sevlets to manipulate the images between the client and server.
We used two servlets, one for uploading the images into the server and one for manipulating the images once they are saved on the server. The operations include loading a person most recent portrait, displaying all the available portraits for a given person, deleting a portrait, and zooming in and out a portrait.

A this point of the project, I have completed implementing the upload portrait functionality. I have also implemented the loading the most recent portrait of a person.
This week, I am planning to complete the project by implementing the functionalities for displaying all available portraits for a person, deleting a portrait, and zooming in and out a portrait. Once all the features are implemented, I will finilize the project by performing some testings of the module.

Tuesday, July 22, 2008

Starting the implementing phase

Last week, I started the implementation of the person portrait module. I created a module by following the instructions from "Creating Your First OpenMRS Module" on the OpenMRS "Developer How-To Guide". The instructions are easy to understand and I was able to run my first module at the first try. The module was accessible through the OpenMRS's Administration page. For this first version, the module had only a jsp file and a controller.

I was also given svn space on openmrs.org, where I can store the module code. I added the module code to the svn repository in the folder "personportrait", the ID of the module. Now, I feel more safer than just having the code on my laptop.

Last week also, after creating the module skeleton, I started the implementation detail. I decided to break down the implementation into two parts. The first part is uploading the person picture and saving it into the OpenMRS database. The second part is retrieving the picture from the database and displaying it on the browser. For the first part, after checking around for a while, I decided to use the FileUpload API from Apache Commons; in particular, the Streaming API. This API provides good performance and low memory profile. However, when I began coding, I realized that the version of the FileUpload included in the Complex-Obs branch (commons-fileupload-1.1.1.0.jar) does not support the Streaming API. The current version of the FileUpload, which provides the Streaming API is 1.2.1. I am planning to talk to my mentor, David Thomas, about this issue. In the mean time, I am using the MultipartFile class to upload the image.