Skip to main content
Previous sectionNext section

Generating a C-CDA Document from an HL7 Message

InterSystems products includes transformations that can accept an HL7 message, transform it into SDA (an internal representation), and then transform it into a C-CDA document. You can then provide and register the C-CDA to an XDS document repository.

HL7 to C-CDA Provide and Register Message Trace

The following diagram is an annotated message trace for an HL7 message transformed into a C-CDA followed by an XDS provide and register. The provide and register includes a PIX search to get the MPI ID from the MRN extracted from the C-CDA.

The test service shown in the diagram is a simple message router. Trace operations is a utility that makes intermediate processing steps visible in the trace. The numbers in the diagram match the steps in the procedure below.

HL7 to C-CDA Provide and Register Procedure

To set up InterSystems products to convert HL7 into C-CDA:

  1. Create an HL7 input service (for example, an HL7 file service). Set up the HL7 input service to forward HL7 messages to some operation named in the TargetConfigNames setting.

  2. Create the operation named in the previous step, and set it up to:

    1. transform the HL7 message into SDA3.

    2. transform the SDA into a C-CDA 1.1 or 2.1 document

    3. package the C-CDA into a Provide and Register request.

    4. send the Provide and Register request to the InterSystems Document Source.

  3. The Document Source then follows the path laid out in the section “Provide and Register a CDA document”.

HL7 to C-CDA Provide and Register Components and Settings

Components and Settings Used in Transformation of HL7 to C-CDA followed by a Provide and Register
Component Setting
Business Hosts HL7 Service: EnsLib.HL7.Service.FileService (or similar)
Business Hosts HL7 to C-CDA Transformer: Custom Business Operation
Business Hosts Document Source: HS.IHE.XDSb.DocumentSource.Operations
Business Hosts PIX Consumer: HS.IHE.PIXv3.Consumer.Operations
Production Settings TargetConfigNames in the HL7 Service
Production Messages HS.Message.IHE.XDSb.ProvideAndRegisterRequest
Production Messages HS.Message.XMLMessage:
  • RegistryResponse
Production Messages HS.Message.PatientSearchRequest
Production Messages HS.Message.PatientSearchResponse
XSL Transformations SDA-to-CCDAv21-CCD.xsl or other SDA to C-CDA transformation
Service Registry Entries XDSb.Repository
Service Registry Entries PIXv3.Manager
External IHE Actor Endpoints XDS Document Repository
External IHE Actor Endpoints PIX Manager

Example Transformer Business Operation to Generate a C-CDA Document from an HL7 Message

Below is a sample business operation that accepts an HL7 message and transforms it into a C-CDA document:

 Class Test.HL7Transformer Extends (Ens.BusinessOperation)
       [ Inheritance = right, ProcedureBlock ]
{
  Parameter INVOCATION = "Queue";
 
  /// XDSb source operations component
  Property XDSbSourceOperations As Ens.DataType.ConfigName
     [ InitialExpression = "HS.IHE.XDSb.DocumentSource.Operations"];
  Parameter SETTINGS As %String = "XDSbSourceOperations";
 
  XData MessageMap
  {
    <MapItems>
       <MapItem MessageType="EnsLib.HL7.Message">
         <Method>ProcessHL7Message</Method>
       </MapItem>
    </MapItems>
  }
  /// Process an inbound HL7 v2.5.1 message
  Method ProcessHL7Message(pRequest As EnsLib.HL7.Message,
                           Output pResponse As EnsLib.HL7.Message) As %Status
  {
    Try {
         // Convert the HL7 message to SDA3
         Set tSC = ##class(HS.Gateway.HL7.HL7ToSDA3).GetSDA(pRequest,.tSDA3Stream)
         Quit:$$$ISERR(tSC)
 
         // Transform the SDA3 to a C-CDA
         Set tTransformer = ##class(HS.Util.XSLTTransformer).%New()
         Set tSC= tTransformer.Transform(tSDA3Stream,"SDA3/SDA-to-CCDA-CCD.xsl",.tCDAStream)
         Quit:$$$ISERR(tSC)
 
         // Create a Provide and Register
         Set tRequest = ##class(HS.Message.IHE.XDSb.ProvideAndRegisterRequest).%New()
         Set tDocument = ##class(HS.Message.IHE.XDSb.Document).%New()
         Set tDocument.FormatCode=##class(HS.IHE.XDSb.Types.CodedValue).Create(
            "urn:hl7-org:sdwg:ccda-structuredBody:1.1","1.3.6.1.4.1.19376.1.2.3","Consolidated CDA R1.1 Structured Body Document")
         Set tDocument.MimeType="text/xml"
 
         // Copy the C-CDA into the message
         Do tDocument.BodyCharacter.CopyFrom(tCDAStream)
         Do tRequest.Documents.Insert(tDocument)
 
         // Call the document source operation
         Set tSC = ..SendRequestSync(..XDSbSourceOperations,tRequest,.tResponse)
         Quit:$$$ISERR(tSC)
       } Catch ex {
                    Set tSC= ex.AsStatus()
                   }
         Quit tSC
  }
}
Copy code to clipboard