What can I do in Commando Script?

Top  Previous  Next

In a word, anything you like.  Commando Script is just a custom IDE (Integrated Development Environment) for MicroSoft VBScript.  Anything that you can do in VBScript you can do in your CommandoScript projects.  VBScript is an incredibly powerful programming language, made even more powerful with Commando's built-in objects that help you process and manipulate your HL7 messages directly.

 

Commando HL7 Message Processors use the VBScript in a Commando Script project to do one of two (or both) things:

 

1. Preprocessing:  If your processor profile indicates that you wish to do preprocessing then you will need to make sure that your Commando Script project has a Public Function called PREPROCESS() that takes no parameters and returns either True or False.  When running as a preprocessor, your message processor profile will call the PREPROCESS() function every <polling interval> seconds (see the Commando HL7 help for more information on the polling interval).  You can write VBScript code in the PREPROCESS() function to:

Connect to a database and export your data to HL7 messages (use the oMSG object to create them).
Do system maintenance, backups, or preparation

2. Message Processing:  When working as a message processor, your Commando Script project must have a Public Function Called MESSAGEIN() that takes no parameters and returns either True or False.  If this is configured correctly, the running commando profile will do the following:

Poll the input folder every <polling interval> seconds looking for HL7 message files.
Open detected files and parse out individual messages.
As messages are detected, the processor will load that message into the oMSG object.
The processor will then call the MESSAGEIN() function of your Commando Script project.
If the MESSAGEIN() function ever returns False, the processor will halt, otherwise it continues.

Typically you would write VBScript code into your MESSAGEIN() function to do things like:

Get the pertinent data out of the HL7 message (using the oMSG object).
Write that data into a database
Filter out unwanted messages and save selected messages to another folder.

 

 

 

 

hmtoggle_arrow1Click to see an example of a MESSAGEIN() Function that randomizes patient names

Public Function MESSAGEIN()

'This Function MUST be in your script, MUST be Public, and MUST take NO parameters

'if you want your processor to actually process HL7 messages.

'

'The oMSG object will be a loaded Commando HL7 Message object that will contain your

'HL7 message.

     Dim retValue

     Dim hPID, sFirstName, sLastName, sRandomID

     If oMSG.Testing = True Then 

        'The user either clicked the 'Test MessageIN()' button in Commando

        'OR they are running the script in the debugger.

           sFirstName = oUTILITIES.RandomFirstName()

           sLastName = oUTILITIES.RandomLastName()

           sRandomID = oUTILITIES.RandomNumberString(10)

       SMEVENT.Raise "TRACE", "Changing Patient Name to: " & sLastName & ", " & sFirstName 

       Msgbox "oMSG.Testing is True....No Processing will occur",VBINFORMATION,"Testing"   

       Msgbox "RandomFirstName = " & sFirstName & " Last = " & sLastName & " Number = " & sRandomID ,VBINFORMATION,"Testing"   

 

       MESSAGEIN = True  

       Exit Function 

     End If 

'Code from here and below will only execute if oMSG.Testing is False.

'What we're going to do here is test to see if there is a PID segment in the message

'and if there is, we're going to change the Patient IDs and Patient Last and First names

'to a random value, then save the message into the Output folder defined in the 

'profile.

     With oMSG

 

        hPID = .GetSegment("PID")

        If hPID <> "" Then 

        sFirstName = oUTILITIES.RandomFirstName()

           sLastName = oUTILITIES.RandomLastName()

           sRandomID = oUTILITIES.RandomNumberString(10)

           SMEVENT.Raise "TRACE", "Changing Patient Name to: " & sLastName & ", " & sFirstName 

           'Resetting the patient first and last name to a random value

           .SetFieldValue sRandomID, hPID, 2,1

           .SetFieldValue sRandomID, hPID, 3,1

           .SetFieldValue sLastName, hPID, 5, 1

           .SetFieldValue sFirstName, hPID, 5, 2

        End If 

        retValue = .HL7      

        oUTILITIES.SaveHL7Message retValue, oUTILITIES.OutputFolder

     End With

       MESSAGEIN = True

End Function

 

 

 

 

See the Commando HL7 documentation for further information on how to use Commando HL7:

 

http://www.hermetechnz.com/documentation/Commando/V1/index.html