be.fgov.ehealth.ehvalidator.core
Class EhValidator

java.lang.Object
  extended by be.fgov.ehealth.ehvalidator.core.EhValidator

public class EhValidator
extends Object

EhValidator

This library can help software makers or command-line enthusiasts to validate a file against the Sumehr standard. These standards are published by the e-Health platform on the KMEHR website. For a file to be validated, it must use the kmehr namespace (xmlns="http://www.ehealth.fgov.be/standards/kmehr/schema/v1"). A Sumehr is considered valid if and only if the validation report contains no lines with Error, Warning messages are allowed. Depending on the type of file, the result of the validation will be as follows :
File TypeValidation ResultComments
Any file but a Kmehr DocumentFailureThis will generate an EhValidatorXmlValidationException - The file will fail the basic XML checks
A Kmehr Document that does not follow the Sumehr StandardFailureThis will produce a validation report containing at least one Error
A Sumehr DocumentSuccessThis will produce a validation report containing no Error messages. Warning messages may be present.

Since:
1.0
Author:
Charles-Louis de Maere

Nested Class Summary
static class EhValidator.Language
          allowed languages.
static class EhValidator.ValidationResult
          Validation results.
 
Constructor Summary
EhValidator()
           
 
Method Summary
static String getHTMLReport(String fileName)
          This method performs a validation of the file whose file name is provided as parameter.
static String getHTMLView(String fileName)
          This method allows to get the HTML representation of a valid Sumehr file.
static String getHTMLView(String fileName, EhValidator.Language language)
          This method allows to get the HTML representation of a valid Sumehr file.
static String getXMLReport(String fileName)
          This method performs a validation of the file whose file name is provided as parameter.
static void main(String[] args)
          This is the main method of the eHealth Validator, used when run in command-line mode.
static EhValidator.ValidationResult validate(String fileName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EhValidator

public EhValidator()
Method Detail

getHTMLReport

public static String getHTMLReport(String fileName)
                            throws SAXException
This method performs a validation of the file whose file name is provided as parameter. The method then returns a String containing the validation report in HTML format.

Parameters:
fileName - Name of the file to validate.
Returns:
a String containing the HTML representation of the report.
Throws:
SAXException

getXMLReport

public static String getXMLReport(String fileName)
                           throws SAXException
This method performs a validation of the file whose file name is provided as parameter. The method then returns a String containing the validation report in XML format. The report uses the following format :
 <report>
      <header>
          <validationResult>
              <errors> </errors>
              <warnings> </warnings>
          </validationResult>
      </header>
      <messages>
          <message>
              <type> </type>
              <subject> </subject>
              <description>
                  <en> </en>
                  <fr> </fr>
                  <nl> </nl>
                  <de> </de>
              </description>
              <line> </line>
              <col> </col>
              <location> </location>
              <test> </test>
          </message>
          ...
      </messages>
 </report> 
 

Parameters:
fileName - Name of the file to validate
Returns:
a String containing an XML representation of the report.
Throws:
SAXException

getHTMLView

public static String getHTMLView(String fileName)
                          throws EhValidatorXmlValidationException,
                                 EhValidatorSchematronException,
                                 EhValidatorXsltTransformException
This method allows to get the HTML representation of a valid Sumehr file. If the file is valid, and can be viewed as HTML, it returns a String representation of this HTML visualisation. Use english as default language for Sumehr visualization.

Parameters:
fileName - Name of the Sumehr file to view as HTML. It should be a valid Sumehr.
Returns:
a String containing an HTML representation of the Sumehr.
Throws:
EhValidatorXmlValidationException - when the file fails basic schema validation.
EhValidatorSchematronException - when the file is not a valid sumehr, and there were issues with the schematron validation.
EhValidatorXsltTransformException - when there was an issue producing the HTML view of the file.

getHTMLView

public static String getHTMLView(String fileName,
                                 EhValidator.Language language)
                          throws EhValidatorXmlValidationException,
                                 EhValidatorSchematronException,
                                 EhValidatorXsltTransformException
This method allows to get the HTML representation of a valid Sumehr file. If the file is valid, and can be viewed as HTML, it returns a String representation of this HTML visualisation.

Parameters:
fileName - Name of the Sumehr file to view as HTML. It should be a valid Sumehr.
language - Default language for Sumehr visualization
Returns:
a String containing an HTML representation of the Sumehr.
Throws:
EhValidatorXmlValidationException - when the file fails basic schema validation.
EhValidatorSchematronException - when the file is not a valid sumehr, and there were issues with the schematron validation.
EhValidatorXsltTransformException - when there was an issue producing the HTML view of the file.

validate

public static EhValidator.ValidationResult validate(String fileName)
                                             throws EhValidatorXmlValidationException,
                                                    EhValidatorSchematronException
Parameters:
fileName - Name of the Sumehr file to validate. It should be a valid Kmehr.
Returns:
a boolean containing true if the input file is a correct Sumehr, false otherwise.
Throws:
EhValidatorXmlValidationException - when the file fails basic schema validation.
EhValidatorSchematronException - when the file is not a valid sumehr, and there were issues with the schematron validation.

main

public static void main(String[] args)
This is the main method of the eHealth Validator, used when run in command-line mode. In this mode, the tool can be used as follows :
ehvalidator-core-0.1.0.jar [option] [choice] [inputfile]

Options:

-v|--version : Show version info and halt
-h|--help|-? : Show usage
-r|--request : Execute validation

Choices:

validation : Get Validation Result
xmlreport : Get Report as XML
htmlreport : Get Report as HTML
htmlview : Get View as HTML (default language : english)
htmlviewen : Get View as HTML with english as default language
htmlviewfr : Get View as HTML with french as default language
htmlviewnl : Get View as HTML with dutch as default language
htmlviewde : Get View as HTML with german as default language

Example:

ehvalidator-core-0.1.0.jar -request xmlreport sumehrdocument.xml

Parameters:
args - The arguments as defined above.


eHealth Validator Master project 1.1.0 API
Copyright © 2010 Smals. All Rights Reserved.