Click here to Skip to main content
12,751,832 members (30,912 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


5 bookmarked
Posted 5 May 2014

CCDA Generation using Everest API

, 6 May 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
This tip is a continuation of my series on CCDA XML Generation. It talks about how to quickly get up and running on generating CCDA documents.


I recommend you go through these 2 short articles to get an introduction to the concepts and terminologies. They should also give you a good background to this post.

  1. How To Generate CCDA/CCD XML Documents for MU 2014
  2. Open Source APIs for CCDA Generation

Basically, we want a quick way to generate documents such as Transition of Care, Discharge Summary, etc. which need to be compliant with standards such as CCDA, QRDA, etc. which are part of the HL7 umbrella standard. MARC HI Everest API exposes .NET types that help us do this as explained in this tip. Typically, you would have an EMR/EHR system written in .NET where you would want to integrate this functionality as part of the MU certification compliance initiatives.


First, go to their website and download the installer. Install like you would install a regular app.

Assuming you are on Windows, you should see the program menu items such as this:

All Programs  -> Mohawk College -> Everest 

And an installation folder such as:

C:\Program Files (x86)\Mohawk College\Everest 

If you are planning to use Everest on long term projects and want to use many of its features, then it is worth spending time through various menu items. I recommend you click on "Getting Started" in the menu and start browsing through the content there. Please note that Everest is much more than just a HL7 document generator. Though the documentation is quite exhaustive, it is clearly not good enough for a beginner. Be aware, you may feel lost at times.

How to Use the API

To get started making CCDA documents programmatically, follow the steps as mentioned below.

First up, add references to the following DLLs in your .NET project:


You should be able to find them in the folder:

C:\Program Files (x86)\Mohawk College\Everest\lib\ 

Then add the relevant using statements like this:

using MARC.Everest.Attributes;
using MARC.Everest.DataTypes;
using MARC.Everest.DataTypes.Interfaces;
using MARC.Everest.Formatters.XML.Datatypes.R1;
using MARC.Everest.RMIM.UV.CDAr2.POCD_MT000040UV;
using MARC.Everest.RMIM.UV.CDAr2.Vocabulary;
using MARC.Everest.Xml;  

Now, we are ready to build the CCDA XML document.

Build CCDA

Now we will write code to build the CCDA XML. However, before that, we need to know a bit about the document itself.

I am assuming you have read the articles pointed out in the Introduction. A CCDA document is an XML document that has a set structure. We have to ensure that we make a document that adheres exactly to that structure, else the document will not pass the validations and hence wouldn't be compliant to the MU certification requirements.

The CCDA XML has nodes that can be broadly classified into 3 sections:

  1. The static header section - comprising nodes like realmCode, typeId, id, title, etc.
  2. The dynamic header section - comprising nodes like recordTarget, author, dataEnterer, custodian, etc.
  3. The body section - comprising of component nodes inside the node structuredBody.

First, we initialize the clinical document object with this:

ClinicalDocument ccda = new ClinicalDocument(); 

Then, we populate the static nodes at the beginning of the document like this:

//CONF 16791
ccda.RealmCode = new SET<CS<BindingRealm>>(new CS<BindingRealm>(BindingRealm.UnitedStatesOfAmerica));
//CONF 5252
ccda.TemplateId = new LIST<II>();
ccda.TemplateId.Add(new II(
//The next templateId, code and title will differ depending on what type of document is being sent.
//Confirms to the document specific requirements
ccda.TemplateId.Add(new II("2.16.840.1.113883."));
//CONF 5363 
ccda.Id = new II("", "Test CCDA");
//CONF 5253 "CCD document"
ccda.Code = new CE<string>(
    "Summarization of Episode Note",
//CONF 5254
ccda.Title = new ST("Primo Adult Health: Health Summary"); 

Not all fields are depicted above for brevity. But it is enough to understand how to locate the fields and how to populate them in the ClinicalDocument object. Similarly, we populate the other sections of the document.

Source Code

At this point, you can download the source code of the Proof Of Concept attached to the tip. This code shows how each and every field is populated in the document object. Just open the solution using VS 2010 and build it. If you face any problems building or generating XMLs, ping back.

The code is broken down into methods per section to make it readable. It also has an XML along with it that has all the static fields and their values. We load that into a dictionary object and use it from the memory each time we need the value of a static field.

Formatting and Generating the XML

Now to the critical bit, formatting and generating the XML that will pass the validation.

We initialize the formatter like this:

MARC.Everest.Formatters.XML.ITS1.Formatter fmtr = new MARC.Everest.Formatters.XML.ITS1.Formatter(); 

Then we build the XML using the XmlStateWriter class provided by the API:

XmlStateWriter xsw = new XmlStateWriter(
    XmlWriter.Create("D:\\EverestPoC.xml", new XmlWriterSettings() 
    { Indent = true }));
DateTime start = DateTime.Now;
var result = fmtr.Graph(xsw, ccda);

That's it! We are done!

How to Validate?

Depending on which type of document you are trying to build for which type of provider, you may use one of the validators at NIST's website.


Please note the following before you use the code or the instructions mentioned above:

  • The conformance to the certification requirement is as claimed by the API. I have verified the generated XML for my specific case using the NIST validator mentioned above [See the message validator page and Transitions Of Care Ambulatory Summary - MU2 170.314(b)(2) option].
  • The source code is just a proof of concept. It is not a working solution to an existing EMR/EHR system that you may have. You will have to populate all mandatory fields depending on the specific document that you are trying to create. Most of the fields may come from patient specific data from your transactions DB.
  • Again the source code is just a proof of concept. It may need to be optimized at various places for better performance.
  • This tip doesn't intend to be a tutorial on CCDA or HL7 itself. However, there are links to good tutorials in my blogs mentioned in the Introduction section in this tip.


  • 3rd May 2014: v 1.0


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

India India
I dabble at many things and many of them at the same time. In short, I am a jack of all trades.

I am a software engineer by profession. My current area of expertise include .net Programming, Analysis, Software Operations and Architecture. I am equally conversant with greenfield and brownfield projects.

By hobby, I am a Technology Enthusiast, Blogger, Arm chair Movie Critic and self-proclaimed Cricket Expert. I have assisted in reviewing quite a few technology books so far. Sometimes I get lucky and take nice pics when I have my D-SLR in my hand.

Hope you found my article useful.

Also check out my blogs here:

You may also be interested in...


Comments and Discussions

QuestionCan we generate C-CDA 2.1 using this libarary. Pin
Faisal KK6-Feb-17 0:41
memberFaisal KK6-Feb-17 0:41 
QuestionHealthCareFacility new CE<string Error> Pin
Member 1117040327-May-15 11:10
memberMember 1117040327-May-15 11:10 
QuestionError when validating on NIST Pin
joshfonseca5-Mar-15 4:52
memberjoshfonseca5-Mar-15 4:52 
AnswerRe: Error when validating on NIST Pin
CoderPanda5-Mar-15 8:30
professionalCoderPanda5-Mar-15 8:30 
QuestionMARC.Everest.RMIM.UV.CDAr2.POCD_MT000040UV.Encounter Pin
PeterMehrkens27-Oct-14 18:47
memberPeterMehrkens27-Oct-14 18:47 
AnswerRe: MARC.Everest.RMIM.UV.CDAr2.POCD_MT000040UV.Encounter Pin
CoderPanda28-Oct-14 11:46
professionalCoderPanda28-Oct-14 11:46 
GeneralRe: MARC.Everest.RMIM.UV.CDAr2.POCD_MT000040UV.Encounter Pin
PeterMehrkens28-Oct-14 12:53
memberPeterMehrkens28-Oct-14 12:53 
GeneralRe: MARC.Everest.RMIM.UV.CDAr2.POCD_MT000040UV.Encounter Pin
CoderPanda28-Oct-14 19:03
professionalCoderPanda28-Oct-14 19:03 
GeneralRe: MARC.Everest.RMIM.UV.CDAr2.POCD_MT000040UV.Encounter Pin
PeterMehrkens29-Oct-14 4:37
memberPeterMehrkens29-Oct-14 4:37 
GeneralRe: MARC.Everest.RMIM.UV.CDAr2.POCD_MT000040UV.Encounter Pin
WeaselWes8-Nov-14 6:03
memberWeaselWes8-Nov-14 6:03 
GeneralRe: MARC.Everest.RMIM.UV.CDAr2.POCD_MT000040UV.Encounter Pin
CoderPanda10-Nov-14 20:44
professionalCoderPanda10-Nov-14 20:44 
GeneralRe: MARC.Everest.RMIM.UV.CDAr2.POCD_MT000040UV.Encounter Pin
WeaselWes27-Nov-14 11:57
memberWeaselWes27-Nov-14 11:57 
GeneralRe: MARC.Everest.RMIM.UV.CDAr2.POCD_MT000040UV.Encounter Pin
CoderPanda28-Nov-14 9:16
professionalCoderPanda28-Nov-14 9:16 
QuestionSchema validation problem Pin
Member 1114563411-Oct-14 4:08
memberMember 1114563411-Oct-14 4:08 
AnswerRe: Schema validation problem Pin
CoderPanda12-Oct-14 2:09
professionalCoderPanda12-Oct-14 2:09 
QuestionHard wired path Pin
Member 1114563411-Oct-14 4:06
memberMember 1114563411-Oct-14 4:06 
AnswerRe: Hard wired path Pin
CoderPanda12-Oct-14 1:48
professionalCoderPanda12-Oct-14 1:48 
QuestionDocumentation of API Pin
mdp14_200511-Sep-14 20:32
membermdp14_200511-Sep-14 20:32 
AnswerRe: Documentation of API Pin
CoderPanda12-Sep-14 0:03
professionalCoderPanda12-Sep-14 0:03 
QuestionCan please provide me XSLT style sheet for this xml Pin
mdp14_20058-Sep-14 20:48
membermdp14_20058-Sep-14 20:48 
AnswerRe: Can please provide me XSLT style sheet for this xml Pin
CoderPanda9-Sep-14 0:59
professionalCoderPanda9-Sep-14 0:59 
GeneralRe: Can please provide me XSLT style sheet for this xml Pin
mdp14_200511-Sep-14 20:33
membermdp14_200511-Sep-14 20:33 
QuestionNIST Validation Question Pin
dmdport5-Aug-14 4:05
memberdmdport5-Aug-14 4:05 
AnswerRe: NIST Validation Question Pin
CoderPanda5-Aug-14 20:56
professionalCoderPanda5-Aug-14 20:56 
GeneralRe: NIST Validation Question Pin
dmdport6-Aug-14 7:20
memberdmdport6-Aug-14 7:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170217.1 | Last Updated 6 May 2014
Article Copyright 2014 by CoderPanda
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid