Page tree
Skip to end of metadata
Go to start of metadata

The following is an example of a default XSLT used to translate FormEntry data submissions from XML into a pipe-delimited HL7 message.

Download from here.

Changes in 1.9.9

  • Added NK1 (relationship) segment encoding. Expects data in the following format:
<patient>
	...
	<person_relationship>
		<person_relationship.person_relationship_type_id>5</person_relationship.person_relationship_type_id>
		<person_relationship.a_or_b>B</person_relationship.a_or_b>
		<person_relationship.voided></person_relationship.voided>
		<relative>
			<relative.uuid>6b0948af-1a55-11df-9b5b-8615d3e2f525</relative.uuid>
			<relative.identifier>00001MT-9</relative.identifier>
			<relative.identifier_type>OpenMRS Universal ID</relative.identifier_type>
			<relative.location>1</relative.location>
			<relative.birthdate>19470301</relative.birthdate>
			<relative.gender>M</relative.gender>
			<relative.given_name>John</relative.given_name>
			<relative.middle_name>Henry</relative.middle_name>
			<relative.family_name>Doe</relative.family_name>
		</relative>
    </person_relationship>
    ...
</patient>

Changes in 1.9.8

  • Now escape strings (OBX text values) according to HL7 encoding rules The following condition for text (datatype ST) was added to handling OBX values
<xsl:when test="$datatype = 'ST'">
<xsl:call-template name="encodeString">
<xsl:with-param name="value" select="$value" />
</xsl:call-template>
</xsl:when>using the following template<\!-\- Escape text according to HL7 encoding rules \-->
<xsl:template name="encodeString">
<xsl:param name="value" />
<xsl:if test="$value&nbsp;\!= ''">
<xsl:value-of select="replace(replace(replace(replace(replace($value,'\\','\\E\\'),'\|','\\F\\'),'^','\\S\\'),'&','\\T\\'),'~','\\R
\\')" />
</xsl:if>
</xsl:template>

Changes in 1.9.7

  • Moved encounter/encounter.encounter_id to use PV1-19 instead of PV1-1
<xsl:text>\|</xsl:text>              <\!-\- PV1-19 Visit Number \-->
<xsl:value-of select="encounter/encounter.encounter_id" />

Changes in 1.9.6

  • added encounter/encounter.encounter_id to PV1-1
<\!-\- PV1 header \-->
<xsl:text>PV1</xsl:text>            <\!-\- Message type \-->
<xsl:text>\|</xsl:text>              <\!-\- PV1-1 Sub ID \-->
<xsl:value-of select="encounter/encounter.encounter_id" />

Changes in 1.9.5

  • Added support for subsections (observations can be one or two layers deep), allowing for forms to use subsections to better organize their observations. The "obsList" changed from...
<\!-\- Observation(s) \-->
<xsl:variable name="obsList" select="obs/*\[(@openmrs_concept and value and
value/text()&nbsp; != '') or *<a href=!archive:@openmrs_concept and text()='true'\]"/>to...<"/>-\- Observation(s) \-->
<xsl:variable name="obsList" select="obs/*\[(@openmrs_concept and value and
value/text()&nbsp;\!= '') or *[]\]\|
obs/*[]**/*\[(@openmrs_concept and value and value/text()&nbsp;\!= '')
or *[]\]" />and "obsGroupList" changed from...<\!-\- Grouped observation(s) \-->
<xsl:variable name="obsGroupList" select="obs/*\[@openmrs_concept and
not(date) and \*\[(@openmrs_concept and value and value/text()&nbsp;\!= '') or
\*[]\]\]"/>

to...

<\!-\- Grouped observation(s) \-->
<xsl:variable name="obsGroupList" select="obs/*\[@openmrs_concept and
not(date) and \*\[(@openmrs_concept and value and value/text()&nbsp;\!= '') or
*[]**\]\]\|obs/*[]/*\[@openmrs_concept
and not(date) and \*\[(@openmrs_concept and value and value/text()&nbsp;\!= '') or
\*[]\]\]" />

Changes in 1.9.4

  • Added support for unique id (/form/header/uid) for forms that transforms into HL7 control id In MSH-10, we replaced...
<xsl:text>formentry-</xsl:text>
<xsl:call-template name="hl7Timestamp">
<xsl:with-param name="date" select="current-dateTime()" />
</xsl:call-template>

with...

<xsl:choose>
<xsl:when test="header/uid">
<xsl:value-of select="header/uid" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="patient/patient.patient_id" />
<xsl:call-template name="hl7Timestamp">
<xsl:with-param name="date" select="current-dateTime()" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
  • The following was added to PV1-37 to fill HL7's Discharge To field with any value from /form/patient/patient.health_center. This is used during HL7 processing to update the patient's health center. Note: since all values entered from InfoPath's task pane currently use the format "123^Asthma" to emulate HL7 id & name separated by a circumflex (^), we strip only the first part — PV1-37 expects the 2nd component to be a date. We could consider translating the circumflex to a subcomponent delimiter (&) in the future if we want to preserve the location name.
<xsl:if test="patient/patient.health_center">
<xsl:value-of select="replace(patient/patient.health_center,'^','&')" />
</xsl:if>
  • To correct an error when encounter dates are manually entered in InfoPath (#265), lines of the form: <xsl:with-paramname="date"select="xs:date(encounter/encounter.encounter_datetime)"/>were replaced with...<xsl:with-paramname="date"select="encounter/encounter.encounter_datetime"/>
  • To correct an error with rounding up tenths of seconds, the XPath floor() function was added around the seconds-from-dateTime() and seconds-from-time() methods, e.g. seconds-from-dateTime($date)becamefloor(seconds-from-dateTime($date)andseconds-from-time($time)becamefloor(seconds-from-time($time))