Software Development: OpenMRS Information

[article] [edit page] [discussion] [history]

From Humanitarian-FOSS Project Development Site


The Project

OpenMRS Information

Installing OpenMRS

We will get our copy of OpenMRS from the OpenMRS subversion repository. This will not be a problem, as we will be developing a module, so we will never need to change the core code. I strongly recommend doing this over a wired network connection, as the OpenMRS trunk is rather large download. These instructions are modifications of the official Step-by-Step Installation for Developers on the OpenMRS website.

  1. Download the OpenMRS source code.
    1. Start EasyEclipse.
    2. Select File->New...->Project. Untie the SVN twistie, select "Checkout Projects from SVN," and press Next.
    3. Select "Create a new repository location" and press Next.
    4. Enter for the URL and press Next.
    5. Untie the openmrs twistie, then the branches twistie, and select 1.3.x, and press Next.
    6. You should only be able to select "Check out as a project in the workspace;" I recommend leaving the Project Name alone, and be sure that "Head Revision" is selected for "Revision to check out." Press Next.
    7. Select "Use default workspace location." Press Finish. Take a rest---this is not a fast process.
  2. Install the OpenMRS database.
    1. Change directory to .../workspace/openmrs-trunk/metadata/model.
    2. Start MySQL and then start the MySQL command-line interface as root:
      $ mysql -u root -p
    3. Run the provided scripts in the following order:
      mysql> source 1.3.0-createdb-from-scratch-with-demo-data.sql ;
      mysql> source update-to-latest-db.mysqldiff.sql ;

      Note that if you have a MySql user named test, this user will be deleted. Regardless, the user test@localhost will be created with password test. This is not very secure...

  3. Follow the instructions in Step 4 (Set up your local configuration) of the Step-by-Step Installation for Developers. In the file, be sure to specify your Tomcat installation directory as well as the Tomcat manager username and password. I do not think you need to modify properties.xml or build.xml.
  4. Follow the instructions in Step 5 (Deploy OpenMRS) in the Step-by-Step Installation for Developers.

You should routinely make sure that you have the latest revision of OpenMRS, which is easy to do using Subversion.

  1. Right-click on the OpenMRS project that you created above.
  2. In the context menu that appears, select Team->Update.

That's it!

Initial module setup under Eclipse and Subversion

The Visit Register project will be built as an OpenMRS module. An OpenMRS module is basically a small application that can be loaded into OpenMRS at run-time. As such, it has a specific file-system structure that must be followed (just like for a web application). To make this a little easier, OpenMRS provides a module called Basic Module that is properly organized; the intent is that a new module developer download the Basic Module, makes the appropriate changes (primarily, changing "Basic Module" to a new name everywhere), and then starts working on the new functionality. However, this process is not as automated as one might hope. Instead, I have done almost all the manual work for you; you just need to get a copy of the Visit Register module from our Subversion repository, copy it into your team's repository, and change just a few things where my name appears (and, of course, adding all your new files as you develop the module). Here are the steps, assuming you have Eclipse started:

  1. Check out the Visit Register module.
    1. Select File->New->Project. Untie the SVN twistie, select "Checkout Projects from SVN," and press Next.
    2. Select "Create a new repository location" and press Next.
    3. Enter svn:// for the URL and press Next.
    4. Select visitregister and press Next.
    5. You should only be able to select "Check out as a project in the workspace." Set the project name to VisitRegister or visitregister (no spaces). Select revision 4 as the revision to check out. Press Next.
    6. Select "Use default workspace location" and press Finish.
  2. Disconnect your copy of the visit register module from the subversion server and make it the trunk of your team's subversion directory.
    1. Right-click on the Visit Register project you just created and select Team->Disconnect....
    2. Select "Also delete the SVN meta information..." and press Yes. You will be warned about not being able to reconnect your project to the repository; press Yes.
    3. Right-click on the Visit Register project and select Team->Share Project....
    4. Select SVN as the repository type and press Next.
    5. Select "Use existing repository location" and svn:// and press Next.
    6. Select "Use specified folder name" and press Browse. In the Repository Browser window, untie the teams twistie, select the folder corresponding to your team, and press OK. Replace New Folder with trunk, so that the folder name is teams/.../trunk. Press Next.
    7. Edit the initial commit comment to be Copy of visitregister[4] and press Finish.
  3. Now play just a bit with making changes and committing them.
    1. Look through all the files in your Visit Register project and replace every occurrence of my name with your names. Each file that you change should get a little snowflake icon in the Eclipse navigator, indicating that your working copy of this file is different than the version that was most recently downloaded from the repository. Notice also that if you consider the navigator as a tree in the obvious way, then every node above any file you change also has the snowflake icon.
    2. Once you have made your changes, you can get a quick view of what those changes are by right-clicking on your project and selecting Compare with->Latest from repository. This will open a tab where you usually edit files. The upper part of the tab is a list of files that are different (deleted, added, or modified). Double-clicking on any such file displays your version of the file side-by-side with the version in the repository, and indications of where the differences are.
    3. You can commit your changes by right-clicking on your project and selecting Team->Commit.... Add an appropriate comment to indicate what changes you have made. Check the resources that will be committed; make sure that you are not committing anything in the build or dist folders, as these are all files that are generated from source code or copied from elsewhere in the project.
Personal tools