From 5634de32bd93225c5ae1790e623043ed85fb453f Mon Sep 17 00:00:00 2001 From: aai <aai@kereval.com> Date: Fri, 7 Jan 2022 18:23:22 +0100 Subject: [PATCH] Add GOC Tests Runner Module --- .../goc-tests/goc-tests-runner/pom.xml | 69 ++++ .../goctests/application/CDAValidator.java | 30 ++ .../application/DetailedResultAdapter.java | 14 + .../application/ResourceRetreiver.java | 50 +++ .../application/ValidatorGenerator.java | 34 ++ .../exceptions/ConfigurationException.java | 14 + .../exceptions/ReportGenerationException.java | 14 + .../exceptions/TestRunnerException.java | 14 + .../exceptions/ValidationException.java | 14 + .../ValidatorGenerationException.java | 14 + .../models/GeneratedValidator.java | 139 +++++++ .../models/NotificationElements.java | 56 +++ .../application/models/OracleResult.java | 87 +++++ .../application/models/TestResult.java | 72 ++++ .../application/models/TestResultReport.java | 138 +++++++ .../application/models/ValidationResult.java | 25 ++ .../oracles/CardinalityTestOracle.java | 33 ++ .../application/oracles/ChoiceTestOracle.java | 32 ++ .../application/oracles/ClosedTestOracle.java | 32 ++ .../oracles/ContextTestOracle.java | 33 ++ .../oracles/DatatypeTestOracle.java | 32 ++ .../oracles/FixedvalTestOracle.java | 32 ++ .../application/oracles/GlobalTestOracle.java | 33 ++ .../oracles/MandatoryTestOracle.java | 33 ++ .../application/oracles/TestOracle.java | 42 ++ .../application/oracles/TestOracleImpl.java | 117 ++++++ .../oracles/VocabularyTestOracle.java | 34 ++ .../oracles/exceptions/OracleException.java | 14 + .../specifications/CardinalityTestRunner.java | 34 ++ .../specifications/ChoiceTestRunner.java | 30 ++ .../ClosedSpecificationRunner.java | 13 + .../specifications/ContextTestRunner.java | 30 ++ .../specifications/DatatypeTestRunner.java | 30 ++ .../specifications/FixedvalTestRunner.java | 30 ++ .../specifications/GlobalTestRunner.java | 30 ++ .../specifications/MandatoryTestRunner.java | 33 ++ .../SpecificationTestRunner.java | 27 ++ .../SpecificationTestRunnerImpl.java | 149 ++++++++ .../specifications/SpecificationType.java | 68 ++++ .../specifications/VocabularyTestRunner.java | 30 ++ .../src/main/resources/application.properties | 11 + .../resources/cardinality/cda_cardinality.xml | 62 +++ .../cardinality/decor_cardinality.xml | 53 +++ .../cardinality/expected_cardinality.xml | 180 +++++++++ .../main/resources/datatype/cda_datatype.xml | 80 ++++ .../resources/datatype/decor_datatype.xml | 59 +++ .../resources/datatype/expected_datatype.xml | 343 +++++++++++++++++ .../resources/fixedvalue/cda_fixedvalue.xml | 61 +++ .../resources/fixedvalue/decor_fixedvalue.xml | 30 ++ .../fixedvalue/expected_fixedvalue.xml | 231 +++++++++++ .../resources/mandatory/cda_mandatory.xml | 56 +++ .../resources/mandatory/decor_mandatory.xml | 53 +++ .../mandatory/expected_mandatory.xml | 202 ++++++++++ .../main/resources/specifications.properties | 19 + .../resources/vocabulary/cda_vocabulary.xml | 82 ++++ .../resources/vocabulary/decor_vocabulary.xml | 75 ++++ .../vocabulary/expected_vocabulary.xml | 359 ++++++++++++++++++ .../interlay/ValidatorGeneratorTest.java | 30 ++ .../action/RuleDefinitionAnalyzer.java | 6 + .../peripherals/GOCLoggerImpl.java | 2 +- .../peripherals/HL7Templates2GOC.java | 27 +- 61 files changed, 3770 insertions(+), 6 deletions(-) create mode 100644 hl7templates/goc-tests/goc-tests-runner/pom.xml create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/CDAValidator.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/DetailedResultAdapter.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/ResourceRetreiver.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/ValidatorGenerator.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/exceptions/ConfigurationException.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/exceptions/ReportGenerationException.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/exceptions/TestRunnerException.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/exceptions/ValidationException.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/exceptions/ValidatorGenerationException.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/models/GeneratedValidator.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/models/NotificationElements.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/models/OracleResult.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/models/TestResult.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/models/TestResultReport.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/models/ValidationResult.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/CardinalityTestOracle.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/ChoiceTestOracle.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/ClosedTestOracle.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/ContextTestOracle.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/DatatypeTestOracle.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/FixedvalTestOracle.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/GlobalTestOracle.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/MandatoryTestOracle.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/TestOracle.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/TestOracleImpl.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/VocabularyTestOracle.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/exceptions/OracleException.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/CardinalityTestRunner.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/ChoiceTestRunner.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/ClosedSpecificationRunner.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/ContextTestRunner.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/DatatypeTestRunner.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/FixedvalTestRunner.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/GlobalTestRunner.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/MandatoryTestRunner.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/SpecificationTestRunner.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/SpecificationTestRunnerImpl.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/SpecificationType.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/VocabularyTestRunner.java create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/resources/application.properties create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/resources/cardinality/cda_cardinality.xml create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/resources/cardinality/decor_cardinality.xml create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/resources/cardinality/expected_cardinality.xml create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/resources/datatype/cda_datatype.xml create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/resources/datatype/decor_datatype.xml create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/resources/datatype/expected_datatype.xml create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/resources/fixedvalue/cda_fixedvalue.xml create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/resources/fixedvalue/decor_fixedvalue.xml create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/resources/fixedvalue/expected_fixedvalue.xml create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/resources/mandatory/cda_mandatory.xml create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/resources/mandatory/decor_mandatory.xml create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/resources/mandatory/expected_mandatory.xml create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/resources/specifications.properties create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/resources/vocabulary/cda_vocabulary.xml create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/resources/vocabulary/decor_vocabulary.xml create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/main/resources/vocabulary/expected_vocabulary.xml create mode 100644 hl7templates/goc-tests/goc-tests-runner/src/test/java/net/ihe/gazelle/goctests/interlay/ValidatorGeneratorTest.java diff --git a/hl7templates/goc-tests/goc-tests-runner/pom.xml b/hl7templates/goc-tests/goc-tests-runner/pom.xml new file mode 100644 index 0000000..8953d40 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/pom.xml @@ -0,0 +1,69 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <parent> + <artifactId>goc-tests</artifactId> + <groupId>net.ihe.gazelle</groupId> + <version>3.0.4-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <modelVersion>4.0.0</modelVersion> + <groupId>net.ihe.gazelle.goctests</groupId> + <artifactId>goc-tests-runner</artifactId> + <name>GOC Tests Runner</name> + <version>3.0.4-SNAPSHOT</version> + + + <build> + + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>2.3</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.20</version> + <configuration> + <argLine>-Dfile.encoding=UTF-8</argLine> + </configuration> + <dependencies> + <dependency> + <groupId>org.apache.maven.surefire</groupId> + <artifactId>surefire-junit47</artifactId> + <version>2.20</version> + </dependency> + </dependencies> + </plugin> + + + <plugin> + <artifactId>maven-failsafe-plugin</artifactId> + <version>2.17</version> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + <configuration> + <argLine>-DHL7TEMP_RESOURCES_PATH="/tmp/GOCResources/hl7templates-resources"</argLine> + </configuration> + </plugin> + + + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>net.ihe.gazelle</groupId> + <artifactId>hl7templates-packager-jar</artifactId> + <version>3.0.4-SNAPSHOT</version> + </dependency> + </dependencies> +</project> diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/CDAValidator.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/CDAValidator.java new file mode 100644 index 0000000..53c48e1 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/CDAValidator.java @@ -0,0 +1,30 @@ +package net.ihe.gazelle.goctests.application; + +import net.ihe.gazelle.goctests.application.exceptions.ValidationException; +import net.ihe.gazelle.goctests.application.models.GeneratedValidator; +import net.ihe.gazelle.goctests.application.models.ValidationResult; + +import java.net.URL; + +public interface CDAValidator { + + /** + * Validate CDA Document based on path and a validator + * throught the MBVal CLI (validator.sh) + * @param documentPath String path + * @param validator the generated validator object + * @return The validation result object + * @throws ValidationException + */ + ValidationResult validateDocument(String documentPath, GeneratedValidator validator) throws ValidationException; + + /** + * Validate CDA Document based on URL and a validator + * throught the MBVal CLI (validator.sh) + * @param documentURL URL Path (from resources) + * @param validator the generated validator object + * @return The validation result object + * @throws ValidationException + */ + ValidationResult validateDocument(URL documentURL, GeneratedValidator validator) throws ValidationException; +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/DetailedResultAdapter.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/DetailedResultAdapter.java new file mode 100644 index 0000000..f14d42b --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/DetailedResultAdapter.java @@ -0,0 +1,14 @@ +package net.ihe.gazelle.goctests.application; + +import net.ihe.gazelle.goctests.application.oracles.exceptions.OracleException; +import net.ihe.gazelle.validation.DetailedResult; + +import java.net.URL; + +/** + * This Adapter interface provide a single API to get DetailedResult + */ +public interface DetailedResultAdapter { + + DetailedResult getDetailedResult(URL url) throws OracleException; +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/ResourceRetreiver.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/ResourceRetreiver.java new file mode 100644 index 0000000..eff55f4 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/ResourceRetreiver.java @@ -0,0 +1,50 @@ +package net.ihe.gazelle.goctests.application; + +import net.ihe.gazelle.goctests.application.exceptions.ConfigurationException; +import net.ihe.gazelle.goctests.application.specifications.SpecificationType; + +import java.net.URL; + +/** + * This Interface provide APIs to retreive needed resources + * Concrete Implementations could be found in the <b>Interlay</b> layer + */ + +public interface ResourceRetreiver { + + /** + * Retreive BBR Resources based on specification + * @param specificationType + * @return URL from resource + * @throws ConfigurationException + */ + URL retreiveBBRResource(SpecificationType specificationType) throws ConfigurationException; + + /** + * Retreive CDA Resources based on specification + * @param specificationType + * @return URL from resource + * @throws ConfigurationException + */ + + URL retreiveCDAResource(SpecificationType specificationType) throws ConfigurationException; + + /** + * Retreive ExpectedResult Resources based on specification + * @param specificationType + * @return URL from resource + * @throws ConfigurationException + */ + + URL retreiveExpectedResultResource(SpecificationType specificationType) throws ConfigurationException; + + /** + * Implement this method in a matter to match value of + * Specification Enumartion, with keys in property files + * default behavior is to replace " " with "" + * @param specificationType + * @return + */ + String adaptSpecification(SpecificationType specificationType); + +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/ValidatorGenerator.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/ValidatorGenerator.java new file mode 100644 index 0000000..7900c6f --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/ValidatorGenerator.java @@ -0,0 +1,34 @@ +package net.ihe.gazelle.goctests.application; + +import net.ihe.gazelle.goctests.application.exceptions.ValidatorGenerationException; +import net.ihe.gazelle.goctests.application.models.GeneratedValidator; + +import java.net.URL; + +public interface ValidatorGenerator { + + /** + * Generate Model Based Validator with String parameters + * @param bbr The path to the BBR file (XML) + * @param outputFolder Main output directory that will contains /Validator and /logs + * @param mvn The path to the Maven <b>Binary</b> + * @return GeneratedValidator, the model definition of the validator + * @throws ValidatorGenerationException + */ + GeneratedValidator generateValidator(String bbr, String outputFolder, String mvn) throws ValidatorGenerationException; + + + /** + * <b>Generation EntryPoint</b><br> + * Generate Model Based Validator with URL with: + * <ul> + * <li><b>OutputFolder:</b> Temporary folder for Testing</li> + * <li><b>MavenBinary:</b> From application.properties File</li> + * </ul> + * @param bbrURL URL of BBR Resource + * @return GeneratedValidator, the model definition of the validator + * @throws ValidatorGenerationException + */ + GeneratedValidator generateValidator(URL bbrURL) throws ValidatorGenerationException; + +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/exceptions/ConfigurationException.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/exceptions/ConfigurationException.java new file mode 100644 index 0000000..86bf980 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/exceptions/ConfigurationException.java @@ -0,0 +1,14 @@ +package net.ihe.gazelle.goctests.application.exceptions; + +public class ConfigurationException extends Exception { + + private static final String EXCEPTION_MESSAGE = "Configuration problem: "; + + public ConfigurationException(String message) { + super(EXCEPTION_MESSAGE+message); + } + + public ConfigurationException(String message, Throwable cause) { + super(EXCEPTION_MESSAGE+message, cause); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/exceptions/ReportGenerationException.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/exceptions/ReportGenerationException.java new file mode 100644 index 0000000..35ad9ce --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/exceptions/ReportGenerationException.java @@ -0,0 +1,14 @@ +package net.ihe.gazelle.goctests.application.exceptions; + +public class ReportGenerationException extends Exception{ + + private static final String EXCEPTION_MESSAGE = "Report Generation Failed: "; + + public ReportGenerationException(String message) { + super(EXCEPTION_MESSAGE+message); + } + + public ReportGenerationException(String message, Throwable cause) { + super(EXCEPTION_MESSAGE+message, cause); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/exceptions/TestRunnerException.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/exceptions/TestRunnerException.java new file mode 100644 index 0000000..8375def --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/exceptions/TestRunnerException.java @@ -0,0 +1,14 @@ +package net.ihe.gazelle.goctests.application.exceptions; + +public class TestRunnerException extends Exception{ + + private static final String EXCEPTION_MESSAGE = "Test Running failed: "; + + public TestRunnerException(String message) { + super(EXCEPTION_MESSAGE+message); + } + + public TestRunnerException(String message, Throwable cause) { + super(EXCEPTION_MESSAGE+message, cause); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/exceptions/ValidationException.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/exceptions/ValidationException.java new file mode 100644 index 0000000..c8b6f19 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/exceptions/ValidationException.java @@ -0,0 +1,14 @@ +package net.ihe.gazelle.goctests.application.exceptions; + +public class ValidationException extends Exception{ + + private static final String EXCEPTION_MESSAGE = "CDA Document Validation failed: "; + + public ValidationException(String message) { + super(EXCEPTION_MESSAGE+message); + } + + public ValidationException(String message, Throwable cause) { + super(EXCEPTION_MESSAGE+message, cause); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/exceptions/ValidatorGenerationException.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/exceptions/ValidatorGenerationException.java new file mode 100644 index 0000000..3919e5d --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/exceptions/ValidatorGenerationException.java @@ -0,0 +1,14 @@ +package net.ihe.gazelle.goctests.application.exceptions; + +public class ValidatorGenerationException extends Exception{ + + private static final String EXCEPTION_MESSAGE = "Validator Generation process failed: "; + + public ValidatorGenerationException(String message) { + super(EXCEPTION_MESSAGE+message); + } + + public ValidatorGenerationException(String message, Throwable cause) { + super(EXCEPTION_MESSAGE+message, cause); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/models/GeneratedValidator.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/models/GeneratedValidator.java new file mode 100644 index 0000000..5b9bfa0 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/models/GeneratedValidator.java @@ -0,0 +1,139 @@ +package net.ihe.gazelle.goctests.application.models; + +import javax.xml.bind.annotation.XmlRootElement; +import java.io.Serializable; + +@XmlRootElement +public class GeneratedValidator implements Serializable { + + public static final String ROOT_LOG_DIRECTORY = "logs"; + + public static final String ROOT_LOG_PREFIX = "log-"; + + public static final String HL7TEMPLATE_RESOURCES_PATH = "hl7templates-resources"; + + public static final String VALIDATOR_APP_SUFFIX = "-validator-app"; + + public static final String ROOT_VALIDATOR_DIRECTORY = "validator"; + + public static final String VALIDATOR_BINARY_SHELL = "/bin/validator.sh"; + + public static final String VALIDATOR_RESOURCES_DIRECTORY = "/bin/resources"; + + private String outputFolder; + + private String logFolder; + + private String generationDate; + + private String usedBBR; + + private String hl7TemplateResources; + + private String validatorBinaryPath; + + private String projectName; + + private String validatorResources; + + + /** + * Private base constructor for only XML Marshalling use by JAXB + */ + private GeneratedValidator() { + } + + public GeneratedValidator(String outputFolder, String generationDate, String projectName, String usedBBR) { + this.outputFolder = outputFolder; + this.generationDate = generationDate; + this.projectName = projectName; + this.usedBBR = usedBBR; + this.logFolder = outputFolder+"/"+ROOT_LOG_DIRECTORY+"/"+ROOT_LOG_PREFIX+generationDate+"/"; + this.validatorBinaryPath = outputFolder+"/"+ROOT_VALIDATOR_DIRECTORY+"/"+projectName+VALIDATOR_APP_SUFFIX+VALIDATOR_BINARY_SHELL; + this.hl7TemplateResources = outputFolder+"/"+HL7TEMPLATE_RESOURCES_PATH; + this.validatorResources = outputFolder+"/"+ROOT_VALIDATOR_DIRECTORY+"/"+projectName+VALIDATOR_APP_SUFFIX+VALIDATOR_RESOURCES_DIRECTORY; + } + + + public String getUsedBBR() { + return usedBBR; + } + + public String getOutputFolder() { + return outputFolder; + } + + public String getLogFolder() { + return logFolder; + } + + public String getGenerationDate() { + return generationDate; + } + + public String getHl7TemplateResources() { + return hl7TemplateResources; + } + + public String getValidatorBinaryPath() { + return validatorBinaryPath; + } + + public String getProjectName() { + return projectName; + } + + public String getValidatorResources() { + return validatorResources; + } + + // TODO: 04/01/2022 Check if accessors need to be private + + public void setOutputFolder(String outputFolder) { + this.outputFolder = outputFolder; + } + + public void setLogFolder(String logFolder) { + this.logFolder = logFolder; + } + + public void setGenerationDate(String generationDate) { + this.generationDate = generationDate; + } + + public void setUsedBBR(String usedBBR) { + this.usedBBR = usedBBR; + } + + public void setHl7TemplateResources(String hl7TemplateResources) { + this.hl7TemplateResources = hl7TemplateResources; + } + + public void setValidatorBinaryPath(String validatorBinaryPath) { + this.validatorBinaryPath = validatorBinaryPath; + } + + public void setProjectName(String projectName) { + this.projectName = projectName; + } + + public void setValidatorResources(String validatorResources) { + this.validatorResources = validatorResources; + } + + @Override + public String toString() { + return "GeneratedValidator{" + + "outputFolder='" + outputFolder + '\'' + + ", logFolder='" + logFolder + '\'' + + ", generationDate='" + generationDate + '\'' + + ", usedBBR='" + usedBBR + '\'' + + ", hl7TemplateResources='" + hl7TemplateResources + '\'' + + ", validatorBinaryPath='" + validatorBinaryPath + '\'' + + ", projectName='" + projectName + '\'' + + ", validatorResources='" + validatorResources + '\'' + + '}'; + } + + +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/models/NotificationElements.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/models/NotificationElements.java new file mode 100644 index 0000000..f836f38 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/models/NotificationElements.java @@ -0,0 +1,56 @@ +package net.ihe.gazelle.goctests.application.models; + +import net.ihe.gazelle.validation.Error; +import net.ihe.gazelle.validation.Info; +import net.ihe.gazelle.validation.Note; +import net.ihe.gazelle.validation.Notification; +import net.ihe.gazelle.validation.Warning; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElements; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; +import java.util.List; + +@XmlRootElement +@XmlType(propOrder = {"count","warningOrErrorOrNote"}) +public class NotificationElements { + + private int count; + + @XmlElements({@XmlElement( + name = "Warning", + type = Warning.class + ), @XmlElement( + name = "Note", + type = Note.class + ), @XmlElement( + name = "Info", + type = Info.class + ), @XmlElement( + name = "Error", + type = Error.class + )}) + private List<Notification> warningOrErrorOrNote; + + public NotificationElements() { + } + + public NotificationElements(List<Notification> elements) { + this.warningOrErrorOrNote = elements; + this.count = elements.size(); + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } + + + public void setWarningOrErrorOrNote2(List<Notification> warningOrErrorOrNote) { + this.warningOrErrorOrNote = warningOrErrorOrNote; + } +} \ No newline at end of file diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/models/OracleResult.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/models/OracleResult.java new file mode 100644 index 0000000..d6fe1a4 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/models/OracleResult.java @@ -0,0 +1,87 @@ +package net.ihe.gazelle.goctests.application.models; + +; +import net.ihe.gazelle.validation.Notification; + +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + +@XmlRootElement +public class OracleResult { + + private boolean valid; + + private List<Notification> processed; + + private List<Notification> expectedElements; + + private List<Notification> missedElements; + + private List<Notification> unexpectedElements; + + /** + * Private base constructor for only XML Marshalling use by JAXB + */ + private OracleResult(){} + + public OracleResult(List<Notification> processed, List<Notification> expectedElements, List<Notification> missedElements, List<Notification> unexpectedElements) { + this.processed = processed; + this.expectedElements = expectedElements; + this.missedElements = missedElements; + this.unexpectedElements = unexpectedElements; + this.valid = ((missedElements.size() == 0) && (unexpectedElements.size() == 0)); + } + + public boolean isValid() { + return valid; + } + + public List<Notification> getProcessed() { + return processed; + } + + public List<Notification> getExpectedElements() { + return expectedElements; + } + + public List<Notification> getMissedElements() { + return missedElements; + } + + public List<Notification> getUnexpectedElements() { + return unexpectedElements; + } + + // TODO: 04/01/2022 Check if accessors need to be private + + public void setValid(boolean valid) { + this.valid = valid; + } + + public void setProcessed(List<Notification> processed) { + this.processed = processed; + } + + public void setExpectedElements(List<Notification> expectedElements) { + this.expectedElements = expectedElements; + } + + public void setMissedElements(List<Notification> missedElements) { + this.missedElements = missedElements; + } + + public void setUnexpectedElements(List<Notification> unexpectedElements) { + this.unexpectedElements = unexpectedElements; + } + + @Override + public String toString() { + return "OracleResult{" + + "valid=" + valid + + ", processed=" + processed + + ", expected=" + expectedElements + + ", missedElements=" + missedElements + + ", unexpectedElements=" + unexpectedElements + + '}'; + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/models/TestResult.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/models/TestResult.java new file mode 100644 index 0000000..c65392f --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/models/TestResult.java @@ -0,0 +1,72 @@ +package net.ihe.gazelle.goctests.application.models; + +import net.ihe.gazelle.goctests.application.specifications.SpecificationType; + +import java.text.SimpleDateFormat; +import java.util.Date; + + +public class TestResult { + + private final static SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); + + private GeneratedValidator usedValidator; + + private Date validationDate; + + private String formattedValidationDate; + + private String usedCDA; + + private SpecificationType specificationType; + + private OracleResult oracleResult; + + + public TestResult(GeneratedValidator usedValidator, String usedCDA, + SpecificationType specificationType, OracleResult oracleResult) { + this.usedValidator = usedValidator; + this.usedCDA = usedCDA; + this.specificationType = specificationType; + this.validationDate = new Date(); + this.formattedValidationDate = TestResult.formatter.format(validationDate); + this.oracleResult = oracleResult; + } + + public GeneratedValidator getUsedValidator() { + return usedValidator; + } + + public Date getValidationDate() { + return validationDate; + } + + public String getFormattedValidationDate(){ + return formattedValidationDate; + } + + + public String getUsedCDA() { + return usedCDA; + } + + public SpecificationType getSpecificationType() { + return specificationType; + } + + public OracleResult getOracleResult() { + return oracleResult; + } + + @Override + public String toString() { + return "TestResult{" + + " usedValidator=" + usedValidator + + ", validationDate=" + validationDate + + ", formattedValidationDate='" + formattedValidationDate + '\'' + + ", usedCDA='" + usedCDA + '\'' + + ", specificationType=" + specificationType + + ", oracleResult=" + oracleResult + + '}'; + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/models/TestResultReport.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/models/TestResultReport.java new file mode 100644 index 0000000..5b92a8b --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/models/TestResultReport.java @@ -0,0 +1,138 @@ +package net.ihe.gazelle.goctests.application.models; + + +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; +import java.io.Serializable; + +@XmlRootElement +@XmlType(propOrder = {"validationDate","testResult","specification","usedCDA","processedElements" + ,"expectedElements","missedElements","unexpectedElements","usedValidator"}) +public class TestResultReport implements Serializable { + + private String testResult; + + private GeneratedValidator usedValidator; + + private String validationDate; + + private String usedCDA; + + private String specification; + + private int processedElements; + + private int expectedElements; + + private NotificationElements missedElements; + + private NotificationElements unexpectedElements; + + + + + public TestResultReport() { + } + + public TestResultReport(String testResult, GeneratedValidator usedValidator, String generationDate, String usedCDA, String specification, + int processedElements, int expectedElements, NotificationElements missedElements, NotificationElements unexpectedElements) { + this.testResult = testResult; + this.usedValidator = usedValidator; + this.validationDate = generationDate; + this.usedCDA = usedCDA; + this.specification = specification; + this.processedElements = processedElements; + this.expectedElements = expectedElements; + this.missedElements = missedElements; + this.unexpectedElements = unexpectedElements; + + } + + public String getTestResult() { + return testResult; + } + + public void setTestResult(String testResult) { + this.testResult = testResult; + } + + public GeneratedValidator getUsedValidator() { + return usedValidator; + } + + public void setUsedValidator(GeneratedValidator usedValidator) { + this.usedValidator = usedValidator; + } + + public String getUsedCDA() { + return usedCDA; + } + + public void setUsedCDA(String usedCDA) { + this.usedCDA = usedCDA; + } + + public String getSpecification() { + return specification; + } + + public void setSpecification(String specification) { + this.specification = specification; + } + + public String getValidationDate() { + return validationDate; + } + + public void setValidationDate(String validationDate) { + this.validationDate = validationDate; + } + + public int getProcessedElements() { + return processedElements; + } + + public void setProcessedElements(int processedElements) { + this.processedElements = processedElements; + } + + public int getExpectedElements() { + return expectedElements; + } + + public void setExpectedElements(int expectedElements) { + this.expectedElements = expectedElements; + } + + public NotificationElements getMissedElements() { + return missedElements; + } + + public void setMissedElements(NotificationElements missedElements) { + this.missedElements = missedElements; + } + + public NotificationElements getUnexpectedElements() { + return unexpectedElements; + } + + public void setUnexpectedElements(NotificationElements unexpectedElements) { + this.unexpectedElements = unexpectedElements; + } + + @Override + public String toString() { + return "TestResultReport{" + + "testResult='" + testResult + '\'' + + ", usedValidator=" + usedValidator + + ", validationDate='" + validationDate + '\'' + + ", usedCDA='" + usedCDA + '\'' + + ", specification='" + specification + '\'' + + ", processedElements=" + processedElements + + ", expectedElements=" + expectedElements + + ", missedElements=" + missedElements + + ", unexpectedElements=" + unexpectedElements + + '}'; + } + +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/models/ValidationResult.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/models/ValidationResult.java new file mode 100644 index 0000000..30c3c4f --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/models/ValidationResult.java @@ -0,0 +1,25 @@ +package net.ihe.gazelle.goctests.application.models; + +import net.ihe.gazelle.validation.DetailedResult; + +public class ValidationResult { + + private DetailedResult detailedResult; + + private String usedCDA; + + + public ValidationResult(DetailedResult detailedResult, String usedCDA) { + this.detailedResult = detailedResult; + this.usedCDA = usedCDA; + } + + public DetailedResult getDetailedResult() { + return detailedResult; + } + + public String getUsedCDA() { + return usedCDA; + } + +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/CardinalityTestOracle.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/CardinalityTestOracle.java new file mode 100644 index 0000000..23ca310 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/CardinalityTestOracle.java @@ -0,0 +1,33 @@ +package net.ihe.gazelle.goctests.application.oracles; + +import net.ihe.gazelle.goctests.application.DetailedResultAdapter; +import net.ihe.gazelle.goctests.application.ResourceRetreiver; +import net.ihe.gazelle.goctests.application.models.OracleResult; +import net.ihe.gazelle.goctests.application.specifications.SpecificationType; +import net.ihe.gazelle.goctests.application.oracles.exceptions.OracleException; + +import net.ihe.gazelle.validation.DetailedResult; +import net.ihe.gazelle.validation.Notification; + +import java.util.List; + +public class CardinalityTestOracle extends TestOracleImpl { + + public CardinalityTestOracle(ResourceRetreiver resourceRetreiver, DetailedResultAdapter detailedResultAdapter) { + super(SpecificationType.CARDINALITY, resourceRetreiver, detailedResultAdapter); + } + + @Override + public OracleResult compareWithExpectedResult(DetailedResult actualResult) throws OracleException { + // Add more processing if needed + + return super.compareWithExpectedResult(actualResult); + } + + @Override + public boolean matchingCriteria(Notification target, List<Notification> elements) { + // Override to change comparison criteria + + return super.matchingCriteria(target, elements); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/ChoiceTestOracle.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/ChoiceTestOracle.java new file mode 100644 index 0000000..d87af3f --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/ChoiceTestOracle.java @@ -0,0 +1,32 @@ +package net.ihe.gazelle.goctests.application.oracles; + +import net.ihe.gazelle.goctests.application.DetailedResultAdapter; +import net.ihe.gazelle.goctests.application.ResourceRetreiver; +import net.ihe.gazelle.goctests.application.models.OracleResult; +import net.ihe.gazelle.goctests.application.oracles.exceptions.OracleException; +import net.ihe.gazelle.goctests.application.specifications.SpecificationType; +import net.ihe.gazelle.validation.DetailedResult; +import net.ihe.gazelle.validation.Notification; + +import java.util.List; + +public class ChoiceTestOracle extends TestOracleImpl{ + + public ChoiceTestOracle(ResourceRetreiver resourceRetreiver, DetailedResultAdapter detailedResultAdapter) { + super(SpecificationType.CHOICE, resourceRetreiver, detailedResultAdapter); + } + + @Override + public OracleResult compareWithExpectedResult(DetailedResult actualResult) throws OracleException { + //Additional processing if needed + + return super.compareWithExpectedResult(actualResult); + } + + @Override + public boolean matchingCriteria(Notification target, List<Notification> elements) { + // Override to change comparison criteria + + return super.matchingCriteria(target, elements); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/ClosedTestOracle.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/ClosedTestOracle.java new file mode 100644 index 0000000..f82c1af --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/ClosedTestOracle.java @@ -0,0 +1,32 @@ +package net.ihe.gazelle.goctests.application.oracles; + +import net.ihe.gazelle.goctests.application.DetailedResultAdapter; +import net.ihe.gazelle.goctests.application.ResourceRetreiver; +import net.ihe.gazelle.goctests.application.models.OracleResult; +import net.ihe.gazelle.goctests.application.oracles.exceptions.OracleException; +import net.ihe.gazelle.goctests.application.specifications.SpecificationType; +import net.ihe.gazelle.validation.DetailedResult; +import net.ihe.gazelle.validation.Notification; + +import java.util.List; + +public class ClosedTestOracle extends TestOracleImpl{ + + public ClosedTestOracle(ResourceRetreiver resourceRetreiver, DetailedResultAdapter detailedResultAdapter) { + super(SpecificationType.CLOSED, resourceRetreiver, detailedResultAdapter); + } + + @Override + public OracleResult compareWithExpectedResult(DetailedResult actualResult) throws OracleException { + // Add more processing if needed + + return super.compareWithExpectedResult(actualResult); + } + + @Override + public boolean matchingCriteria(Notification target, List<Notification> elements) { + // Add more processing if needed + + return super.matchingCriteria(target, elements); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/ContextTestOracle.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/ContextTestOracle.java new file mode 100644 index 0000000..fdaf69e --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/ContextTestOracle.java @@ -0,0 +1,33 @@ +package net.ihe.gazelle.goctests.application.oracles; + +import net.ihe.gazelle.goctests.application.DetailedResultAdapter; +import net.ihe.gazelle.goctests.application.ResourceRetreiver; +import net.ihe.gazelle.goctests.application.models.OracleResult; +import net.ihe.gazelle.goctests.application.specifications.SpecificationType; +import net.ihe.gazelle.goctests.application.oracles.exceptions.OracleException; +import net.ihe.gazelle.validation.DetailedResult; +import net.ihe.gazelle.validation.Notification; + +import java.util.List; + +public class ContextTestOracle extends TestOracleImpl { + + + public ContextTestOracle(ResourceRetreiver resourceRetreiver, DetailedResultAdapter detailedResultAdapter) { + super(SpecificationType.CONTEXT, resourceRetreiver, detailedResultAdapter); + } + + @Override + public OracleResult compareWithExpectedResult(DetailedResult actualResult) throws OracleException { + // Add more processing if needed + + return super.compareWithExpectedResult(actualResult); + } + + @Override + public boolean matchingCriteria(Notification target, List<Notification> elements) { + // Override to change comparison criteria + + return super.matchingCriteria(target, elements); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/DatatypeTestOracle.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/DatatypeTestOracle.java new file mode 100644 index 0000000..6c43fb8 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/DatatypeTestOracle.java @@ -0,0 +1,32 @@ +package net.ihe.gazelle.goctests.application.oracles; + +import net.ihe.gazelle.goctests.application.DetailedResultAdapter; +import net.ihe.gazelle.goctests.application.ResourceRetreiver; +import net.ihe.gazelle.goctests.application.specifications.SpecificationType; +import net.ihe.gazelle.goctests.application.models.OracleResult; +import net.ihe.gazelle.goctests.application.oracles.exceptions.OracleException; +import net.ihe.gazelle.validation.DetailedResult; +import net.ihe.gazelle.validation.Notification; + +import java.util.List; + +public class DatatypeTestOracle extends TestOracleImpl{ + + public DatatypeTestOracle(ResourceRetreiver resourceRetreiver, DetailedResultAdapter detailedResultAdapter) { + super(SpecificationType.DATATYPE, resourceRetreiver, detailedResultAdapter); + } + + @Override + public OracleResult compareWithExpectedResult(DetailedResult actualResult) throws OracleException { + // Add more processing if needed + + return super.compareWithExpectedResult(actualResult); + } + + @Override + public boolean matchingCriteria(Notification target, List<Notification> elements) { + // Override to change comparison criteria + + return super.matchingCriteria(target, elements); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/FixedvalTestOracle.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/FixedvalTestOracle.java new file mode 100644 index 0000000..91976b9 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/FixedvalTestOracle.java @@ -0,0 +1,32 @@ +package net.ihe.gazelle.goctests.application.oracles; + +import net.ihe.gazelle.goctests.application.DetailedResultAdapter; +import net.ihe.gazelle.goctests.application.ResourceRetreiver; +import net.ihe.gazelle.goctests.application.models.OracleResult; +import net.ihe.gazelle.goctests.application.oracles.exceptions.OracleException; +import net.ihe.gazelle.goctests.application.specifications.SpecificationType; +import net.ihe.gazelle.validation.DetailedResult; +import net.ihe.gazelle.validation.Notification; + +import java.util.List; + +public class FixedvalTestOracle extends TestOracleImpl{ + + public FixedvalTestOracle(ResourceRetreiver resourceRetreiver, DetailedResultAdapter detailedResultAdapter) { + super(SpecificationType.FIXEDVAL, resourceRetreiver, detailedResultAdapter); + } + + @Override + public OracleResult compareWithExpectedResult(DetailedResult actualResult) throws OracleException { + // Add more processing if needed + + return super.compareWithExpectedResult(actualResult); + } + + @Override + public boolean matchingCriteria(Notification target, List<Notification> elements) { + // Override to change comparison criteria + + return super.matchingCriteria(target, elements); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/GlobalTestOracle.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/GlobalTestOracle.java new file mode 100644 index 0000000..078dba5 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/GlobalTestOracle.java @@ -0,0 +1,33 @@ +package net.ihe.gazelle.goctests.application.oracles; + +import net.ihe.gazelle.goctests.application.DetailedResultAdapter; +import net.ihe.gazelle.goctests.application.ResourceRetreiver; +import net.ihe.gazelle.goctests.application.models.OracleResult; +import net.ihe.gazelle.goctests.application.specifications.SpecificationType; +import net.ihe.gazelle.goctests.application.oracles.exceptions.OracleException; +import net.ihe.gazelle.validation.DetailedResult; +import net.ihe.gazelle.validation.Notification; + +import java.util.List; + +public class GlobalTestOracle extends TestOracleImpl { + + + public GlobalTestOracle(ResourceRetreiver resourceRetreiver, DetailedResultAdapter detailedResultAdapter) { + super(SpecificationType.GLOBAL, resourceRetreiver, detailedResultAdapter); + } + + @Override + public OracleResult compareWithExpectedResult(DetailedResult actualResult) throws OracleException { + // Add more processing if needed + + return super.compareWithExpectedResult(actualResult); + } + + @Override + public boolean matchingCriteria(Notification target, List<Notification> elements) { + // Override to change comparison criteria + + return super.matchingCriteria(target, elements); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/MandatoryTestOracle.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/MandatoryTestOracle.java new file mode 100644 index 0000000..f153290 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/MandatoryTestOracle.java @@ -0,0 +1,33 @@ +package net.ihe.gazelle.goctests.application.oracles; + +import net.ihe.gazelle.goctests.application.DetailedResultAdapter; +import net.ihe.gazelle.goctests.application.ResourceRetreiver; +import net.ihe.gazelle.goctests.application.models.OracleResult; +import net.ihe.gazelle.goctests.application.specifications.SpecificationType; +import net.ihe.gazelle.goctests.application.oracles.exceptions.OracleException; +import net.ihe.gazelle.validation.DetailedResult; +import net.ihe.gazelle.validation.Notification; + +import java.util.List; + +public class MandatoryTestOracle extends TestOracleImpl { + + + public MandatoryTestOracle(ResourceRetreiver resourceRetreiver, DetailedResultAdapter detailedResultAdapter) { + super(SpecificationType.MANDATORY, resourceRetreiver, detailedResultAdapter); + } + + @Override + public OracleResult compareWithExpectedResult(DetailedResult actualResult) throws OracleException { + // Add more processing if needed + + return super.compareWithExpectedResult(actualResult); + } + + @Override + public boolean matchingCriteria(Notification target, List<Notification> elements) { + // Override to change comparison criteria + + return super.matchingCriteria(target, elements); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/TestOracle.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/TestOracle.java new file mode 100644 index 0000000..d6f354b --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/TestOracle.java @@ -0,0 +1,42 @@ +package net.ihe.gazelle.goctests.application.oracles; + +import net.ihe.gazelle.goctests.application.models.OracleResult; +import net.ihe.gazelle.goctests.application.oracles.exceptions.OracleException; +import net.ihe.gazelle.goctests.application.specifications.SpecificationType; +import net.ihe.gazelle.validation.DetailedResult; +import net.ihe.gazelle.validation.Notification; + +import java.util.List; + +/** + * This interface provides APIs to compare <b>actual</b> TestResult with the <b>expected</b> one + */ +public interface TestOracle { + + /** + * comparing actual with expected is done with comparing: + * <ul> + * <li>Erros</li> + * <li>Warnings</li> + * <li>Infos</li> + * <li>Notes</li> + * </ul> + * @return + */ + OracleResult compareWithExpectedResult(DetailedResult actualResult) throws OracleException; + + + /** + * The default pre-defined criteria is to search for match based on + * the <b>Location</b> and <b>Description</b> of Notification object + * in a list of Notifications objects. + * You can override this behavior in subclasses + * @param target + * @param elements + * @return True if a math found, false otherwise + */ + boolean matchingCriteria(Notification target, List<Notification> elements); + + + SpecificationType getSpecificationType(); +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/TestOracleImpl.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/TestOracleImpl.java new file mode 100644 index 0000000..142026b --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/TestOracleImpl.java @@ -0,0 +1,117 @@ +package net.ihe.gazelle.goctests.application.oracles; + + +import net.ihe.gazelle.goctests.application.DetailedResultAdapter; +import net.ihe.gazelle.goctests.application.ResourceRetreiver; +import net.ihe.gazelle.goctests.application.models.OracleResult; +import net.ihe.gazelle.goctests.application.exceptions.ConfigurationException; +import net.ihe.gazelle.goctests.application.oracles.exceptions.OracleException; +import net.ihe.gazelle.goctests.application.specifications.SpecificationType; + +import net.ihe.gazelle.validation.DetailedResult; +import net.ihe.gazelle.validation.Notification; + + +import java.net.URL; +import java.util.List; +import java.util.stream.Collectors; + +/** + * {@inheritDoc} + */ +abstract public class TestOracleImpl implements TestOracle { + + private SpecificationType specificationType; + + private ResourceRetreiver resourceRetreiver; + + private DetailedResultAdapter detailedResultAdapter; + + protected TestOracleImpl(SpecificationType specificationType, ResourceRetreiver resourceRetreiver, DetailedResultAdapter detailedResultAdapter) { + this.specificationType = specificationType; + this.resourceRetreiver = resourceRetreiver; + this.detailedResultAdapter = detailedResultAdapter; + } + + /** + * + * {@inheritDoc} + */ + @Override + public OracleResult compareWithExpectedResult(DetailedResult actualResult) throws OracleException { + + if (specificationType == null){ + throw new OracleException("FATAL: Specification type not specified"); + } + + if(actualResult == null || actualResult.getMDAValidation() == null){ + throw new OracleException("Validation result not correctly set"); + } + + try { + URL expectedResultURL = resourceRetreiver.retreiveExpectedResultResource(specificationType); + DetailedResult expectedResult = detailedResultAdapter.getDetailedResult(expectedResultURL); + if(expectedResult == null || expectedResult.getMDAValidation() == null){ + throw new OracleException("Problem in local resources"); + } + + // Filter on specification and cast to Notification + List<Notification> filteredExcpected = filterDetailResultBySpec(expectedResult); + List<Notification> filteredActual = filterDetailResultBySpec(actualResult); + + // Look for missing elements + List<Notification> missedElements = matchElements1inElements2(filteredExcpected, filteredActual); + + // Look for unexpected (additional) elements + List<Notification> unexpectedElements = matchElements1inElements2(filteredActual, filteredExcpected); + + OracleResult oracleResult = + new OracleResult(filteredActual,filteredExcpected,missedElements,unexpectedElements); + + return oracleResult; + + } catch (ConfigurationException e) { + throw new OracleException("Could not retreive Expected Result resources path",e); + } + } + + /** + * + * {@inheritDoc} + */ + @Override + public boolean matchingCriteria(Notification target, List<Notification> elements) { + for(Notification element : elements){ + if(target.getLocation().equals(element.getLocation()) + && target.getDescription().equals(element.getDescription())){ + return true; + } + } + return false; + } + + public SpecificationType getSpecificationType() { + return specificationType; + } + + private List<Notification> filterDetailResultBySpec(DetailedResult detailedResult){ + return detailedResult + .getMDAValidation().getWarningOrErrorOrNote() + .stream().map(e->(Notification)e) + .filter(this::filteringCriteria) + .collect(Collectors.toList()); + } + + private boolean filteringCriteria(Notification notification){ + return (specificationType.equals(SpecificationType.GLOBAL) || + (notification.getType() !=null && notification.getType() + .equalsIgnoreCase(specificationType.getValue()))); + } + + private List<Notification> matchElements1inElements2(List<Notification> elements1, List<Notification> elements2){ + return elements1 + .stream().filter(e->!matchingCriteria(e,elements2)) + .collect(Collectors.toList()); + + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/VocabularyTestOracle.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/VocabularyTestOracle.java new file mode 100644 index 0000000..57ef993 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/VocabularyTestOracle.java @@ -0,0 +1,34 @@ +package net.ihe.gazelle.goctests.application.oracles; + +import net.ihe.gazelle.goctests.application.DetailedResultAdapter; +import net.ihe.gazelle.goctests.application.ResourceRetreiver; +import net.ihe.gazelle.goctests.application.models.OracleResult; +import net.ihe.gazelle.goctests.application.specifications.SpecificationType; +import net.ihe.gazelle.goctests.application.oracles.exceptions.OracleException; + +import net.ihe.gazelle.validation.DetailedResult; +import net.ihe.gazelle.validation.Notification; + +import java.util.List; + +public class VocabularyTestOracle extends TestOracleImpl { + + + public VocabularyTestOracle(ResourceRetreiver resourceRetreiver, DetailedResultAdapter detailedResultAdapter) { + super(SpecificationType.VOCABULARY, resourceRetreiver, detailedResultAdapter); + } + + @Override + public OracleResult compareWithExpectedResult(DetailedResult actualResult) throws OracleException { + // Add more processing if needed + + return super.compareWithExpectedResult(actualResult); + } + + @Override + public boolean matchingCriteria(Notification target, List<Notification> elements) { + // Override to change comparison criteria + + return super.matchingCriteria(target, elements); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/exceptions/OracleException.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/exceptions/OracleException.java new file mode 100644 index 0000000..14ea067 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/oracles/exceptions/OracleException.java @@ -0,0 +1,14 @@ +package net.ihe.gazelle.goctests.application.oracles.exceptions; + +public class OracleException extends Exception{ + + private static final String EXCEPTION_MESSAGE = "Test Oracle failed: "; + + public OracleException(String message) { + super(EXCEPTION_MESSAGE+message); + } + + public OracleException(String message, Throwable cause) { + super(EXCEPTION_MESSAGE+message, cause); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/CardinalityTestRunner.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/CardinalityTestRunner.java new file mode 100644 index 0000000..834a98a --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/CardinalityTestRunner.java @@ -0,0 +1,34 @@ +package net.ihe.gazelle.goctests.application.specifications; + +import net.ihe.gazelle.goctests.application.CDAValidator; +import net.ihe.gazelle.goctests.application.ResourceRetreiver; +import net.ihe.gazelle.goctests.application.ValidatorGenerator; +import net.ihe.gazelle.goctests.definitions.annotations.Covers; +import net.ihe.gazelle.goctests.definitions.annotations.TestType; + +import net.ihe.gazelle.goctests.application.oracles.TestOracle; +import net.ihe.gazelle.goctests.application.models.TestResult; +import net.ihe.gazelle.goctests.application.exceptions.ReportGenerationException; +import net.ihe.gazelle.goctests.application.exceptions.TestRunnerException; + +public class CardinalityTestRunner extends SpecificationTestRunnerImpl{ + + public CardinalityTestRunner(ResourceRetreiver resourceRetreiver, CDAValidator cdaValidator, ValidatorGenerator validatorGenerator, TestOracle testOracle) { + super(SpecificationType.CARDINALITY, resourceRetreiver, cdaValidator, validatorGenerator,testOracle); + } + + + @Override + public void runTest() throws TestRunnerException { + //Additional processing if needed + + super.runTest(); + } + + @Override + public TestResult generateResult() throws ReportGenerationException { + //Additional processing if needed + + return super.generateResult(); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/ChoiceTestRunner.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/ChoiceTestRunner.java new file mode 100644 index 0000000..95c2a0b --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/ChoiceTestRunner.java @@ -0,0 +1,30 @@ +package net.ihe.gazelle.goctests.application.specifications; + +import net.ihe.gazelle.goctests.application.CDAValidator; +import net.ihe.gazelle.goctests.application.ResourceRetreiver; +import net.ihe.gazelle.goctests.application.ValidatorGenerator; +import net.ihe.gazelle.goctests.application.exceptions.ReportGenerationException; +import net.ihe.gazelle.goctests.application.exceptions.TestRunnerException; +import net.ihe.gazelle.goctests.application.models.TestResult; +import net.ihe.gazelle.goctests.application.oracles.TestOracle; + +public class ChoiceTestRunner extends SpecificationTestRunnerImpl{ + + public ChoiceTestRunner(ResourceRetreiver resourceRetreiver, CDAValidator cdaValidator, ValidatorGenerator validatorGenerator, TestOracle testOracle) { + super(SpecificationType.CHOICE, resourceRetreiver, cdaValidator, validatorGenerator, testOracle); + } + + @Override + public void runTest() throws TestRunnerException { + //Additional processing if needed + + super.runTest(); + } + + @Override + public TestResult generateResult() throws ReportGenerationException { + //Additional processing if needed + + return super.generateResult(); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/ClosedSpecificationRunner.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/ClosedSpecificationRunner.java new file mode 100644 index 0000000..8f407c9 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/ClosedSpecificationRunner.java @@ -0,0 +1,13 @@ +package net.ihe.gazelle.goctests.application.specifications; + +import net.ihe.gazelle.goctests.application.CDAValidator; +import net.ihe.gazelle.goctests.application.ResourceRetreiver; +import net.ihe.gazelle.goctests.application.ValidatorGenerator; +import net.ihe.gazelle.goctests.application.oracles.TestOracle; + +public class ClosedSpecificationRunner extends SpecificationTestRunnerImpl{ + + public ClosedSpecificationRunner(ResourceRetreiver resourceRetreiver, CDAValidator cdaValidator, ValidatorGenerator validatorGenerator, TestOracle testOracle) { + super(SpecificationType.CLOSED, resourceRetreiver, cdaValidator, validatorGenerator, testOracle); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/ContextTestRunner.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/ContextTestRunner.java new file mode 100644 index 0000000..45abbc4 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/ContextTestRunner.java @@ -0,0 +1,30 @@ +package net.ihe.gazelle.goctests.application.specifications; + +import net.ihe.gazelle.goctests.application.CDAValidator; +import net.ihe.gazelle.goctests.application.ResourceRetreiver; +import net.ihe.gazelle.goctests.application.ValidatorGenerator; +import net.ihe.gazelle.goctests.application.exceptions.ReportGenerationException; +import net.ihe.gazelle.goctests.application.exceptions.TestRunnerException; +import net.ihe.gazelle.goctests.application.models.TestResult; +import net.ihe.gazelle.goctests.application.oracles.TestOracle; + +public class ContextTestRunner extends SpecificationTestRunnerImpl{ + + public ContextTestRunner(ResourceRetreiver resourceRetreiver, CDAValidator cdaValidator, ValidatorGenerator validatorGenerator, TestOracle testOracle) { + super(SpecificationType.CONTEXT, resourceRetreiver, cdaValidator, validatorGenerator, testOracle); + } + + @Override + public void runTest() throws TestRunnerException { + //Additional processing if needed + + super.runTest(); + } + + @Override + public TestResult generateResult() throws ReportGenerationException { + //Additional processing if needed + + return super.generateResult(); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/DatatypeTestRunner.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/DatatypeTestRunner.java new file mode 100644 index 0000000..dcb1d7a --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/DatatypeTestRunner.java @@ -0,0 +1,30 @@ +package net.ihe.gazelle.goctests.application.specifications; + +import net.ihe.gazelle.goctests.application.CDAValidator; +import net.ihe.gazelle.goctests.application.ResourceRetreiver; +import net.ihe.gazelle.goctests.application.ValidatorGenerator; +import net.ihe.gazelle.goctests.application.exceptions.ReportGenerationException; +import net.ihe.gazelle.goctests.application.exceptions.TestRunnerException; +import net.ihe.gazelle.goctests.application.models.TestResult; +import net.ihe.gazelle.goctests.application.oracles.TestOracle; + +public class DatatypeTestRunner extends SpecificationTestRunnerImpl{ + + public DatatypeTestRunner(ResourceRetreiver resourceRetreiver, CDAValidator cdaValidator, ValidatorGenerator validatorGenerator, TestOracle testOracle) { + super(SpecificationType.DATATYPE, resourceRetreiver, cdaValidator, validatorGenerator, testOracle); + } + + @Override + public void runTest() throws TestRunnerException { + //Additional processing if needed + + super.runTest(); + } + + @Override + public TestResult generateResult() throws ReportGenerationException { + //Additional processing if needed + + return super.generateResult(); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/FixedvalTestRunner.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/FixedvalTestRunner.java new file mode 100644 index 0000000..4cf5836 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/FixedvalTestRunner.java @@ -0,0 +1,30 @@ +package net.ihe.gazelle.goctests.application.specifications; + +import net.ihe.gazelle.goctests.application.CDAValidator; +import net.ihe.gazelle.goctests.application.ResourceRetreiver; +import net.ihe.gazelle.goctests.application.ValidatorGenerator; +import net.ihe.gazelle.goctests.application.exceptions.ReportGenerationException; +import net.ihe.gazelle.goctests.application.exceptions.TestRunnerException; +import net.ihe.gazelle.goctests.application.models.TestResult; +import net.ihe.gazelle.goctests.application.oracles.TestOracle; + +public class FixedvalTestRunner extends SpecificationTestRunnerImpl{ + + public FixedvalTestRunner(ResourceRetreiver resourceRetreiver, CDAValidator cdaValidator, ValidatorGenerator validatorGenerator, TestOracle testOracle) { + super(SpecificationType.FIXEDVAL, resourceRetreiver, cdaValidator, validatorGenerator, testOracle); + } + + @Override + public void runTest() throws TestRunnerException { + //Additional processing if needed + + super.runTest(); + } + + @Override + public TestResult generateResult() throws ReportGenerationException { + //Additional processing if needed + + return super.generateResult(); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/GlobalTestRunner.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/GlobalTestRunner.java new file mode 100644 index 0000000..54fc69f --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/GlobalTestRunner.java @@ -0,0 +1,30 @@ +package net.ihe.gazelle.goctests.application.specifications; + +import net.ihe.gazelle.goctests.application.CDAValidator; +import net.ihe.gazelle.goctests.application.ResourceRetreiver; +import net.ihe.gazelle.goctests.application.ValidatorGenerator; +import net.ihe.gazelle.goctests.application.models.TestResult; +import net.ihe.gazelle.goctests.application.exceptions.ReportGenerationException; +import net.ihe.gazelle.goctests.application.exceptions.TestRunnerException; +import net.ihe.gazelle.goctests.application.oracles.TestOracle; + +public class GlobalTestRunner extends SpecificationTestRunnerImpl{ + + public GlobalTestRunner(ResourceRetreiver resourceRetreiver, CDAValidator cdaValidator, ValidatorGenerator validatorGenerator, TestOracle testOracle) { + super(SpecificationType.GLOBAL, resourceRetreiver, cdaValidator,validatorGenerator, testOracle); + } + + @Override + public void runTest() throws TestRunnerException { + //Additional processing if needed + + super.runTest(); + } + + @Override + public TestResult generateResult() throws ReportGenerationException { + //Additional processing if needed + + return super.generateResult(); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/MandatoryTestRunner.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/MandatoryTestRunner.java new file mode 100644 index 0000000..f27f23b --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/MandatoryTestRunner.java @@ -0,0 +1,33 @@ +package net.ihe.gazelle.goctests.application.specifications; + +import net.ihe.gazelle.goctests.application.CDAValidator; +import net.ihe.gazelle.goctests.application.ResourceRetreiver; +import net.ihe.gazelle.goctests.application.ValidatorGenerator; +import net.ihe.gazelle.goctests.application.oracles.TestOracle; +import net.ihe.gazelle.goctests.definitions.annotations.Covers; +import net.ihe.gazelle.goctests.definitions.annotations.TestType; + +import net.ihe.gazelle.goctests.application.models.TestResult; +import net.ihe.gazelle.goctests.application.exceptions.ReportGenerationException; +import net.ihe.gazelle.goctests.application.exceptions.TestRunnerException; + +public class MandatoryTestRunner extends SpecificationTestRunnerImpl{ + + public MandatoryTestRunner(ResourceRetreiver resourceRetreiver, CDAValidator cdaValidator, ValidatorGenerator validatorGenerator, TestOracle testOracle) { + super(SpecificationType.MANDATORY, resourceRetreiver, cdaValidator, validatorGenerator,testOracle); + } + + @Override + public void runTest() throws TestRunnerException { + //Additional processing if needed + + super.runTest(); + } + + @Override + public TestResult generateResult() throws ReportGenerationException { + //Additional processing if needed + + return super.generateResult(); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/SpecificationTestRunner.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/SpecificationTestRunner.java new file mode 100644 index 0000000..d2bcaa4 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/SpecificationTestRunner.java @@ -0,0 +1,27 @@ +package net.ihe.gazelle.goctests.application.specifications; + +import net.ihe.gazelle.goctests.application.models.TestResult; +import net.ihe.gazelle.goctests.application.exceptions.ReportGenerationException; +import net.ihe.gazelle.goctests.application.exceptions.TestRunnerException; + +public interface SpecificationTestRunner { + + /** + * Running a Specification Test aims to: + * <ul> + * <li>1- Generate a validator</li> + * <li>2- Validate CDA document</li> + * <li>3- Run Oracle Test</li> + * </ul> + * To generate a report describing the state of theses Tests (PASSED | FAILED) + * @throws TestRunnerException + */ + void runTest() throws TestRunnerException; + + /** + * Generated report based on the related test + * This Test could be transformed based on local Transformation APIs + * @return Report as TestResult object + */ + TestResult generateResult() throws ReportGenerationException; +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/SpecificationTestRunnerImpl.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/SpecificationTestRunnerImpl.java new file mode 100644 index 0000000..3766355 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/SpecificationTestRunnerImpl.java @@ -0,0 +1,149 @@ +package net.ihe.gazelle.goctests.application.specifications; + + +import net.ihe.gazelle.goctests.application.CDAValidator; +import net.ihe.gazelle.goctests.application.ResourceRetreiver; +import net.ihe.gazelle.goctests.application.ValidatorGenerator; +import net.ihe.gazelle.goctests.application.models.OracleResult; +import net.ihe.gazelle.goctests.application.models.GeneratedValidator; +import net.ihe.gazelle.goctests.application.models.TestResult; +import net.ihe.gazelle.goctests.application.models.ValidationResult; + +import net.ihe.gazelle.goctests.application.oracles.TestOracle; +import net.ihe.gazelle.goctests.application.oracles.exceptions.OracleException; + +import net.ihe.gazelle.goctests.application.exceptions.ValidatorGenerationException; +import net.ihe.gazelle.goctests.application.exceptions.ValidationException; +import net.ihe.gazelle.goctests.application.exceptions.ReportGenerationException; +import net.ihe.gazelle.goctests.application.exceptions.TestRunnerException; +import net.ihe.gazelle.goctests.application.exceptions.ConfigurationException; + + +import java.net.URL; + +abstract public class SpecificationTestRunnerImpl implements SpecificationTestRunner{ + + private URL BBR; + + private URL CDA; + + private ValidationResult validationResult; + + private GeneratedValidator generatedValidator; + + private OracleResult oracleResult; + + private SpecificationType specificationType; + + private ResourceRetreiver resourceRetreiver; + + private CDAValidator cdaValidator; + + private ValidatorGenerator validatorGenerator; + + private TestOracle testOracle; + + public SpecificationTestRunnerImpl(SpecificationType specificationType, ResourceRetreiver resourceRetreiver, + CDAValidator cdaValidator, ValidatorGenerator validatorGenerator, TestOracle testOracle) { + this.specificationType = specificationType; + this.resourceRetreiver = resourceRetreiver; + this.cdaValidator = cdaValidator; + this.validatorGenerator = validatorGenerator; + this.testOracle = testOracle; + } + + /** + * {@inheritDoc} + */ + @Override + public void runTest() throws TestRunnerException { + + //Check if specification specialisation is instantiated + if(this.specificationType == null){ + throw new TestRunnerException("CDA is not set, Test Failed"); + } + try { + this.BBR = resourceRetreiver.retreiveBBRResource(this.specificationType); + this.CDA = resourceRetreiver.retreiveCDAResource(this.specificationType); + } catch (ConfigurationException e) { + throw new TestRunnerException("Problem in BBR and/or CDA",e); + } + + // Check if we could load resources correctly + if(this.BBR == null){ + throw new TestRunnerException("BBR is not set, Test Failed"); + } + if(this.CDA == null){ + throw new TestRunnerException("CDA is not set, Test Failed"); + } + if(generatedValidator != null || validationResult != null){ + throw new TestRunnerException("Something wrong happened please re-run the application: previous generationg already in the queue"); + } + + //Generate Validator + try { + this.generatedValidator = this.validatorGenerator.generateValidator(BBR); + } catch (ValidatorGenerationException e) { + throw new TestRunnerException("Exception durin generating validator",e); + } + + //Validator CDA & set detailedResult + try { + this.validationResult = this.cdaValidator.validateDocument(CDA,generatedValidator); + + //Comparing with expected "Test Oracle" + if(testOracle == null){ + throw new TestRunnerException("Authentication not implemented for this specification type, Test failed."); + } + + //Guarentee the match between Test Oracle and Specification Runner + if(!this.testOracle.getSpecificationType().equals(this.specificationType)){ + throw new TestRunnerException("Fatal Error: Test Oracle and Spec Runner doesn't have same specification type"); + } + + this.oracleResult = this.testOracle.compareWithExpectedResult(validationResult.getDetailedResult()); + if(this.oracleResult == null){ + throw new TestRunnerException("Authentication not performed correctly"); + } + + } catch (ValidationException e) { + throw new TestRunnerException("Exception during validating CDA document",e); + } catch (OracleException e) { + throw new TestRunnerException("Exception during Authentication CDA Document",e); + } + + //Destroy validation resources + this.CDA = null; + this.BBR = null; + + } + + /** + * {@inheritDoc} + */ + @Override + public TestResult generateResult() throws ReportGenerationException { + + //Check if detailedResult and validator are set + if(this.validationResult == null){ + throw new ReportGenerationException("Validation resutl not found, probably validation not performed"); + } + if(this.generatedValidator == null){ + throw new ReportGenerationException("Validator not found, probably validation not performed"); + } + if(this.oracleResult == null){ + throw new ReportGenerationException("Authentication result not found!"); + } + + //Generate Report + TestResult testResult = new TestResult(this.generatedValidator, + this.validationResult.getUsedCDA(),this.specificationType, this.oracleResult); + + //Destroy current validation + this.generatedValidator = null; + this.validationResult = null; + + //Return testResult + return testResult; + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/SpecificationType.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/SpecificationType.java new file mode 100644 index 0000000..0b8b8f1 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/SpecificationType.java @@ -0,0 +1,68 @@ +package net.ihe.gazelle.goctests.application.specifications; + + +public enum SpecificationType { + + // TODO: 05/01/2022 There is incoherence with Notification types, to be reviewed, check: src/main/java/net/ihe/gazelle/goc/xmm/OwnedRuleKind.java + + GLOBAL("global"), + CARDINALITY("cardinality"), + VOCABULARY("vocabulary"), + MANDATORY("mandatory"), + CONTEXT("context"), + DATATYPE("datatype"), + FIXEDVAL("fixed value"), + CLOSED("closed"), + CHOICE("chocie"); +// CONFORMANCE("conformance"), +// NULLFLAVOR("nullflavor"), +// FLEXIBILITY("flexibility"), +// STRENGTH("strength"), +// ITEM("item"), +// FRIENDLY("friendly"), +// PROPERTY("property"), +// TEXT("text"), +// ATTRIBUT("attribut"), +// OPTIONAL("optional"), +// INCLUDE("include"), +// VALUESET("valueset"), +// ASSERT("assert"), +// REPORT("report"), +// LET("let"), +// CONSTRAINT("constraint"); + + + private String value; + + private SpecificationType(String value){ + this.value = value; + } + + public String getValue() { + return value; + } + + public static final String possibleValues = generatePossibleValues() ; + + public static SpecificationType of(String value){ + for(SpecificationType specificationType : SpecificationType.values()){ + if(specificationType.getValue().equals(value)){ + return specificationType; + } + } + return null; + } + + private static String generatePossibleValues(){ + StringBuilder result = new StringBuilder("["); + for(SpecificationType s : SpecificationType.values()){ + result.append(s.value).append(",").append("\n"); + } + result.append("]"); + return result.toString(); + } + + public static String getPossibleValues(){ + return possibleValues; + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/VocabularyTestRunner.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/VocabularyTestRunner.java new file mode 100644 index 0000000..cb70d80 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/VocabularyTestRunner.java @@ -0,0 +1,30 @@ +package net.ihe.gazelle.goctests.application.specifications; + +import net.ihe.gazelle.goctests.application.CDAValidator; +import net.ihe.gazelle.goctests.application.ResourceRetreiver; +import net.ihe.gazelle.goctests.application.ValidatorGenerator; +import net.ihe.gazelle.goctests.application.models.TestResult; +import net.ihe.gazelle.goctests.application.exceptions.ReportGenerationException; +import net.ihe.gazelle.goctests.application.exceptions.TestRunnerException; +import net.ihe.gazelle.goctests.application.oracles.TestOracle; + +public class VocabularyTestRunner extends SpecificationTestRunnerImpl{ + + public VocabularyTestRunner(ResourceRetreiver resourceRetreiver, CDAValidator cdaValidator, ValidatorGenerator validatorGenerator, TestOracle testOracle) { + super(SpecificationType.VOCABULARY, resourceRetreiver, cdaValidator, validatorGenerator, testOracle); + } + + @Override + public void runTest() throws TestRunnerException { + //Additional processing if needed + + super.runTest(); + } + + @Override + public TestResult generateResult() throws ReportGenerationException { + //Additional processing if needed + + return super.generateResult(); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/resources/application.properties b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/application.properties new file mode 100644 index 0000000..bed2470 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/application.properties @@ -0,0 +1,11 @@ +maven.path=[YOUR MAVEN PATH] +goc.outputFolderPrefix=GOCTestSystemTemp/validators +goc.persistValidator=false +goc.resultFolderPrefix=GOCTestSystemTemp/validationResults +goc.persistResult=false + +# Possible values [standard, XML] +result.type=xml + +# If result.type is set to XML, this property is needed +result.type.xmlpath=[YOUR PATH] \ No newline at end of file diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/resources/cardinality/cda_cardinality.xml b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/cardinality/cda_cardinality.xml new file mode 100644 index 0000000..99ce50e --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/cardinality/cda_cardinality.xml @@ -0,0 +1,62 @@ +<?xml version="1.0"?> +<ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdtc="urn:hl7-org:sdtc" xsi:schemaLocation="http://www.w3schools.com/RedsDevils ./xsd/CDA.xsd"> + <!-- START HEADER: REQUIRED ELEMENTS FOR XSD VALIDATION --> + <typeId root="2.16.840.1.113883.1.3" extension="POCD_HD000040"/> + <id root="1.2.3.4.5.1.7.5.10567878.0"/> + <code code="34133-9" codeSystem="2.16.840.1.113883.6.1" displayName="Summarization of Episode Note"/> + <effectiveTime value="20201201100749-0500"/> + <confidentialityCode code="N" codeSystem="2.16.840.1.113883.5.25"/> + <recordTarget> + <patientRole nullFlavor="UNK"> + <id root="1.2.3.4.5.1.7" extension="19173"/> + </patientRole> + </recordTarget> + <author nullFlavor="UNK" > + <time value="20220101100749-0500"/> + <assignedAuthor> + <id root="2.2.2.2.2.2.2"/> + </assignedAuthor> + </author> + <custodian> + <assignedCustodian> + <representedCustodianOrganization> + <id root="2.2.2.2.2.2.2"/> + </representedCustodianOrganization> + </assignedCustodian> + </custodian> + <componentOf> + <encompassingEncounter> + <effectiveTime value="20201201"/> + </encompassingEncounter> + </componentOf> + <!-- END OF HEADER --> + + <!-- START OF TEST ELEMENTS --> + <component> + <structuredBody> + <component> + <section> + <templateId root="1.1.1.1.1.1.1.1"/> + <id root="1.2.3.5.6"/> + <code code="29545-1" codeSystem="2.11.111.1.111111.1.1" codeSystemName="LOINC"/> + <title>CDA For Test</title> + <entry> + <act classCode="ACT" moodCode="DEF"> + + <!-- Test CONF:0005 "1_n" FALSE [DO NOT UNCOMENT, EXPECTED TO BE MISSING]--> + <!-- <realmCode />--> + + <!-- Test CONF:0004 "1_n" TRUE--> + <typeId extension="123456789" root="2.16.840.1.113883.1.3" /> + + <!-- Test CONF:0006 "1_1" TRUE--> + <code code="12345-6" /> + </act> + </entry> + </section> + </component> + </structuredBody> + </component> + <!-- END OF TEST ELEMENTS --> + +</ClinicalDocument> \ No newline at end of file diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/resources/cardinality/decor_cardinality.xml b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/cardinality/decor_cardinality.xml new file mode 100644 index 0000000..385aed8 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/cardinality/decor_cardinality.xml @@ -0,0 +1,53 @@ +<decor> + + <project id="2.16.840.1.113883.2.4.3.11.60.22" prefix="card-" defaultLanguage="en-US"> + </project> + + <rules> + <template id="1.1.1.1.1.1.1.1" name="TestCardinality" displayName="Test Cardinality Template" effectiveDate="2022-01-01T00:00:00" statusCode="active" versionLabel="1.0"> + <context id="**"></context> + <element name="cda:section" id="2.16.840.1.113883.3.1937.99.3.9.5334"> + + <element name="cda:templateId" datatype="II" minimumMultiplicity="1" maximumMultiplicity="1" isMandatory="true"> + <item label="CONF:0001"></item> + <attribute name="root" value="1.1.1.1.1.1.1.1" datatype="uid"></attribute> + </element> + <element name="cda:code" datatype="CE" minimumMultiplicity="1" maximumMultiplicity="1" isMandatory="true" id="2.16.840.1.113883.3.1937.99.3.9.5338"> + <desc language="en-US">SHALL contain exactly one [1..1] code (CONF:0002).</desc> + <item label="CONF:0002"></item> + <vocabulary code="29545-1" codeSystem="2.11.111.1.111111.1.1"></vocabulary> + </element> + <element name="cda:title" datatype="ST" minimumMultiplicity="1" maximumMultiplicity="1" id="2.16.840.1.113883.3.1937.99.3.9.5339"> + <desc language="en-US">SHALL contain exactly one [1..1] title (CONF:0003).</desc> + <item label="CONF:0003"></item> + </element> + + <element name="cda:entry" minimumMultiplicity="1" maximumMultiplicity="*" id="2.16.840.1.113883.3.1937.99.3.9.5341"> + <element name="cda:act" minimumMultiplicity="1" maximumMultiplicity="*" id="2.16.840.1.113883.3.1937.99.3.9.5347"> + + <!-- Test element: NEED TO BE FALSE 1_n --> + <element name="cda:realmCode" minimumMultiplicity="1" maximumMultiplicity="*"> + <item label="CONF:0004"></item> + </element> + + <!-- Test element: NEED TO BE TRUE 1_n --> + <element name="cda:typeId" minimumMultiplicity="1" maximumMultiplicity="*"> + <item label="CONF:0005"></item> + </element> + + <!-- Test element: NEED TO BE TRUE 1_1 --> + <element name="cda:code" datatype="CD" minimumMultiplicity="1" maximumMultiplicity="1" isMandatory="true" id="2.16.840.1.113883.3.1937.99.3.9.3914"> + <item label="CONF:0006"></item> + </element> + + <attribute name="classCode"/> + <attribute name="moodCode" /> + + </element> + <item label="CONF:0007"></item> + </element> + + </element> + </template> + </rules> +</decor> \ No newline at end of file diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/resources/cardinality/expected_cardinality.xml b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/cardinality/expected_cardinality.xml new file mode 100644 index 0000000..77df1c9 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/cardinality/expected_cardinality.xml @@ -0,0 +1,180 @@ + +<detailedResult> + <DocumentValidXSD> + <Result>PASSED</Result> + </DocumentValidXSD> + <DocumentWellFormed> + <Result>PASSED</Result> + </DocumentWellFormed> + <MDAValidation> + <Warning> + <Test>NullFlavorChecker</Test> + <Location>/ClinicalDocument/recordTarget/patientRole</Location> + <Description>In /ClinicalDocument/recordTarget/patientRole nullFlavor is defined but the element still defines attributes and sub-elements</Description> + <Identifiant>NullFlavorChecker</Identifiant> + <Type>Null Flavor Check</Type> + </Warning> + <Warning> + <Test>NullFlavorChecker</Test> + <Location>/ClinicalDocument/author</Location> + <Description>In /ClinicalDocument/author nullFlavor is defined but the element still defines attributes and sub-elements</Description> + <Identifiant>NullFlavorChecker</Identifiant> + <Type>Null Flavor Check</Type> + </Warning> + <Note> + <Test>test_IDs</Test> + <Location>/ClinicalDocument</Location> + <Description>Success: Found all IDs referenced</Description> + </Note> + <Note> + <Test>card001</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Cardinality Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:templateId[@root='1.1.1.1.1.1.1.1'], the attribute root SHALL be present</Description> + <Identifiant>card-TestCardinality-card001</Identifiant> + <assertion idScheme="card" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>card002</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Cardinality Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'], the element(s) hl7:templateId[@root='1.1.1.1.1.1.1.1'] SHALL not have nullFlavor (mandatory) (Item : CONF:0001)</Description> + <Identifiant>card-TestCardinality-card002</Identifiant> + <assertion idScheme="card" assertionId="CONF:0001"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>card003</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Cardinality Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at most ONE hl7:templateId[@root='1.1.1.1.1.1.1.1'] (Item : CONF:0001)</Description> + <Identifiant>card-TestCardinality-card003</Identifiant> + <assertion idScheme="card" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>card004</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Cardinality Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:templateId[@root='1.1.1.1.1.1.1.1'] (Item : CONF:0001)</Description> + <Identifiant>card-TestCardinality-card004</Identifiant> + <assertion idScheme="card" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>card005</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Cardinality Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:code, the attribute code SHALL be present</Description> + <Identifiant>card-TestCardinality-card005</Identifiant> + <assertion idScheme="card" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>card006</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Cardinality Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:code, the attribute code SHALL have the value '29545-1' if present</Description> + <Identifiant>card-TestCardinality-card006</Identifiant> + <assertion idScheme="card" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>card007</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Cardinality Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:code, the attribute codeSystem SHALL have the value '2.11.111.1.111111.1.1' if present</Description> + <Identifiant>card-TestCardinality-card007</Identifiant> + <assertion idScheme="card" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>card008</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Cardinality Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'], the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0002)</Description> + <Identifiant>card-TestCardinality-card008</Identifiant> + <assertion idScheme="card" assertionId="CONF:0002"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>card009</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Cardinality Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:code (Item : CONF:0002)</Description> + <Identifiant>card-TestCardinality-card009</Identifiant> + <assertion idScheme="card" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>card010</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Cardinality Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:title (Item : CONF:0003)</Description> + <Identifiant>card-TestCardinality-card010</Identifiant> + <assertion idScheme="card" assertionId="CONF:0003"/> + <Type>Cardinality</Type> + </Note> + <Error> + <Test>card011</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Cardinality Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act SHALL contain at least ONE hl7:realmCode (Item : CONF:0004)</Description> + <Identifiant>card-TestCardinality-card011</Identifiant> + <assertion idScheme="card" assertionId="CONF:0004;CONF:0007"/> + <Type>Cardinality</Type> + </Error> + <Note> + <Test>card012</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Cardinality Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act SHALL contain at least ONE hl7:typeId (Item : CONF:0005)</Description> + <Identifiant>card-TestCardinality-card012</Identifiant> + <assertion idScheme="card" assertionId="CONF:0005;CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>card013</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Cardinality Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act, the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0006)</Description> + <Identifiant>card-TestCardinality-card013</Identifiant> + <assertion idScheme="card" assertionId="CONF:0006;CONF:0007"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>card014</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Cardinality Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry SHALL contain at least ONE hl7:act</Description> + <Identifiant>card-TestCardinality-card014</Identifiant> + <assertion idScheme="card" assertionId="CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>card015</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Cardinality Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:entry (Item : CONF:0007)</Description> + <Identifiant>card-TestCardinality-card015</Identifiant> + <assertion idScheme="card" assertionId="CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>test_IDs</Test> + <Location>/ClinicalDocument</Location> + <Description>Success: Found all IDs referenced</Description> + </Note> + <Warning> + <Test>rmim052</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>Section.text SHALL be specified, as it is a required element (RMIM-052)</Description> + <Identifiant>cdabasic-SectionSpec-rmim052</Identifiant> + <assertion idScheme="RMIM" assertionId="RMIM-052"/> + <Type>Mandatory</Type> + </Warning> + <Note> + <Test>test_IDs</Test> + <Location>/ClinicalDocument</Location> + <Description>Success: Found all IDs referenced</Description> + </Note> + <Result>FAILED</Result> + </MDAValidation> + <ValidationResultsOverview> + <ValidationDate>2022, 01 07</ValidationDate> + <ValidationTime>12:31:39</ValidationTime> + <ValidationServiceName>Gazelle CDA Validation : card</ValidationServiceName> + <ValidationTestResult>FAILED</ValidationTestResult> + </ValidationResultsOverview> + <TemplateDesc validation="Error"> + <Template validation="Error" type="POCDMT000040Section" location="/ClinicalDocument/component/structuredBody/component[0]/section"> + <templateId id="1.1.1.1.1.1.1.1" name="TestCardinality"/> + </Template> + </TemplateDesc> +</detailedResult> diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/resources/datatype/cda_datatype.xml b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/datatype/cda_datatype.xml new file mode 100644 index 0000000..94851c7 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/datatype/cda_datatype.xml @@ -0,0 +1,80 @@ +<?xml version="1.0"?> +<ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdtc="urn:hl7-org:sdtc" xsi:schemaLocation="http://www.w3schools.com/RedsDevils ./xsd/CDA.xsd"> + <!-- START HEADER: REQUIRED ELEMENTS FOR XSD VALIDATION --> + <typeId root="2.16.840.1.113883.1.3" extension="POCD_HD000040"/> + <id root="1.2.3.4.5.1.7.5.10567878.0"/> + <code code="34133-9" codeSystem="2.16.840.1.113883.6.1" displayName="Summarization of Episode Note"/> + <effectiveTime value="20201201100749-0500"/> + <confidentialityCode code="N" codeSystem="2.16.840.1.113883.5.25"/> + <recordTarget> + <patientRole nullFlavor="UNK"> + <id root="1.2.3.4.5.1.7" extension="19173"/> + </patientRole> + </recordTarget> + <author nullFlavor="UNK" > + <time value="20220101100749-0500"/> + <assignedAuthor> + <id root="2.2.2.2.2.2.2"/> + </assignedAuthor> + </author> + <custodian> + <assignedCustodian> + <representedCustodianOrganization> + <id root="2.2.2.2.2.2.2"/> + </representedCustodianOrganization> + </assignedCustodian> + </custodian> + <componentOf> + <encompassingEncounter> + <effectiveTime value="20201201"/> + </encompassingEncounter> + </componentOf> + <!-- END OF HEADER --> + + <!-- START OF TEST ELEMENTS --> + <component> + <structuredBody> + <component> + <section> + <templateId root="1.1.1.1.1.1.1.1"/> + <id root="1.2.3.5.6"/> + <code code="29545-1" codeSystem="2.11.111.1.111111.1.1" codeSystemName="LOINC"/> + <title>CDA For Test</title> + <entry> + + <!-- Test CONF:0006 "boolean in Attribute" (no rule generated for this) TRUE--> + <act classCode="ACT" moodCode="DEF" negationInd="false"> + + <!-- Test CONF:0004 "CE Element" (inherit from CD) TRUE--> + <code code="12345" xsi:type="CE" /> + + <!-- Test CONF:0005 "CV Element" (inherit from CE) TRUE--> + <priorityCode code="12345" xsi:type="CV" /> + + </act> + </entry> + </section> + </component> + <component> + <section> + <templateId root="1.1.1.1.1.1.1.1"/> + <id root="1.2.3.5.7"/> + <code code="29545-1" codeSystem="2.11.111.1.111111.1.1" codeSystemName="LOINC"/> + <title>CDA For Test</title> + <entry> + <act classCode="ACT" moodCode="DEF" negationInd="true"> + <!-- Test CONF:0004 "CE Element" (inherit from CD) FALSE--> + <code code="12345" xsi:type="CD" /> + + <!-- Test CONF:0005 "CV Element" (inherit from CE) FALSE--> + <priorityCode code="12345" xsi:type="CE" /> + + </act> + </entry> + </section> + </component> + </structuredBody> + </component> + <!-- END OF TEST ELEMENTS --> + +</ClinicalDocument> \ No newline at end of file diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/resources/datatype/decor_datatype.xml b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/datatype/decor_datatype.xml new file mode 100644 index 0000000..277caca --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/datatype/decor_datatype.xml @@ -0,0 +1,59 @@ +<decor> + + <project id="2.16.840.1.113883.2.4.3.11.60.22" prefix="datatype-" defaultLanguage="en-US"> + </project> + + <rules> + <template id="1.1.1.1.1.1.1.1" name="TestDataType" displayName="Test Datatype Template" effectiveDate="2022-01-01T00:00:00" statusCode="active" versionLabel="1.0"> + <context id="**"></context> + <element name="cda:section" id="2.16.840.1.113883.3.1937.99.3.9.5334"> + + <element name="cda:templateId" datatype="II" minimumMultiplicity="1" maximumMultiplicity="1" isMandatory="true"> + <item label="CONF:0001"></item> + <attribute name="root" value="1.1.1.1.1.1.1.1" datatype="uid"></attribute> + </element> + <element name="cda:code" datatype="CE" minimumMultiplicity="1" maximumMultiplicity="1" isMandatory="true" id="2.16.840.1.113883.3.1937.99.3.9.5338"> + <desc language="en-US">SHALL contain exactly one [1..1] code (CONF:0002).</desc> + <item label="CONF:0002"></item> + <vocabulary code="29545-1" codeSystem="2.11.111.1.111111.1.1"></vocabulary> + </element> + <element name="cda:title" datatype="ST" minimumMultiplicity="1" maximumMultiplicity="1" id="2.16.840.1.113883.3.1937.99.3.9.5339"> + <desc language="en-US">SHALL contain exactly one [1..1] title (CONF:0003).</desc> + <item label="CONF:0003"></item> + </element> + + <element name="cda:entry" flexibility="2015-08-01T00:00:00" minimumMultiplicity="1" maximumMultiplicity="*" id="2.16.840.1.113883.3.1937.99.3.9.5341"> + <element name="cda:act" minimumMultiplicity="1" maximumMultiplicity="*" id="2.16.840.1.113883.3.1937.99.3.9.5347"> + + <!-- NOTICE: GOC Process only constrainted Datatypes (i.e. if a child type of the default defined type (in XSD) is used) --> + <!-- EXAMPLE: <priorityCode /> have a default DT 'CE' if we specify datatype="CE" GOC won't provide a rule, but if we + specify datatype="CV" (which inherit from CE) GOC will create a Datatype rule--> + <!-- So the following datatypes test make a kind of inheritance --> + + <!-- Test element: HAVE TWO INSTANCES, 1st TRUE and 2nd FALSE "CE Element" (inherit from CD) --> + <element name="cda:code" datatype="CE" minimumMultiplicity="1" maximumMultiplicity="1" isMandatory="true" id="2.16.840.1.113883.3.1937.99.3.9.5342"> + <item label="CONF:0004"></item> + </element> + + <!-- Test element: HAVE TWO INSTANCES, 1st TRUE and 2nd FALSE "CV Element" (inherit from CE) --> + <element name="cda:priorityCode" datatype="CV" minimumMultiplicity="1" maximumMultiplicity="1" id="2.16.840.1.113883.3.1937.99.3.9.5343"> + <item label="CONF:0005"></item> + </element> + + + <attribute name="classCode"/> + <attribute name="moodCode" /> + + <!-- Test element: HAVE TWO INSTANCES, 1st TRUE (no rule) and 2nd FALSE "bl Attribute" --> + <attribute name="negationInd" datatype="bl"> + <item label="CONF:0006"></item> + </attribute> + + </element> + <item label="CONF:0007"></item> + </element> + + </element> + </template> + </rules> +</decor> \ No newline at end of file diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/resources/datatype/expected_datatype.xml b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/datatype/expected_datatype.xml new file mode 100644 index 0000000..28df5e5 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/datatype/expected_datatype.xml @@ -0,0 +1,343 @@ + +<detailedResult> + <DocumentValidXSD> + <Result>PASSED</Result> + </DocumentValidXSD> + <DocumentWellFormed> + <Result>PASSED</Result> + </DocumentWellFormed> + <MDAValidation> + <Warning> + <Test>NullFlavorChecker</Test> + <Location>/ClinicalDocument/recordTarget/patientRole</Location> + <Description>In /ClinicalDocument/recordTarget/patientRole nullFlavor is defined but the element still defines attributes and sub-elements</Description> + <Identifiant>NullFlavorChecker</Identifiant> + <Type>Null Flavor Check</Type> + </Warning> + <Warning> + <Test>NullFlavorChecker</Test> + <Location>/ClinicalDocument/author</Location> + <Description>In /ClinicalDocument/author nullFlavor is defined but the element still defines attributes and sub-elements</Description> + <Identifiant>NullFlavorChecker</Identifiant> + <Type>Null Flavor Check</Type> + </Warning> + <Note> + <Test>test_IDs</Test> + <Location>/ClinicalDocument</Location> + <Description>Success: Found all IDs referenced</Description> + </Note> + <Note> + <Test>datatype001</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:templateId[@root='1.1.1.1.1.1.1.1'], the attribute root SHALL be present</Description> + <Identifiant>datatype-TestDataType-datatype001</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>datatype002</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'], the element(s) hl7:templateId[@root='1.1.1.1.1.1.1.1'] SHALL not have nullFlavor (mandatory) (Item : CONF:0001)</Description> + <Identifiant>datatype-TestDataType-datatype002</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0001"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>datatype003</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Datatype Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at most ONE hl7:templateId[@root='1.1.1.1.1.1.1.1'] (Item : CONF:0001)</Description> + <Identifiant>datatype-TestDataType-datatype003</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>datatype004</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Datatype Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:templateId[@root='1.1.1.1.1.1.1.1'] (Item : CONF:0001)</Description> + <Identifiant>datatype-TestDataType-datatype004</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>datatype005</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:code, the attribute code SHALL be present</Description> + <Identifiant>datatype-TestDataType-datatype005</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>datatype006</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:code, the attribute code SHALL have the value '29545-1' if present</Description> + <Identifiant>datatype-TestDataType-datatype006</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>datatype007</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:code, the attribute codeSystem SHALL have the value '2.11.111.1.111111.1.1' if present</Description> + <Identifiant>datatype-TestDataType-datatype007</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>datatype008</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'], the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0002)</Description> + <Identifiant>datatype-TestDataType-datatype008</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0002"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>datatype009</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Datatype Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:code (Item : CONF:0002)</Description> + <Identifiant>datatype-TestDataType-datatype009</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>datatype010</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Datatype Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:title (Item : CONF:0003)</Description> + <Identifiant>datatype-TestDataType-datatype010</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0003"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>datatype011</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act, the attribute negationInd SHALL be present (Item : CONF:0006)</Description> + <Identifiant>datatype-TestDataType-datatype011</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0006;CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>datatype012</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act, the element(s) hl7:code SHALL be from the datatype CE (Item : CONF:0004)</Description> + <Identifiant>datatype-TestDataType-datatype012</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0004;CONF:0007"/> + <Type>Datatype</Type> + </Note> + <Note> + <Test>datatype013</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act, the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0004)</Description> + <Identifiant>datatype-TestDataType-datatype013</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0004;CONF:0007"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>datatype014</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act, the element(s) hl7:priorityCode SHALL be from the datatype CV (Item : CONF:0005)</Description> + <Identifiant>datatype-TestDataType-datatype014</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0005;CONF:0007"/> + <Type>Datatype</Type> + </Note> + <Note> + <Test>datatype015</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Datatype Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act SHALL contain at least ONE hl7:priorityCode (Item : CONF:0005)</Description> + <Identifiant>datatype-TestDataType-datatype015</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0005;CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>datatype016</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Datatype Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry SHALL contain at least ONE hl7:act</Description> + <Identifiant>datatype-TestDataType-datatype016</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>datatype017</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Datatype Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:entry (Item : CONF:0007)</Description> + <Identifiant>datatype-TestDataType-datatype017</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>datatype001</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:templateId[@root='1.1.1.1.1.1.1.1'], the attribute root SHALL be present</Description> + <Identifiant>datatype-TestDataType-datatype001</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>datatype002</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'], the element(s) hl7:templateId[@root='1.1.1.1.1.1.1.1'] SHALL not have nullFlavor (mandatory) (Item : CONF:0001)</Description> + <Identifiant>datatype-TestDataType-datatype002</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0001"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>datatype003</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Datatype Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at most ONE hl7:templateId[@root='1.1.1.1.1.1.1.1'] (Item : CONF:0001)</Description> + <Identifiant>datatype-TestDataType-datatype003</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>datatype004</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Datatype Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:templateId[@root='1.1.1.1.1.1.1.1'] (Item : CONF:0001)</Description> + <Identifiant>datatype-TestDataType-datatype004</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>datatype005</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:code, the attribute code SHALL be present</Description> + <Identifiant>datatype-TestDataType-datatype005</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>datatype006</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:code, the attribute code SHALL have the value '29545-1' if present</Description> + <Identifiant>datatype-TestDataType-datatype006</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>datatype007</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:code, the attribute codeSystem SHALL have the value '2.11.111.1.111111.1.1' if present</Description> + <Identifiant>datatype-TestDataType-datatype007</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>datatype008</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'], the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0002)</Description> + <Identifiant>datatype-TestDataType-datatype008</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0002"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>datatype009</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Datatype Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:code (Item : CONF:0002)</Description> + <Identifiant>datatype-TestDataType-datatype009</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>datatype010</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Datatype Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:title (Item : CONF:0003)</Description> + <Identifiant>datatype-TestDataType-datatype010</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0003"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>datatype011</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act, the attribute negationInd SHALL be present (Item : CONF:0006)</Description> + <Identifiant>datatype-TestDataType-datatype011</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0006;CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Error> + <Test>datatype012</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act, the element(s) hl7:code SHALL be from the datatype CE (Item : CONF:0004)</Description> + <Identifiant>datatype-TestDataType-datatype012</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0004;CONF:0007"/> + <Type>Datatype</Type> + </Error> + <Note> + <Test>datatype013</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act, the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0004)</Description> + <Identifiant>datatype-TestDataType-datatype013</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0004;CONF:0007"/> + <Type>Mandatory</Type> + </Note> + <Error> + <Test>datatype014</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act, the element(s) hl7:priorityCode SHALL be from the datatype CV (Item : CONF:0005)</Description> + <Identifiant>datatype-TestDataType-datatype014</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0005;CONF:0007"/> + <Type>Datatype</Type> + </Error> + <Note> + <Test>datatype015</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Datatype Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act SHALL contain at least ONE hl7:priorityCode (Item : CONF:0005)</Description> + <Identifiant>datatype-TestDataType-datatype015</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0005;CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>datatype016</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Datatype Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry SHALL contain at least ONE hl7:act</Description> + <Identifiant>datatype-TestDataType-datatype016</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>datatype017</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Datatype Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:entry (Item : CONF:0007)</Description> + <Identifiant>datatype-TestDataType-datatype017</Identifiant> + <assertion idScheme="datatype" assertionId="CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>test_IDs</Test> + <Location>/ClinicalDocument</Location> + <Description>Success: Found all IDs referenced</Description> + </Note> + <Warning> + <Test>rmim052</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>Section.text SHALL be specified, as it is a required element (RMIM-052)</Description> + <Identifiant>cdabasic-SectionSpec-rmim052</Identifiant> + <assertion idScheme="RMIM" assertionId="RMIM-052"/> + <Type>Mandatory</Type> + </Warning> + <Warning> + <Test>rmim052</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>Section.text SHALL be specified, as it is a required element (RMIM-052)</Description> + <Identifiant>cdabasic-SectionSpec-rmim052</Identifiant> + <assertion idScheme="RMIM" assertionId="RMIM-052"/> + <Type>Mandatory</Type> + </Warning> + <Note> + <Test>test_IDs</Test> + <Location>/ClinicalDocument</Location> + <Description>Success: Found all IDs referenced</Description> + </Note> + <Result>FAILED</Result> + </MDAValidation> + <ValidationResultsOverview> + <ValidationDate>2022, 01 07</ValidationDate> + <ValidationTime>06:00:31</ValidationTime> + <ValidationServiceName>Gazelle CDA Validation : datatype</ValidationServiceName> + <ValidationTestResult>FAILED</ValidationTestResult> + </ValidationResultsOverview> + <TemplateDesc validation="Error"> + <Template validation="Report" type="POCDMT000040Section" location="/ClinicalDocument/component/structuredBody/component[0]/section"> + <templateId id="1.1.1.1.1.1.1.1" name="TestDataType"/> + </Template> + <Template validation="Error" type="POCDMT000040Section" location="/ClinicalDocument/component/structuredBody/component[1]/section"> + <templateId id="1.1.1.1.1.1.1.1" name="TestDataType"/> + </Template> + </TemplateDesc> +</detailedResult> diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/resources/fixedvalue/cda_fixedvalue.xml b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/fixedvalue/cda_fixedvalue.xml new file mode 100644 index 0000000..2b21717 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/fixedvalue/cda_fixedvalue.xml @@ -0,0 +1,61 @@ +<?xml version="1.0"?> +<ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdtc="urn:hl7-org:sdtc" xsi:schemaLocation="http://www.w3schools.com/RedsDevils ./xsd/CDA.xsd"> + <!-- START HEADER: REQUIRED ELEMENTS FOR XSD VALIDATION --> + <typeId root="2.16.840.1.113883.1.3" extension="POCD_HD000040"/> + <id root="1.2.3.4.5.1.7.5.10567878.0"/> + <code code="34133-9" codeSystem="2.16.840.1.113883.6.1" displayName="Summarization of Episode Note"/> + <effectiveTime value="20201201100749-0500"/> + <confidentialityCode code="N" codeSystem="2.16.840.1.113883.5.25"/> + <recordTarget> + <patientRole nullFlavor="UNK"> + <id root="1.2.3.4.5.1.7" extension="19173"/> + </patientRole> + </recordTarget> + <author nullFlavor="UNK" > + <time value="20220101100749-0500"/> + <assignedAuthor> + <id root="2.2.2.2.2.2.2"/> + </assignedAuthor> + </author> + <custodian> + <assignedCustodian> + <representedCustodianOrganization> + <id root="2.2.2.2.2.2.2"/> + </representedCustodianOrganization> + </assignedCustodian> + </custodian> + <componentOf> + <encompassingEncounter> + <effectiveTime value="20201201"/> + </encompassingEncounter> + </componentOf> + <!-- END OF HEADER --> + + <!-- START OF TEST ELEMENTS --> + <component> + <structuredBody> + <component> + <section> + <templateId root="1.1.1.1.1.1.1.1"/> + <id root="1.2.3.5.6"/> + + <!-- Test CONF:0002 "Fixed Value" TRUE--> + <code code="29545-1" codeSystem="2.11.111.1.111111.1.1" codeSystemName="LOINC"/> + <title>CDA For Test Instance-1</title> + </section> + </component> + <component> + <section> + <templateId root="1.1.1.1.1.1.1.1"/> + <id root="1.2.3.5.7"/> + + <!-- Test CONF:0002 "Fixed Value" FALSE--> + <code code="111111" codeSystem="2.11.111.1.111111.1.1" codeSystemName="LOINC"/> + <title>CDA For Test Instance-2</title> + </section> + </component> + </structuredBody> + </component> + <!-- END OF TEST ELEMENTS --> + +</ClinicalDocument> \ No newline at end of file diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/resources/fixedvalue/decor_fixedvalue.xml b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/fixedvalue/decor_fixedvalue.xml new file mode 100644 index 0000000..3aecc02 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/fixedvalue/decor_fixedvalue.xml @@ -0,0 +1,30 @@ +<decor> + + <project id="2.16.840.1.113883.2.4.3.11.60.22" prefix="fixedVal-" defaultLanguage="en-US"> + </project> + + <rules> + <template id="1.1.1.1.1.1.1.1" name="TestFixedVal" displayName="Test Fixed Value Template" effectiveDate="2022-01-01T00:00:00" statusCode="active" versionLabel="1.0"> + <context id="**"></context> + <element name="cda:section" id="2.16.840.1.113883.3.1937.99.3.9.5334"> + + <element name="cda:templateId" datatype="II" minimumMultiplicity="1" maximumMultiplicity="1" isMandatory="true"> + <item label="CONF:0001"></item> + <attribute name="root" value="1.1.1.1.1.1.1.1" datatype="uid"></attribute> + </element> + <element name="cda:code" datatype="CE" minimumMultiplicity="1" maximumMultiplicity="1" isMandatory="true" id="2.16.840.1.113883.3.1937.99.3.9.5338"> + <desc language="en-US">SHALL contain exactly one [1..1] code (CONF:0002).</desc> + <item label="CONF:0002"></item> + + <!-- Test element: HAVE TWO INSTANCES, 1st TRUE and 2nd FALSE --> + <vocabulary code="29545-1" codeSystem="2.11.111.1.111111.1.1"></vocabulary> + </element> + <element name="cda:title" datatype="ST" minimumMultiplicity="1" maximumMultiplicity="1" id="2.16.840.1.113883.3.1937.99.3.9.5339"> + <desc language="en-US">SHALL contain exactly one [1..1] title (CONF:0003).</desc> + <item label="CONF:0003"></item> + </element> + + </element> + </template> + </rules> +</decor> \ No newline at end of file diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/resources/fixedvalue/expected_fixedvalue.xml b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/fixedvalue/expected_fixedvalue.xml new file mode 100644 index 0000000..c83ca05 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/fixedvalue/expected_fixedvalue.xml @@ -0,0 +1,231 @@ + +<detailedResult> + <DocumentValidXSD> + <Result>PASSED</Result> + </DocumentValidXSD> + <DocumentWellFormed> + <Result>PASSED</Result> + </DocumentWellFormed> + <MDAValidation> + <Warning> + <Test>NullFlavorChecker</Test> + <Location>/ClinicalDocument/recordTarget/patientRole</Location> + <Description>In /ClinicalDocument/recordTarget/patientRole nullFlavor is defined but the element still defines attributes and sub-elements</Description> + <Identifiant>NullFlavorChecker</Identifiant> + <Type>Null Flavor Check</Type> + </Warning> + <Warning> + <Test>NullFlavorChecker</Test> + <Location>/ClinicalDocument/author</Location> + <Description>In /ClinicalDocument/author nullFlavor is defined but the element still defines attributes and sub-elements</Description> + <Identifiant>NullFlavorChecker</Identifiant> + <Type>Null Flavor Check</Type> + </Warning> + <Note> + <Test>test_IDs</Test> + <Location>/ClinicalDocument</Location> + <Description>Success: Found all IDs referenced</Description> + </Note> + <Note> + <Test>fixedval001</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Fixed Value Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:templateId[@root='1.1.1.1.1.1.1.1'], the attribute root SHALL be present</Description> + <Identifiant>fixedval-TestFixedVal-fixedval001</Identifiant> + <assertion idScheme="fixedval" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>fixedval002</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Fixed Value Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'], the element(s) hl7:templateId[@root='1.1.1.1.1.1.1.1'] SHALL not have nullFlavor (mandatory) (Item : CONF:0001)</Description> + <Identifiant>fixedval-TestFixedVal-fixedval002</Identifiant> + <assertion idScheme="fixedval" assertionId="CONF:0001"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>fixedval003</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Fixed Value Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at most ONE hl7:templateId[@root='1.1.1.1.1.1.1.1'] (Item : CONF:0001)</Description> + <Identifiant>fixedval-TestFixedVal-fixedval003</Identifiant> + <assertion idScheme="fixedval" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>fixedval004</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Fixed Value Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:templateId[@root='1.1.1.1.1.1.1.1'] (Item : CONF:0001)</Description> + <Identifiant>fixedval-TestFixedVal-fixedval004</Identifiant> + <assertion idScheme="fixedval" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>fixedval005</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Fixed Value Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:code, the attribute code SHALL be present</Description> + <Identifiant>fixedval-TestFixedVal-fixedval005</Identifiant> + <assertion idScheme="fixedval" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>fixedval006</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Fixed Value Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:code, the attribute code SHALL have the value '29545-1' if present</Description> + <Identifiant>fixedval-TestFixedVal-fixedval006</Identifiant> + <assertion idScheme="fixedval" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>fixedval007</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Fixed Value Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:code, the attribute codeSystem SHALL have the value '2.11.111.1.111111.1.1' if present</Description> + <Identifiant>fixedval-TestFixedVal-fixedval007</Identifiant> + <assertion idScheme="fixedval" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>fixedval008</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Fixed Value Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'], the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0002)</Description> + <Identifiant>fixedval-TestFixedVal-fixedval008</Identifiant> + <assertion idScheme="fixedval" assertionId="CONF:0002"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>fixedval009</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Fixed Value Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:code (Item : CONF:0002)</Description> + <Identifiant>fixedval-TestFixedVal-fixedval009</Identifiant> + <assertion idScheme="fixedval" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>fixedval010</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Fixed Value Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:title (Item : CONF:0003)</Description> + <Identifiant>fixedval-TestFixedVal-fixedval010</Identifiant> + <assertion idScheme="fixedval" assertionId="CONF:0003"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>fixedval001</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Fixed Value Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:templateId[@root='1.1.1.1.1.1.1.1'], the attribute root SHALL be present</Description> + <Identifiant>fixedval-TestFixedVal-fixedval001</Identifiant> + <assertion idScheme="fixedval" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>fixedval002</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Fixed Value Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'], the element(s) hl7:templateId[@root='1.1.1.1.1.1.1.1'] SHALL not have nullFlavor (mandatory) (Item : CONF:0001)</Description> + <Identifiant>fixedval-TestFixedVal-fixedval002</Identifiant> + <assertion idScheme="fixedval" assertionId="CONF:0001"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>fixedval003</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Fixed Value Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at most ONE hl7:templateId[@root='1.1.1.1.1.1.1.1'] (Item : CONF:0001)</Description> + <Identifiant>fixedval-TestFixedVal-fixedval003</Identifiant> + <assertion idScheme="fixedval" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>fixedval004</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Fixed Value Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:templateId[@root='1.1.1.1.1.1.1.1'] (Item : CONF:0001)</Description> + <Identifiant>fixedval-TestFixedVal-fixedval004</Identifiant> + <assertion idScheme="fixedval" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>fixedval005</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Fixed Value Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:code, the attribute code SHALL be present</Description> + <Identifiant>fixedval-TestFixedVal-fixedval005</Identifiant> + <assertion idScheme="fixedval" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Error> + <Test>fixedval006</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Fixed Value Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:code, the attribute code SHALL have the value '29545-1' if present</Description> + <Identifiant>fixedval-TestFixedVal-fixedval006</Identifiant> + <assertion idScheme="fixedval" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Error> + <Note> + <Test>fixedval007</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Fixed Value Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:code, the attribute codeSystem SHALL have the value '2.11.111.1.111111.1.1' if present</Description> + <Identifiant>fixedval-TestFixedVal-fixedval007</Identifiant> + <assertion idScheme="fixedval" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>fixedval008</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Fixed Value Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'], the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0002)</Description> + <Identifiant>fixedval-TestFixedVal-fixedval008</Identifiant> + <assertion idScheme="fixedval" assertionId="CONF:0002"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>fixedval009</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Fixed Value Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:code (Item : CONF:0002)</Description> + <Identifiant>fixedval-TestFixedVal-fixedval009</Identifiant> + <assertion idScheme="fixedval" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>fixedval010</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Fixed Value Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:title (Item : CONF:0003)</Description> + <Identifiant>fixedval-TestFixedVal-fixedval010</Identifiant> + <assertion idScheme="fixedval" assertionId="CONF:0003"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>test_IDs</Test> + <Location>/ClinicalDocument</Location> + <Description>Success: Found all IDs referenced</Description> + </Note> + <Warning> + <Test>rmim052</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>Section.text SHALL be specified, as it is a required element (RMIM-052)</Description> + <Identifiant>cdabasic-SectionSpec-rmim052</Identifiant> + <assertion idScheme="RMIM" assertionId="RMIM-052"/> + <Type>Mandatory</Type> + </Warning> + <Warning> + <Test>rmim052</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>Section.text SHALL be specified, as it is a required element (RMIM-052)</Description> + <Identifiant>cdabasic-SectionSpec-rmim052</Identifiant> + <assertion idScheme="RMIM" assertionId="RMIM-052"/> + <Type>Mandatory</Type> + </Warning> + <Note> + <Test>test_IDs</Test> + <Location>/ClinicalDocument</Location> + <Description>Success: Found all IDs referenced</Description> + </Note> + <Result>FAILED</Result> + </MDAValidation> + <ValidationResultsOverview> + <ValidationDate>2022, 01 07</ValidationDate> + <ValidationTime>12:25:30</ValidationTime> + <ValidationServiceName>Gazelle CDA Validation : fixedval</ValidationServiceName> + <ValidationTestResult>FAILED</ValidationTestResult> + </ValidationResultsOverview> + <TemplateDesc validation="Error"> + <Template validation="Report" type="POCDMT000040Section" location="/ClinicalDocument/component/structuredBody/component[0]/section"> + <templateId id="1.1.1.1.1.1.1.1" name="TestFixedVal"/> + </Template> + <Template validation="Error" type="POCDMT000040Section" location="/ClinicalDocument/component/structuredBody/component[1]/section"> + <templateId id="1.1.1.1.1.1.1.1" name="TestFixedVal"/> + </Template> + </TemplateDesc> +</detailedResult> diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/resources/mandatory/cda_mandatory.xml b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/mandatory/cda_mandatory.xml new file mode 100644 index 0000000..d8a8f31 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/mandatory/cda_mandatory.xml @@ -0,0 +1,56 @@ +<?xml version="1.0"?> +<ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdtc="urn:hl7-org:sdtc" xsi:schemaLocation="http://www.w3schools.com/RedsDevils ./xsd/CDA.xsd"> + <typeId root="2.16.840.1.113883.1.3" extension="POCD_HD000040"/> + <id root="1.2.3.4.5.1.7.5.10567878.0"/> + <code code="34133-9" codeSystem="2.16.840.1.113883.6.1" displayName="Summarization of Episode Note"/> + <effectiveTime value="20201201100749-0500"/> + <confidentialityCode code="N" codeSystem="2.16.840.1.113883.5.25"/> + <recordTarget> + <patientRole nullFlavor="UNK"> + <id root="1.2.3.4.5.1.7" extension="19173"/> + </patientRole> + </recordTarget> + <author nullFlavor="UNK" > + <time value="20220101100749-0500"/> + <assignedAuthor> + <id root="2.2.2.2.2.2.2"/> + </assignedAuthor> + </author> + <custodian> + <assignedCustodian> + <representedCustodianOrganization> + <id root="2.2.2.2.2.2.2"/> + </representedCustodianOrganization> + </assignedCustodian> + </custodian> + <componentOf> + <encompassingEncounter> + <effectiveTime value="20201201"/> + </encompassingEncounter> + </componentOf> + <component> + <structuredBody> + <component> + <section> + <templateId root="1.1.1.1.1.1.1.1"/> + <id root="1.2.3.5.6"/> + <code code="29545-1" codeSystem="2.11.111.1.111111.1.1" codeSystemName="LOINC"/> + <title>CDA For Test</title> + <entry> + <act classCode="ACT" moodCode="DEF"> + + <!-- Test CONF:0004 "not mandatory" TRUE--> + <realmCode code="12345-7" nullFlavor="UNK"/> + + <!-- Test CONF:0005 "mandatory" FALSE--> + <typeId extension="123456789" root="2.16.840.1.113883.1.3" nullFlavor="UNK" /> + + <!-- Test CONF:0006 "mandatory" TRUE--> + <code code="12345-6" /> + </act> + </entry> + </section> + </component> + </structuredBody> + </component> +</ClinicalDocument> diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/resources/mandatory/decor_mandatory.xml b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/mandatory/decor_mandatory.xml new file mode 100644 index 0000000..254a9d2 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/mandatory/decor_mandatory.xml @@ -0,0 +1,53 @@ +<decor> + + <project id="2.16.840.1.113883.2.4.3.11.60.22" prefix="mand-" defaultLanguage="en-US"> + </project> + + <rules> + <template id="1.1.1.1.1.1.1.1" name="TestMandatory" displayName="Test Mandatory Template" effectiveDate="2022-01-01T00:00:00" statusCode="active" versionLabel="1.0"> + <context id="**"></context> + <element name="cda:section" id="2.16.840.1.113883.3.1937.99.3.9.5334"> + + <element name="cda:templateId" datatype="II" minimumMultiplicity="1" maximumMultiplicity="1" isMandatory="true"> + <item label="CONF:0001"></item> + <attribute name="root" value="1.1.1.1.1.1.1.1" datatype="uid"></attribute> + </element> + <element name="cda:code" datatype="CE" minimumMultiplicity="1" maximumMultiplicity="1" isMandatory="true" id="2.16.840.1.113883.3.1937.99.3.9.5338"> + <desc language="en-US">SHALL contain exactly one [1..1] code (CONF:0002).</desc> + <item label="CONF:0002"></item> + <vocabulary code="29545-1" codeSystem="2.11.111.1.111111.1.1"></vocabulary> + </element> + <element name="cda:title" datatype="ST" minimumMultiplicity="1" maximumMultiplicity="1" id="2.16.840.1.113883.3.1937.99.3.9.5339"> + <desc language="en-US">SHALL contain exactly one [1..1] title (CONF:0003).</desc> + <item label="CONF:0003"></item> + </element> + + <element name="cda:entry" flexibility="2015-08-01T00:00:00" minimumMultiplicity="1" maximumMultiplicity="*" id="2.16.840.1.113883.3.1937.99.3.9.5341"> + <element name="cda:act" minimumMultiplicity="1" maximumMultiplicity="*" id="2.16.840.1.113883.3.1937.99.3.9.5347"> + + <!-- Test element: NEED TO BE TRUE --> + <element name="cda:realmCode" minimumMultiplicity="1" maximumMultiplicity="*" isMandatory="false" > + <item label="CONF:0004"></item> + </element> + + <!-- Test element: NEED TO BE FALSE --> + <element name="cda:typeId" minimumMultiplicity="1" maximumMultiplicity="*" isMandatory="true"> + <item label="CONF:0005"></item> + </element> + + <!-- Test element: NEED TO BE TRUE --> + <element name="cda:code" datatype="CD" minimumMultiplicity="1" maximumMultiplicity="1" isMandatory="true" id="2.16.840.1.113883.3.1937.99.3.9.3914"> + <item label="CONF:0006"></item> + </element> + + <attribute name="classCode"/> + <attribute name="moodCode" /> + + </element> + <item label="CONF:0007"></item> + </element> + + </element> + </template> + </rules> +</decor> diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/resources/mandatory/expected_mandatory.xml b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/mandatory/expected_mandatory.xml new file mode 100644 index 0000000..1abc701 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/mandatory/expected_mandatory.xml @@ -0,0 +1,202 @@ + +<detailedResult> + <DocumentValidXSD> + <Result>PASSED</Result> + </DocumentValidXSD> + <DocumentWellFormed> + <Result>PASSED</Result> + </DocumentWellFormed> + <MDAValidation> + <Warning> + <Test>NullFlavorChecker</Test> + <Location>/ClinicalDocument/recordTarget/patientRole</Location> + <Description>In /ClinicalDocument/recordTarget/patientRole nullFlavor is defined but the element still defines attributes and sub-elements</Description> + <Identifiant>NullFlavorChecker</Identifiant> + <Type>Null Flavor Check</Type> + </Warning> + <Warning> + <Test>NullFlavorChecker</Test> + <Location>/ClinicalDocument/author</Location> + <Description>In /ClinicalDocument/author nullFlavor is defined but the element still defines attributes and sub-elements</Description> + <Identifiant>NullFlavorChecker</Identifiant> + <Type>Null Flavor Check</Type> + </Warning> + <Warning> + <Test>NullFlavorChecker</Test> + <Location>/ClinicalDocument/component/structuredBody/component/section/entry/act/realmCode</Location> + <Description>In /ClinicalDocument/component/structuredBody/component/section/entry/act/realmCode nullFlavor is defined but the element still defines attributes and sub-elements</Description> + <Identifiant>NullFlavorChecker</Identifiant> + <Type>Null Flavor Check</Type> + </Warning> + <Warning> + <Test>NullFlavorChecker</Test> + <Location>/ClinicalDocument/component/structuredBody/component/section/entry/act/typeId</Location> + <Description>In /ClinicalDocument/component/structuredBody/component/section/entry/act/typeId nullFlavor is defined but the element still defines attributes and sub-elements</Description> + <Identifiant>NullFlavorChecker</Identifiant> + <Type>Null Flavor Check</Type> + </Warning> + <Note> + <Test>test_IDs</Test> + <Location>/ClinicalDocument</Location> + <Description>Success: Found all IDs referenced</Description> + </Note> + <Note> + <Test>mand001</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Mandatory Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:templateId[@root='1.1.1.1.1.1.1.1'], the attribute root SHALL be present</Description> + <Identifiant>mand-TestMandatory-mand001</Identifiant> + <assertion idScheme="mand" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>mand002</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Mandatory Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'], the element(s) hl7:templateId[@root='1.1.1.1.1.1.1.1'] SHALL not have nullFlavor (mandatory) (Item : CONF:0001)</Description> + <Identifiant>mand-TestMandatory-mand002</Identifiant> + <assertion idScheme="mand" assertionId="CONF:0001"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>mand003</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Mandatory Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at most ONE hl7:templateId[@root='1.1.1.1.1.1.1.1'] (Item : CONF:0001)</Description> + <Identifiant>mand-TestMandatory-mand003</Identifiant> + <assertion idScheme="mand" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>mand004</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Mandatory Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:templateId[@root='1.1.1.1.1.1.1.1'] (Item : CONF:0001)</Description> + <Identifiant>mand-TestMandatory-mand004</Identifiant> + <assertion idScheme="mand" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>mand005</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Mandatory Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:code, the attribute code SHALL be present</Description> + <Identifiant>mand-TestMandatory-mand005</Identifiant> + <assertion idScheme="mand" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>mand006</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Mandatory Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:code, the attribute code SHALL have the value '29545-1' if present</Description> + <Identifiant>mand-TestMandatory-mand006</Identifiant> + <assertion idScheme="mand" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>mand007</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Mandatory Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:code, the attribute codeSystem SHALL have the value '2.11.111.1.111111.1.1' if present</Description> + <Identifiant>mand-TestMandatory-mand007</Identifiant> + <assertion idScheme="mand" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>mand008</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Mandatory Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'], the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0002)</Description> + <Identifiant>mand-TestMandatory-mand008</Identifiant> + <assertion idScheme="mand" assertionId="CONF:0002"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>mand009</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Mandatory Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:code (Item : CONF:0002)</Description> + <Identifiant>mand-TestMandatory-mand009</Identifiant> + <assertion idScheme="mand" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>mand010</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Mandatory Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:title (Item : CONF:0003)</Description> + <Identifiant>mand-TestMandatory-mand010</Identifiant> + <assertion idScheme="mand" assertionId="CONF:0003"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>mand011</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Mandatory Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act SHALL contain at least ONE hl7:realmCode (Item : CONF:0004)</Description> + <Identifiant>mand-TestMandatory-mand011</Identifiant> + <assertion idScheme="mand" assertionId="CONF:0004;CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Error> + <Test>mand012</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Mandatory Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act, the element(s) hl7:typeId SHALL not have nullFlavor (mandatory) (Item : CONF:0005)</Description> + <Identifiant>mand-TestMandatory-mand012</Identifiant> + <assertion idScheme="mand" assertionId="CONF:0005;CONF:0007"/> + <Type>Mandatory</Type> + </Error> + <Note> + <Test>mand013</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Mandatory Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act SHALL contain at least ONE hl7:typeId (Item : CONF:0005)</Description> + <Identifiant>mand-TestMandatory-mand013</Identifiant> + <assertion idScheme="mand" assertionId="CONF:0005;CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>mand014</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Mandatory Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act, the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0006)</Description> + <Identifiant>mand-TestMandatory-mand014</Identifiant> + <assertion idScheme="mand" assertionId="CONF:0006;CONF:0007"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>mand015</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Mandatory Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry SHALL contain at least ONE hl7:act</Description> + <Identifiant>mand-TestMandatory-mand015</Identifiant> + <assertion idScheme="mand" assertionId="CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>mand016</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Mandatory Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:entry (Item : CONF:0007)</Description> + <Identifiant>mand-TestMandatory-mand016</Identifiant> + <assertion idScheme="mand" assertionId="CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>test_IDs</Test> + <Location>/ClinicalDocument</Location> + <Description>Success: Found all IDs referenced</Description> + </Note> + <Warning> + <Test>rmim052</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>Section.text SHALL be specified, as it is a required element (RMIM-052)</Description> + <Identifiant>cdabasic-SectionSpec-rmim052</Identifiant> + <assertion idScheme="RMIM" assertionId="RMIM-052"/> + <Type>Mandatory</Type> + </Warning> + <Note> + <Test>test_IDs</Test> + <Location>/ClinicalDocument</Location> + <Description>Success: Found all IDs referenced</Description> + </Note> + <Result>FAILED</Result> + </MDAValidation> + <ValidationResultsOverview> + <ValidationDate>2022, 01 07</ValidationDate> + <ValidationTime>02:14:48</ValidationTime> + <ValidationServiceName>Gazelle CDA Validation : mand</ValidationServiceName> + <ValidationTestResult>FAILED</ValidationTestResult> + </ValidationResultsOverview> + <TemplateDesc validation="Error"> + <Template validation="Error" type="POCDMT000040Section" location="/ClinicalDocument/component/structuredBody/component[0]/section"> + <templateId id="1.1.1.1.1.1.1.1" name="TestMandatory"/> + </Template> + </TemplateDesc> +</detailedResult> diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/resources/specifications.properties b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/specifications.properties new file mode 100644 index 0000000..fe46dc7 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/specifications.properties @@ -0,0 +1,19 @@ +cardinality.bbr=cardinality/decor_cardinality.xml +cardinality.cda=cardinality/cda_cardinality.xml +cardinality.expected=cardinality/expected_cardinality.xml + +mandatory.bbr=mandatory/decor_mandatory.xml +mandatory.cda=mandatory/cda_mandatory.xml +mandatory.expected=mandatory/expected_mandatory.xml + +vocabulary.bbr=vocabulary/decor_vocabulary.xml +vocabulary.cda=vocabulary/cda_vocabulary.xml +vocabulary.expected=vocabulary/expected_vocabulary.xml + +fixedvalue.bbr=fixedvalue/decor_fixedvalue.xml +fixedvalue.cda=fixedvalue/cda_fixedvalue.xml +fixedvalue.expected=fixedvalue/expected_fixedvalue.xml + +datatype.bbr=fixedvalue/decor_fixedvalue.xml +datatype.cda=fixedvalue/cda_fixedvalue.xml +datatype.expected=fixedvalue/expected_fixedvalue.xml \ No newline at end of file diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/resources/vocabulary/cda_vocabulary.xml b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/vocabulary/cda_vocabulary.xml new file mode 100644 index 0000000..09c297b --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/vocabulary/cda_vocabulary.xml @@ -0,0 +1,82 @@ +<?xml version="1.0"?> +<ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdtc="urn:hl7-org:sdtc" xsi:schemaLocation="http://www.w3schools.com/RedsDevils ./xsd/CDA.xsd"> + <!-- START HEADER: REQUIRED ELEMENTS FOR XSD VALIDATION --> + <typeId root="2.16.840.1.113883.1.3" extension="POCD_HD000040"/> + <id root="1.2.3.4.5.1.7.5.10567878.0"/> + <code code="34133-9" codeSystem="2.16.840.1.113883.6.1" displayName="Summarization of Episode Note"/> + <effectiveTime value="20201201100749-0500"/> + <confidentialityCode code="N" codeSystem="2.16.840.1.113883.5.25"/> + <recordTarget> + <patientRole nullFlavor="UNK"> + <id root="1.2.3.4.5.1.7" extension="19173"/> + </patientRole> + </recordTarget> + <author nullFlavor="UNK" > + <time value="20220101100749-0500"/> + <assignedAuthor> + <id root="2.2.2.2.2.2.2"/> + </assignedAuthor> + </author> + <custodian> + <assignedCustodian> + <representedCustodianOrganization> + <id root="2.2.2.2.2.2.2"/> + </representedCustodianOrganization> + </assignedCustodian> + </custodian> + <componentOf> + <encompassingEncounter> + <effectiveTime value="20201201"/> + </encompassingEncounter> + </componentOf> + <!-- END OF HEADER --> + + <!-- START OF TEST ELEMENTS --> + + <component> + <structuredBody> + <component> + <section> + <templateId root="1.1.1.1.1.1.1.1"/> + <id root="1.2.3.5.6"/> + <code code="29545-1" codeSystem="2.11.111.1.111111.1.1" codeSystemName="LOINC"/> + <title>CDA For Test</title> + <entry> + <act classCode="ACT" moodCode="DEF"> + <!-- Test CONF:0005 "matchesValueSet" TRUE--> + <code code="testVocab" codeSystem="2.11.111.1.111111.1.2"/> + + <!-- Test CONF:0006 "multiple ValueSets" TRUE--> + <priorityCode code="testVocab2" codeSystem="2.11.111.1.111111.1.3" /> + + <!-- Test CONF:0007 "flexibility" TRUE--> + <languageCode code="testVocabOld" /> + </act> + </entry> + </section> + </component> + <component> + <section> + <templateId root="1.1.1.1.1.1.1.1"/> + <id root="1.2.3.5.7"/> + <code code="29545-1" codeSystem="2.11.111.1.111111.1.1" codeSystemName="LOINC"/> + <title>CDA For Test</title> + <entry> + <act classCode="ACT" moodCode="DEF"> + <!-- Test CONF:0005 "matchesValueSet" FALSE--> + <code code="B" /> + + <!-- Test CONF:0006 "multiple ValueSets" False--> + <priorityCode code="wrongValue" /> + + <!-- Test CONF:0007 "flexibility" FALSE--> + <languageCode code="wrongValue" /> + </act> + </entry> + </section> + </component> + </structuredBody> + </component> + <!-- END OF TEST ELEMENTS --> + +</ClinicalDocument> \ No newline at end of file diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/resources/vocabulary/decor_vocabulary.xml b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/vocabulary/decor_vocabulary.xml new file mode 100644 index 0000000..2ecb5b4 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/vocabulary/decor_vocabulary.xml @@ -0,0 +1,75 @@ +<decor> + + <project id="2.16.840.1.113883.2.4.3.11.60.22" prefix="vocab-" defaultLanguage="en-US"> + </project> + + <terminology> + <valueSet id="1.2.3.4.5.6.7.8.9" name="TestValueSet" displayName="TestValueSet" effectiveDate="2022-01-01T00:00:00" statusCode="final"> + <conceptList> + <concept code="testVocab" codeSystem="2.11.111.1.111111.1.2" displayName="valueForTest" level="0" type="L"></concept> + </conceptList> + </valueSet> + <valueSet id="1.2.3.4.5.6.7.8.9" name="TestValueSet" displayName="TestValueSet" effectiveDate="2021-01-01T00:00:00" statusCode="final"> + <conceptList> + <concept code="testVocabOld" codeSystem="2.11.111.1.111111.1.2" displayName="valueForTest" level="0" type="L"></concept> + </conceptList> + </valueSet> + <valueSet id="1.2.3.4.5.6.7.8.10" name="TestValueSet2" displayName="TestValueSet2" effectiveDate="2022-01-01T00:00:00" statusCode="final"> + <conceptList> + <concept code="testVocab2" codeSystem="2.11.111.1.111111.1.3" displayName="valueForTest2" level="0" type="L"></concept> + </conceptList> + </valueSet> + </terminology> + + <rules> + <template id="1.1.1.1.1.1.1.1" name="TestVocabulary" displayName="Test Vocabulary Template" effectiveDate="2022-01-01T00:00:00" statusCode="active" versionLabel="1.0"> + <context id="**"></context> + <element name="cda:section" id="2.16.840.1.113883.3.1937.99.3.9.5334"> + + <element name="cda:templateId" datatype="II" minimumMultiplicity="1" maximumMultiplicity="1" isMandatory="true"> + <item label="CONF:0001"></item> + <attribute name="root" value="1.1.1.1.1.1.1.1" datatype="uid"></attribute> + </element> + <element name="cda:code" datatype="CE" minimumMultiplicity="1" maximumMultiplicity="1" isMandatory="true" id="2.16.840.1.113883.3.1937.99.3.9.5338"> + <desc language="en-US">SHALL contain exactly one [1..1] code (CONF:0002).</desc> + <item label="CONF:0002"></item> + <vocabulary code="29545-1" codeSystem="2.11.111.1.111111.1.1"></vocabulary> + </element> + <element name="cda:title" datatype="ST" minimumMultiplicity="1" maximumMultiplicity="1" id="2.16.840.1.113883.3.1937.99.3.9.5339"> + <desc language="en-US">SHALL contain exactly one [1..1] title (CONF:0003).</desc> + <item label="CONF:0003"></item> + </element> + + <element name="cda:entry" flexibility="2015-08-01T00:00:00" minimumMultiplicity="1" maximumMultiplicity="*" id="2.16.840.1.113883.3.1937.99.3.9.5341"> + <element name="cda:act" minimumMultiplicity="1" maximumMultiplicity="*" id="2.16.840.1.113883.3.1937.99.3.9.5347"> + + <!-- Test element: HAVE TWO INSTANCES, 1st TRUE and 2nd FALSE "matchsValueSet" --> + <element name="cda:code" datatype="CD" minimumMultiplicity="1" maximumMultiplicity="1" isMandatory="true" id="2.16.840.1.113883.3.1937.99.3.9.5342"> + <item label="CONF:0005"></item> + <vocabulary valueSet="1.2.3.4.5.6.7.8.9"></vocabulary> + </element> + + <!-- Test element: HAVE TWO INSTANCES, 1st TRUE and 2nd FALSE "multiple valueSets" --> + <element name="cda:priorityCode" datatype="CE" minimumMultiplicity="1" maximumMultiplicity="1" id="2.16.840.1.113883.3.1937.99.3.9.5343"> + <item label="CONF:0006"></item> + <vocabulary valueSet="1.2.3.4.5.6.7.8.9"></vocabulary> + <vocabulary valueSet="1.2.3.4.5.6.7.8.10"></vocabulary> + </element> + + <!-- Test element: HAVE TWO INSTANCES, 1st TRUE and 2nd FALSE "flexibility" --> + <element name="cda:languageCode" datatype="CS" minimumMultiplicity="1" maximumMultiplicity="1" id="2.16.840.1.113883.3.1937.99.3.9.53414"> + <item label="CONF:0007"></item> + <vocabulary valueSet="1.2.3.4.5.6.7.8.9" flexibility="2021-01-01T00:00:00"></vocabulary> + </element> + + <attribute name="classCode"/> + <attribute name="moodCode" /> + + </element> + <item label="CONF:0006"></item> + </element> + + </element> + </template> + </rules> +</decor> \ No newline at end of file diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/resources/vocabulary/expected_vocabulary.xml b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/vocabulary/expected_vocabulary.xml new file mode 100644 index 0000000..2cdd5d9 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/vocabulary/expected_vocabulary.xml @@ -0,0 +1,359 @@ + +<detailedResult> + <DocumentValidXSD> + <Result>PASSED</Result> + </DocumentValidXSD> + <DocumentWellFormed> + <Result>PASSED</Result> + </DocumentWellFormed> + <MDAValidation> + <Warning> + <Test>NullFlavorChecker</Test> + <Location>/ClinicalDocument/recordTarget/patientRole</Location> + <Description>In /ClinicalDocument/recordTarget/patientRole nullFlavor is defined but the element still defines attributes and sub-elements</Description> + <Identifiant>NullFlavorChecker</Identifiant> + <Type>Null Flavor Check</Type> + </Warning> + <Warning> + <Test>NullFlavorChecker</Test> + <Location>/ClinicalDocument/author</Location> + <Description>In /ClinicalDocument/author nullFlavor is defined but the element still defines attributes and sub-elements</Description> + <Identifiant>NullFlavorChecker</Identifiant> + <Type>Null Flavor Check</Type> + </Warning> + <Note> + <Test>test_IDs</Test> + <Location>/ClinicalDocument</Location> + <Description>Success: Found all IDs referenced</Description> + </Note> + <Note> + <Test>vocab001</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Vocabulary Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:templateId[@root='1.1.1.1.1.1.1.1'], the attribute root SHALL be present</Description> + <Identifiant>vocab-TestVocabulary-vocab001</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>vocab002</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Vocabulary Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'], the element(s) hl7:templateId[@root='1.1.1.1.1.1.1.1'] SHALL not have nullFlavor (mandatory) (Item : CONF:0001)</Description> + <Identifiant>vocab-TestVocabulary-vocab002</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0001"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>vocab003</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Vocabulary Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at most ONE hl7:templateId[@root='1.1.1.1.1.1.1.1'] (Item : CONF:0001)</Description> + <Identifiant>vocab-TestVocabulary-vocab003</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>vocab004</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Vocabulary Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:templateId[@root='1.1.1.1.1.1.1.1'] (Item : CONF:0001)</Description> + <Identifiant>vocab-TestVocabulary-vocab004</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>vocab005</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Vocabulary Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:code, the attribute code SHALL be present</Description> + <Identifiant>vocab-TestVocabulary-vocab005</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>vocab006</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Vocabulary Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:code, the attribute code SHALL have the value '29545-1' if present</Description> + <Identifiant>vocab-TestVocabulary-vocab006</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>vocab007</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Vocabulary Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:code, the attribute codeSystem SHALL have the value '2.11.111.1.111111.1.1' if present</Description> + <Identifiant>vocab-TestVocabulary-vocab007</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>vocab008</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Vocabulary Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'], the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0002)</Description> + <Identifiant>vocab-TestVocabulary-vocab008</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0002"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>vocab009</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Vocabulary Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:code (Item : CONF:0002)</Description> + <Identifiant>vocab-TestVocabulary-vocab009</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>vocab010</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Vocabulary Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:title (Item : CONF:0003)</Description> + <Identifiant>vocab-TestVocabulary-vocab010</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0003"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>vocab011</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Vocabulary Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act, the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0005)</Description> + <Identifiant>vocab-TestVocabulary-vocab011</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0005;CONF:0006"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>vocab012</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Vocabulary Template, the code of /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act/hl7:code SHALL be from the valueSet 1.2.3.4.5.6.7.8.9 (flexibility : dynamic) (Item : CONF:0005)</Description> + <Identifiant>vocab-TestVocabulary-vocab012</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0005;CONF:0006"/> + <Type>Vocabulary</Type> + </Note> + <Note> + <Test>vocab013</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Vocabulary Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act SHALL contain at least ONE hl7:priorityCode (Item : CONF:0006)</Description> + <Identifiant>vocab-TestVocabulary-vocab013</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0006"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>vocab014</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Vocabulary Template, the code of /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act/hl7:priorityCode SHALL be from the valueSet 1.2.3.4.5.6.7.8.9 (flexibility : dynamic) OR SHALL be from the valueSet 1.2.3.4.5.6.7.8.10 (flexibility : dynamic) (Item : CONF:0006)</Description> + <Identifiant>vocab-TestVocabulary-vocab014</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0006"/> + <Type>Vocabulary</Type> + </Note> + <Note> + <Test>vocab015</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Vocabulary Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act SHALL contain at least ONE hl7:languageCode (Item : CONF:0007)</Description> + <Identifiant>vocab-TestVocabulary-vocab015</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0006;CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>vocab016</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Vocabulary Template, the code of /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act/hl7:languageCode SHALL be from the valueSet 1.2.3.4.5.6.7.8.9 (flexibility : 2021-01-01T00:00:00) (Item : CONF:0007)</Description> + <Identifiant>vocab-TestVocabulary-vocab016</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0006;CONF:0007"/> + <Type>Vocabulary</Type> + </Note> + <Note> + <Test>vocab017</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Vocabulary Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry SHALL contain at least ONE hl7:act</Description> + <Identifiant>vocab-TestVocabulary-vocab017</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0006"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>vocab018</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Vocabulary Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:entry (Item : CONF:0006)</Description> + <Identifiant>vocab-TestVocabulary-vocab018</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0006"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>vocab001</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Vocabulary Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:templateId[@root='1.1.1.1.1.1.1.1'], the attribute root SHALL be present</Description> + <Identifiant>vocab-TestVocabulary-vocab001</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>vocab002</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Vocabulary Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'], the element(s) hl7:templateId[@root='1.1.1.1.1.1.1.1'] SHALL not have nullFlavor (mandatory) (Item : CONF:0001)</Description> + <Identifiant>vocab-TestVocabulary-vocab002</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0001"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>vocab003</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Vocabulary Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at most ONE hl7:templateId[@root='1.1.1.1.1.1.1.1'] (Item : CONF:0001)</Description> + <Identifiant>vocab-TestVocabulary-vocab003</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>vocab004</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Vocabulary Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:templateId[@root='1.1.1.1.1.1.1.1'] (Item : CONF:0001)</Description> + <Identifiant>vocab-TestVocabulary-vocab004</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>vocab005</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Vocabulary Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:code, the attribute code SHALL be present</Description> + <Identifiant>vocab-TestVocabulary-vocab005</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>vocab006</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Vocabulary Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:code, the attribute code SHALL have the value '29545-1' if present</Description> + <Identifiant>vocab-TestVocabulary-vocab006</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>vocab007</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Vocabulary Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:code, the attribute codeSystem SHALL have the value '2.11.111.1.111111.1.1' if present</Description> + <Identifiant>vocab-TestVocabulary-vocab007</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>vocab008</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Vocabulary Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'], the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0002)</Description> + <Identifiant>vocab-TestVocabulary-vocab008</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0002"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>vocab009</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Vocabulary Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:code (Item : CONF:0002)</Description> + <Identifiant>vocab-TestVocabulary-vocab009</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>vocab010</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Vocabulary Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:title (Item : CONF:0003)</Description> + <Identifiant>vocab-TestVocabulary-vocab010</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0003"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>vocab011</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Vocabulary Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act, the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0005)</Description> + <Identifiant>vocab-TestVocabulary-vocab011</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0005;CONF:0006"/> + <Type>Mandatory</Type> + </Note> + <Error> + <Test>vocab012</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Vocabulary Template, the code of /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act/hl7:code SHALL be from the valueSet 1.2.3.4.5.6.7.8.9 (flexibility : dynamic) (Item : CONF:0005)</Description> + <Identifiant>vocab-TestVocabulary-vocab012</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0005;CONF:0006"/> + <Type>Vocabulary</Type> + </Error> + <Note> + <Test>vocab013</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Vocabulary Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act SHALL contain at least ONE hl7:priorityCode (Item : CONF:0006)</Description> + <Identifiant>vocab-TestVocabulary-vocab013</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0006"/> + <Type>Cardinality</Type> + </Note> + <Error> + <Test>vocab014</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Vocabulary Template, the code of /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act/hl7:priorityCode SHALL be from the valueSet 1.2.3.4.5.6.7.8.9 (flexibility : dynamic) OR SHALL be from the valueSet 1.2.3.4.5.6.7.8.10 (flexibility : dynamic) (Item : CONF:0006)</Description> + <Identifiant>vocab-TestVocabulary-vocab014</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0006"/> + <Type>Vocabulary</Type> + </Error> + <Note> + <Test>vocab015</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Vocabulary Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act SHALL contain at least ONE hl7:languageCode (Item : CONF:0007)</Description> + <Identifiant>vocab-TestVocabulary-vocab015</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0006;CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Error> + <Test>vocab016</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Vocabulary Template, the code of /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act/hl7:languageCode SHALL be from the valueSet 1.2.3.4.5.6.7.8.9 (flexibility : 2021-01-01T00:00:00) (Item : CONF:0007)</Description> + <Identifiant>vocab-TestVocabulary-vocab016</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0006;CONF:0007"/> + <Type>Vocabulary</Type> + </Error> + <Note> + <Test>vocab017</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Vocabulary Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry SHALL contain at least ONE hl7:act</Description> + <Identifiant>vocab-TestVocabulary-vocab017</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0006"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>vocab018</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Vocabulary Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] SHALL contain at least ONE hl7:entry (Item : CONF:0006)</Description> + <Identifiant>vocab-TestVocabulary-vocab018</Identifiant> + <assertion idScheme="vocab" assertionId="CONF:0006"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>test_IDs</Test> + <Location>/ClinicalDocument</Location> + <Description>Success: Found all IDs referenced</Description> + </Note> + <Warning> + <Test>rmim052</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>Section.text SHALL be specified, as it is a required element (RMIM-052)</Description> + <Identifiant>cdabasic-SectionSpec-rmim052</Identifiant> + <assertion idScheme="RMIM" assertionId="RMIM-052"/> + <Type>Mandatory</Type> + </Warning> + <Warning> + <Test>rmim052</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>Section.text SHALL be specified, as it is a required element (RMIM-052)</Description> + <Identifiant>cdabasic-SectionSpec-rmim052</Identifiant> + <assertion idScheme="RMIM" assertionId="RMIM-052"/> + <Type>Mandatory</Type> + </Warning> + <Note> + <Test>test_IDs</Test> + <Location>/ClinicalDocument</Location> + <Description>Success: Found all IDs referenced</Description> + </Note> + <Result>FAILED</Result> + </MDAValidation> + <ValidationResultsOverview> + <ValidationDate>2022, 01 07</ValidationDate> + <ValidationTime>11:57:33</ValidationTime> + <ValidationServiceName>Gazelle CDA Validation : vocab</ValidationServiceName> + <ValidationTestResult>FAILED</ValidationTestResult> + </ValidationResultsOverview> + <TemplateDesc validation="Error"> + <Template validation="Report" type="POCDMT000040Section" location="/ClinicalDocument/component/structuredBody/component[0]/section"> + <templateId id="1.1.1.1.1.1.1.1" name="TestVocabulary"/> + </Template> + <Template validation="Error" type="POCDMT000040Section" location="/ClinicalDocument/component/structuredBody/component[1]/section"> + <templateId id="1.1.1.1.1.1.1.1" name="TestVocabulary"/> + </Template> + </TemplateDesc> +</detailedResult> diff --git a/hl7templates/goc-tests/goc-tests-runner/src/test/java/net/ihe/gazelle/goctests/interlay/ValidatorGeneratorTest.java b/hl7templates/goc-tests/goc-tests-runner/src/test/java/net/ihe/gazelle/goctests/interlay/ValidatorGeneratorTest.java new file mode 100644 index 0000000..e5e6b3e --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/test/java/net/ihe/gazelle/goctests/interlay/ValidatorGeneratorTest.java @@ -0,0 +1,30 @@ +package net.ihe.gazelle.goctests.interlay; + +import net.ihe.gazelle.goctests.application.exceptions.ValidatorGenerationException; +import net.ihe.gazelle.goctests.application.models.GeneratedValidator; +import net.ihe.gazelle.goctests.application.ValidatorGenerator; +import org.junit.Ignore; +import org.junit.Test; + +public class ValidatorGeneratorTest { + + /** + * This is made as utility for local tests, to be ignore at package time + * due to performance issues + */ + @Ignore + @Test + public void generateValidatorTest(){ + + ValidatorGenerator validatorGenerator = new ValidatorGeneratorImpl(); + String bbr = "/home/aai@kereval.com/IdeaProjects/GOCFomGit/gazelle-objects-checker/hl7templates/goc-tests/goc-tests-runner/src/main/resources/datatype/decor_datatype.xml"; + String output = "/home/aai@kereval.com/IdeaProjects/GOCFomGit/gazelle-objects-checker/testing/test-4"; + String mvn = "/opt/apache-maven-3.5.4/bin/mvn"; + try { + GeneratedValidator validator = validatorGenerator.generateValidator(bbr,output,mvn); + System.out.println(validator); + } catch (ValidatorGenerationException e) { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/hl7templates/hl7templates-generator-jar/src/main/java/net/ihe/gazelle/tempgen/action/RuleDefinitionAnalyzer.java b/hl7templates/hl7templates-generator-jar/src/main/java/net/ihe/gazelle/tempgen/action/RuleDefinitionAnalyzer.java index 3d1c8d1..012e51e 100644 --- a/hl7templates/hl7templates-generator-jar/src/main/java/net/ihe/gazelle/tempgen/action/RuleDefinitionAnalyzer.java +++ b/hl7templates/hl7templates-generator-jar/src/main/java/net/ihe/gazelle/tempgen/action/RuleDefinitionAnalyzer.java @@ -409,6 +409,7 @@ public class RuleDefinitionAnalyzer extends RuleDefinitionProcessorImpl { @UsedByArtDecor @Override public void processMinimumMultiplicity(Integer minimumMultiplicity) { + // TODO: 23/12/2021 Highly need to be reviewed if (this.ignoreMinCardinality()) { // this is the case where the RuleDefinition is included in a choice return; @@ -424,6 +425,11 @@ public class RuleDefinitionAnalyzer extends RuleDefinitionProcessorImpl { (new RDMinimumMultiplicityAnalyzer()).getProcessIdentifier()); } } + else{ + ProblemHandler.handleRuleDefinitionInfo(selectedRuleDefinition, + "The minimumMultiplicity attribute doesn't match specifications", + (new RDMinimumMultiplicityAnalyzer()).getProcessIdentifier()); + } } diff --git a/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/peripherals/GOCLoggerImpl.java b/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/peripherals/GOCLoggerImpl.java index 1f513f9..4890756 100644 --- a/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/peripherals/GOCLoggerImpl.java +++ b/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/peripherals/GOCLoggerImpl.java @@ -101,7 +101,7 @@ public class GOCLoggerImpl implements GOCLogger { if(logStream != null){ printClosingSeparator(); long milliseconds = (this.totalElapsedTime/1000000)%1000; - long seconds = (this.totalElapsedTime/1000000 * 1000)%60; + long seconds = (this.totalElapsedTime/(1000000 * 1000))%60; long minutes = (this.totalElapsedTime/(1000000L * 1000 *60)); String stringToLog = "The generation took [ "+minutes+"m "+seconds+"s "+milliseconds+"ms ] to complete"; logStream.println("\n"+stringToLog+"\n"); diff --git a/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/peripherals/HL7Templates2GOC.java b/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/peripherals/HL7Templates2GOC.java index 99bb6aa..4136665 100644 --- a/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/peripherals/HL7Templates2GOC.java +++ b/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/peripherals/HL7Templates2GOC.java @@ -4,14 +4,19 @@ import net.ihe.gazelle.lib.hl7templatespackager.adapters.ProcessExecutor; import net.ihe.gazelle.lib.hl7templatespackager.application.*; import net.ihe.gazelle.lib.hl7templatespackager.application.exception.EnvironementException; import net.ihe.gazelle.lib.hl7templatespackager.application.exception.PackagerProcessException; +import org.apache.log4j.PropertyConfigurator; import org.kohsuke.args4j.CmdLineException; import org.kohsuke.args4j.CmdLineParser; import org.kohsuke.args4j.Option; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.Properties; public class HL7Templates2GOC { @@ -66,6 +71,8 @@ public class HL7Templates2GOC { private String generationDate; + private ValidatorConfiguration validatorConfiguration; + /** * @return the rootClassName */ @@ -194,8 +201,15 @@ public class HL7Templates2GOC { this.HL7TEMP_RESOURCES_PATH = HL7TEMP_RESOURCES_PATH; } + public String getGenerationDate() { + return generationDate; + } + + public ValidatorConfiguration getValidatorConfiguration() { + return validatorConfiguration; + } - public void execute(String[] args) { + public boolean execute(String[] args) { CmdLineParser parser = new CmdLineParser(this); try { parser.parseArgument(args); @@ -223,16 +237,18 @@ public class HL7Templates2GOC { EnvironementConfiguration.configure(); log.info("Generation started at : "+generationDate); - log.info("Workspace root is : " + getWorkspaceRoot(getOutputFile())); log.info("Workspace name is : " + getWorkspaceName(getOutputFile())); GOCPackager packager = new GOCPackagerFactory().createGOCPackager(getWorkspaceRoot(getOutputFile()), mvnExecPath, generationDate, gocLogger, processExecutor); - packager.packageBBRToGOCValidationTool(new Workspace(getWorkspaceName(getOutputFile())), - new ValidatorConfiguration(getBbr(), getVersionLabel(), getIgnoreTemplateIdRequirements(), getIgnoreCdaBasicRequirements(), - getServiceName())); + this.validatorConfiguration = new ValidatorConfiguration(getBbr(), getVersionLabel(), getIgnoreTemplateIdRequirements(), getIgnoreCdaBasicRequirements(), + getServiceName()); + + packager.packageBBRToGOCValidationTool(new Workspace(getWorkspaceName(getOutputFile())),this.validatorConfiguration); + + return true; } catch (CmdLineException e) { System.out.println("Exception in the execution of command line"); e.printStackTrace(); @@ -241,6 +257,7 @@ public class HL7Templates2GOC { } catch (EnvironementException e) { log.error("A problem in the environement configuration",e); } + return false; } /** -- GitLab