/
Custom Code

Custom Code

The Custom Code feature offers a mini-programming environment for developing custom functions. These functions can be used for tasks like generating a CSV file of patient attributes that match complex criteria, filing data into a database, analyzing complex message exchanges, or any task that isn't directly supported by HL7Spy.


Requirements

Using the Custom Code tool requires some programming experience, particularly in .NET C#, as it is the language used within the tool.

Resources

  1. HL7Spy comes with preloaded sample functions.
  2. You can find user-submitted, goal-oriented function samples here: http://hl7spy.ca/hl7-code/.
  3. Documentation of the available classes in HL7Spy.Core can be found here: HL7Spy.Core.chm  (Right-Click after downloading and "Unblock" to view)

Hello World!

When showing how to use a programming language/tool it is customary to print "Hello World!" since it is usually the simplest starting point. In HL7Spy we will set MSH-3 to "Hello World!" to keep with this tradition.

  public override void Run()
  {
    // Get an HL7 Message in parsed format
    HL7Message message = GetParsedMessage();
    // Set MSH-3 to "Hello World!"
    message["MSH-3"] = "Hello World";
    // Same thing, but using a different syntax
    message.MSH.SendingApplication_03.NamespaceID_01.Value = "Hello World!";
    // Save the altered message into a new tab
    SaveMessage(message,"Hello World Tab");
  }

The result if you press the Run button is that a new Tab will be generated and every message will have a value of "Hello World!" in MSH-3.



Related content