Skip to content

Commit

Permalink
Update template-creation-how-to-guide.md
Browse files Browse the repository at this point in the history
  • Loading branch information
CaitlinV39 authored Feb 21, 2020
1 parent 417037c commit f697f66
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions docs/template-creation-how-to-guide.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# How to create a template

In this how-to guide, we will cover some of the basics around creating templates for convert HL7 v2 messages into FHIR bundles. The templates are an implementation of the open-source project [handlebars](https://handlebarsjs.com/). Handlebars compiles templates into JavaScript functions. When building templates, there are top level templates that will translate the HL7 v2 message into FHIR bundles. These top-level templates can reference partial templates, which are used as building blocks to pull the data into the top level template. The handlebars website has the most up to date information and is a great reference as you get into template building.
In this how-to guide, we will cover some of the basics around creating templates for converting HL7 v2 messages into FHIR bundles. The templates are an implementation of the open-source project [handlebars](https://handlebarsjs.com/). Handlebars compiles templates into JavaScript functions. The handlebars website has the most up to date information and is a great reference as you get into template building.

The templates included in the release were created by generating the data from [Google spreadsheets](https://docs.google.com/spreadsheets/d/1PaFYPSSq4oplTvw_4OgOn6h2Bs_CMvCAU9CqC4tPBgk) created by the HL7 community as part of their [V2 to FHIR mapping project](https://confluence.hl7.org/display/OO/2-To-FHIR+Project) that describe the mapping of HL7 v2 version 2.8.2 in FHIR bundles version R4. There are top level templates that can be used to create a FHIR bundle by translating a full HL7 v2 message and partial templates that are used as building blocks to create the top level template. For more details on the partial templates, see the partial template concept section.
The templates included in the release were created by generating the data from [Google spreadsheets](https://docs.google.com/spreadsheets/d/1PaFYPSSq4oplTvw_4OgOn6h2Bs_CMvCAU9CqC4tPBgk) created by the HL7 community as part of their [V2 to FHIR mapping project](https://confluence.hl7.org/display/OO/2-To-FHIR+Project) that describes the mapping of HL7 v2 version 2.8.2 into FHIR bundles version R4. There are top level templates that can be used to create a FHIR bundle by translating a full HL7 v2 message and partial templates that are used as building blocks to create the top level template. For more details on the partial templates, see the [partial template concept section](partial-template-concept.md).

## Prerequisites

Before starting to create template, ensure that you have deployed the GitHub code and have a local repository of the existing templates. As part of the code we have included an optional web editor to assist with modifying and creating templates. You can choose to use this functionality or another code editor. For a high level overview of the features for the web UI, see the [web UI summary](web-ui-summary).
Before starting to create a template, ensure that you have deployed the GitHub code and have a local repository of the existing templates. As part of the code, we have included an optional web editor to assist with modifying and creating templates. You can choose to use this web editor or another code editor. For a high level overview of the features for the web UI, see the [web UI summary](web-ui-summary).

## Getting started

The easiest way to create a template is to start with an existing template and modify that template. Right now, we have top level templates for ADT_A01 (admit message), ORU_R01 (observation result message), and VXU_V04 (vaccination update message). We will add more templates as the HL7 community defines them. You can also start from scratch to create your template.

To get started updating templates:
To get started updating/creating templates:

1. Load or paste in the sample message that you are using to validate your template. When modifying and creating templates, it’s helpful to have your sample message loaded so that you are able to see the FHIR results real time as you’re editing.

Expand All @@ -39,8 +39,9 @@ To get started updating templates:
### Creating Template best practices

1. Read the [handlebars documentation](https://handlebarsjs.com/guide/) for best practices on handlebars
1. When creating FHIR resources, you will create a unique URL for each resource leveraging the helper function generateUUID. When you pass in the parameters for this helper function, you should consider what data would remain drive the same unique URL. For example, for a patient, you may only pass in the MRN to ensure that the unique URL For the patient resource is consistent.
1. In general, it is better to parse message in the top level template and pass individual segment references to partial templates
1. As part of handlebars, you have if, each, with, and unless helper functions available to you for logic in creating the template
1. As part of handlebars, there are some build-in helper functions available to you. The handlebars documentation will have the most up to date information on this.
1. Leveraging partial templates allows you to build building block and utilize them across multiple templates
1. Helper functions give you additional functionality for parsing the data. See the helper section below for more details.

Expand All @@ -51,7 +52,7 @@ Handlebars allows for nested templates, enabling you to create partial templates
![edit partial template](images/partial-template-edit.png)

>[!NOTE]
>When creating a FHIR bundle, it is often required to pull details from several sub-templates. When doing this, it is possible that resources could be repeated. To avoid duplicate entries, once the message has been compiled, it will merge/de-dup any created resources that have the same resourceType, ID, or versionID. An example of a template leveraging this is ADT.hbs.
>When creating a FHIR bundle, it is often required to pull details from several sub-templates. When doing this, it is possible that resources could be repeated. To avoid duplicate entries, once the message has been compiled, it will merge/de-dup any created resources that have the same resourceType, ID, and versionID. An example of a template leveraging this is ADT.hbs.
While you’re modifying a partial template, decide if you want to modify the partial template for all main templates that reference this partial or just the one you’re working on. If you only want to modify it for the one template you are working on, make sure to rename the template at the top before make any changes and hit save. On the main template you will have to update the partial template to call your newly named partial.

Expand Down

0 comments on commit f697f66

Please sign in to comment.