Warning: This documentation is out-dated, newest version of the documentation is available at https://gazelle.ihe.net/gazelle-documentation
This page describes how to perform a CDA document validation using the SChematron Validator tool which have been developed for the gazelle project :
- How to perform a CDA document validation
- How to get the current CDA schematrons
- How does CDA validation works
- How to report a bug on CDA schematrons
- How to develop / correct a schematron
CDA documents validation is performed using Schematrons. A Schematrons defines the requirements to be tested in a CDA document. Note that there are some other ways to perform CDA content validation. For instance on can use the CDA Tools from OHT. More information about the CDA tool can be found here.
Due to limitation in time, we have not yet used the CDA Tools from OHT, however this tool is in our pipe line and we are investigating its use.
There are different ways to validating CDA documents using the :
- Using the Gazelle External Validation Service Front End. This tool provide a GUI to access the different validation services configured in the Gazelle plateform. For CDA validation is one of the services proposed by that tool.
- Download the Schematrons source code on your computer and perform the validation using an XSLT Processor. The Schematrons used by the External Validation Service Front End can be downloaded from the GUI
- Using the Schematron Validation Webservice. This solution might not be the easiest to implement, however it presents the advantage that it can be integrated in an application.
The Schematrons used by the EVS are available for download from the External Validation Service Front End GUI, under the menu : schematrons. The rest of this section is of interest for the readers who would like to understand the mechanism of creating a Schematron or reusing the templates that are available on the forge in order to develop validation Schematron for other CDA documents.
The sources of Schematrons are available on the INRIA forge. Note that
Here is the URL pointing the location of the Schematron project repository, you can use svn to import the project into your workspace.
To perform a validation of any of the documents which Schematron is available, you need to execute two actions :
- Generate the "dist" folder
- Validate the document
Generating the "dist" folder
To generate the "dist" folder you need to run the 'make-dist.sh' script, this shell script is classified under '/workspace/schematron/epSOS/tools'.
To run this script :
After been generated the "dist" folder will contain the final preprocessed Schematrons which will be used to validate your documents.
You will notice that the CDA Schematrons are divided into two kind
- Pivot : The Schematrons in this folder uses epSOS pivot codes listed in the epSOS_MVC_V1_5.xls for the validation
- Friendly : The Schematrons in this folder doesn't use epSOS pivot codes for the validation
Validating the CDA document
Now that the Schematrons are available in the "dist", the validation of a document is done thanks to the 'validate.sh' script, this shell script is classified under '/workspace/schematron/epSOS/tools'.
To run this script :
~/workspace/schematron/epSOS/tools$ ./validate.sh ../dist/cda/pivot/ePrescription.sch ../src/cda/samples/ePrescription/ePSample.xml
The first argument of the 'validate.sh' script will be the preprocessed Schematron and the second argument will be the document to validate. The example above shows the command to validate an ePrescription sample with the ePrescription schematron.
The result of the validation will figure in the "test-doc.svrl" file, you'll just need to open that file to see the result.
In order to make the result of the validation more readable, a transformation from 'svrl' to 'html' is done in the 'validate.sh' script which will out come with an html file : 'results.html'.
Here below the overall architecture of the project :
The main used folders are :
src:Contains the necessary files for the validation of CDA, SAML, ATNA and PRPA documents.
Each of these folders (cda, saml, audit...) is organized as follows :
- samples : Contains valid samples (.xml)
- sch : Contains the developed Schematrons (.sch)
- xsd : Contains the used schema (.xsd)
table_data : Contains xml files that list the codes used for the validation.
tools : Contains all the libraries used to perfom the preprocessing of the Schematrons and the validation of the documents.
This script is placed under '/workspace/schematron/epSOS/tools'.
The main goal of this script is to preprocess the developed Schematrons available under '/workspace/schematron/epSOS/src/*/sch' in order to build a consolidated one and make them available in the "dist" folder under '/workspace/schematron/epSOS/dist/'.
The preprocessing conssist mainly on :
- Resolving inclusion
- Reformating and indenting the schematrons
- Building xsl from schematrons
- Building the phases of the schematrons
- Building friendly and pivot Schematrons (just for CDA)
This script is placed under '/workspace/schematron/epSOS/tools'.
The main goal of this script is to validate an xml documents thanks to a schematron.
Schematron validation takes four XSLT stages :
- Process inclusions
- Process abstract patterns
- Compile the schema
The result of the validation is placed in the 'test-doc.svrl' file under '/workspace/schematron/epSOS/tools'.
The main goal of inclusion is to merge a number of XML information sets into a single composite infoset. In this project the inclusion is used to merge all the required schematron for the validation of a document in one Schematron file.
For example : An epSOS ePrescription document like all the CDA documents, contains different set of clinical informations. Every set of informations is represented by a 'templateId'. Every 'templateId' plays the role of a reference for the schematrons.
Almost every set of informations represented by a 'templateId' have a Schematron able of validating it.
Knowing that the ePrescription document (templateId 22.214.171.124.4.1.125126.96.36.199.188.8.131.52) must contain a Prescription Section (templateId 184.108.40.206.4.1.125220.127.116.11.18.104.22.168), and the Prescription Section, for his turn, shall include a Prescription Item Entry Content Module (templateId 22.214.171.124.4.1.125126.96.36.199.188.8.131.52)...The ePrescription Schematron which will be able to validate an ePrescription document, must include the Prescription Section schematron, and that last shall include the Prescription Item Entry Content Module schematron.
A FreeMind map available in '/workspace/schematron/epSOS/docs' describe all the set up inclusion for the CDA documents.
Issues on CDA Schematrons can be reported in the Gazelle issue tracker available here.
Schematron is a ...
- Well-formed XML document
- Technique to specify and test statements about your XML document
A Schematron specifies the checks to be performed on the tested CDA document, those tests are in fact a set of declarations for a process, it act like (test this, tell me that!). To perform the schematron's specifications, a Schematron processor is necessary :
- It reads and interprets your Schematron tests
- Applies the tests to your documents
- Reports back with any messages
Schematron development environment
In order to get your Schematron up and running we propose two environments that you can download from Oxygen web site:
- Oxygen XML plugin for Eclipse
- Oxygen XML Editor
More informations about the Oxygen XML Editor are here.
The basic Schematronbuilding blocks are :
- Phases : Activate different families called patterns. (ex: There's two phases for the validation of the CDA documents, the "pivot" and the "friendly" )
- Patterns : Rules are grouped into families called Patterns.
- Rules : Tests are collected into rules, which apply to particular XML elements (context)
- Assertions : Conditions to test, and are divided into two kind
- assert : If the condition is true, fine! If it is not, you get your message
- report : If the condition is true, you get your message
- Messages : the log you get back if the condition fail (assert), or succeed (report). We defined four kind of messages in this project. Messages starting with :
- "Error:" are interpreted as error messages
- "Success:" are interpreted as success messages
- "Note:" are interpreted as note messages
- "Warning:" are interpreted as warning messages
A phase is used to activate patterns (templates) so that they can perform a validation. To activate a pattern you simply need to declare it in a phase.
ex: Activating the pattern which id = p-184.108.40.206.4.1.125220.127.116.11.18.104.22.168-errors.
<phase id="all"> <active pattern="p-22.214.171.124.4.1.125126.96.36.199.188.8.131.52-errors"/></phase>
In our case we create two kind of phases that we called 'all' and 'no-codes'. The phase we called 'all' is intended to perform a global validation, and so we have to declare in this phase all the patterns included by the Schematron (errors + warnings + notes + codes). On the other hand, the phase we called 'no-codes' is intended to perform a validation without using pivot codes, and so we have to declare in this phase all the patterns except the ones validating the pivot codes (errors + warnings + notes).
The CDA templates performing pivot codes validation are placed under "schematron/epSOS/src/cda/sch/templates/codes".
The default Phase parameter "defaultPhase" defined in the Schematron is the one responsible of choosing which phase to perform while validation. We manipulate this parameter in the 'Make_dist' script in order to generate :
- Schematrons using pivot codes validation under 'schematron/epSOS/dist/cda/pivot' by setting the "defaultPhase" to "all"
- Schematrons not using pivot codes validation under 'schematron/epSOS/dist/cda/friendly' by setting the "defaultPhase" to "no-codes"
The main goal of inclusion is to merge a number of XML information sets into a single composite infoset.
In our case we use inclusion to merge all included patterns into a one final Schematron.
<xi:include parse="xml" href="templates/errors/184.108.40.206.4.1.125220.127.116.11.18.104.22.168.sch" xpointer="xmlns(x=http://purl.oclc.org/dsdl/schematron) xpointer(//x:pattern)">
<!-- xi:include error : file not found : templates/errors/22.214.171.124.4.1.125126.96.36.199.188.8.131.52.sch -->
The example shows the syntaxe we use to include the patterns available in the template "184.108.40.206.4.1.125220.127.116.11.18.104.22.168.sch" into the Schematrons who initiated this command.
PS: In order to use inclusion, you shall declare the following name space : "xmlns:xi="http://www.w3.org/2003/XInclude"