Mapping HL7 Data Part 2

 Uncategorized  Comments Off on Mapping HL7 Data Part 2
Feb 042015

Building off the previous entry, I want to map data from the OBR3.1 into each corresponding OBX15.1

Originally, I was lazy, and just mass copied the input to the output

  <xsl:copy-of select="./@*" />
  <xsl:copy-of select="./*" />

So I need to create a mapping for each element so I can map the specific element. As I am too lazy to do start typing, I use the BizTalk mapper and drag the OBX_ObservationResult and link it by structure. I get this:

I then validate the map so I can see the underlying xsl:

<xsl:for-each select="OBX_ObservationResult[2]">
  <xsl:if test="OBX_1_SetIdObx">
      <xsl:value-of select="OBX_1_SetIdObx/text()" />
  <xsl:if test="OBX_2_ValueType">

Since I already have the for-each properly defined all I really need to copy is the children of the OBX_ObservationResult logic to my real map.

Once I have got it in the map, I simply need to map the OBR3.1 data into the OBX15.1

So I look at the code that maps to the OBX15

<xsl:for-each select="OBX_15_ProducerSId">
    <xsl:if test="CE_0_Identifier">
        <xsl:value-of select="CE_0_Identifier/text()" />
    <xsl:if test="CE_1_Text">
        <xsl:value-of select="CE_1_Text/text()" />
    <xsl:if test="CE_2_NameOfCodingSystem">
        <xsl:value-of select="CE_2_NameOfCodingSystem/text()" />
    <xsl:if test="CE_3_AlternateIdentifier">
        <xsl:value-of select="CE_3_AlternateIdentifier/text()" />
    <xsl:if test="CE_4_AlternateText">
        <xsl:value-of select="CE_4_AlternateText/text()" />
    <xsl:if test="CE_5_NameOfAlternateCodingSystem">
        <xsl:value-of select="CE_5_NameOfAlternateCodingSystem/text()" />
    <xsl:value-of select="./text()" />

I want to remove the ‘dependency’ on the input of of the OBX15, I want to create it regardless. So I remove the for-each wrapping around the OBX15 node

I also need access to to OBR data, so i create a variable that I can access in my for-each loop

  <xsl:template match="OBR_ObservationRequest">
    <xsl:variable name="Anchor" select="OBR_1_SetIdObr/text()"/>
    <xsl:variable name="OBR31" select="OBR_3_FillerOrderNumber/EI_0_EntityIdentifier/text()"/>

So now I want to map from my variable into the proper location:

  <xsl:value-of select="$OBR31"/>


Which now creates the following output: