This topic helps users validate the Schematron configuration in HL7 adapter.
The Schematron uses the concept of finding tree patterns in the parsed document rather than the grammar. This approach allows representation of numerous structures that are inconvenient and difficult in grammar-based schema languages.
Example:
<?xml version="1.0" encoding="UTF-8"?><Person><Name>Eddie</Name><Gender>Male</Gender><Person>
The above example is an XML document. This xml document can be validated against the below schematron:
<?xml version="1.0" encoding="UTF-8"?><sch:schema xmlns:sch="http://www.ascc.net/xml/schematron"><sch:pattern name="Check structure"><sch:rule context="Person"><sch:assert test="@Title">The element Person must have a Title attribute<sch:assert><sch:assert test="count(*) = 2 and count(Name) = 1 and count(Gender) = 1">he element Person should have the child elements Name and Gender.<sch:assert><sch:assert test="*[1] = Name">The element Name must appear before elementGender.</sch:assert></sch:rule></sch:pattern></sch:schema>
In HL7 adapter, this schematron is useful for validating a HL7 V3 document against predefined schematron schemas. Users can write these schematron schemas. These can be obtained from organizations like NHS, HL7 org. For example, NHS provides few schematrons for CDA documents.
The schematron validation is configured from the Connectivity Map Properties dialog box.
There are two properties listed for Schematron support:
Schematron Validation: Enabled or Disabled.
This opens the Enable Schematron Validation LDAP Setting box. When Enabled the Schematron Configuration is performed.
Provide the LDAP Reference value. Prefix ldap:// or ldaps:// when providing a LDAP reference.
This is not case sensitive.
Schematron Files: Provide the list of schematron files. Use commas to separate multiple files.
Example, checkprofileid.xml
Change the extension to .xml.
Click OK.
Click OK.
The below steps explains about Schematron support using a sample project prhHL7V3Inbound_WithSchematron.zip.
The sample project comes along with the HL7eWay.sar. This can be downloaded from the Downloads tab from the SAR uploader GUI.
Upload the .sar files to the Repository and download sample project from the repository.
For detailed instructions, see Installing the TCP/IP HL7 Adapter and Sample Projects in Sun Adapter for TCP/IP HL7 Tutorial.
Ensure the required HL7 V3 SAR files are uploaded to the repository.
HL7eWay.sar
HL7OTDLibrary.sar
HL7OTDLibraryGeneric.sar
HL7V32006PatientAdmin.sar
HL7V32006TransInfra.sar
Click the Downloads tab on the Suite Uploader.
Click on HL7 Adapter Inbound Collaboration Project for HL7V3 PRPA_IN403001UV01 With Schematron Validation Enabled and save prjHL7V3Inbound_WithSchematron.zip to a local directory.
There is a new API added in HL7 adapter for schematron validation. This API is a wrapper of the Open source XSLT based API available at http://xml.ascc.net/schematron/1.5. The API is an XSL file called metastylesheet (skeleton1-5.xsl) . Applying the metastylesheet to the schematron xml document generates another xsl file. This xsl file can be applied to the input xml document to validate, which produces the output xml document.
This metastylesheet can be extended and overridden so that you can customize the output xml document.
The output xml document contains details of all the validation failures. This document can be embedded inside the V3 acknowledgement and can be sent to the original sender.
Example,
A resultant xml document generated after invoking the api using the XML document and the schematron document mentioned in the overview section. The xml document will look as follows -
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <schematron-output phase="#ALL" schemaVersion="" title="" xmlns: sch="http://www.ascc.net/xml/schematron"> <active-pattern name="Check structure"/> <fired-rule context="Person" id="" role=""/> <failed-assert id="" role="" test="@Title" location="/@Person[1]"> <text>The element Person must have a Title attribute</text> </failed-assert> <schematron-output> |
Use the methods mentioned below ton invoke the schematron API from the JCD. The following are discussed.
Obtaining the Factory Object
Obtaining the Validator Object
Performing the Validation
com.stc.connector.hl7.schematron.SchematronValidatorFactory factory = com.stc.connector.hl7.schematron.SchematronValidatorFactory.getSchematronValidatorFactory();
com.stc.connector.hl7.schematron.SchematronValidator validator = factory.getDefaultValidator( domSource );
domSource is the DOMSource object of the schematron XML.
com.stc.connector.hl7.schematron.ValidationOutput output = validator.validate( dataSrc );
dataSrc is a Source of the payload. The payload can be an entire V3 XML document or a CDA document.
The ValidationOutput object contains the resultant XML document as well as a method is Valid() which returns values when the validation has passed or failed.