Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The Template device allows you to take any incoming HL7 message and transform it into CDA (or HTML) document using a template, as defined by your organization. The transformation is handled by C# or VB code. It is just like any other custom code device, except it comes pre-populated with template code. You can write your own or use the provided samples.

Note

The Template device requires knowledge of either the C# or VB code languages. This page focuses solely on device usage and is not intended for as a code language tutorial.

...

Viewing Event Publications

An Event Publication is ????. The Each device in a Connexion channel fires off an "event" when it processes. Using a custom code device (such as the Template device), you can create custom validation routines for messages. For example, you may receive messages in a non-standar format. Using custom validation, you can accept these messages for processing even if they don't conform to an HL7 standard.

The Template device ships with two standard publications, the Event Publications: BeforeDecideProcessMessage and AfterDeviceProcessMessage.

Image Added

To use the event in your code:

  1. Select the code item you want to add the even to.
  2. Drag the event into the proper place in the code OR right-click on the event and choose Copy Event Subscription Code. The locate the place in the code where you want to insert the event, right-click

...

  1. , and choose Paste.
  2. Modify the event code as necessary and save the device.

As you modify, the device will check the compile. Any errors will be displayed on the Compile Errors tab of the Input pane.

Viewing Templates

The templates associated with the device will dictate how the HL7 message will be transformed into the target file. The device ships with two standard templates: one for HTML and one for CDA. Select the template in the tree node to view the template code. The standard templates include some basic help text (highlighted in yellow).

...

The Template Code identifies variables that will be passed to the template, as well as identifying the specific template to use with the device. The Template Code contains one public class called CustomDevice. The name of this public class cannot be changed. From the code, you will call the name of your template.

You can edit the sample Template Code that is standard with the device or create your own code. Code can be written in either C# or VB.

...

Above is a sample of Template Code. Code can be written directly in Connexion, or copied to Visual Studio for editing.

Editing template context

The template context is an object that the Razor engine uses to get the values for the template. In essence, the Template Context is called by the Template Code and tells the Razor engine where to pull the values that are inserted into the template. The device must include at least one Template Context, which is created by the user. You can use the sample context provided or create your own.

As with the Template Code, you can edit the sample provided with the device, or write your own. The Template Context can be coded in either C# or VB.

Image Added

Above is a sample Template Context. Code can be written directly in Connexion, or copied to Visual Studio for editing.

Editing the template

The template used by the device will map segments and fields in the HL7 message to the target output. Templates can be written for HTML or CDA documents. At the top of the template, you will specify the context to use by the "@model <name>. If you use one of the sample templates provided with the device, you will not need to change this. If you create your own template, you must include this context call.

Image Added

As with the Template Code and Context, you can choose to modify the sample templates included in the device or create your own. The template will be called by the device based on the Template Code and Template context. Any variables that must be passed to the template are defined in those two areas. Because the template device uses the Microsoft Razor templating engine, there are tutorials available online that can assist with template creation.

As a general abstraction, each segment/field of the HL7 message must be mapped to a section of the template by defining the variable in the Template Context and passing that variable to the template. In the below illustration, you can see how the elements of the Attending Physician Name are defined in the Template Context and then passed to the template, where they are written to the appropriate element in the CDA document layout.

Image Added

For additional information on coding the template, see the highlighted notations in the provided template samples.