๐๏ธ This project is archived because the CDA-CH-EMED specification is deprecated in favor of CH-EMED. It won't be updated anymore.
This project provides pre-compiled XSLT files for the CDA-CH-EMED Schematron definitions.
The official CDA-CH-EMED Schematron definitions can be downloaded from Art-Decor or github.com/hl7ch/hl7ch-cda.
The two following version of XSLT files are created:
cdachemed-[type]-all.xslt
contain all original rules;cdachemed-[type]-error.xslt
contain only rules that have an 'error' role (this de facto excludes all 'reports').
Here is a usage example with the ph-schematron library.
final SchematronResourceXSLT mtpValidator = SchematronResourceXSLT.fromFile("cdachemed-MTP-all.xslt");
// The content to validate, whether from a file or a string
final Source fileSource = new StreamSource(new BufferedInputStream(new FileInputStream(new File("mtp.xml"))));
final Source stringSource = new StreamSource(new StringReader("<?xml version="1.0" encoding="utf-8"?>"));
final SchematronOutputType report = mtpValidator.applySchematronValidationToSVRL(fileSource);
// Retrieve all error failed asserts in the report
final List<FailedAssert> failedAsserts = report.getActivePatternAndFiredRuleAndFailedAssert()
.stream()
.filter(object -> object instanceof FailedAssert)
.map(object -> (FailedAssert) object)
.collect(Collectors.toList());
// Whether the validation is a success or a failure is yours to decide, depending on triggered reports, failed
asserts and their roles