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

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

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]">
  <OBX_ObservationResult>
  <xsl:if test="OBX_1_SetIdObx">
    <OBX_1_SetIdObx>
      <xsl:value-of select="OBX_1_SetIdObx/text()" />
    </OBX_1_SetIdObx>
  </xsl:if>
  <xsl:if test="OBX_2_ValueType">
    <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">
  <OBX_15_ProducerSId>
    <xsl:if test="CE_0_Identifier">
      <CE_0_Identifier>
        <xsl:value-of select="CE_0_Identifier/text()" />
      </CE_0_Identifier>
    </xsl:if>
    <xsl:if test="CE_1_Text">
      <CE_1_Text>
        <xsl:value-of select="CE_1_Text/text()" />
      </CE_1_Text>
    </xsl:if>
    <xsl:if test="CE_2_NameOfCodingSystem">
      <CE_2_NameOfCodingSystem>
        <xsl:value-of select="CE_2_NameOfCodingSystem/text()" />
      </CE_2_NameOfCodingSystem>
    </xsl:if>
    <xsl:if test="CE_3_AlternateIdentifier">
      <CE_3_AlternateIdentifier>
        <xsl:value-of select="CE_3_AlternateIdentifier/text()" />
      </CE_3_AlternateIdentifier>
    </xsl:if>
    <xsl:if test="CE_4_AlternateText">
      <CE_4_AlternateText>
        <xsl:value-of select="CE_4_AlternateText/text()" />
      </CE_4_AlternateText>
    </xsl:if>
    <xsl:if test="CE_5_NameOfAlternateCodingSystem">
      <CE_5_NameOfAlternateCodingSystem>
        <xsl:value-of select="CE_5_NameOfAlternateCodingSystem/text()" />
      </CE_5_NameOfAlternateCodingSystem>
    </xsl:if>
    <xsl:value-of select="./text()" />
  </OBX_15_ProducerSId>
</xsl:for-each>

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:

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

 

Which now creates the following output:

    <OBX_15_ProducerSId>
      <CE_1_Text>B13573501L</CE_1_Text>
    </OBX_15_ProducerSId>
  </OBX_ObservationResult>
</ns1:ORU_R01_25_GLO_DEF>

Sorry, the comment form is closed at this time.