Please feel free to send us any questions you have about HL7 and HL7 Interfaces at support@transworldscribe.com and if possible we will answer them here in this Blog/FAQ!
🛠️ Manipulating HL7 using our C# Script Library is surprisingly easy. The C# Script Library is implemented in 2 of our commercial products, the CORE HL7 C# Script Engine and the CORE HL7 TCP/IP Listener, as well as in our FREE product the CORE HL7 Viewer.
You don't have to be an expert C# coder and you don't have to be an expert in HL7 to write quick and easy scripts in Microsoft C# to perform HL7 related tasks! When you create your scripts you don't have to worry about where the messages come from, our platform will prevent the raw HL7 message to your script for you to manipulate as you like. In your scripts you have the ability to:
We have extensive help available for programmers as well as a robust library of YouTube Videos on creating, testing, and implementing your C# scripts. See the C# Script Engine YouTube Playlist for tutorial videos.
Download and install the CORE HL7 C# Script Engine. FYI, you can activate the Script Engine software and get fully functional 30 day demo license!
If you want to run your C# Scripts as HL7 is being received by the HL7 TCP/IP Listener download and install the CORE HL7 TCP/IP Listener.
We recommend that you use Microsoft Visual Studio to edit your scripts. You can download the FREE Community edition if you don't have Visual Studio installed.
Watch a few of the HL7 C# tutorial videos on our YouTube channel.
Get Coding! If you need any help at all please just contact us here at support@transworldscribe.com OR by phone 24/7 at our USA number 254-549-0825 (Country Code 1)
Below is an example CORE HL7 C# Script. This is an example of what we call a TYPE 1 script, meaning that is meant to be "fed" HL7 messages by the hosting application one by one. In the CORE HL7 Viewer you can run this script against any HL7 messages you have loaded into your viewer. The CORE HL7 Script Engine will monitor a Windows folder for HL7 message data files and when one (or more) is detected it will extract all messages into memory and "feed" them one at a time to this script. The script is only compiled ONCE and then run many times with fresh HL7 messages. We clock this script on our development computers as taking about 6 to 7 milliseconds to run for each message.
//This very simple script only does a couple of simple things
//It resets the Message Control ID to a GUID and it changes the
//Patient Name to John Smith
using System;
using COREHL7;
using COREHL7ScriptHost;
/* ABOVE are the using statements which are required */
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Xml;
using System.Data;
using System.Data.SqlClient;
using System.Text;
/* ABOVE are the optional using statements you can include */
public static COREHL7Script globals;
public static CHS_Message MyMessage;
public class Script
{
public void Execute(COREHL7Script parent)
{
globals = parent;
try
{
globals.Trace("Script is running.");
globals.Completed = true;
if (string.IsNullOrEmpty(globals.InitialHL7Message))
{
globals.SetException("No action required.No initial message", "Script()", 321342);
globals.Completed = true;
return;
}
MyMessage = globals.CreateInitialMessage();
if (globals.HasException)
{
globals.MoveInitialMessageToError();
globals.Completed = true;
return;
}
//We will set the Message Control ID (MSH 10.1) to a GUID
MyMessage.MessageControlID = System.Guid.NewGuid().ToString();
CHS_Segment pid = MyMessage.GetFirstSegmentNamed("PID");
if (pid != null)
{
//Get the Patient Name Field
CHS_Field pid5 = pid.GetFieldToEdit(5);
//Set Last Name and First Name just for fun
pid5.SetValue("Smith", 1); //Last Name
pid5.SetValue("John", 2); //First Name
}
//Commit message to see changes in viewer OR write to output folder in Script Engine
globals.CommitMessage(MyMessage);
globals.Completed = true;
return;
}
catch (Exception ex)
{
//This SetException method is your global method to handle exceptions
globals.SetException("System Error: " + ex.Message, "RunScript()", 10201);
globals.Completed = false;
return;
}
}
} //End of Script Class
/* This line below MUST be the LAST line in your script */
return new Script();
TransWorld Scribes Ltd is a New Zealand company. We have been providing a unique and innovative collection of HL7 tools, components, and application software since 2003 as HermeTech International. As a wholly owned division of TWS we are proud to offer their entire suite of HL7 solutions under our umbrella.
Email us at support@transworldscribe.com.
OR contact us by phone at our USA phone
number:
For more information visit:
Or email us at: