Modules


(Redirected from Module)


The goal of the module system is to allow other developers to write and integrate code into OpenMRS without having to modify the core codebase. Our online Module Repository has been developed to facilitate searching and sharing of modules.

What is a module?

  • Modules are packaged java code that can be installed into a running OpenMRS instance and is able to modify almost all aspects of OpenMRS. They can provide web pages, add tables, change how service calls work, and add new functionality (like report options, person attribute types, etc)

Quick Overview

Overall Module Structure

build
Folder automatically created by build script
Contains the compiled files and pre-jarring files
dist
Folder automatically created by build script
Contains the distributable .omod (openmrs module) file
lib
Place any module specific libraries in this folder. All jars in this folder will be packaged into your distributed omod file.
lib-common
Place the jars/libraries that you need for building/compiling/testing your module. The jars in this folder will not be included in the packaged module.
metadata
config.xml
*.hbm.xml files
messages_*.properties files
moduleApplicationContext.xml
sqldiff.xml
src
Contains the java source files for the module
web
module
Contains the jsp and web files. All files will be placed into /WEB-INF/view/modules/moduleId/*
portlets
Any portlet in this folder can be accessed like any other portlet (i.e. <openmrs:portlet id="thismodulesportlet" moduleId="moduleId" />)
resources
All non-jsp files need to be placed and accessed in this folder
tags
Put JSP tag files here
taglibs
Put JSP taglib files here
src
Contains web java source files like controllers and servlets
build.xml
Shouldn't need modifying other then the Module Name (for display) and Module version
Copies the right files into their necessary places and creates the omod file

Resources

FAQ

How do I create a new module?
See Creating Your First OpenMRS Module
Where can I find examples?
Several samples have been committed to the subversion repository: http://dev.openmrs.org/browser/openmrs-modules . All code in the repository is open for download
How do I deploy my module?
  1. Run the the target "package-module" in the ant build.xml in the root of your module.
  2. Option 1: Go to Manage Modules in the Administration section of the webapp. Upload your compiled .omod file from the /dist folder in your module
  3. Option 2: Drop your .omod file into the <openmrs application directory>/modules folder and restart openmrs. (The application directory is either /home/tomcatuser/.OpenMRS or c:/docs and settings/tomcatuser/application data/openmrs)
How do I redeploy my updated module?
Option 1: Choose the "undeploy" link on the Manage Modules page and then deploy your module again
Option 2: Drop your new .omod file in the application data directory and restart openmrs
How do I specify Module Updates?
There is a page dedicated to the update.rdf file
How can I allow administration of the modules through the web?
You need to be sure the line module.allow_web_admin=true is in your runtime properties file
Can I store my module source code in your subversion repository?
We welcome and encourage you to use our source code repository. Contact code@openmrs.org for additional help.
How do I perform unit testing in my module?
See Module Unit Testing
How can my module access the database? (Aka How can my module create its own service?)
See page on creating the moduleApplicationContext.xml file
How do I extend an OpenMRS table with a module?
See Extending an OpenMRS Table Through a Module
What parts of OpenMRS does a module have access to override?
See Module Access
How can I set module level log4j properties?
Put "log4j.xml" in the metadata directory of the module
Why aren't my module classes loaded properly?
There is an issue for this in Trac. For a better explanation and temporary fix, see http://dev.openmrs.org/ticket/848.
How can I add a new hibernate interceptor?
See the interceptorexample module's application context file (requires at least v1.6.0.8566)
What is a good/bad example of a Module adding functionality to OpenMRS?
A Module would not be used for to create a javaSwing client, but would be used to provide a RESTful view of the OpenMRS API via web services which could perhaps be connected to that Swing client.
Where does a Module fit into the larger OpenMRS architecture?
A Module is simply extended code in the OpenMRS web application. However modules are not permitted to alter web.xml except via the config.xml file.
How do I call one module from another? Can one module depend on another?
If you want to have your module (child module) depend on another module (parent module), you need to:
  1. Declare the dependency in the config.xml of the child module:
    <require_modules>
        <require_module>org.openmrs.module.parentmodule</require_module>
    </require_modules>
  2. In the parent module, run the package-jar ANT task — to build a jar file for the parent module — and include this parent-x.y.jar file in the lib-common directly of the child module.
Does a Module have any special relationship to Spring?
No. A module is simply additional servlets, JSPs and resources to extend the OpenMRS web application. A module can use Spring, but is not tied to it.
I can't work on my module anymore, how do I abandon/retire my module?
There might be someone else in the community that wants to take over development. Send an email to the developer's list asking for volunteers.
If no takers, put a note about the module's abandonment on the module's wiki page and in the module repository] (if the omod has been uploaded)
If you have not made a release, you can delete the module code from the repository and leave the abandonment note on the module wiki page with a link to the last working changeset in the repository.
A page requires certain global properties to be filled in, how to force the user to fill those out?
RequireConfiguration Taglib

TODO

  • Requiring a specific version of another module (done in version 1.5.0.3)
  • Implement business database knowledge
  • A clean unload option for "undiffing" and removing all of a module's privileges/global properties. - http://dev.openmrs.org/ticket/1179