Write Modules, Save Lives – Part 1

Following is the article on OpenMRS module development that I wrote for Linux For You (July, 2012 Edition) . This article is released under CC by SA by Linux for You.

OpenMRS, a widely used Electronic Medical Record system, is a community-developed, open-source, and enterprise-grade platform. Its core is very thin, and almost every functionality is provided through pluggable modules. It’s robust enough for a nationwide health-care system, and nimble enough for a field-based clinic. This article series will cover how to do OpenMRS module development, and is aimed at J2EE developers, and people who want to contribute to OpenMRS.

A lot of OpenMRS modules exist, and the list is constantly increasing. A detailed list is available at https://modules.openmrs.org/modules/. OpenMRS offers functionality to directly install/update modules through a Web interface—on the fly, without restarting Tomcat.

This first article in this series will cover the basics of the OpenMRS architecture and how to install, update, stop and start a module in OpenMRS. The OpenMRS is built on the Spring and Hibernate Stack and uses MySQL as the database.

Basic architecture

Figure 1: Typical architecture of the OpenMRS stack

The components are:

  • Spring: An application development framework for developing MVC architecture applications.

  • POJO: Plain Old Java Object.

  • Hibernate: The Java persistence framework project, performs powerful object-relational mapping, and queries databases using HQL and SQL.

  • DAO: Direct Access Object

  • Liquibase: Database-independent library for tracking, managing and applying database changes.

An interesting fact about OpenMRS modules is that they are like mini subsystems that can not only communicate with OpenMRS core services, but can also have their own services and schema that can be used by other modules. This makes modules flexible enough to be independent of the system, and robust enough to be dependent on each other, if required.

Module installation

Note: Installing modules through the Web interface is disabled by default (for security purposes). To enable it, set the ‘module.allow_web_admin‘ runtime property to true and restart the application.

  1. Download the module to the local filesystem.

  2. Go to the Manage Module page on the administration page, then click Add or Upgrade Module.

  3. After this, select the .omod module file you downloaded, and click Upload.

  4. The module will be installed without restarting the server. Note that each time an action is taken on a module, the OpenMRS context is restarted. When a module is loaded, database changes in Liquibase that will be required by the module (if any) are applied to the database.

The module is now accessible to everyone privileged to use it. Modules can have granular privileges i.e. any specific set of roles as required by the module.

Note: There are other ways of installing modules, like directly searching the OpenMRS modules repository and installing directly from the repository—or dropping the .omod file in the defined module repository folder.

Module start/stop

Go to the OpenMRS module management page and click the red button to stop it, or the green button to start it. During this, no database changes made by the module are lost; only the OpenMRS context is restarted, and the module is started or stopped.

Module updates

You can check for updates to modules by clicking the Check For Update button on the Manage Modules page. You can also upload a newer version of the module through the Web interface, or directly dump the module file to the OpenMRS module repository.

On an update, first the old module is removed. After that, database changes from the previous version to the newer version (i.e. with different IDs) are applied to the database. Then the module is loaded.

Module deletion

To delete a module, in the module management page, click the grey icon next to the module you want to delete. Any database changes done by the module are not deleted. The OpenMRS context will be restarted after removal of the module from the module repository folder.

References

  • List of OpenMRS sites: http://openmrs.org/about/locations/

  • OpenMRS module repository: http://modules.openmrs.org/

  • Most downloaded modules: https://modules.openmrs.org/modules/stats.jsp

Sweet words of Evangelism

Though I am no more a student these days to apply for GSoC, but its feel great helping others.
———- Forwarded message ———-
From: Harsha Siriwardena
Date: Tue, Apr 24, 2012 at 2:07 AM
Subject: Thank you so much Gaurav
To: Gaurav Paliwal
Hi Gaurav,Thank you so much Gaurav, I am really happy today.. 🙂 🙂 🙂
I will never forget your helps to come up this much so far Gaurav.

Thanks lot again.

Regards,
Harsha

————-

———- Forwarded message ———-
From: Amandeep Singh
Date: Tue, Apr 24, 2012 at 5:32 PM
Subject: Thank you
To: Gaurav Paliwal
Hi,
As you might know, my proposal for GSoC for KDE project has been selected this year. Its really amazing.
Also I think this year around 3 students from USIT have been selected, which is really great.
I would like to thank you for guiding and motivating me all along. It really helped me a lot.


Aman
irc: dedman @ freenode.net
blog: amanonit.blogspot.com

Submitted #GSoC Code sample

Just now submitted the Google Summer of Code 2011 sample code of project General Feedback Mechanism to the OpenMRS 2011 GSoC Repository. Link for the code submitted : http://code.google.com/p/google-summer-of-code-2011-openmrs/downloads/detail?name=Gaurav_Paliwal.tar.gz

Other Details Inline :

######################################################################
Project Details :     General Feedback Mechanism Module for OpenMRS
Project Guide :
Ben Wolfe ( http://blog.eflow.org/ )
Burke Mamlin ( http://blog.burkeware.com/ )
Student :
Gaurav Paliwal ( http://gauravpaliwal.com/ )

#######################################################################
Included Files Details :
trunk :                     Source Code Directory
Feedback-1.0.1.omod :                 Binary OMOD
openmrs-gsoc2011-gauravpaliwal.diff :         Project Diff
#######################################################################
Other Details :
Code :
git : https://github.com/gauravpaliwal/General-Feedback-Module-OpenMRS
svn : https://source.openmrs.org/browse/Modules/feedback/trunk

Design :         https://wiki.openmrs.org/display/projects/General+Feedback+Mechanism+%28Design+Page%29
Implementation Idea :     https://wiki.openmrs.org/display/projects/General+Feedback+Mechanism+%28Implementation+Ideas%29
User Documentation :     https://wiki.openmrs.org/display/docs/Feedback+Module
Module Page :         https://modules.openmrs.org/modules/view.jsp?module=feedback
Issue’s Page :         https://tickets.openmrs.org/browse/FDBK

Thanks for Support of OpenMRS Community during GSoC

For more then 3+ months I have been working with OpenMRS community working on General Feedback Mechanism Module, I would like to thanks my mentor Ben Wolfe and Burke Mamlin for providing full support even during busiest of their schedule.At the same time I would also like to thanks them for correcting my typos 😀 (especially Ben Wolfe).I would also like to thanks Jeremy Keiper and Jan Flower who had given very valuable comment on my project proposal during the project proposal submission phase in early phase of Google Summer of code.At the same time I would also like to thanks Michael for providing 100% community infrastructure support, he solved our problem/doubts even during night hours.At the same time I would also like to thanks whole OpenMRS community for giving support especially during the Weekly developer meeting and on IRC.Will see you all in #IRC , Developer meets and also wiki/answers.openmrs.org in near future:)