Question Glenn Elliott · 44 min ago

HL7 Field Iteration and SDA3 / FHIR

I have a question around mapping between different datasets during the HL7 -> SDA3 -> FHIR transformation.

We have a FHIR server which uses the standard ISC HL7->SDA3->FHIR conversion when ingesting HL7 messages. There is the odd requirement to enrich FHIR data from the original HL7 message.. due to site specific HL7. Our approach is to extend HS.Gateway.HL7.HL7ToSDA3 with a custom GetSDA method that includes the original HL7 Message ID via CustomPairs. This makes the original HL7 message available at a later stage for enrichment.

Our enrichment occurs in DTLs for example a custom Patient DTL would subtransform HS.FHIR.DTL.SDA3.vR4.Patient.Patient and then make a number of site specific tweaks. 

My question is it safe to assume that data mapped by the standard ISC transformations (HL7->SDA3->FHIR) is in the same order when dealing with repeating elements? 

For example in the below DTL snippet there is an assumption that key tAddrIdx on Source.Addresses will also match the same address on the HL7 message fetched by GetAddressUse method.

DTL:

<foreach property='source.Addresses()' key='tAddrIdx' >

  <if condition='tAddrIdx &lt;= target.address.Count()' >

    <true>

      <!-- Fetch AddressUse from HL7 message -->

      <assign value='##class(MQHealth.Transform.PatientHelper).GetAddressUse(HL7MessageId, tAddrIdx)'

              property='tAddrUseCode'

              action='set' />


GetAddressUse Method:

    /// Get Address Use Code from PID.11.7 using the Message ID 
    /// and index of the address as PID.11 can repeat
    ClassMethod GetAddressUse(HL7MessageId As %String, myIdx as %Integer) As %String
    {
        Set addrType = ""
        set MsgObj = ##class(EnsLib.HL7.Message).%OpenId(HL7MessageId)
        if MsgObj {
            Set addrType = MsgObj.GetValueAt("PID:11(" _ myIdx _ ").7")
        }
        Return addrType
    }
Product version: IRIS 2026.1