OpenMRS Development Guide

Setup OpenMRS development platform:

OpenMRS development is best done using the OpenMRS SDK

  1. Visit the link: https://wiki.openmrs.org/display/docs/OpenMRS+SDK for a better understanding.
  2. Install Jdk 1.8, MySQL 5.6 (install all components) and Maven (make sure to set environment variable if it is not done by default).
  3. Install the OpenMRS SDK using ' mvn org.openmrs.maven.plugins:openmrs-sdk-maven-plugin:setup-sdk ' command in the terminal.
  4. Upgrade it using ' mvn openmrs-sdk:setup-sdk -U '.
  5. Now we will need to create a project using the SDK we just installed.
  6. Clone Intelehealth's OpenMRS repo using GIT.
  7. We can setup a project using ' mvn openmrs-sdk:setup ', select distribution server.
  8. Use RefApp 2.6 and SDK will ask a few questions related to SQL database and ask you the port, use the default 8080 and then it will setup a new project for you.
  9. After the setup finishes, navigate to the cloned folder of Intelehealth's OpenMRS repo and type, ' mvn clean install openmrs-sdk:watch -DserverId=('server-name) '
  10. Mind the spaces and the cases because they are sensitive. Watch parameter helps while development, you can directly reload page to see changes you made in the code, otherwise you will have to use clean install command every time.
  11. Now you have setup the project as well as the server. You need to use ' mvn clean install openmrs-sdk:run -DserverId=(server-name) ' and the server will start and you can start with the development.
  12. Import SQL dump with complete concept dictionary, stop the server and restart using "mvn openmrs-sdk:run -DserverId='(server-name)' " and this is the command you will be using to start the server everytime.
  13. If you miss any step you will have to redo from the start so be careful and understand the instructions before running them. Also refer the link provided.

OpenMRS project structure:

  1. All the front end development stuff goes into omod ->Webapp
  2. Webapp has fragments, pages and resources
  3. Diagnoses, Medical advice, Recent Visits, Patient profile etc, these are fragments
  4. Patient Summary page, Patient Overview page, Active Visits page, these are pages which are accessed and these pages have above fragments included in them
  5. Scripts are all the required libraries and other general files like encounter service, profile image service etc.

OpenMRS - How to make fragments:

  1. Make a new .gsp page in the fragment directory using Angular JS. Inject the dependency into the respective page's module. For eg, we need xyz fragment on patient summary page. For that we will make a new angular app with name suppose, 'xyz'. Now in patienSummary page, you have to include 'xyz' module into patient summary angular app. This is called dependency injection. You also have to include this - " ${ui.includeFragment("intelehealth", "xyz", [patient: patient])} "
  2. Encounter values are stored in EncounterService.encounterValue and you can get it from there on patient summary page. No need to make http calls to the api for that.
  3. Go through the code, documentation is done wherever felt necessary.

OpenMRS - How to implement client specific fragments:

Let's consider the RHPT deployment:

  1. Create a new recentVisitsRhpt fragment
  2. In the fragment where on click points to a url, in the url replace patientSummary page to patientSummaryRhpt.
  3. Make the patientSummaryRhpt page in the correct folder, copy paste code from patientSummary page and then include required / developed fragments.
  4. Create a new APP in manage apps with following template, replace rhpt with project shorthand in all the properties:

{

"id": "intelehealth.rhptSummary",

"icon": "icon-vitals",

"order": 3,

"extensions": [{

"id": "${project.parent.groupId}.${project.parent.artifactId}.rhptSummary.clinicianDashboardFirstColumn",

"appId": "intelehealth.rhptSummary",

"extensionPointId": "patientDashboard.firstColumnFragments",

"extensionParams": {

"fragment": "intelehealthPatientDashboard/recentVisitsRhpt"

}

}]

}

VOILA! That is it.