How do I validate a CCD HL7 document?
Asked Answered
D

4

6

When I have an example CCD, should I use:

  1. An XSD schema and conclude that I have a valid CCD.

    or

  2. I use some other (non-schema based) method. (UML model rules in addition to a valid XML document.)

Is there even such a thing as ccd.xsd? Even if it only partially guides me to create a valid CCD.

Dancette answered 17/10, 2012 at 14:15 Comment(0)
V
9

To quickly answer your questions:

A: There is an XSD schema, but only to ensure if the document is a valid CDA document (this means it only validates the CDA RIM, not the CCD Implementation Guide)

B: The non-schema based method is to use schematron, and a ccd.sch does come shipped with the standard provided by HL7. This is the best way to validate it as a valid CCD document.

C: There is no such thing as a ccd.xsd that I'm aware of.


Background

Here's a bit of background and instructions on how to acquire the CCD standard from HL7. Acquiring the Standard would also provide you with the CDA.xsd and CCD.sch for file validation.

CCD is a specific implementation derived from the CDA RIM. Both CCD and CDA are standards that are maintained by HL7. CCD is currently a “Section 1” type standard by HL7.

The full standard can be downloaded from the HL7 website. The full standard is full standard is free to download - Although you may have to register to the site (also free). http://www.hl7.org/implement/standards/product_brief.cfm?product_id=6

Because I don’t know what other resources you have available, I am going to only use supporting documents that can be acquired from the HL7 website.

There are two layers when it comes to validating a CCD document. First, you have to validate to make sure that the document is a valid CDA file, and then you have to validate to ensure it follows the implementation constraints outlined in the CCD Implementation Guide.

To make sure it is a valid CDA file, there is a CDA.xsd schema that comes with the full CCD spec download.

The standard also comes with a schematron file to validate it as a CCD document.

In the unlikely scenario that there is a disagreement between the schematron validator and the Implementation Guide, always go with the Implementation Guide.


Acronyms

CCD – Continuity of Care Document

CDA – Clinical Document Architecture

RIM – Reference Information Model

As a supplementary link, a pretty handy online tool for CCD document validation can be found here: https://www.lantanagroup.com/validator/

Vulgate answered 7/8, 2014 at 19:11 Comment(6)
Welcome to Stack Overflow. Generally, link-answers are frowned upon. However, this question has already attracted a number of tool-recommendation answers (which are also generally not accepted on the site). I see no reason you should be downvoted though. I'm not familiar with the tech in question verify any of the answers, so I'll leave it at that.Marchellemarcher
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.Snoop
Hi @PatrickM, Thank you for the information. I am new to the site and I am still learning how to properly answer everything. I will update this answer to be more complete.Vulgate
@JasonMArcher, I will work to fix this. Thank you for your feedback!Vulgate
@Snoop I know this is an old question, but I thought it could use a more complete answer. I hope this helped answer everything! Let me know if I was confusing at any point!Vulgate
Yes, see, that makes a much better answer. :)Snoop
F
3

Option A is more recommended, which involves parsing the XML document with a DocumentBuilder that has a specific CCD schema source and then checking for validation errors. I recommend looking at the XMLValidation class in the SchematronValidator project; the validXMLUsingXSD(...) method does what you are describing. There are several places to find an XSD for valid CCD XML, but if you don't know where to start, you can find most of the XSDs for CDA/CCR schemas at Microsoft HealthVault. There are some additional ways to use schematron rules to further validate your CCD document (see the Meaningful Use Validator from NIST).

The code for what you are doing will look like the snippet below, where schemaLocation is your XSD file location. The ErrorHandler will store any validation errors.

DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
docFactory.setNamespaceAware(true);
docFactory.setValidating(true);
docFactory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
docFactory.setAttribute(JAXP_SCHEMA_SOURCE, schemaLocation);
docFactory.setIgnoringElementContentWhitespace(true);
DocumentBuilder builder = null;
try {
    builder = docFactory.newDocumentBuilder();
} catch (ParserConfigurationException pce) {
    pce.printStackTrace();
    return null;
}

builder.setErrorHandler(handler);
Document doc = null;
try {
   doc = builder.parse(xml);
} catch (SAXException e) {
    System.out.println("Message is not valid XML.");
    handler.addError("Message is not valid XML.", null);
    e.printStackTrace();
} catch (IOException e) {
    System.out.println("Message is not valid XML.  Possible empty message.");
    handler.addError("Message is not valid XML.  Possible empty message.", null);
    e.printStackTrace();
}
return doc;
Flinty answered 27/11, 2012 at 20:39 Comment(0)
L
2

I realize this is a pretty old question, but I wanted to add my two cents as well.

cdatools.org has some great tools for validating CDA documents. Since you're creating a CCD, the validation process will be the same.

Furthermore, the cdatools infocenter has fantastic information about different documents and their requirements.

Lakieshalakin answered 5/8, 2014 at 20:33 Comment(0)
V
0

Old question, but I still thought I would answer it because I was looking for a solution to this problem recently and ended up doing a fair amount of research.

I tried using the Everest API which has a built in API to validate various HL7 documents. This is a great way to test within your code if you have generated a valid document.

NIST provides a webservice (and a sample client too!) that can be used (within your code again) to validate documents like CCD/CCDA etc.

If you just need to manually validate a generated document then NIST has another one.

I hope it helps...

Varico answered 17/1, 2014 at 9:13 Comment(1)
These links are all broken.Nubilous

© 2022 - 2024 — McMap. All rights reserved.