I’ve been there several times with multiple engines over the past few years.
I use the same process each time:
1. Convert the HL7 Version 2 message to HL7 Version 2 XML (you can download the DTDs or schemas for V2 XML formats from the HL7 Web site). I’ve discovered that the DTDs work better than the Schemas.
2. Generate the CCD via an XSLT transform of the V2 XML message.
V2 Segment — CDA Component
TXA -> Clinical Document Header
PID -> patientRole
PV1 -> componentOf/encompassingEncounter
OBR -> sections
OBX -> components of a section
3. You may need to run two passes, first to generate CDA Level 3 structures using the CCD, then use those to generate the narrative text.
I use a fairly simple Java UPOC to support the XSLT transform in the version of Cloverleaf I’m using but I understand later versions of Cloverleaf supports XSLT natively.