Click here to Skip to main content
15,886,110 members
Articles / Programming Languages / C#
Tip/Trick

CCDA Generation using Everest API

Rate me:
Please Sign up or sign in to vote.
5.00/5 (5 votes)
6 May 2014CPOL4 min read 66.3K   568   7   32
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.

Introduction

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.

Pre-requisites

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:

C#
MARC.Everest.Attributes
MARC.Everest.Formatters.XML.Datatypes.R1
MARC.Everest.Formatters.XML.ITS1
MARC.Everest.RMIM.UV.CDAr2  

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:

C#
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:

C#
ClinicalDocument ccda = new ClinicalDocument(); 

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

C#
//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(
    "2.16.840.1.113883.10.20.22.1.1"));
//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.10.20.22.1.2"));
//CONF 5363 
ccda.Id = new II("1.1.1.1.1.1.1.1.1", "Test CCDA");
//CONF 5253 "CCD document"
ccda.Code = new CE<string>(
    "34133-9",
    "2.16.840.1.113883.6.1",
    "LOINC",
    null,
    "Summarization of Episode Note",
    null);
//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:

C#
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);
xsw.Flush(); 

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.

Disclaimer

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.

History

  • 3rd May 2014: v 1.0

License

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


Written By
Architect
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:
http://pandaxp.wordpress.com
http://coderpanda.blogspot.in

Comments and Discussions

 
QuestionCan we generate C-CDA 2.1 using this libarary. Pin
Faisal KK5-Feb-17 23:41
Faisal KK5-Feb-17 23:41 
AnswerRe: Can we generate C-CDA 2.1 using this libarary. Pin
Member 1332241521-Jul-17 10:20
Member 1332241521-Jul-17 10:20 
QuestionHealthCareFacility new CE<string Error> Pin
Member 1117040327-May-15 10:10
Member 1117040327-May-15 10:10 
QuestionError when validating on NIST Pin
joshfonseca5-Mar-15 3:52
joshfonseca5-Mar-15 3:52 
AnswerRe: Error when validating on NIST Pin
CoderPanda5-Mar-15 7:30
professionalCoderPanda5-Mar-15 7:30 
QuestionMARC.Everest.RMIM.UV.CDAr2.POCD_MT000040UV.Encounter Pin
PeterMehrkens27-Oct-14 17:47
PeterMehrkens27-Oct-14 17:47 
AnswerRe: MARC.Everest.RMIM.UV.CDAr2.POCD_MT000040UV.Encounter Pin
CoderPanda28-Oct-14 10:46
professionalCoderPanda28-Oct-14 10:46 
GeneralRe: MARC.Everest.RMIM.UV.CDAr2.POCD_MT000040UV.Encounter Pin
PeterMehrkens28-Oct-14 11:53
PeterMehrkens28-Oct-14 11:53 
GeneralRe: MARC.Everest.RMIM.UV.CDAr2.POCD_MT000040UV.Encounter Pin
CoderPanda28-Oct-14 18:03
professionalCoderPanda28-Oct-14 18:03 
Yeah, if I don't have an encounter section, then I wouldn't know. I wonder why I don't have it though. Because I know the XML that I generated using this code passed all validations.

May be encounter isn't a mandatory section? Or Is it a new addition to CCDA documents?
Braj
http://coderpanda.blogspot.in
http://pandaxp.wordpress.com
[If you find the articles or solutions useful then please up-vote or recommend them to encourage participation]

GeneralRe: MARC.Everest.RMIM.UV.CDAr2.POCD_MT000040UV.Encounter Pin
PeterMehrkens29-Oct-14 3:37
PeterMehrkens29-Oct-14 3:37 
GeneralRe: MARC.Everest.RMIM.UV.CDAr2.POCD_MT000040UV.Encounter Pin
WeaselWes8-Nov-14 5:03
WeaselWes8-Nov-14 5:03 
GeneralRe: MARC.Everest.RMIM.UV.CDAr2.POCD_MT000040UV.Encounter Pin
CoderPanda10-Nov-14 19:44
professionalCoderPanda10-Nov-14 19:44 
GeneralRe: MARC.Everest.RMIM.UV.CDAr2.POCD_MT000040UV.Encounter Pin
WeaselWes27-Nov-14 10:57
WeaselWes27-Nov-14 10:57 
GeneralRe: MARC.Everest.RMIM.UV.CDAr2.POCD_MT000040UV.Encounter Pin
CoderPanda28-Nov-14 8:16
professionalCoderPanda28-Nov-14 8:16 
QuestionSchema validation problem Pin
Jim Bowring11-Oct-14 3:08
Jim Bowring11-Oct-14 3:08 
AnswerRe: Schema validation problem Pin
CoderPanda12-Oct-14 1:09
professionalCoderPanda12-Oct-14 1:09 
QuestionHard wired path Pin
Jim Bowring11-Oct-14 3:06
Jim Bowring11-Oct-14 3:06 
AnswerRe: Hard wired path Pin
CoderPanda12-Oct-14 0:48
professionalCoderPanda12-Oct-14 0:48 
QuestionDocumentation of API Pin
mdp14_200511-Sep-14 19:32
mdp14_200511-Sep-14 19:32 
AnswerRe: Documentation of API Pin
CoderPanda11-Sep-14 23:03
professionalCoderPanda11-Sep-14 23:03 
QuestionCan please provide me XSLT style sheet for this xml Pin
mdp14_20058-Sep-14 19:48
mdp14_20058-Sep-14 19:48 
AnswerRe: Can please provide me XSLT style sheet for this xml Pin
CoderPanda8-Sep-14 23:59
professionalCoderPanda8-Sep-14 23:59 
GeneralRe: Can please provide me XSLT style sheet for this xml Pin
mdp14_200511-Sep-14 19:33
mdp14_200511-Sep-14 19:33 
QuestionNIST Validation Question Pin
dmdport5-Aug-14 3:05
dmdport5-Aug-14 3:05 
AnswerRe: NIST Validation Question Pin
CoderPanda5-Aug-14 19:56
professionalCoderPanda5-Aug-14 19:56 

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.