Testing Node.js + Global Storage using the dEWDrop VM

If you’re wanting to try out the Node.js OO projection of Mumps Global Storage, and you’re not familiar with using or setting up a Mumps system, the simplest approach right now is to download and run a copy of David Wicksell’s dEWDrop Virtual Machine (VM).

Here’s a step-by-step guide to running an example Node.js file that will create some data and exercise some of the OO APIs.  I’m assuming you’re going to use VMWare Player.

Step 1: Download a copy of the latest dEWDrop VM (version 5 at the time of writing) from:

http://www.fourthwatchsoftware.com/dEWDrop/dEWDrop.7z

This file is about 1.6Gb in size.

Step 2: Create a directory for the Virtual Machine you’re going to unpack from the zip file, eg:

~/Virtual_Machines/dEWDrop5

or on Windows machines, something like:

 c:\Virtual_Machines\dEWDrop5

Step 3: Move the downloaded zip file into this directory

Step 4: Exand the zip file.  You’ll need to use a 7-zip expander.

If your host machine is running Ubuntu Linux, you can install one using:

    sudo apt-get install p7zip

If you’re using Windows or Mac OS X, Stuffit Expander will do the job, or, for Windows users, check out:

http://www.7-zip.org/

Note: if you’re using Windows as your host machine, you’ll need to place your Virtual_Machines directory on a drive that is formatted as NTFS, because the main file (dEWDrop.vmdk) expands to about 8.7Gb.

If your host machine is running Ubuntu Linux, expand the dEWDrop VM files as follows:

  cd ~/Virtual_Machines/dEWDrop5

  7za e dEWDrop.7z

Step 5: You’ll need to have VMWare Player installed to proceed to the next steps.  If you don’t already have VMWare Player installed, you’ll find the details on how to download and install it at:

http://www.vmware.com/products/player/

Step 6: Start up VMWare Player and select the menu option to open a new File.

Navigate to your Virtual_Machines/dEWDrop5 directory and select the file:

 dEWDrop.vmx

(Alternatively use your host machine’s  file manager utility and double click on dEWDrop.vmx).

Note: VMWare Player may tell you that it can’t find the Virtual Disk file.  If so, navigate to and select the file dEWDrop.vmdk.

The first time you start the dEWDrop VM, VMWare will ask you whether you moved it or copied it.  Select “I Copied It”

If it asks you whether you want to download VMWare Tools, you can tell it to not bother.

Step 7: The dEWDrop VM should now boot up inside the VMWare Player console.  When it asks you for Username, enter:

vista

and when it asks for Password, enter:

  ewd

You should now be logged in to the dEWDrop VM, which is a Ubuntu 12.04 system.

Step 8: Find out the IP Address that was assigned to the VM by your host’s machine by typing the command:

 ifconfig

Look for the section titled eth0 and you should see a line commencing:inet addr.  This should tell you the IP address, eg 192.168.1.68

Step 9: You should leave the console alone at this stage and fire up a terminal or puTTY session and make an SSH connection into the dEWDrop server.  Use the IP address you discovered in Step 8.  eg from a Linux/Unix terminal, connect using:

  ssh vista@192.168.1.68

Then enter the password: ewd

Step 10: Switch directory to /home/vista/www/node/ewdGateway2, ie:

  cd /home/vista/www/node/ewdGateway2

Actually, when you log in you’re automatically placed in the directory /home/vista, so you can just type:

  cd www/node/ewdGateway2

Step 11: Update the latest version of the ewdGateway2 software and files:

  git pull

Step 12: You can now switch to the examples sub-directory and try out the pre-written example which is contained in the file phoenixExample1.js:

  cd examples

  node phoenixExample1

You should see the following:

vista@dEWDrop:~/www/node/ewdGateway2/examples$ node phoenixExample1
Condition: Diagnosis, Active: Hospital Measures - AMI (Code List: 2.16.840.1.113883.3.666.5.3011)
ICD-10 procedure code: R94.31
meds: {"_type":"Medication","administrationTiming":"","codes":{"RxNorm":[238721]},"cumulativeMedicationDuration":"","deliveryMethod":"","description":"Medication, Administered: Hospital Measures-Fibrinolytic Therapy (Code List: 2.16.840.1.113883.3.666.5.736)","dose":"","doseIndicator":"","doseRestriction":"","end_time":1272659400,"freeTextSig":"","free_text":"","fulfillmentInstructions":"","indication":"","mood_code":"EVN","negationInd":"","negationReason":"","oid":"2.16.840.1.113883.3.560.1.14","patientInstructions":"","productForm":"","reaction":"","reason":"","route":"","site":"","specifics":"","start_time":1272657600,"statusOfMedication":"","status_code":{"HL7 ActStatus":["administered"]},"time":"","typeOfMedication":"","vehicle":""}
vista@dEWDrop:~/www/node/ewdGateway2/examples$

It worked!  You’ve just been accessing Mumps Global Storage from Node.js.

This example has created a set of data nodes in the Mumps Global named ^patient from a JSON document, and then run a number of my APIs to examine data within that Global.

Step 13: If you want to take a look at this actual Global, you can start the GT.M shell.  Simply type:

  mumps -dir

You should get the GT.M shell user prompt:

MU-beta>

Type:

zwr ^patient

and you should see a long listing that starts:

MU-beta>zwr ^patient
^patient(123456,"birthdate")=-851884200
^patient(123456,"conditions",0,"_type")="Condition"
^patient(123456,"conditions",0,"causeOfDeath")=""
^patient(123456,"conditions",0,"codes","ICD-10-CM",0)="I21.01"
^patient(123456,"conditions",0,"codes","ICD-9-CM",0)="410.00"
^patient(123456,"conditions",0,"description")="Diagnosis, Active: Hospital Measu
          res - AMI (Code List: 2.16.840.1.113883.3.666.5.3011)"
^patient(123456,"conditions",0,"end_time")=1273104000
...etc

To exit the GT.M shell, simply type:

  h

and you’ll be returned to the Linux shell prompt:

  vista@dEWDrop:~/www/node/ewdGateway2/examples$

Step 14: You can now try playing about with the example file, and/or create your own Node.js / Javascript files to manipulate the Global Store in the GT.M database.

For example, take a look at the second example Node.js file:

  phoenixExample2.js

and try running it:

  node phoenixExample2

This demonstrates and exercises all the other main OO APIs that weren’t used in the first example.  Note: you should run phoenixExample1 before running phoenixExample2, since the second example uses the Mumps Global Nodes created by the first example.

You’ll now have all the examples you need to try using Mumps Global Storage from within Node.js for yourself.

Step 15: When you’ve finished and you want to shut down the dEWDrop VM, type:

  sudo halt

This will shut everything down cleanly, including the GT.M database, and eventually the VMWare console should shut down.

Of course, next time you want to try it out again, you can just start from Step 6.

 

That’s it! Have fun!

Advertisements

10 comments

  1. Rob
    Many thanks for the detailed directions on getting the VMWare up and running
    Thanks to David Wicksell too. for his work with you on this.
    I’m pretty close to playing with this example, but coming across an error in node, as per below.
    Thought it was a path issue initially, now am not so sure?
    thanks for any help
    regards
    Tony

    ###take 1
    After pulling your examples down from git onto the dEWDrop VM….
    I tried your suggested approach of invoking phoenixExample1 from the ewdGateway2 folder..

    vista@dEWDrop:~/www/node/ewdGateway2$ git pull
    Already up-to-date.
    vista@dEWDrop:~/www/node/ewdGateway2$ node phoenixExample1

    …which caused this error..

    module.js:340
    throw err;
    ^
    Error: Cannot find module ‘/home/vista/www/node/ewdGateway2/phoenixExample1’
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.runMain (module.js:492:10)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)
    vista@dEWDrop:~/www/node/ewdGateway2$

    ###take 2
    So then I moved into the examples subfolder where phoenixExamples1.js is and tried again..

    vista@dEWDrop:~/www/node/ewdGateway2$ cd examples
    vista@dEWDrop:~/www/node/ewdGateway2/examples$ dir
    ewdStart-cache.js ewdStart-gtm.js phoenixExample1.js
    vista@dEWDrop:~/www/node/ewdGateway2/examples$ node phoenixExample1

    ..but got the same error

    module.js:340
    throw err;
    ^
    Error: Cannot find module ‘./ewdGlobals’
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at Object. (/home/vista/www/node/ewdGateway2/examples/phoenixExample1.js:3:11)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.runMain (module.js:492:10)
    vista@dEWDrop:~/www/node/ewdGateway2/examples$

  2. Tony

    I’ll fix the Github files – I can see what’s happened. In the meantime, copy the file phoenixExample1.js to the /home/vista/www/node/ewdGateway2 directory and you should find it works as per my original instructions.

    Rob

    1. Got it.. sorted.. many thanks!
      Tony

  3. I’ve now modified the require path of the Phoenix Example 1 file and modified the main posting where it explains how to run it. Hopefully it’s now properly consistent!

    Rob

  4. Works in Iowa, Rob!
    Very nice.

  5. David Heller · · Reply

    Works here! Nice job Rob and David!

  6. Hello friends.

    What about this line in ewdgateway2/package.json?

    , “main” : “./lib/ewdgateway2”

    1. It’s just what I added to the npm packaging – you can pretty much ignore it. It has no effect on the instructions or examples I’ve provided

  7. Gina Hagg · · Reply

    Great job! I have been trying to create the system without dewdrop from scratch. But, i ran into .so compatibility problems. It is nice to have this working right off bat. Now, i can delve into mumps mysteries. It is a beautiful database. Thanks again for creating this opportunity.

  8. Gina, I am happy to give you hand in fixing your object incompatibilities. I have not seen your response to my post in the EWD google group forum. Did my suggestions help you figure out where the issue lies?

    On the other hand, I am going to be adding quite a bit of new stuff to dEWDrop 6, and as you have noted, everything just works there. Which is, of course, the point.

    Good luck with your exploration of M.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: