What is Commando Script?

Top  Previous  Next

What Commando Script Is

 

Commando Script is a MicroSoft VBScript development and runtime environment created especially for the HL7 Commando application. If you already know Visual Basic or Visual Basic for Applications (VBA), Using CommandoScript will be very familiar once you become familiar with the IDE (Integrated Development Environment). Even if you do not know Visual Basic, once you learn VBScript, you are on your way to programming with the whole family of Visual Basic languages. Although you can learn about VBScript using online resources (see the Language Reference), they do not teach you how to program. To learn programming, take a look at Step by Step books available from Microsoft Press or any of the literally hundreds of books and resources available on the subject.

 

Every Commando Message Processor profile has a Commando Script project associated with it.  When you start a profile, the Commando Script project is loaded into memory and executed.  When this happens any code in the initialization section is immediately executed (see Project Startup Code).  If your project has a Public Function called LoadSettings() it will also be called.   If your project has a public function called LoadSettings(), it MUST take no parameters and it must return either True or False.  If it returns False, script execution will halt.  After this initial code execution the script engine goes into a 'waiting state'.  Every <xx> seconds (as defined in the Polling Interval property of your processor profile) the profile will:

 

1.If your profile is designated as a Pre-Processor profile, it will call the PREPROCESS() function defined in you Commando Script project.  For example, you can use this function to connect to your database and export HL7 messages to disk for a Commando Router profile to pick up and send to another computer.
2.If your profile is designated as a message processor it will look in the HL7 message folder for HL7 message files, open the file and split out individual HL7 messages.  And then for each HL7 message, it will load it into the oMSG object and then call the MESSAGEIN() function in your Commando Script project.

 

 

 

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