What does CDAPI do?
CDAPI is a Java library that leverages mdht to accomplish two things:
- Populate an object model and convert it into a CDA document
- Converts a CDA document to a populated object model
Why is it useful?
You shouldn't have to be an expert in CDAs to produce and consume them. CDAPI makes this possible. Let's look at an excerpt of a CDA that says that a "reaction is hives":
As you can see, this is difficult to read and requires a lot of boilerplate. You don't care that a reaction's templateId is 2.16.840.1.113883.10.20.1.54 and that the entryRelationship's typeCode has to be MFST. You care that the "reaction is hives". CDAPI lets you work at this level of abstraction.
How do I produce CDA Documents?
Producing a CDA document takes 4 steps:
- Populate a
ClinicalDocumentModel. The majority of your time will be spent on this. - Create a
CdaDocumentFactory - Build the documents you want with the factory (EG: C32, C37, etc.)
- Turn the documents into xml
This is the only part of CDAPI you need to use to produce documents. But, the majority of your time will be spent in step 1. So, now we'll learn how to do that.
How do I populate the ClinicalDocumentModel?
Populating the ClinicalDocumentModel is pretty straightforward. For example, this is how you add an allergy to the patient:
How do I populate the AllergyModel (or the ProcedureModel, or the DiagnosisModel, etc.)?
Lets say you wanted to add an allergy section to your CDA document but you don't know exactly how you should set the fields of the AllergyModel. The CDAPI tests can be used as a reference. Let's look at the AllergySectionProducerTest.
The buildPenicillinAllergyModel() method shows you how to populate the AllergyModel. If a field is set in this test, it's guaranteed to be used in the generated CDA document somewhere.
|
Just because you can set a field on the model doesn't mean it'll be used in the CDA document. |
How do the fields of the AllergyModel (or the ProcedureModel, or the DiagnosisModel, etc.) map to the CDA document?
To answer this question, we'll look at another method in the same test file.
| Warning This method uses internal CDAPI code that you should not use. It may change in the future. |
This method uses the AllergyModel generated by buildPenicillinAllergyModel() and builds a CDA document from it. We only care about the xml file it generates. So, lets open up the build_one_allergy_section.xml file:
So, how would you use this to figure out where the AllergyModel.setId() method went in the CDA document? If you recall, the buildPenicillinAllergyModel() method had this line in it:
If we search for "36e3e930-7b14-11db-9fe1-0800200c9a66" in the build_one_allergy_section.xml file, we'll find exactly where that value went. You can use this approach to map any field of the model to any field of the CDA document. There are similar tests for the ProcedureModel and the DiagnosisModel and their test files are all named with the same pattern.


