You are on page 1of 10

Setup Servers - Sana

http://sana.mit.edu/wiki/index.php?title=Setup_Servers

Setup Servers
From Sana ATTENTION! Content on this page is currently being updated in preparation for the 1.1 release of Sana. Please report any issues on the Sana users group. Beta versions of the 1.1 release currently available on the Sana Googlecode downloads page or through SVN. Thanks, Sana Development Team October 13, 2011

We recommend using Debian Packages to install the server software. If you need to perform a manual installation, please use the steps outlined below.

Contents
1 Setup Linux Environment 1.1 VM Workstation 1.2 Ubuntu 1.3 New Virtual Machine 1.4 VM Tools 1.5 Troubleshooting 1.6 References 2 Installing OpenMRS 2.1 Install Software 2.2 Load in OpenMRS war file Using Tomcat Manager 2.3 Initial Setup Wizard for OpenMRS 2.4 Load in Sana module 2.5 Load in Media Viewer module 2.6 Load in Rest module 2.7 IMPORTANT: Configure OpenMRS for Sana 2.8 Miscellaneous Commands 2.9 Reference 3 Install Mobile Dispatch Server (MDS) 3.1 Install Software 3.2 Create MySQL database for MDS 3.3 Setup settings file 3.4 Run MDS on Django Development Server 3.5 View Error Logs and Admin Interface 3.6 Configure Apache to serve the MDS 3.7 Make sure OpenMRS on public IP address 3.8 Test request to verify MDS / OpenMRS Connection
1 of 10 08-Nov-12 1:38 AM

Setup Servers - Sana

http://sana.mit.edu/wiki/index.php?title=Setup_Servers

3.9 Setup SMS Messaging with the MDS 3.10 Reference

Setup Linux Environment


If you already have Ubuntu setup, you can skip this step. To setup a Ubuntu OS on your machine to run the Sana servers locally for testing or to create a VM image of the server to take to a deployment site for testing, setup VMWare Workstation. These directions are compatible with Ubuntu 9.10.
VM Workstation

