Laura Diane Hamilton

Technical Product Manager at Groupon

Resumé

Tutorial: Getting Started with MUMPS

Many Electronic Medical Record systems, including Epic, use the MUMPS programming language / database.

MUMPS stands for Massachusetts General Hospital Utility Multi-Programming System. It is a multi-user, strongly imperative language that's designed to deal with very large databases.

Here is a tutorial for getting started with MUMPS.

There are two main software development environments — Intersystems Caché and FIS GT.M. (FIS GT.M is open source.)

First, let's install GT.M on linux. wget http://sourceforge.net/projects/fis-gtm/files/GT.M%20Installer/v0.11/gtminstall $ chmod +x gtminstall $ sudo ./gtminstall --utf8 default

The executables will go to: /usr/lib/fis-gtm/V6.0-003_x86_64/

Now, set up the environment variables for GT.M by sourcing the gtmprofile file. From your shell, run: source /usr/lib/fis-gtm/V6.0-003_x86_64/gtmprofile

You should see output that looks like this: %GDE-I-GDUSEDEFS, Using defaults for Global Directory /home/laura/.fis-gtm/V6.0-003_x86_64/g/gtm.gld GDE> %GDE-I-EXECOM, Executing command file /usr/lib/fis-gtm/V6.0-003_x86_64/gdedefaults GDE> %GDE-I-VERIFY, Verification OK %GDE-I-GDCREATE, Creating Global Directory file /home/laura/.fis-gtm/V6.0-003_x86_64/g/gtm.gld Created file /home/laura/.fis-gtm/V6.0-003_x86_64/g/gtm.dat %GTM-I-JNLCREATE, Journal file /home/laura/.fis-gtm/V6.0-003_x86_64/g/gtm.mjl created for region DEFAULT with BEFORE_IMAGES %GTM-I-JNLSTATE, Journaling state for region DEFAULT is now ON

You may want to add the following lines to your $Home/.bashrc file: # Set up GT.M environment. source /usr/lib/fis-gtm/V6.0-003_x86/gtmprofile

This adds some GT.M variables to your environment, and it also adds the GT.M executables to your PATH. Run this to have a look at those changes: env | grep gtm

Now, let's run GT.M for the first time. gtm

This should open the GT.M command prompt: GTM>

Next, let's try some commands. GTM>write $zversion The variable $zversion is what's known as an "intrinsic special variable," and it returns the version of the installed MUMPS environment.

And to get out of the GTM command prompt: GTM>halt

The initialization process creates a local instillation in your home directory. $HOME/.fis-gtm

It has the following subdirectories: $HOME/.fis-gtm/r $HOME/.fis-gtm/V6.0-003_x86_64

Our code examples will go in these directories.

MUMPS is a combination of a database and a programming language. So, if come from a ruby/rails background like I do, that may take a bit of getting used to.

First, set the path to your favorite editor in the "EDITOR" environment variable: EDITOR=/usr/bin/vim

Now, start gtm, and at the gtm command prompt open the "Hello.m" file for editing. GTM>ZEDIT "Hello.m"

That should open up a new "Hello.m" file for editing. In that file, put in the following code: MYLABEL ; This is a comment WRITE "Hello World",! QUIT Be sure that lines 2 and 3 are each preceded by 1 blank space. Be sure that you are using straight quotation marks instead of curly quotes. Save and close the file.

Now, let's run our program: GTM>ZLINK "Hello" GTM>DO MYLABEL^Hello

Next, let's open the file again for editing and add another line. MYLABEL ; This is a comment WRITE "Hello World",! WRITE !,$HOROLOG QUIT

Now call ZLINK in order to recompile the source code. GTM>ZLINK "Hello"

Now, when you execute your new version of Hello.m, you should see the following: GTM>DO MYLABEL^Hello Hello World 63132,48540 $HOROLOG is a special variable that returns the date and time. It counts the number of days since December 31, 1840 and the number of seconds since midnight today.

Lauradhamilton.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.com.