Sample FormEntry XSLT

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

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...

to...

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...

with...

  • 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.

  • 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))