Download VM Workstation (If you are an MIT student, you can obtain the software from the MIT Software Downloads page: http://ist.mit.edu/services/software/available-software?page=7)
Ubuntu

Get a CD of Ubuntu OR go to the Ubuntu website, download it, and make a CD. 1. Get an iso image for Ubuntu vers. 10.04 LTS, Lucid Lynx, available from the official Ubuntu web site. 2. Get a blank CD larger than 700MB. Burn a CD by following these instructions. https://help.ubuntu.com/community/BurningIsoHowto (You will need to download Infra Recorder to burn the CD image. http://infrarecorder.org/)
New Virtual Machine

Launch VM Workstation application. On the home page, click New Virtual Machine. 1. 2. 3. 4. Create a Linux, Ubuntu new virtual machine. Insert the Ubuntu CD into CD drive. Click Start this Virtual Machine. It will boot from the CD and install Ubuntu. Go through the steps to configure the installation. Once completed, restart by powering off and starting the virtual machine again.

VM Tools

Once the virtual machine loads, install the VM Tools. 1. 2. 3. 4. 5. Unmount the CD from the Ubuntu VM desktop. From the menu bar, click VM and click Install VM Tools. Drag and drop the VMwareTools-x.x.x-xxxx.tar.gz file to your desktop. Right click and Extract Here. Open a terminal and execute these commands. 1. cd ~/Desktop/vmware-tools-distrib 2. sudo ./vmware-install.pl 6. Itll say: You can now run VMWare Tools by invoking the following command: /usr/bin/vmwaretoolbox during an X server session.
08-Nov-12 1:38 AM

2 of 10

Setup Servers - Sana

http://sana.mit.edu/wiki/index.php?title=Setup_Servers

Troubleshooting

If you have Internet connectivity problems, try powering off the virtual machine. 1. 2. 3. 4. Plug in an Ethernet cable Edit the device settings Make sure the Ethernet option is Bridged Start the virtual machine again

References

VMWare Workstation Installation Guide http://pubs.vmware.com/guestnotes/wwhelp/wwhimpl/js/html /wwhelp.htm VM Tools Installation https://help.ubuntu.com/community/VMware/Workstation

Installing OpenMRS
In OpenMRS there are concepts in a concept dictionary (click on Dictionary at the top of OpenMRS webpage) like heart rate, blood pressure, tuberculosis. Then there are observations like the actual value of the heart rate. So for patient 123, they will have an encounter (patient visit with a doctor) on 3/2/09 and there will be a bunch of observations listed. Each observation is linked to a concept (similar to the idea of a category). This will make more sense if you view an encounter in OpenMRS. Some of the concepts say "Picture" or "Audio File," so that's the category. The actual observation or value is the actual picture or audio file. Or the concepts can be the questions from the phone procedure and the value will be the patients response for that question. These instructions are up to date using the OpenMRS 1.6.1 stable release from March 28, 2010.
Install Software

1. Install VMware Ubuntu Linux workstation (see section above) or open Linux environment. 2. Open Terminal window (Applications > Accessories > Terminal). Execute these commands. 1. sudo apt-get install subversion 2. sudo apt-get install mysql-server (Choose your own password for MySQL root) 3. sudo apt-get install sun-java6-jdk (When it brings you to an installation screen, press the Page Down key to scroll all the way to the bottom, hit the right arrow, and hit Enter for OK. On Ubuntu 10.04, this requires enabling an additional repository in /etc/apt/sources.list: Uncomment the line that reads 'deb http://archive.canonical.com/ubuntu lucid partner', or add this line if it is not present.) 4. sudo apt-get install ant 5. sudo apt-get install tomcat6 6. sudo apt-get install tomcat6-admin 7. sudo nano /etc/tomcat6/tomcat-users.xml (Or use your favorite editor to make the file appear as shown below. Make sure to uncomment this part of the file.)

3 of 10

08-Nov-12 1:38 AM

Setup Servers - Sana

http://sana.mit.edu/wiki/index.php?title=Setup_Servers

8.

9.

10. 11. 12. 13.

<tomcat-users> <role rolename="admin"/> <role rolename="manager"/> <role rolename="tomcat"/> <user username="test" password="test" roles = "admin,manager,tomcat"/> </tomcat-users> sudo nano /etc/default/tomcat6 (Turn off tomcat security flag in "/etc/init.d/tomcat6" file. Uncomment the following line and set value to no.) TOMCAT6_SECURITY=no sudo nano /etc/tomcat6/policy.d/03catalina.policy (Add the following lines to the policy file.) grant codeBase "file:${catalina.home}/openmrs/-" { permission java.security.AllPermission; }; sudo mkdir /usr/share/tomcat6/.OpenMRS (Fix application data directory) sudo chown -R tomcat6:root /usr/share/tomcat6/.OpenMRS (Note the space between root and /usr) sudo /etc/init.d/tomcat6 restart Check that it works by going to http://localhost:8080/ The webpage should say It works!

Load in OpenMRS war file Using Tomcat Manager

1. Click on the link to manager webapp or go to http://localhost:8080/manager/html Username: test Password: test (from tomcat users xml file) 2. Check if MySQL is running ps -ef | grep -i mysql 3. Start MySQL if it's not running sudo /etc/init.d/mysql start 4. Download OpenMRS Version 1.6.1 WAR file from website http://openmrs.org/download 5. Open the Tomcat manager page listed below and scroll down to WAR file to deploy. http://localhost:8080/manager/html 6. Browse and find the WAR file you just downloaded and deploy it. /openmrs should now show up in the list of applications.
Initial Setup Wizard for OpenMRS

1. Click the /openmrs link to start the OpenMRS setup wizard. 2. For Do you have an OpenMRS DB installed, select No call it openmrs and set the password to be the MySQL root password you created earlier. 3. For page 2, select "Yes" you want the demo data loaded in. Then select Yes and enter the username root and the MySQL root password. 4. Use the default values and continue.

4 of 10

08-Nov-12 1:38 AM

Setup Servers - Sana

http://sana.mit.edu/wiki/index.php?title=Setup_Servers

5. When selecting a password for the login page of OpenMRS, the password has to contain uppercase characters and a number. 6. Use the default values and continue. 7. Click Finish. Let it install which will take about 10 minutes and then it will automatically redirect you to the OpenMRS login page. (Note: even if the browser page says Done or the page says Error - get Service Context is null, it should be fine. If you wait a couple more minutes, it should still continue making progress.) 8. Troubleshooting: If the initial setup wizard doesn't work, you might have to start again. Check whether the openmrs database is already created: 1. mysql -u root -p 2. show databases; 3. If openmrs shows up, then drop database by doing the following command 4. drop database openmrs; 5. Go back to initial setup page and start again 9. Login to OpenMRS with the admin user and password created above. Leave this window open for upcoming steps. 10. If this doesn't work the first time, try again, but this time on page 1, say "Yes" the database called "openmrs" is already created and go through and try again making sure that you enter "root" and the root password for MySQL.
Load in Sana module

1. Load Moca module into OpenMRS 1. Open Terminal window 2. Change directory to a place where you want the moca code to be downloaded to. (For example your home directory or /tmp.) 3. Check out the code: 1. If you're downloading the code for deployment, use our stable release 1.0. svn co https://moca.googlecode.com/svn/servers/openmrs-modules/moca/tags/release-1.0 2. If you're downloading the code for development, you'll want to take the code from the trunk and make sure you branch the code before making changes. Once the feature/changes are done, you can merge it back into the trunk. svn co https://moca.googlecode.com/svn/servers/openmrs-modules/moca/trunk 3. If this gives an error such as svn: Cant make directory moca: Permission denied, you need to change to a different directory such as the Documents folder in the above example provided in step b. 4. Change directory into the moca code directory you just downloaded. 5. ant clean package-module 1. If this gives an error such as BUILD FAILED /moca/build.xml:40: Directory /moca/build creation was not successful for an unknown reason, you need to change to a different directory such as the Documents folder in the above example provided in step b and download the code again. 6. Should create a .omod file in the dist folder which is in the moca folder. 7. Login to OpenMRS > Administration > Manage Modules using the OpenMRS window you left open earlier. 8. Browse for .omod file you just made 9. Add the module (Press Upload)

5 of 10

08-Nov-12 1:38 AM

Setup Servers - Sana

http://sana.mit.edu/wiki/index.php?title=Setup_Servers

Load in Media Viewer module

1. Load Media Viewer module into OpenMRS. Repeat Step 4 above with the following modifications. 2. svn co https://moca.googlecode.com/svn/servers/openmrs-modules/viewer (You should rename the folder to flashmediaviewer. When loading into OpenMRS, load the flashmediaviewer-1.0.omod file).
Load in Rest module

1. Load Media Viewer module into OpenMRS. Repeat Step 4 above with the following modifications. 2. svn co https://moca.googlecode.com/svn/servers/openmrs-modules/rest
IMPORTANT: Configure OpenMRS for Sana

Execute all the steps to setup OpenMRS for Sana (creating new concepts, setting up roles and privileges, setting global properties, etc..).
Miscellaneous Commands

(You dont need these, but these are left here for reference in special circumstances) 1. Copying over SQL Database Manually from MIT Moca server 1. Go to moca machine 2. ssh kkuan87@demo.sanamobile.org 3. mysqldump u root p openmrs > openmrs.sql 4. password: enter your MySQL root password 5. Go back into local machine 6. mysqladmin u root p create openmrs 7. mysql u root p openmrs < openmrs.sql 8. (if these instructions have errors, check man pages for mysql or mysqldump to figure out whats wrong) 2. Create a WAR file from Build 7010 of OpenMRS 1. svn co http://svn.openmrs.org/openmrs/trunk/ -r 7010 2. Ant build it to get a WAR file 3. Deploy the WAR on tomcat manager web interface via http://localhost:8080/manager 4. Go through the OpenMRS wizard (make sure you use the MySQL root password) 3. OpenMRS doesnt load 1. tail f /var/log/daemon.log 2. waiting for changelog lock 3. cd /etc/tomcat6 4. mysql-u root p 5. use openmrs; 6. delete from liquibasechangeloglock; 7. tail f /var/log/daemon.log 8. Restart tomcat
Reference

Installing An OpenMRS Server on Linux http://openmrs.org

6 of 10

08-Nov-12 1:38 AM

Setup Servers - Sana

http://sana.mit.edu/wiki/index.php?title=Setup_Servers

/wiki/Installing_An_OpenMRS_Server_On_Linux OpenMRS Step-by-Step Installation for Implementers http://openmrs.org/wiki/Stepby-Step_Installation_for_Implementers OpenMRS Step-by-Step Installation for Developers http://openmrs.org/wiki/Stepby-Step_Installation_for_Developers Installing OpenMRS on Ubuntu by Clark Freifeld http://people.thirteen.net/~clark /moca/openmrs.install.steps.txt Moca Installation Guide by Clark (not necessary anymore, we dont use gmapsimageviewer anymore) http://people.thirteen.net/~clark/moca/Moca_Installation_Guide3.pdf

Install Mobile Dispatch Server (MDS)


The procedure from the Sana client application on the Android phone is put into JSON format and then sent to the Mobile Dispatch server (MDS) in chunks. The MDS then waits for all the chunks to arrive and assembles them together into a patient encounter with the patient ID, description of the visit, and etc.. Then the MDS logs into OpenMRS and creates a new patient if the patient ID doesn't already exist in the medical record system. Then the MDS will create a new encounter (patient visit) for that patient ID, uploading the images/audio/video files as complex observations and the each text question/answer pair as an observation. Step by step guide for installing the MDS on Ubuntu 9.10
Install Software

Execute the following in a terminal window: 1. cd 2. sudo apt-get install python-mysqldb python-cjson apache2 libapache2-mod-python mysql-server subversion unzip 3. wget http://www.djangoproject.com/download/1.0.2/tarball/ 4. tar zxf Django-1.0.2-final.tar.gz 5. cd Django-1.0.2-final 6. sudo python setup.py install 7. cd 8. Download Code 1. If you're developing on Sana, execute: svn checkout https://moca.googlecode.com/svn/servers /mds/branches/release-1.1.x ./mds 2. If you're just installing the MDS, download the Moca-MDS zip or tar.gz file from Google Code: the http://code.google.com/p/moca/downloads/list 1. tar zxf Sana-MDS-1.0.tar.gz ***OR*** unzip Sana-MDS-1.0.zip 2. mv Moca-MDS-1.0 mds 9. sudo mv mds/sana /opt/sana/ 10. cd /opt/sana 11. sudo mv settings.py.tmpl settings.py

7 of 10

08-Nov-12 1:38 AM

Setup Servers - Sana

http://sana.mit.edu/wiki/index.php?title=Setup_Servers

Create MySQL database for MDS

1. Open another terminal window and login to your MySQL database to create another database named mds 1. mysql u root p 2. <enter your own password> 3. show databases; 4. create database mds; 5. show databases;
Setup settings file

1. Back in the original terminal window, edit settings.py 1. sudo nano settings.py 2. Example settings: 1. DATABASE_ENGINE = 'mysql' 2. DATABASE_NAME = 'mds' 3. DATABASE_USER = 'root' 4. DATABASE_PASSWORD = '<put in your MySQL password from above>' 5. DATABASE_HOST = 6. DATABASE_PORT = 7. MEDIA_URL = '/mds/media' 8. MEDIA_ROOT = '/opt/sana/media' 9. ADMIN_MEDIA_PREFIX = '/mds/media/admin' 10. OPENMRS_SERVER_URL='http://<IPaddress>:8080/openmrs/' Remember the trailing slash! 3. Set template settings to enable logging TEMPLATE_DIRS = ( '/opt/sana/templates', ) 2. ./manage.py syncdb 3. You may create a login account (for accessing the Django admin interface)
Run MDS on Django Development Server

At this point, you have configured the MDS so that it should work with your database. To verify that it works you can use the Django development server with these instructions. WARNING: Using the development server is not suitable for deployment purposes. 1. Back to the terminal window in the moca mds folder where the settings.py file resides 2. ./manage.py runserver 0.0.0.0:<port number> (e.g. ./manage.py runserver 0.0.0.0:8000) 3. ./manage.py runserver <public IP address>:<port number> Make a test request to http://localhost:8000 -- you should see a 'Sanamobile MDS Online' message.
View Error Logs and Admin Interface

1. Will be able to view logs: http://<IP address>:<Port number>/mds/log/ (i.e.

8 of 10

08-Nov-12 1:38 AM

Setup Servers - Sana

http://sana.mit.edu/wiki/index.php?title=Setup_Servers

http://demo.sana.csail.mit.edu/mds/log/ 2. Now you have the development interface running on the specified port (8000). You should be able to open a web browser and go to http://localhost:8000/admin to get the MDS admin interface. Click on request logs to see the django debug/error messages.
Configure Apache to serve the MDS

1. sudo nano /etc/apache2/sites-enabled/000-default 1. Add a handler for the /mds location. Insert this <Location> block somewhere inside the <VirtualHost> block. <Location "/mds"> SetHandler python-program PythonHandler django.core.handlers.modpython PythonDebug On SetEnv DJANGO_SETTINGS_MODULE sana.settings PythonPath "['/opt'] + sys.path" PythonInterpreter mds PythonOption django.root /mds </Location> <Location "/mds/media"> SetHandler none </Location> 2. sudo ln -s /opt/sana /var/www/ 3. sudo ln -s /usr/local/lib/python2.6/dist-packages/django/contrib/admin/media /opt/sana/media/admin (or sudo ln -s /usr/lib/pymodules/python2.6/django/contrib/admin/media/ /opt/sana/media/admin) If you're using Python 2.5, replace python2.6 in this path with python2.5 4. sudo chown -R www-data:www-data /opt/sana (added 08/03/2011 after having some issues - Michal) 5. sudo apache2ctl restart You should now be able to verify that the MDS is running on Apache by navigating with a browser to: http://localhost/mds/ You should see the same 'Sanamobile MDS Online' message that was shown before in the Development Server step, except now the MDS is being served by Apache, which is more suitable for production purposes.
Make sure OpenMRS on public IP address

1. sudo nano /etc/tomcat6/server.xml 2. Add address tag with the IP address 1. <Connector port="8080" protocol="HTTP/1.1" address="0.0.0.0" connectionTimeout="20000" redirectPort="8443" /> 3. sudo /etc/init.d/tomcat6 restart
Test request to verify MDS / OpenMRS Connection

To verify that the MDS and OpenMRS are successfully connected, you can use this test request to have the MDS connect to the OpenMRS and verify the credentials provided. Make sure to replace <your OpenMRS
08-Nov-12 1:38 AM

9 of 10

Setup Servers - Sana

http://sana.mit.edu/wiki/index.php?title=Setup_Servers

admin password> with the password for the OpenMRS admin account. The MDS should respond with a JSON file -- if you open it up, it should have information about whether the request succeeded. 1. You can check that it works by http://<ipaddress>/mds/json/validate/credentials/?username=admin& password=<your OpenMRS admin password>
Setup SMS Messaging with the MDS

1. Make sure you have an SMS gateway hooked up to your MDS. You can get a clickatell account for sending SMS messages by applying here: http://www.clickatell.com/login.php 1. Sign up for a Clickatell Central API account 2. Buy SMS credits 3. Setup a "moca mds" HTTP connection, which should give you a numerical API ID, which you need to enter below in the settings.py file 2. In the MDS settings.py file, you'll need to fill in the appropriate values here according to your registered account: 1. CLICKATELL_URI = "http://api.clickatell.com/http/sendmsg?%s" 2. CLICKATELL_USER = 3. CLICKATELL_PASSWORD = 4. CLICKATELL_API = 3. Make sure you have a SIM card in your phone, and in the Moca phone app settings page, the Phone Number field should be the phone number of the phone you're using. When you upload a case to Moca, it should show up in the Queue with contact # being the phone number of the phone. 1. Make sure the phone number is entered properly with the country code found here: http://www.clickatell.com/products/test_gateway.php 2. Example, a US phone number that is 617-234-3928 would be entered in the phone as 16172343928 because the US country code is 1.
Reference

Installing the MDS by RJ Ryan http://dagny.mit.edu/trac/moca/wiki/MDSInstall Retrieved from "http://sana.mit.edu/wiki/index.php?title=Setup_Servers&oldid=1834"

10 of 10

08-Nov-12 1:38 AM

You might also like