diff --git a/.gitignore b/.gitignore index ea6cc40afc0a6c65944634f633434f354fb7b945..4ad4cad14550134324d93a640f68cc6cbd6b4544 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ *.iml .idea/ target/ +hl7templates/goc-tests/goc-tests-runner/src/main/resources/application.properties +hl7templates/goc-tests/goc-tests-runner/src/test/resources/application.properties \ No newline at end of file diff --git a/archetype/generated-validator/pom.xml b/archetype/generated-validator/pom.xml index e91935946e1c4dee2f7d75def04a7d0168a312a6..ed6c5b65d509085d6c88d70b6953678011b6beeb 100644 --- a/archetype/generated-validator/pom.xml +++ b/archetype/generated-validator/pom.xml @@ -42,4 +42,12 @@ </plugin> </plugins> </build> + + <dependencies> + <dependency> + <groupId>net.ihe.gazelle.goctests</groupId> + <artifactId>goc-annotations</artifactId> + <version>3.0.4-SNAPSHOT</version> + </dependency> + </dependencies> </project> diff --git a/archetype/generated-validator/validator-archetype-instantiator/src/main/java/net/ihe/gazelle/goc/ValidatorInstantiator.java b/archetype/generated-validator/validator-archetype-instantiator/src/main/java/net/ihe/gazelle/goc/ValidatorInstantiator.java index 0c10a73f68c1f765758a91b4b99dc300f869597d..b2ed43fb16a64b0e60c818310de3ab23f443fa8e 100644 --- a/archetype/generated-validator/validator-archetype-instantiator/src/main/java/net/ihe/gazelle/goc/ValidatorInstantiator.java +++ b/archetype/generated-validator/validator-archetype-instantiator/src/main/java/net/ihe/gazelle/goc/ValidatorInstantiator.java @@ -20,10 +20,12 @@ public class ValidatorInstantiator { if(javaHome != null && !javaHome.isEmpty()){ javaEnv = "env $JAVA_HOME=\""+javaHome+"\" "; } + String version = getVersion(); + version = version==null?gocVersion:version; return CD_COMMAND + workspacePath + "\"\n" + javaEnv + mvnExecPath + " org.apache.maven.plugins:maven-archetype-plugin:2.3:generate -B " + "-DarchetypeGroupId=net.ihe.gazelle.goc " + "-DarchetypeArtifactId=validator-archetype " + - "-DarchetypeVersion=" + getVersion() + " " + + "-DarchetypeVersion=" + version + " " + "-DprojectName=" + projectName + " " + "-DgroupId=net.ihe.gazelle.goc " + "-DartifactId=" + projectName + "-validator-jar " + diff --git a/docs/installation-guide.md b/docs/installation-guide.md index 648dbdba57fd8a79e5320c594cb301d83b78e84a..8a1b08528bd1e1a465a760baa049b5576f27c42b 100644 --- a/docs/installation-guide.md +++ b/docs/installation-guide.md @@ -17,7 +17,8 @@ date: 19/10/2021 7. ##### [Generation Validator form UML (Alternative)](#generateValidatorFromUML) 8. ##### [Validate CDA](#validateCDA) 9. ##### [Utility Scripts](#utilityScripts) -10. ##### [Extras](#extras) +10. ##### [System Testing](#systemTesting) +11. ##### [Extras](#extras) <div id='introduction'></div> @@ -183,6 +184,25 @@ The Artifact is generated at _**gazelle-objects-checker/hl7templates-packager-ja > here: [GOC Artifact Nexus](https://gazelle.ihe.net/nexus/#nexus-search;quick~hl7templates-packager) > Choose the latest version, and download the: **hl7templates-packager-jar-X.X.X-jar-with-dependencies.jar** artifact +### Generate tests coverage report: + +#### Overview: +Some Tests methods in GOC, are annotated with `@Covers` annotation (GOC Specific), +these methods tests a given HL7 Specification, these annotations are used later to generate a coverd +report if requested. + +#### Usage +You can generate a coverage report of all covered HL7 specifications by GOC, with passing the +following parameters during install process: +- `-Dcsv`: Path to a CSV that will aggregate all +- `-Ddest`: Destination path to generated XML report +- `-Dtype`: (OPTIONAL) Report type (Only XML is available so far, which is the default one) + +> Notice: if one of the first parameters is missing, coverage report not generated, but packagin +> should be done succcessfully + +/!\ Be careful to not generate the coverage with same csv file, because it will aggregate with old results + <div id='generateValidator'></div> ## 6. Generate Validator @@ -485,11 +505,72 @@ For SEQUOIA: > ./SEQUOIAGeneration.sh ``` +<div id='systemTesting'></div> + +## 10. System Testing + +### Overview: +Due to the variety of the HL7 specifications handled by GOC, and the Conversion & Generation processes +that it executed, we created a new module to perform a System Test for all known (i.e main) rules by GOC. +Each specification has its own _DECOR_, _CDA_ and _Expected Results_ for comparaison.<br> +The following specifications are supported so far by GOC System Testing module: +- Cardinality +- Mandatory +- Vocabulary +- Context +- Datatype +- Fixed Value +- **GLOBAL**** + +** The **_Global_** type is not a specification, but a pre-defined profile with _DECOR_, _CDA_ and _Expected Results_ +that contains all other specifications, for a general system testing. + +### Configuration +Before using the provided APIs, you need to make a basic configuration in: +- `application.properties`<br> + +Required properties to be set: +- `maven.path`: The binary path to your maven installation (you can reference the wrapped one) +- `result.type`: **xml** for xml generated report or **standard** for console output +- `result.type.xmlpath`: You need to set a path if the `result.type` is set to XML + +Optional properties (could keep the default value): +- `goc.persistValidator`: set to true if you want to keep the generated validator during the test +- `goc.persistResult`: set to true if you want to keep the validation result during test + +**NOT RECOMMENDED** to change: +- `goc.outputFolderPrefix`: prefix of the generation folder +- `goc.resultFolderPrefix`: prefix for the results folder + +### Usage: +####10.1 From IDE with JUnit + +The module have an integrated interface with JUnit annotations, with pre-defined assertions (that could be overriden +by the use), so could easly be executed from your IDE. +The main Test Class called `SystemTest` at +`hl7templates/goc-tests/goc-tests-runner/src/test/java/net/ihe/gazelle/goctests/SystemTests.java` + +####10.2 From Command Line Interface +The module provides a user-friendly CLI with one parameter `-S` or `--spec-type` +The executable jar in `hl7templates/goc-tests/goc-tests-runner/target/goc-tests-runner-[X.X.X]-jar-with-dependencies.jar` + +```bash +> java -jar goc-tests-runner-[X.X.X]-jar-with-dependencies.jar --spec-type <SPECIFICATION> +``` + +Available options for `SPECIFICATION` are: +- cardinality +- mandatory +- vocabulary +- context +- datatype +- "fixed value" +- global <div id='extras'></div> -## 10. Extras +## 11. Extras You can find some previous made documentation here _(belong the old GOC, and could probably not represent the actual version)_: - [GOC Installation guide for developers](https://docs.google.com/document/d/1G5bmLhFKNjOvg_rxEllidTofYrwxBeZG_kigTM0pqXM/edit?usp=sharing) diff --git a/hl7templates/goc-tests/goc-annotations/pom.xml b/hl7templates/goc-tests/goc-annotations/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..d9b9dc94b565591ca54a2d46928f97f2642c9d7c --- /dev/null +++ b/hl7templates/goc-tests/goc-annotations/pom.xml @@ -0,0 +1,142 @@ +<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-annotations</artifactId> + <name>GOC Annotations</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-compiler-plugin</artifactId> + <version>3.8.1</version> + <configuration> + <source>11</source> + <target>11</target> + </configuration> + <executions> <!-- exclude src from annotation processing --> + <execution> + <id>default-compile</id> + <goals> + <goal>compile</goal> + <goal>testCompile</goal> + </goals> + <configuration> + <proc>none</proc> + </configuration> + </execution> + </executions> + </plugin> + + + </plugins> + </build> + + <reporting> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <version>2.17</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <version>2.10.4</version> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>gazelle-plugins</artifactId> + <version>1.60</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-project-info-reports-plugin</artifactId> + <version>2.9</version> + </plugin> + </plugins> + </reporting> + + + <dependencies> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.10</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>net.sf.trove4j</groupId> + <artifactId>trove4j</artifactId> + <version>3.0.3</version> + </dependency> + + <dependency> + <groupId>com.google.auto.service</groupId> + <artifactId>auto-service</artifactId> + <version>1.0.1</version> + </dependency> + + <!-- dependency used for XLSX file format --> + <dependency> + <groupId>org.apache.poi</groupId> + <artifactId>poi-ooxml</artifactId> + <version>3.17</version> + </dependency> + + <!-- dependency used for XLS older file format + (added for information) --> + <dependency> + <groupId>org.apache.poi</groupId> + <artifactId>poi</artifactId> + <version>3.17</version> + </dependency> + + + <dependency> + <groupId>javax.xml.bind</groupId> + <artifactId>jaxb-api</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.glassfish.jaxb</groupId> + <artifactId>jaxb-runtime</artifactId> + <version>2.3.0</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>args4j</groupId> + <artifactId>args4j</artifactId> + <version>2.0.23</version> + </dependency> + <dependency> + <groupId>javax.activation</groupId> + <artifactId>javax.activation-api</artifactId> + <version>1.2.0</version> + </dependency> + + + + </dependencies> +</project> diff --git a/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/annotations/Covers.java b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/annotations/Covers.java new file mode 100644 index 0000000000000000000000000000000000000000..7ff55fa7724144a9ed66cca26237029eb4c45560 --- /dev/null +++ b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/annotations/Covers.java @@ -0,0 +1,19 @@ +package net.ihe.gazelle.goctests.definitions.annotations; + + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.METHOD) +public @interface Covers { + + String[] requirements(); + + TestType testType() default TestType.UNIT_TEST; + + String comment() default ""; + +} diff --git a/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/annotations/TestType.java b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/annotations/TestType.java new file mode 100644 index 0000000000000000000000000000000000000000..c549599f77af718710842e02773d2bf3d6bfbb73 --- /dev/null +++ b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/annotations/TestType.java @@ -0,0 +1,28 @@ +package net.ihe.gazelle.goctests.definitions.annotations; + +public enum TestType { + + SYSTEM_TEST("system-test"), + UNIT_TEST("unit-test"), + INTEGRATION_TEST("integration-test"); + + private String value; + + private TestType(String value){ + this.value = value; + } + + public String getValue(){ + return value; + } + + public static TestType of(String value){ + for(TestType testType : TestType.values()){ + if(testType.value.equals(value)){ + return testType; + } + } + return null; + } + +} diff --git a/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/CSVParser.java b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/CSVParser.java new file mode 100644 index 0000000000000000000000000000000000000000..6bcfaa0d918e3416587a560f5557465e7f7f58b5 --- /dev/null +++ b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/CSVParser.java @@ -0,0 +1,103 @@ +package net.ihe.gazelle.goctests.definitions.application; + +import net.ihe.gazelle.goctests.definitions.annotations.TestType; +import net.ihe.gazelle.goctests.definitions.application.models.AnnotatedTestMethod; +import net.ihe.gazelle.goctests.definitions.application.models.CSVColumn; +import net.ihe.gazelle.goctests.definitions.application.models.CoverageReport; +import net.ihe.gazelle.goctests.definitions.application.models.Requirement; + +import java.io.*; +import java.util.*; + +public class CSVParser { + + public static final String REQUIREMENTS_DELIMITER = ";"; + + private CSVParser(){} + + public static CoverageReport parseCoverageReport(String csvPath) throws CSVParsingException { + File file = new File(csvPath); + if(!file.exists()){ + throw new CSVParsingException("CSV File does not exist"); + } + try(BufferedReader reader = new BufferedReader(new FileReader(csvPath));) { + String line; + int lineCount = 0; + List<AnnotatedTestMethod> methods = new ArrayList<>(); + while((line = reader.readLine()) != null){ + if(lineCount == 0){ + if(!checkCSVColumnsConformance(line)){ + throw new CSVParsingException("CSV File doesn't match expected model, verification was by columns"); + } + } + else{ + String[] values = line.split(","); + if(values.length < 5){ + System.err.println("Invalide line format: missing colomns in "+line); + System.err.println("Skipping entry"); + } + else{ + // TODO: 13/01/2022 This could be improved to be dynamic with reflection + TestType testType = TestType.of(values[2]); + if(testType == null){ + System.err.println("Invalid testype found: "+values[2]+" at line: "+lineCount); + System.err.println("Skipping entry"); + continue; + } + String methodName = values[0]; + String[] requirements = values[1].split(REQUIREMENTS_DELIMITER); + String packageName = values[3]; + String className = values[4]; + String comment = values.length > 5 ? values[5]:""; + methods.add(new AnnotatedTestMethod(methodName, requirements, testType, packageName, className, comment)); + } + } + lineCount++; + } + + Map<String, List<AnnotatedTestMethod>> map = getRequirementsMap(methods); + return convertMapToCoverageReport(map); + + } catch (FileNotFoundException e) { + throw new CSVParsingException("CSV File not found or is a directory",e); + } catch (IOException e) { + throw new CSVParsingException("Could not read from file",e); + } + + + } + + private static boolean checkCSVColumnsConformance(String columns){ + return CSVColumn.CSV_HEADER.equals(columns); + } + + private static Map<String,List<AnnotatedTestMethod>> getRequirementsMap(List<AnnotatedTestMethod> methods){ + Map<String,List<AnnotatedTestMethod>> map = new TreeMap<>(); + for(AnnotatedTestMethod method : methods){ + String[] requirementsString = method.getRequirements(); + for(String reqString : requirementsString){ + if(map.containsKey(reqString)){ + map.get(reqString).add(method); + } + else{ + List<AnnotatedTestMethod> temp = new ArrayList<>(); + temp.add(method); + map.put(reqString, temp); + } + } + } + return map; + } + + private static CoverageReport convertMapToCoverageReport(Map<String,List<AnnotatedTestMethod>> map){ + CoverageReport report = new CoverageReport(); + for(Map.Entry<String, List<AnnotatedTestMethod>> entry : map.entrySet()){ + if(entry.getKey() != null){ + Requirement requirement = new Requirement(entry.getKey()); + requirement.setMethods(entry.getValue()); + report.getRequirements().add(requirement); + } + } + return report; + } +} diff --git a/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/CSVParsingException.java b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/CSVParsingException.java new file mode 100644 index 0000000000000000000000000000000000000000..2ac60eeae11ac6b76dc998c4ab36d446b8346b1a --- /dev/null +++ b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/CSVParsingException.java @@ -0,0 +1,12 @@ +package net.ihe.gazelle.goctests.definitions.application; + +public class CSVParsingException extends Exception{ + + public CSVParsingException(String message) { + super(message); + } + + public CSVParsingException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/CSVWriter.java b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/CSVWriter.java new file mode 100644 index 0000000000000000000000000000000000000000..9bd7d3fbcfe0b55f7c75a4b1371771f84c9d8ed4 --- /dev/null +++ b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/CSVWriter.java @@ -0,0 +1,51 @@ +package net.ihe.gazelle.goctests.definitions.application; + +import net.ihe.gazelle.goctests.definitions.application.models.CSVColumn; + +import java.io.*; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class CSVWriter { + + private final static String CSV_HEADER = CSVColumn.CSV_HEADER; + + private static final Pattern ESCAPED_DATA_PATT = Pattern.compile("\\R"); + + private CSVWriter(){} + + public static String convertLineToCSV(String[] line){ + return Stream.of(line) + .map(CSVWriter::escapeSpecialCharacters) + .collect(Collectors.joining(",")); + } + + public static void writeDataToCSV(List<String[]> data, String filePath) throws IOException { + boolean filExist = Files.exists(Path.of(filePath)); + FileWriter fileWriter = new FileWriter(filePath,true); + PrintWriter printWriter = new PrintWriter(fileWriter); + if(!filExist){ + printWriter.println(CSV_HEADER); + } + data.stream() + .map(CSVWriter::convertLineToCSV) + .forEach(printWriter::println); + printWriter.close(); + } + + + public static String escapeSpecialCharacters(String data) { + String escapedData = ESCAPED_DATA_PATT.matcher(data).replaceAll(" "); + if (data.contains(",") || data.contains("\"") || data.contains("'")) { + data = data.replace("\"", "\"\""); + escapedData = "\"" + data + "\""; + } + return escapedData; + } + + +} diff --git a/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/CSVWriterException.java b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/CSVWriterException.java new file mode 100644 index 0000000000000000000000000000000000000000..8ab366240f4d430e5f47b838d6414dd4d3eebe17 --- /dev/null +++ b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/CSVWriterException.java @@ -0,0 +1,12 @@ +package net.ihe.gazelle.goctests.definitions.application; + +public class CSVWriterException extends Exception{ + + public CSVWriterException(String message) { + super(message); + } + + public CSVWriterException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/models/AnnotatedTestMethod.java b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/models/AnnotatedTestMethod.java new file mode 100644 index 0000000000000000000000000000000000000000..47b31983e5347da5af86e5dd53a7753e39658dd3 --- /dev/null +++ b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/models/AnnotatedTestMethod.java @@ -0,0 +1,110 @@ +package net.ihe.gazelle.goctests.definitions.application.models; + +import net.ihe.gazelle.goctests.definitions.annotations.TestType; + +import javax.xml.bind.annotation.*; +import java.util.Arrays; + +@XmlRootElement +@XmlAccessorType(XmlAccessType.FIELD) +public class AnnotatedTestMethod { + + @XmlElement(name = "MethodName") + private String methodName; + + @XmlTransient + private String[] requirements; + + @XmlElement(name = "Type") + private TestType testType; + + @XmlElement(name = "Package") + private String packageName; + + @XmlElement(name = "ClassName") + private String className; + + @XmlElement(name = "Comment") + private String comment; + + public AnnotatedTestMethod() { + } + + public AnnotatedTestMethod(String methodName) { + this.methodName = methodName; + } + + public String getMethodName() { + return methodName; + } + + public AnnotatedTestMethod(String methodName, String[] requirements, TestType testType, String packageName, String className) { + this(methodName, requirements, testType, packageName, className, ""); + + } + + public AnnotatedTestMethod(String methodName, String[] requirements, TestType testType, String packageName, String className, String comment) { + this.methodName = methodName; + this.requirements = requirements; + this.testType = testType; + this.packageName = packageName; + this.className = className; + this.comment = comment; + } + + public void setMethodName(String methodName) { + this.methodName = methodName; + } + + public String[] getRequirements() { + return requirements; + } + + public void setRequirements(String[] requirements) { + this.requirements = requirements; + } + + public TestType getTestType() { + return testType; + } + + public void setTestType(TestType testType) { + this.testType = testType; + } + + public String getPackageName() { + return packageName; + } + + public void setPackageName(String packageName) { + this.packageName = packageName; + } + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + @Override + public String toString() { + return "AnnotatedTestMethod{" + + "methodName='" + methodName + '\'' + + ", requirements=" + Arrays.toString(requirements) + + ", testType=" + testType + + ", packageName='" + packageName + '\'' + + ", className='" + className + '\'' + + ", comment='" + comment + '\'' + + '}'; + } +} diff --git a/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/models/CSVColumn.java b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/models/CSVColumn.java new file mode 100644 index 0000000000000000000000000000000000000000..d126818da3d3ca45c39fcde4d455b9045dfd8a84 --- /dev/null +++ b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/models/CSVColumn.java @@ -0,0 +1,41 @@ +package net.ihe.gazelle.goctests.definitions.application.models; + +import java.util.Arrays; +import java.util.stream.Collectors; + +public enum CSVColumn { + + METHOD_NAME("Method Name"), + REQUIREMENTS("Requirements"), + TEST_TYPE("Test Type"), + PACKAGE_NAME("Package Name"), + CLASS_NAME("Class Name"), + COMMENT("Comment"); + + public static final String CSV_HEADER = getHeaderForCSV(); + + CSVColumn(String value) { + this.value = value; + } + + private String value; + + public String getValue() { + return value; + } + + private static String getHeaderForCSV(){ + return Arrays.stream(CSVColumn.values()) + .map(CSVColumn::getValue) + .collect(Collectors.joining(",")); + } + + public static CSVColumn of(String value){ + for(CSVColumn col : CSVColumn.values()){ + if(col.value.equals(value)){ + return col; + } + } + return null; + } +} diff --git a/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/models/CoverageReport.java b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/models/CoverageReport.java new file mode 100644 index 0000000000000000000000000000000000000000..6de382a8d2ead95aea4034895cac09eb8270d7f5 --- /dev/null +++ b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/models/CoverageReport.java @@ -0,0 +1,37 @@ +package net.ihe.gazelle.goctests.definitions.application.models; + + +import javax.xml.bind.annotation.*; +import java.util.ArrayList; +import java.util.List; + +@XmlRootElement(name = "Coverage") +@XmlAccessorType(XmlAccessType.FIELD) +public class CoverageReport { + + @XmlElementWrapper(name = "Requirements") + @XmlElement(name = "Requirement") + private List<Requirement> requirements; + + private List<AnnotatedTestMethod> invalidMethods; + + public CoverageReport() { + requirements = new ArrayList<>(); + } + + public List<Requirement> getRequirements() { + return requirements; + } + + public void setRequirements(List<Requirement> requirements) { + this.requirements = requirements; + } + + public List<AnnotatedTestMethod> getInvalidMethods() { + return invalidMethods; + } + + public void setInvalidMethods(List<AnnotatedTestMethod> invalidMethods) { + this.invalidMethods = invalidMethods; + } +} diff --git a/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/models/Requirement.java b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/models/Requirement.java new file mode 100644 index 0000000000000000000000000000000000000000..124c8c879dbd0519547355290e429a2cadd894d3 --- /dev/null +++ b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/models/Requirement.java @@ -0,0 +1,65 @@ +package net.ihe.gazelle.goctests.definitions.application.models; + +import javax.xml.bind.annotation.*; +import java.util.List; +import java.util.Objects; + +@XmlRootElement +@XmlAccessorType(XmlAccessType.FIELD) +public class Requirement { + + private String id; + + @XmlElementWrapper(name = "Methods") + @XmlElement(name = "Method") + private List<AnnotatedTestMethod> methods; + + public Requirement() { + } + + public Requirement(String id) { + this.id = id; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + + public List<AnnotatedTestMethod> getMethods() { + return methods; + } + + public void setMethods(List<AnnotatedTestMethod> methods) { + this.methods = methods; + } + + @Override + public String toString() { + return "Requirement{" + + "id='" + id + '\'' + + ", methods=" + methods + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Requirement)) return false; + Requirement that = (Requirement) o; + return id.equals(that.id); + } + + @Override + public int hashCode() { + return Objects.hash(id); + } + + public boolean equalsById(String id){ + return this.id.equals(id); + } +} diff --git a/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/processors/CoverageProcessor.java b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/processors/CoverageProcessor.java new file mode 100644 index 0000000000000000000000000000000000000000..8dbf53b926e0f5a944d822f84523e41a14697fbf --- /dev/null +++ b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/processors/CoverageProcessor.java @@ -0,0 +1,50 @@ +package net.ihe.gazelle.goctests.definitions.application.processors; + +import com.google.auto.service.AutoService; +import net.ihe.gazelle.goctests.definitions.application.CSVWriterException; +import net.ihe.gazelle.goctests.definitions.application.models.AnnotatedTestMethod; + +import javax.annotation.processing.*; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.Element; +import javax.lang.model.element.TypeElement; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +@SupportedAnnotationTypes("net.ihe.gazelle.goctests.*") +@SupportedSourceVersion(SourceVersion.RELEASE_11) +@AutoService(Processor.class) +public class CoverageProcessor extends AbstractProcessor { + + @Override + public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { + + System.out.println("Start coverage processing"); + + for(TypeElement annotation : annotations){ + + Set<? extends Element> annotatedElements = roundEnv.getElementsAnnotatedWith(annotation); + Map<Boolean, List<Element>> annotatedMethods = annotatedElements.stream() + .collect(Collectors.partitioningBy(element -> + (CoverageProcessorUtil.isElementIdentifierValide(element)))); + + //Generate the report + List<AnnotatedTestMethod> validMethods = CoverageProcessorUtil.getAnnotatedTestMethods(annotatedMethods.get(true)); + ReportGenerator reportGenerator = new ReportGenerator(validMethods, annotatedMethods.get(false)); + try { + reportGenerator.generateReport(); + } catch (IOException | CSVWriterException e) { + System.err.println("The following error has occured: "+e.getMessage()); + System.err.println("Coverage report not generated"); + } + + } + + return false; + } + + +} diff --git a/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/processors/CoverageProcessorUtil.java b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/processors/CoverageProcessorUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..35ebb394366d818cd8c93226e9fc726e267822cc --- /dev/null +++ b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/processors/CoverageProcessorUtil.java @@ -0,0 +1,58 @@ +package net.ihe.gazelle.goctests.definitions.application.processors; + +import net.ihe.gazelle.goctests.definitions.annotations.Covers; +import net.ihe.gazelle.goctests.definitions.annotations.TestType; +import net.ihe.gazelle.goctests.definitions.application.models.AnnotatedTestMethod; + +import javax.lang.model.element.Element; +import javax.lang.model.element.PackageElement; +import java.util.*; +import java.util.stream.Collectors; + +final public class CoverageProcessorUtil { + + private CoverageProcessorUtil(){} + + + public static boolean isElementIdentifierValide(Element element){ + if(element == null || element.getSimpleName() == null){ + return false; + } + return isElementIdentifierValide(element.getSimpleName().toString()); + } + + + public static boolean isElementIdentifierValide(String stringIdentifier){ + if(stringIdentifier == null){ + return false; + } + for(MethodTestIdentifier methodTestIdentifier:MethodTestIdentifier.values()){ + if(stringIdentifier.startsWith(methodTestIdentifier.getValue()) + ||stringIdentifier.endsWith(methodTestIdentifier.getValue())){ + return true; + } + } + return false; + } + + public static List<AnnotatedTestMethod> getAnnotatedTestMethods(List<Element> methods){ + return methods.stream() + .map(CoverageProcessorUtil::constructAnnotatedTestMethod) + .collect(Collectors.toList()); + } + + + + + + private static AnnotatedTestMethod constructAnnotatedTestMethod(Element method){ + String methodName = method.getSimpleName().toString(); + String[] requirements = method.getAnnotation(Covers.class).requirements(); + TestType testType = method.getAnnotation(Covers.class).testType(); + String comment = method.getAnnotation(Covers.class).comment(); + String packageName = ((PackageElement) (method.getEnclosingElement().getEnclosingElement())).toString(); + String className = method.getEnclosingElement().getSimpleName().toString(); + return new AnnotatedTestMethod(methodName, requirements, testType, packageName, className, comment); + } + +} diff --git a/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/processors/MethodTestIdentifier.java b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/processors/MethodTestIdentifier.java new file mode 100644 index 0000000000000000000000000000000000000000..be579aebda886e3c68576fdd4c1d9addf7ae7add --- /dev/null +++ b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/processors/MethodTestIdentifier.java @@ -0,0 +1,24 @@ +package net.ihe.gazelle.goctests.definitions.application.processors; + +/** + * Allowed prefixes and suffixes for test methods, to be recognized by the test-coverage processing + */ + +public enum MethodTestIdentifier { + + test("test"), + Test("Test"), + it("it"), + It("It"), + IT("IT"); + + private String value; + + private MethodTestIdentifier(String value){ + this.value = value; + } + + public String getValue(){ + return value; + } +} diff --git a/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/processors/ReportGenerator.java b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/processors/ReportGenerator.java new file mode 100644 index 0000000000000000000000000000000000000000..8d635ac56d296e88b68b2b44ab716b6f47ab6d20 --- /dev/null +++ b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/processors/ReportGenerator.java @@ -0,0 +1,48 @@ +package net.ihe.gazelle.goctests.definitions.application.processors; + +import net.ihe.gazelle.goctests.definitions.application.CSVParser; +import net.ihe.gazelle.goctests.definitions.application.CSVWriterException; +import net.ihe.gazelle.goctests.definitions.application.models.AnnotatedTestMethod; +import net.ihe.gazelle.goctests.definitions.application.CSVWriter; + +import javax.lang.model.element.Element; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +public class ReportGenerator { + + private final List<AnnotatedTestMethod> validMethods; + private final List<Element> invalidMethods; + + public ReportGenerator(List<AnnotatedTestMethod> validMethods, List<Element> invalidMethods) { + this.validMethods = validMethods; + this.invalidMethods = invalidMethods; + } + + public void generateReport() throws CSVWriterException, IOException { + String filePath = System.getProperty("csv"); + + if(filePath == null || filePath.isEmpty()){ + throw new CSVWriterException("CSV File path not provided, please set it as system property"); + } + + List<String[]> document = new ArrayList<>(); + for(AnnotatedTestMethod method : validMethods){ + document.add(new String[]{method.getMethodName(), + String.join(CSVParser.REQUIREMENTS_DELIMITER,method.getRequirements()), + method.getTestType().getValue(), + method.getPackageName(), + method.getClassName(), + method.getComment()}); + } + CSVWriter.writeDataToCSV(document,filePath); + System.out.println("Report created successfully at: "+filePath); + + // TODO: 25/01/2022 Add invalid methods to report + + + } + + +} diff --git a/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/scripts/ConvertCSV.java b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/scripts/ConvertCSV.java new file mode 100644 index 0000000000000000000000000000000000000000..74f5529578275e16978d3189c343762da7b37a0a --- /dev/null +++ b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/scripts/ConvertCSV.java @@ -0,0 +1,38 @@ +package net.ihe.gazelle.goctests.definitions.application.scripts; + +import net.ihe.gazelle.goctests.definitions.application.CSVParsingException; + +import java.util.Arrays; + +public class ConvertCSV { + + + + public static void main(String[] args) { + + if(args.length<3){ + System.err.println("Invalid number of parameters, CSV Conversion couldn't be done"); + } + else { + String csvPath = args[0]; + String destPath = args[1]; + if(csvPath == null || destPath == null){ + System.err.println("Invalid CSV/Report path, report coverage not converted"); + } + else { + ConverterType type = args[2] == null ? ConverterType.XML : ConverterType.of(args[2]); + if(type == null){ + System.err.println("Invalid converter type"); + } + else{ + Converter converter = ConverterFactory.getConverter(type); + try { + converter.generate(csvPath,destPath); + } catch (CSVParsingException e) { + e.printStackTrace(); + } + } + } + } + } +} diff --git a/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/scripts/Converter.java b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/scripts/Converter.java new file mode 100644 index 0000000000000000000000000000000000000000..d57fc356eadc4f5a5546a77c3909e9157258daae --- /dev/null +++ b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/scripts/Converter.java @@ -0,0 +1,8 @@ +package net.ihe.gazelle.goctests.definitions.application.scripts; + +import net.ihe.gazelle.goctests.definitions.application.CSVParsingException; + +public interface Converter { + + void generate(String csvPath, String destPath) throws CSVParsingException; +} diff --git a/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/scripts/ConverterFactory.java b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/scripts/ConverterFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..2c6e8420c098df2568c4342b9bd1b7ea4ff386ab --- /dev/null +++ b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/scripts/ConverterFactory.java @@ -0,0 +1,21 @@ +package net.ihe.gazelle.goctests.definitions.application.scripts; + +import net.ihe.gazelle.goctests.definitions.application.scripts.excel.ExcelConverter; +import net.ihe.gazelle.goctests.definitions.application.scripts.xml.XMLConverter; + +public class ConverterFactory { + + private ConverterFactory() { + } + + public static Converter getConverter(ConverterType converterType){ + switch (converterType){ + case XML: + return new XMLConverter(); + case EXCEL: + return new ExcelConverter(); + default: + return null; + } + } +} diff --git a/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/scripts/ConverterType.java b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/scripts/ConverterType.java new file mode 100644 index 0000000000000000000000000000000000000000..e954956ac7d0068665e7ae1b1229ec31ae977d1a --- /dev/null +++ b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/scripts/ConverterType.java @@ -0,0 +1,26 @@ +package net.ihe.gazelle.goctests.definitions.application.scripts; + +public enum ConverterType { + + XML("xml"), + EXCEL("excel"); + + private String value; + + ConverterType(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + public static ConverterType of(String type){ + for(ConverterType t : ConverterType.values()){ + if(t.value.equals(type)){ + return t; + } + } + return null; + } +} diff --git a/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/scripts/excel/ExcelConverter.java b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/scripts/excel/ExcelConverter.java new file mode 100644 index 0000000000000000000000000000000000000000..f3f45fccf2929762ac1364ec313dacd4eab7d69b --- /dev/null +++ b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/scripts/excel/ExcelConverter.java @@ -0,0 +1,12 @@ +package net.ihe.gazelle.goctests.definitions.application.scripts.excel; + +import net.ihe.gazelle.goctests.definitions.application.CSVParsingException; +import net.ihe.gazelle.goctests.definitions.application.scripts.Converter; + +public class ExcelConverter implements Converter { + + @Override + public void generate(String csvPath, String destPath) throws CSVParsingException { + // nothing so far + } +} diff --git a/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/scripts/xml/XMLConverter.java b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/scripts/xml/XMLConverter.java new file mode 100644 index 0000000000000000000000000000000000000000..7bcb7f0c67e48d13fbaf43afb4c84cb170fe13a3 --- /dev/null +++ b/hl7templates/goc-tests/goc-annotations/src/main/java/net/ihe/gazelle/goctests/definitions/application/scripts/xml/XMLConverter.java @@ -0,0 +1,33 @@ +package net.ihe.gazelle.goctests.definitions.application.scripts.xml; + +import net.ihe.gazelle.goctests.definitions.application.CSVParser; +import net.ihe.gazelle.goctests.definitions.application.CSVParsingException; +import net.ihe.gazelle.goctests.definitions.application.models.CoverageReport; +import net.ihe.gazelle.goctests.definitions.application.scripts.Converter; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import java.io.File; + +public class XMLConverter implements Converter { + + + public void generate(String csvPath, String desPath) throws CSVParsingException { + CoverageReport report = CSVParser.parseCoverageReport(csvPath); + try { + coverageReportMarshaller(report,desPath); + } catch (JAXBException e) { + throw new CSVParsingException("Report marshalling failed",e); + } + System.out.println("XML Generated at: "+desPath); + } + + private static void coverageReportMarshaller(CoverageReport report, String path) throws JAXBException { + JAXBContext jaxbContext = JAXBContext.newInstance(CoverageReport.class); + Marshaller marshaller = jaxbContext.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); + marshaller.marshal(report,new File(path)); + + } +} 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 0000000000000000000000000000000000000000..8953d40f30cce6c85316082f38429f7acf8b3cd6 --- /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 0000000000000000000000000000000000000000..53c48e1f5ea46adb9b2777be6598becd8da72a0e --- /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 0000000000000000000000000000000000000000..f14d42bc5e56ce928065b22f3dc02c80b5b7b897 --- /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 0000000000000000000000000000000000000000..eff55f4761afbcac1c06332b1a588aa0a4d6f768 --- /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 0000000000000000000000000000000000000000..89f64b1c0027aa43dbcedcde35273109811c646e --- /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(URL bbrURL, 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 0000000000000000000000000000000000000000..86bf98042c55a8c09084bf03dba0f469676bd73c --- /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 0000000000000000000000000000000000000000..35ad9ce3a3e1422e301211eead1dc18447d97f12 --- /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 0000000000000000000000000000000000000000..8375def453d40fc5e35002e644807819d513eaa6 --- /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 0000000000000000000000000000000000000000..c8b6f19bf0f2e9740f0728947d061cb56af137b2 --- /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 0000000000000000000000000000000000000000..3919e5dfffedf198d893a54a1186af53c2fe89c9 --- /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 0000000000000000000000000000000000000000..ee4029e4dfb6c2b2d553a9b78ac49040b15fac81 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/models/GeneratedValidator.java @@ -0,0 +1,150 @@ +package net.ihe.gazelle.goctests.application.models; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import java.io.Serializable; + +@XmlRootElement +@XmlAccessorType(XmlAccessType.FIELD) +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"; + + @XmlElement(name = "OutputFolder") + private String outputFolder; + + @XmlElement(name = "Logs") + private String logFolder; + + @XmlElement(name = "GenerationDate") + private String generationDate; + + @XmlElement(name = "BBR") + private String usedBBR; + + @XmlElement(name = "HL7Resources") + private String hl7TemplateResources; + + @XmlElement(name = "ValidatorBinary") + private String validatorBinaryPath; + + @XmlElement(name = "ProjectName") + private String projectName; + + @XmlElement(name = "ValidatorResources") + 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; + } + + + 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 0000000000000000000000000000000000000000..02accd5964a7cefc8febd201b4ae7d4113135658 --- /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.*; +import java.util.List; + +@XmlRootElement +@XmlType(propOrder = {"count","warningOrErrorOrNote"}) +@XmlAccessorType(XmlAccessType.FIELD) +public class NotificationElements { + + @XmlElement(name = "Count") + private int count; + + @XmlElementWrapper(name = "Rules") + @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 0000000000000000000000000000000000000000..d6fe1a40c3e09474534869e2e20c7b65822ed523 --- /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 0000000000000000000000000000000000000000..80842ed2abae302e62f3e546cf9f6a0c20f8c034 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/models/TestResult.java @@ -0,0 +1,75 @@ +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 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() { + } + + 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 = this.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 0000000000000000000000000000000000000000..20e9cef77f221e98dd216fbb59e2ac90efb09458 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/models/TestResultReport.java @@ -0,0 +1,147 @@ +package net.ihe.gazelle.goctests.application.models; + + +import javax.xml.bind.annotation.*; +import java.io.Serializable; + +@XmlRootElement +@XmlType(propOrder = {"validationDate","testResult","specification","usedCDA","processedElements" + ,"expectedElements","missedElements","unexpectedElements","usedValidator"}) +@XmlAccessorType(XmlAccessType.FIELD) +public class TestResultReport implements Serializable { + + @XmlElement(name = "TestResult") + private String testResult; + + @XmlElement(name = "Validator") + private GeneratedValidator usedValidator; + + @XmlElement(name = "ValidationDate") + private String validationDate; + + @XmlElement(name = "ValidateDocument") + private String usedCDA; + + @XmlElement(name = "Specification") + private String specification; + + @XmlElement(name = "NumberProcessedRules") + private int processedElements; + + @XmlElement(name = "NumberExpectedRules") + private int expectedElements; + + @XmlElement(name = "MissedRules") + private NotificationElements missedElements; + + @XmlElement(name = "UnexpectedRules") + 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 0000000000000000000000000000000000000000..30c3c4fcab6855614a674f58e46b6add2e1584f4 --- /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 0000000000000000000000000000000000000000..23ca3103f07b0b7858132f36c3dda17327dfb6c0 --- /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 0000000000000000000000000000000000000000..d87af3fa92d7ed9efdb8c43a9b94e6cd770a336c --- /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 0000000000000000000000000000000000000000..f82c1af8c07e7d21552bf153b7f0f57dce972c85 --- /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 0000000000000000000000000000000000000000..fdaf69e4526af1d31b2813159fdbf78561e4ea53 --- /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 0000000000000000000000000000000000000000..6c43fb81a847f1aa3590f708d2243799d3af01fd --- /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 0000000000000000000000000000000000000000..91976b9955706f5a36b465a95b85a1a54a048602 --- /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 0000000000000000000000000000000000000000..078dba556ad08486a1d9a44119a1be0d405a742a --- /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 0000000000000000000000000000000000000000..f153290598b945e221cf3fc359ddbcc3d23f556f --- /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 0000000000000000000000000000000000000000..d6f354b4bff097ab7c5683148b4cfbaed18ad878 --- /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 0000000000000000000000000000000000000000..142026b295903798e187fb4c966d766d3dd38da4 --- /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 0000000000000000000000000000000000000000..57ef993f607462ae3901d47aa759488a0c02cbfc --- /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 0000000000000000000000000000000000000000..14ea067884a55b347ed6bc188257a11f362081db --- /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 0000000000000000000000000000000000000000..834a98abff7825fb6832dd1779cac6624848bd36 --- /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 0000000000000000000000000000000000000000..95c2a0b1bfbb20df5485e48564c03e0a3569a95f --- /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 0000000000000000000000000000000000000000..8f407c9bc110bddff789dbd1d5fe2a9631533024 --- /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 0000000000000000000000000000000000000000..45abbc47e180b61308d60906968faadfe0aad013 --- /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 0000000000000000000000000000000000000000..dcb1d7a66724c8669e5c1cb9791ad97ad3a63964 --- /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 0000000000000000000000000000000000000000..4cf5836f0c7dfac42335a50b2c4082f2572002b8 --- /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 0000000000000000000000000000000000000000..54fc69ffe1b353c611628327398ea2076e3eaa02 --- /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 0000000000000000000000000000000000000000..ba6975ab16076e6ff4f423fc2c9d04800cdab602 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/MandatoryTestRunner.java @@ -0,0 +1,31 @@ +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.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 0000000000000000000000000000000000000000..d2bcaa4ab4f9a05dd179347c273f1ed5e0b5efaa --- /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 0000000000000000000000000000000000000000..376528ba2cc2fdfda0b8ef9e28805b500ef25a81 --- /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; + + protected 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 0000000000000000000000000000000000000000..d4062e70acb90ca18980b62f9357f88d0336ee45 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/application/specifications/SpecificationType.java @@ -0,0 +1,51 @@ +package net.ihe.gazelle.goctests.application.specifications; + + +public enum SpecificationType { + + + GLOBAL("global"), + CARDINALITY("cardinality"), + VOCABULARY("vocabulary"), + MANDATORY("mandatory"), + CONTEXT("context"), + DATATYPE("datatype"), + FIXEDVAL("fixed value"), + CLOSED("closed"), + CHOICE("chocie"); + + + 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 0000000000000000000000000000000000000000..cb70d806f1287d80262667ef9eef5be2684122e7 --- /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/java/net/ihe/gazelle/goctests/interlay/CDAValidatorImpl.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/CDAValidatorImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..cbc94352efcfd71454766bc74654f6c52a02455e --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/CDAValidatorImpl.java @@ -0,0 +1,83 @@ +package net.ihe.gazelle.goctests.interlay; + +import net.ihe.gazelle.goctests.interlay.exceptions.ProcessExecutionException; +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 net.ihe.gazelle.gen.common.DetailedResultMarshaller; +import net.ihe.gazelle.goctests.application.CDAValidator; +import net.ihe.gazelle.validation.DetailedResult; +import net.ihe.gazelle.goctests.interlay.utils.StringUtils; + +import javax.xml.bind.JAXBException; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +public class CDAValidatorImpl implements CDAValidator { + + private static final int RESULT_FILENAME_LENGTH = 20; + + private static final String OUTPUT_EXTENSION = ".xml"; + + private ProcessExecutor processExecutor; + + public CDAValidatorImpl(ProcessExecutor processExecutor) { + this.processExecutor = processExecutor; + } + + @Override + public ValidationResult validateDocument(String documentPath, GeneratedValidator validator) throws ValidationException { + if(validator == null){ + throw new ValidationException("Validator is not defined: NULL"); + } + Path validationResultFolder = EnvironementConfiguration.getInstance().getResultFolder(); + if(validationResultFolder == null){ + throw new ValidationException("Validation Result folder output not set in: "+EnvironementConfiguration.APPLICATION_PROPERTIES_FILE); + } + + // Prepare validation command + String resultFileName = StringUtils.getRandomString(RESULT_FILENAME_LENGTH)+OUTPUT_EXTENSION; + String resultFilePath = validationResultFolder.toAbsolutePath().toString()+"/"+resultFileName; + + StringBuilder command = new StringBuilder(validator.getValidatorBinaryPath()) + .append(" -path ").append(documentPath) + .append(" -out ").append(resultFilePath) + .append(" -resources ").append(validator.getValidatorResources()); + + //Validate + try { + processExecutor.executeProcess(command.toString()); + DetailedResult detailedResult = DetailedResultMarshaller.load(new FileInputStream(resultFilePath)); + + return new ValidationResult(detailedResult,documentPath); + + } catch (ProcessExecutionException e) { + throw new ValidationException("Cannot execute CDA validation command",e); + } catch (FileNotFoundException e){ + throw new ValidationException("CDA Valdiation Result not found at: "+resultFilePath,e); + }catch (JAXBException e){ + throw new ValidationException("Failed to parse DetailedResult from "+resultFileName,e); + } + + } + + @Override + public ValidationResult validateDocument(URL documentURL, GeneratedValidator validator) throws ValidationException { + try { + String cdaTemporaryCopy = EnvironementConfiguration.getInstance() + .getResultFolder().toAbsolutePath().toString() + "/" + StringUtils.getRandomString(15); + Files.copy(documentURL.openStream(), Paths.get(cdaTemporaryCopy)); + String documentPath = new File(cdaTemporaryCopy).getAbsolutePath(); + return validateDocument(documentPath,validator); + } catch (IOException e) { + throw new ValidationException("Failed to copy CDA for validation"); + } + } +} + diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/DetailedResultAdapterImpl.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/DetailedResultAdapterImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..7d56d25d9b42b04c5c3817e523b49134197dbf64 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/DetailedResultAdapterImpl.java @@ -0,0 +1,25 @@ +package net.ihe.gazelle.goctests.interlay; + +import net.ihe.gazelle.gen.common.DetailedResultMarshaller; +import net.ihe.gazelle.goctests.application.DetailedResultAdapter; +import net.ihe.gazelle.goctests.application.oracles.exceptions.OracleException; +import net.ihe.gazelle.validation.DetailedResult; + +import javax.xml.bind.JAXBException; +import java.io.IOException; +import java.net.URL; + +public class DetailedResultAdapterImpl implements DetailedResultAdapter { + + @Override + public DetailedResult getDetailedResult(URL url) throws OracleException { + try { + DetailedResult expectedResult = DetailedResultMarshaller.load(url.openStream()); + return expectedResult; + } catch (JAXBException e) { + throw new OracleException("Failed parsing Expected Result"); + } catch (IOException e) { + throw new OracleException("Could not load Expected Result resources"); + } + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/EnvironementConfiguration.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/EnvironementConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..dd5690888717e5ef6109320b7f42812f5c40dba6 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/EnvironementConfiguration.java @@ -0,0 +1,134 @@ +package net.ihe.gazelle.goctests.interlay; + +import net.ihe.gazelle.goctests.interlay.exceptions.EnvironementException; +import org.apache.commons.io.FileUtils; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Properties; + +final public class EnvironementConfiguration { + + + public final static String[] PROPERTIES_FILES = {"application.properties","specifications.properties"}; + + public final static String APPLICATION_PROPERTIES_FILE = PROPERTIES_FILES[0]; + + private final Properties properties = new Properties(); + + private final static EnvironementConfiguration INSTANCE = new EnvironementConfiguration(); + + private final static String TEMPORARY_FOLDER = "/tmp/"; + + private final static String GENERATION_PREFIX = "GOCGeneration"; + + private Path gocOutputFolder; + + private Path resultFolder; + + private boolean persistValidator; + + private boolean persistResult; + + /** + * Private constructor for singleton design pattern + */ + private EnvironementConfiguration(){ + try{ + loadProperties(); + } + catch (IOException e){ + System.err.println("WARN: couldn't load application.properties file: "+e.getMessage()); + } + } + + private void loadProperties() throws IOException { + for(String file:PROPERTIES_FILES){ + InputStream inputStream = EnvironementConfiguration.class.getClassLoader().getResourceAsStream(file); + properties.load(inputStream); + } + } + + public static EnvironementConfiguration getInstance(){ + return INSTANCE; + } + + public String getProperty(String propertyName){ + return properties.getProperty(propertyName); + } + + public Path getGocOutputFolder(){ + return gocOutputFolder; + } + + public Path getResultFolder() { + return resultFolder; + } + + public void initEnvironement() throws EnvironementException { + String outputFolderPrefix = getProperty("goc.outputFolderPrefix"); + String resultFolderPrefix = getProperty("goc.resultFolderPrefix"); + + this.persistValidator = "true".equals(getProperty("goc.persistValidator")); + this.persistResult = "true".equals(getProperty("goc.persistResult")); + + this.gocOutputFolder = initWorkspace(outputFolderPrefix,"Output Folder"); + this.resultFolder = initWorkspace(resultFolderPrefix, "Result Folder"); + } + + public void cleanEnvironement() { + System.out.println("Start cleaning..."); + if(this.gocOutputFolder == null || this.resultFolder == null){ + System.out.println("outputFolder and/or resultFolder not set, probably initialisation failed"); + return; + } + try { + if(!this.persistValidator && Files.exists(this.gocOutputFolder)){ + FileUtils.deleteDirectory(this.gocOutputFolder.toFile()); + } + else{ + System.out.println("Generated validator persisted at: "+this.gocOutputFolder.toAbsolutePath().toString()); + } + if(!this.persistResult && Files.exists(this.resultFolder)){ + FileUtils.deleteDirectory(this.resultFolder.toFile()); + } + else { + System.out.println("Validation result is persisted at: "+this.resultFolder.toAbsolutePath().toString()); + } + System.out.println("Workspace cleaned successfully"); + } catch (IOException e) { + System.out.println("Cleaning failed, please check the stacktrace"); + e.printStackTrace(); + } + } + + + private Path initWorkspace(String prefix, String type) throws EnvironementException { + if(prefix == null){ + throw new EnvironementException("GOC "+type+" prefix path is not set in "+EnvironementConfiguration.APPLICATION_PROPERTIES_FILE); + } + File outputFolderDir = new File(TEMPORARY_FOLDER+prefix); + if(!outputFolderDir.exists()){ + if(outputFolderDir.mkdirs()){ + System.out.println("INFO: "+type+" Temporary directory created at: "+TEMPORARY_FOLDER+prefix); + } + else { + throw new EnvironementException("Could not create GOC "+type); + } + } + else { + System.out.println("INFO: "+type+" Temporary directory exist already, if there was previous generation it will be overwritten"); + } + Path dir = outputFolderDir.toPath(); + try { + Path out = Files.createTempDirectory(dir,GENERATION_PREFIX); + return out; + } catch (IOException e) { + throw new EnvironementException(e.getMessage()); + } + } +} + diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/GOCTestEntry.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/GOCTestEntry.java new file mode 100644 index 0000000000000000000000000000000000000000..9512ba7730abedb2985500805a0c2a47616fa196 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/GOCTestEntry.java @@ -0,0 +1,7 @@ +package net.ihe.gazelle.goctests.interlay; + +public interface GOCTestEntry { + + void runSystemTest(String[] args); + +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/GOCTestEntryCLI.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/GOCTestEntryCLI.java new file mode 100644 index 0000000000000000000000000000000000000000..d951655f3909353aaed76369bfa2f7bf825ea392 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/GOCTestEntryCLI.java @@ -0,0 +1,60 @@ +package net.ihe.gazelle.goctests.interlay; + + +import net.ihe.gazelle.goctests.application.specifications.SpecificationType; +import net.ihe.gazelle.goctests.application.exceptions.ReportGenerationException; +import net.ihe.gazelle.goctests.application.exceptions.TestRunnerException; + +import net.ihe.gazelle.goctests.interlay.exceptions.EnvironementException; +import net.ihe.gazelle.goctests.interlay.exceptions.ResultTransformationException; +import net.ihe.gazelle.goctests.interlay.exceptions.SpecificationException; + +import org.kohsuke.args4j.CmdLineException; +import org.kohsuke.args4j.CmdLineParser; +import org.kohsuke.args4j.Option; + +/** + * GOC System Tests Command Line Interface + */ + +public class GOCTestEntryCLI implements GOCTestEntry { + + @Option(name = "--spec-type",aliases = {"-S"}, metaVar = "Specification Test Type", + usage = "Specification test from list (see Readme.md)", required = false) + private String specificationTypeString; + + public void runSystemTest(String[] args){ + CmdLineParser parser = new CmdLineParser(this); + + SpecificationType specificationType; + try { + parser.parseArgument(args); + if(specificationTypeString == null){ + specificationType = SpecificationType.GLOBAL; + } + else{ + specificationType = SpecificationType.of(specificationTypeString); + } + if(specificationType == null){ + throw new SpecificationException("Provided specification not recognized, " + + "please choose from the following list: "+SpecificationType.getPossibleValues()); + } + + SystemTestExecutor executor = new SystemTestExecutor(specificationType); + executor.execute(); + + } catch (CmdLineException | SpecificationException | TestRunnerException + | ReportGenerationException | ResultTransformationException | EnvironementException e) { + e.printStackTrace(); + } + + } + + public static void main(String[] args) { + GOCTestEntryCLI gocTests = new GOCTestEntryCLI(); + gocTests.runSystemTest(args); + + } + + +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/ProcessExecutor.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/ProcessExecutor.java new file mode 100644 index 0000000000000000000000000000000000000000..45de6c8432db0fcc6d2a75c2fec7b23d93343759 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/ProcessExecutor.java @@ -0,0 +1,13 @@ +package net.ihe.gazelle.goctests.interlay; + +import net.ihe.gazelle.goctests.interlay.exceptions.ProcessExecutionException; + +import java.util.List; + +public interface ProcessExecutor { + + void executeProcess(String command) throws ProcessExecutionException; + + List<String> executeProcessAndReturn(String command) throws ProcessExecutionException; + +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/ProcessExecutorBash.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/ProcessExecutorBash.java new file mode 100644 index 0000000000000000000000000000000000000000..99c38947e04df591bee48b4c0658f1720fc6ec59 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/ProcessExecutorBash.java @@ -0,0 +1,67 @@ +package net.ihe.gazelle.goctests.interlay; + +import net.ihe.gazelle.goctests.interlay.exceptions.ProcessExecutionException; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.List; + +public class ProcessExecutorBash implements ProcessExecutor{ + + @Override + public List<String> executeProcessAndReturn(String command) throws ProcessExecutionException { + ArrayList<String> output; + try { + Process pr = Runtime.getRuntime().exec(command); + BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(pr.getInputStream())); + int result = pr.waitFor(); + if (result != 0){ + throw new ProcessExecutionException("Cannot execute process with code :" + result); + } + output = new ArrayList<>(); + String line = null ; + while((line = bufferedReader.readLine()) != null){ + output.add(line); + } + }catch (IOException e){ + throw new ProcessExecutionException("Failed to execute command",e); + } + catch (InterruptedException e){ + throw new ProcessExecutionException("Execution interrupted",e); + } + return output; + } + + @Override + public void executeProcess(String command) throws ProcessExecutionException { + + System.out.println("Executin command: "+command); + + try{ + Process pr = Runtime.getRuntime().exec(command); + int result = pr.waitFor(); + if (result != 0){ + throw new ProcessExecutionException("Cannot execute process with code :" + result); + } + BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream())); + String line; + System.out.println("Standard output of executing: "+command); + while((line = input.readLine()) != null){ + System.out.println(line); + } + BufferedReader errors = new BufferedReader(new InputStreamReader(pr.getErrorStream())); + System.out.println("Standard error of executing: "+command); + while((line = errors.readLine()) != null){ + System.out.println(line); + } + }catch (IOException e){ + throw new ProcessExecutionException("Failed to execute command: "+command,e); + } + catch (InterruptedException e){ + throw new ProcessExecutionException("Execution interrupted",e); + } + + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/RresourceRetreiverSystem.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/RresourceRetreiverSystem.java new file mode 100644 index 0000000000000000000000000000000000000000..42994558cdcc2602389ec614c499ac9b5dd7e005 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/RresourceRetreiverSystem.java @@ -0,0 +1,115 @@ +package net.ihe.gazelle.goctests.interlay; + +import net.ihe.gazelle.goctests.application.ResourceRetreiver; +import net.ihe.gazelle.goctests.application.specifications.SpecificationType; +import net.ihe.gazelle.goctests.application.exceptions.ConfigurationException; +import org.eclipse.emf.ecore.resource.impl.PlatformResourceURIHandlerImpl; + +import java.net.URL; +import java.util.regex.Pattern; + +/** + * Implementation of ResourceRetreiver API + * Loading resources from FileSystem (i.e <b>.properties</b> files) + */ +public class RresourceRetreiverSystem implements ResourceRetreiver { + + private final static String BBR_SUFFIX = ".bbr"; + + private final static String CDA_SUFFIX = ".cda"; + + private final static String EXPECTED_SUFFIX = ".expected"; + + private final static String EMPTY = ""; + + private final static String SPACE = " "; + + private static final String ADAPTATION_PATTERN_STRING = SPACE; + + private static final Pattern ADAPTATION_PATTERN = Pattern.compile(ADAPTATION_PATTERN_STRING); + + private static final String NULL_STRING = "Specification Type is null"; + + /** + * Retreive BBR resource from .properties specifications files with .bbr suffix + * @param specificationType + * @return URL of Resource + * @throws ConfigurationException + */ + @Override + public URL retreiveBBRResource(SpecificationType specificationType) throws ConfigurationException { + + if(specificationType == null){ + throw new ConfigurationException(NULL_STRING); + } + String specificationString = adaptSpecification(specificationType); + + String bbrPath = EnvironementConfiguration.getInstance().getProperty(specificationString+BBR_SUFFIX); + if(bbrPath == null){ + throw new ConfigurationException("BBR property not set correctly at: "+specificationString+BBR_SUFFIX); + } + URL bbrURL = RresourceRetreiverSystem.class.getClassLoader().getResource(bbrPath); + if(bbrURL == null){ + throw new ConfigurationException("Could not retreive BBR Resource at: "+bbrPath); + } + return bbrURL; + } + + /** + * Retreive CDA resource from .properties specifications files with .cda suffix + * @param specificationType + * @return + * @throws ConfigurationException + */ + @Override + public URL retreiveCDAResource(SpecificationType specificationType) throws ConfigurationException { + + if(specificationType == null){ + throw new ConfigurationException(NULL_STRING); + } + String specificationString = adaptSpecification(specificationType); + + String cdaPath = EnvironementConfiguration.getInstance().getProperty(specificationString+CDA_SUFFIX); + if(cdaPath == null){ + throw new ConfigurationException("CDA property not set correctly at: "+specificationString+CDA_SUFFIX); + } + URL cdaURL = RresourceRetreiverSystem.class.getClassLoader().getResource(cdaPath); + if(cdaURL == null){ + throw new ConfigurationException("Could not retreive CDA Resource at: "+cdaPath); + } + return cdaURL; + } + + /** + * Retreive ExpectedResult resource from .properties specifications files with .expected suffix + * @param specificationType + * @return + * @throws ConfigurationException + */ + @Override + public URL retreiveExpectedResultResource(SpecificationType specificationType) throws ConfigurationException { + + if(specificationType == null){ + throw new ConfigurationException(NULL_STRING); + } + String specificationString = adaptSpecification(specificationType); + + String specificationPath = EnvironementConfiguration.getInstance().getProperty(specificationString+EXPECTED_SUFFIX); + if(specificationPath == null){ + throw new ConfigurationException("Expected result configuration not found"); + } + URL url = RresourceRetreiverSystem.class.getClassLoader().getResource(specificationPath); + if(url == null){ + throw new ConfigurationException("Could not load Expected Result resources at: "+specificationString+EXPECTED_SUFFIX); + } + return url; + } + + + /** + * {@inheritDoc} + */ + public String adaptSpecification(SpecificationType specificationType){ + return ADAPTATION_PATTERN.matcher(specificationType.getValue()).replaceAll(EMPTY); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/SystemTestExecutor.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/SystemTestExecutor.java new file mode 100644 index 0000000000000000000000000000000000000000..b530d444a1457544cf8f897e83bad60ec38d51fa --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/SystemTestExecutor.java @@ -0,0 +1,96 @@ +package net.ihe.gazelle.goctests.interlay; + + +import net.ihe.gazelle.goctests.application.specifications.SpecificationTestRunner; +import net.ihe.gazelle.goctests.application.models.TestResult; +import net.ihe.gazelle.goctests.application.exceptions.TestRunnerException; +import net.ihe.gazelle.goctests.application.exceptions.ReportGenerationException; + +import net.ihe.gazelle.goctests.application.specifications.SpecificationType; +import net.ihe.gazelle.goctests.interlay.exceptions.EnvironementException; +import net.ihe.gazelle.goctests.interlay.exceptions.SpecificationException; +import net.ihe.gazelle.goctests.interlay.exceptions.ResultTransformationException; +import net.ihe.gazelle.goctests.interlay.factories.FactoryProvider; +import net.ihe.gazelle.goctests.interlay.factories.SpecificationFactory; +import net.ihe.gazelle.goctests.interlay.transformers.TestResultTransformer; +import net.ihe.gazelle.goctests.interlay.transformers.TestResultTransformerFactory; +import net.ihe.gazelle.goctests.interlay.transformers.TransformationType; + + +final public class SystemTestExecutor { + + private SpecificationType specificationType; + + public SystemTestExecutor(SpecificationType specificationType) { + this.specificationType = specificationType; + } + + /** + * Main entry point to execute the GOC System Testing, and return testResult, + * for better integration with other modules + * @return The raw TestResult Object + * @throws SpecificationException + * @throws TestRunnerException + * @throws ReportGenerationException + * @throws ResultTransformationException + */ + public TestResult execute() throws ReportGenerationException, TestRunnerException, SpecificationException, + EnvironementException, ResultTransformationException { + + TestResult testResult = new TestResult(); + try{ + if(specificationType == null){ + throw new SpecificationException("Specification is null"); + } + + EnvironementConfiguration.getInstance().initEnvironement(); + + SpecificationFactory factory = FactoryProvider.create(specificationType); + SpecificationTestRunner runner = factory.createTestRunner(); + if(runner == null){ + throw new SpecificationException("Specification not implemented"); + } + + runner.runTest(); + testResult = runner.generateResult(); + + String transformationString = EnvironementConfiguration.getInstance().getProperty("result.type"); + TransformationType transformationType; + if(transformationString == null){ + transformationType = TransformationType.STANDARD; + } + else{ + transformationType = TransformationType.of(transformationString); + } + if(transformationType == null){ + throw new ResultTransformationException("Invalid Transformation Tyoe at: result.type"); + } + + TestResultTransformer transformer = TestResultTransformerFactory.createTestResultTransformer(transformationType); + if(transformer == null){ + throw new ResultTransformationException("An Error has occured during transformation, probably type not implemented yet"); + } + + transformer.transformResult(testResult); + + return testResult; + + } catch (ReportGenerationException e) { + throw new ReportGenerationException("Problem during report generation",e); + } catch (TestRunnerException e) { + throw new TestRunnerException("Problem during running test",e); + } catch (SpecificationException e) { + throw new SpecificationException("Probelm with specification",e); + } catch (EnvironementException e) { + throw new EnvironementException("Something wrong with the environement configuration",e); + } catch (ResultTransformationException e) { + System.err.println("ERROR: Transformation Failed, report not generated, but Test performed"); + return testResult; + } finally { + EnvironementConfiguration.getInstance().cleanEnvironement(); + } + + } + + +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/ValidatorGeneratorImpl.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/ValidatorGeneratorImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..56571131e95d79e634d72c0a3f82d9b980d4c1b8 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/ValidatorGeneratorImpl.java @@ -0,0 +1,77 @@ +package net.ihe.gazelle.goctests.interlay; + +import net.ihe.gazelle.goctests.interlay.exceptions.ProcessExecutionException; +import net.ihe.gazelle.goctests.application.exceptions.ValidatorGenerationException; +import net.ihe.gazelle.goctests.application.models.GeneratedValidator; +import net.ihe.gazelle.goctests.application.ValidatorGenerator; +import net.ihe.gazelle.tempmodel.org.decor.art.utils.StreamBBRResource; +import net.ihe.gazelle.lib.hl7templatespackager.application.ProjectNaming; +import net.ihe.gazelle.lib.hl7templatespackager.application.ValidatorConfiguration; +import net.ihe.gazelle.lib.hl7templatespackager.peripherals.GOCExecutor; +import net.ihe.gazelle.goctests.interlay.utils.ValidatorGeneratorUtils; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.nio.file.Path; + + +public class ValidatorGeneratorImpl implements ValidatorGenerator { + + + @Override + public GeneratedValidator generateValidator(URL bbrUrl, String outputFolder, String mvn) throws ValidatorGenerationException { + + System.out.println("Start generation for test"); + + + //Run GOC + GOCExecutor gocExecutor = new GOCExecutor(outputFolder); + ValidatorConfiguration validatorConfiguration = gocExecutor.execute(new StreamBBRResource(bbrUrl),mvn); + + StringBuilder logPath = new StringBuilder(outputFolder) + .append("/").append(GeneratedValidator.ROOT_LOG_DIRECTORY) + .append("/").append(GeneratedValidator.ROOT_LOG_PREFIX) + .append(gocExecutor.getGenerationDate()); + + if(validatorConfiguration == null){ + throw new ValidatorGenerationException("Please refer to the logs at: "+ logPath.toString()); + } + + //Buil Generated Validator Object + ProjectNaming projectNaming = validatorConfiguration.getProjectNaming(); + String projectName = projectNaming.getProjectName(); + + GeneratedValidator validator = new GeneratedValidator(outputFolder, gocExecutor.getGenerationDate(),projectName,bbrUrl.getPath()); + + // Setup Rights + try { + ValidatorGeneratorUtils.makeGeneratedValidatorExecutable(validator); + System.out.println("Validator generated successfully"); + } catch (ProcessExecutionException | IOException e) { + throw new ValidatorGenerationException("Failed to make generated validator executable",e); + } + + return validator; + + } + + @Override + public GeneratedValidator generateValidator(URL bbrURL) throws ValidatorGenerationException { + + // Get maven path + String mvn = EnvironementConfiguration.getInstance().getProperty("maven.path"); + if(mvn == null){ + throw new ValidatorGenerationException("Maven path is not set in "+EnvironementConfiguration.APPLICATION_PROPERTIES_FILE); + } + + // Check if GOC environment is setup + Path path = EnvironementConfiguration.getInstance().getGocOutputFolder(); + if(path == null){ + throw new ValidatorGenerationException("GOC Output folder is not set"); + } + + return generateValidator(bbrURL,path.toAbsolutePath().toString(),mvn); + + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/exceptions/EnvironementException.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/exceptions/EnvironementException.java new file mode 100644 index 0000000000000000000000000000000000000000..62998350db39cb15878d1851b639c5994016e3d9 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/exceptions/EnvironementException.java @@ -0,0 +1,14 @@ +package net.ihe.gazelle.goctests.interlay.exceptions; + +public class EnvironementException extends Exception{ + + private static final String EXCEPTION_MESSAGE = "Environement Exception: "; + + public EnvironementException(String message) { + super(EXCEPTION_MESSAGE+message); + } + + public EnvironementException(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/interlay/exceptions/ProcessExecutionException.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/exceptions/ProcessExecutionException.java new file mode 100644 index 0000000000000000000000000000000000000000..4860a03a5f3b376d465a459366a66ce65686cff4 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/exceptions/ProcessExecutionException.java @@ -0,0 +1,14 @@ +package net.ihe.gazelle.goctests.interlay.exceptions; + +public class ProcessExecutionException extends Exception{ + + private static final String EXCEPTION_MESSAGE = "Process Execution failed: "; + + public ProcessExecutionException(String message) { + super(EXCEPTION_MESSAGE+message); + } + + public ProcessExecutionException(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/interlay/exceptions/ResultTransformationException.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/exceptions/ResultTransformationException.java new file mode 100644 index 0000000000000000000000000000000000000000..9e5268361121d12980228292f56820e95771223c --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/exceptions/ResultTransformationException.java @@ -0,0 +1,14 @@ +package net.ihe.gazelle.goctests.interlay.exceptions; + +public class ResultTransformationException extends Exception{ + + private static final String EXCEPTION_MESSAGE = "Result Transformation failed: "; + + public ResultTransformationException(String message) { + super(EXCEPTION_MESSAGE+message); + } + + public ResultTransformationException(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/interlay/exceptions/SpecificationException.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/exceptions/SpecificationException.java new file mode 100644 index 0000000000000000000000000000000000000000..240bd7b6e21d0cd9530000ad6ff05e5b115e6166 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/exceptions/SpecificationException.java @@ -0,0 +1,14 @@ +package net.ihe.gazelle.goctests.interlay.exceptions; + +public class SpecificationException extends Exception{ + + private static final String EXCEPTION_MESSAGE = "Problem with provided specification: "; + + public SpecificationException(String message) { + super(EXCEPTION_MESSAGE+message); + } + + public SpecificationException(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/interlay/exceptions/TestResultMarhsallException.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/exceptions/TestResultMarhsallException.java new file mode 100644 index 0000000000000000000000000000000000000000..4adcb8096bc5b64c5234fe1f567f492f2a9399e2 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/exceptions/TestResultMarhsallException.java @@ -0,0 +1,14 @@ +package net.ihe.gazelle.goctests.interlay.exceptions; + +public class TestResultMarhsallException extends Exception{ + + private static final String EXCEPTION_MESSAGE = "Failed to marshall Test Result to XML: "; + + public TestResultMarhsallException(String message) { + super(EXCEPTION_MESSAGE+message); + } + + public TestResultMarhsallException(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/interlay/factories/CardinalityFactory.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/CardinalityFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..00d61b63c311b1bc8890f0395972e5b1e84803a7 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/CardinalityFactory.java @@ -0,0 +1,23 @@ +package net.ihe.gazelle.goctests.interlay.factories; + +import net.ihe.gazelle.goctests.application.specifications.CardinalityTestRunner; +import net.ihe.gazelle.goctests.application.specifications.SpecificationTestRunner; +import net.ihe.gazelle.goctests.application.oracles.CardinalityTestOracle; +import net.ihe.gazelle.goctests.application.oracles.TestOracle; +import net.ihe.gazelle.goctests.interlay.*; + +public class CardinalityFactory implements SpecificationFactory{ + + + + @Override + public SpecificationTestRunner createTestRunner() { + return new CardinalityTestRunner(new RresourceRetreiverSystem(),new CDAValidatorImpl(new ProcessExecutorBash()), + new ValidatorGeneratorImpl(), createTestOracle()); + } + + @Override + public TestOracle createTestOracle() { + return new CardinalityTestOracle(new RresourceRetreiverSystem(),new DetailedResultAdapterImpl()); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/ChoiceFactory.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/ChoiceFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..f06e155a56083c6a79db9a9bb31e5212b2b5a8ac --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/ChoiceFactory.java @@ -0,0 +1,21 @@ +package net.ihe.gazelle.goctests.interlay.factories; + +import net.ihe.gazelle.goctests.application.oracles.ChoiceTestOracle; +import net.ihe.gazelle.goctests.application.oracles.TestOracle; +import net.ihe.gazelle.goctests.application.specifications.ChoiceTestRunner; +import net.ihe.gazelle.goctests.application.specifications.SpecificationTestRunner; +import net.ihe.gazelle.goctests.interlay.*; + +public class ChoiceFactory implements SpecificationFactory{ + + @Override + public SpecificationTestRunner createTestRunner() { + return new ChoiceTestRunner(new RresourceRetreiverSystem(),new CDAValidatorImpl(new ProcessExecutorBash()), + new ValidatorGeneratorImpl(), createTestOracle()); + } + + @Override + public TestOracle createTestOracle() { + return new ChoiceTestOracle(new RresourceRetreiverSystem(),new DetailedResultAdapterImpl()); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/ClosedFactory.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/ClosedFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..89b403e8da06163b756f53781bb56314fe47e224 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/ClosedFactory.java @@ -0,0 +1,21 @@ +package net.ihe.gazelle.goctests.interlay.factories; + +import net.ihe.gazelle.goctests.application.oracles.ClosedTestOracle; +import net.ihe.gazelle.goctests.application.oracles.TestOracle; +import net.ihe.gazelle.goctests.application.specifications.ClosedSpecificationRunner; +import net.ihe.gazelle.goctests.application.specifications.SpecificationTestRunner; +import net.ihe.gazelle.goctests.interlay.*; + +public class ClosedFactory implements SpecificationFactory{ + + @Override + public SpecificationTestRunner createTestRunner() { + return new ClosedSpecificationRunner(new RresourceRetreiverSystem(),new CDAValidatorImpl(new ProcessExecutorBash()), + new ValidatorGeneratorImpl(), createTestOracle()); + } + + @Override + public TestOracle createTestOracle() { + return new ClosedTestOracle(new RresourceRetreiverSystem(),new DetailedResultAdapterImpl()); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/ContextFactory.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/ContextFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..f2041ab8c97a3e3a9b8ef1065d880a99868f4973 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/ContextFactory.java @@ -0,0 +1,20 @@ +package net.ihe.gazelle.goctests.interlay.factories; + +import net.ihe.gazelle.goctests.application.specifications.ContextTestRunner; +import net.ihe.gazelle.goctests.application.specifications.SpecificationTestRunner; +import net.ihe.gazelle.goctests.application.oracles.ContextTestOracle; +import net.ihe.gazelle.goctests.application.oracles.TestOracle; +import net.ihe.gazelle.goctests.interlay.*; + +public class ContextFactory implements SpecificationFactory{ + @Override + public SpecificationTestRunner createTestRunner() { + return new ContextTestRunner(new RresourceRetreiverSystem(),new CDAValidatorImpl(new ProcessExecutorBash()), + new ValidatorGeneratorImpl(), createTestOracle()); + } + + @Override + public TestOracle createTestOracle() { + return new ContextTestOracle(new RresourceRetreiverSystem(),new DetailedResultAdapterImpl()); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/DatatypeFactory.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/DatatypeFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..2b165d397194f9e8a8968830154547df6f0cfa54 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/DatatypeFactory.java @@ -0,0 +1,21 @@ +package net.ihe.gazelle.goctests.interlay.factories; + +import net.ihe.gazelle.goctests.application.oracles.DatatypeTestOracle; +import net.ihe.gazelle.goctests.application.oracles.TestOracle; +import net.ihe.gazelle.goctests.application.specifications.DatatypeTestRunner; +import net.ihe.gazelle.goctests.application.specifications.SpecificationTestRunner; +import net.ihe.gazelle.goctests.interlay.*; + +public class DatatypeFactory implements SpecificationFactory{ + + @Override + public SpecificationTestRunner createTestRunner() { + return new DatatypeTestRunner(new RresourceRetreiverSystem(),new CDAValidatorImpl(new ProcessExecutorBash()), + new ValidatorGeneratorImpl(), createTestOracle()); + } + + @Override + public TestOracle createTestOracle() { + return new DatatypeTestOracle(new RresourceRetreiverSystem(),new DetailedResultAdapterImpl()); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/FactoryProvider.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/FactoryProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..34bd61d126ff932dcbe18f95316dad2a9d8c6101 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/FactoryProvider.java @@ -0,0 +1,33 @@ +package net.ihe.gazelle.goctests.interlay.factories; + +import net.ihe.gazelle.goctests.application.specifications.SpecificationType; + +final public class FactoryProvider { + + private FactoryProvider(){} + + public static SpecificationFactory create(SpecificationType specificationType){ + switch (specificationType){ + case CARDINALITY: + return new CardinalityFactory(); + case MANDATORY: + return new MandatoryFactory(); + case CONTEXT: + return new ContextFactory(); + case VOCABULARY: + return new VocabularyFactory(); + case DATATYPE: + return new DatatypeFactory(); + case FIXEDVAL: + return new FixedvalFactory(); + case CLOSED: + return new ClosedFactory(); + case CHOICE: + return new ChoiceFactory(); + case GLOBAL: + return new GlobalFactory(); + default: + return null; + } + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/FixedvalFactory.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/FixedvalFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..1bdcd0aacf44f8d4fb381f3890a305417e41b741 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/FixedvalFactory.java @@ -0,0 +1,21 @@ +package net.ihe.gazelle.goctests.interlay.factories; + +import net.ihe.gazelle.goctests.application.oracles.FixedvalTestOracle; +import net.ihe.gazelle.goctests.application.oracles.TestOracle; +import net.ihe.gazelle.goctests.application.specifications.FixedvalTestRunner; +import net.ihe.gazelle.goctests.application.specifications.SpecificationTestRunner; +import net.ihe.gazelle.goctests.interlay.*; + +public class FixedvalFactory implements SpecificationFactory{ + + @Override + public SpecificationTestRunner createTestRunner() { + return new FixedvalTestRunner(new RresourceRetreiverSystem(),new CDAValidatorImpl(new ProcessExecutorBash()), + new ValidatorGeneratorImpl(), createTestOracle()); + } + + @Override + public TestOracle createTestOracle() { + return new FixedvalTestOracle(new RresourceRetreiverSystem(),new DetailedResultAdapterImpl()); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/GlobalFactory.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/GlobalFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..7db571908bafc840a273d97bc83b6d302e927e9e --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/GlobalFactory.java @@ -0,0 +1,20 @@ +package net.ihe.gazelle.goctests.interlay.factories; + +import net.ihe.gazelle.goctests.application.specifications.GlobalTestRunner; +import net.ihe.gazelle.goctests.application.specifications.SpecificationTestRunner; +import net.ihe.gazelle.goctests.application.oracles.GlobalTestOracle; +import net.ihe.gazelle.goctests.application.oracles.TestOracle; +import net.ihe.gazelle.goctests.interlay.*; + +public class GlobalFactory implements SpecificationFactory{ + @Override + public SpecificationTestRunner createTestRunner() { + return new GlobalTestRunner(new RresourceRetreiverSystem(),new CDAValidatorImpl(new ProcessExecutorBash()), + new ValidatorGeneratorImpl(), createTestOracle()); + } + + @Override + public TestOracle createTestOracle() { + return new GlobalTestOracle(new RresourceRetreiverSystem(),new DetailedResultAdapterImpl()); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/MandatoryFactory.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/MandatoryFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..4c206617b96b1d49a8ec8f4044a37ab0838823d3 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/MandatoryFactory.java @@ -0,0 +1,21 @@ +package net.ihe.gazelle.goctests.interlay.factories; + +import net.ihe.gazelle.goctests.application.specifications.MandatoryTestRunner; +import net.ihe.gazelle.goctests.application.specifications.SpecificationTestRunner; +import net.ihe.gazelle.goctests.application.oracles.MandatoryTestOracle; +import net.ihe.gazelle.goctests.application.oracles.TestOracle; +import net.ihe.gazelle.goctests.interlay.*; + +public class MandatoryFactory implements SpecificationFactory{ + + @Override + public SpecificationTestRunner createTestRunner() { + return new MandatoryTestRunner(new RresourceRetreiverSystem(),new CDAValidatorImpl(new ProcessExecutorBash()), + new ValidatorGeneratorImpl(), createTestOracle()); + } + + @Override + public TestOracle createTestOracle() { + return new MandatoryTestOracle(new RresourceRetreiverSystem(),new DetailedResultAdapterImpl()); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/SpecificationFactory.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/SpecificationFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..7e4a54ba0f0db830bc08b70caafa2e82794c70c3 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/SpecificationFactory.java @@ -0,0 +1,12 @@ +package net.ihe.gazelle.goctests.interlay.factories; + +import net.ihe.gazelle.goctests.application.specifications.SpecificationTestRunner; +import net.ihe.gazelle.goctests.application.oracles.TestOracle; + +public interface SpecificationFactory { + + SpecificationTestRunner createTestRunner(); + + TestOracle createTestOracle(); + +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/VocabularyFactory.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/VocabularyFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..27442d0aefeb4db3cd47ef0b0cbbf250b59b8113 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/factories/VocabularyFactory.java @@ -0,0 +1,21 @@ +package net.ihe.gazelle.goctests.interlay.factories; + +import net.ihe.gazelle.goctests.application.specifications.SpecificationTestRunner; +import net.ihe.gazelle.goctests.application.specifications.VocabularyTestRunner; +import net.ihe.gazelle.goctests.application.oracles.TestOracle; +import net.ihe.gazelle.goctests.application.oracles.VocabularyTestOracle; +import net.ihe.gazelle.goctests.interlay.*; + +public class VocabularyFactory implements SpecificationFactory{ + + @Override + public SpecificationTestRunner createTestRunner() { + return new VocabularyTestRunner(new RresourceRetreiverSystem(),new CDAValidatorImpl(new ProcessExecutorBash()) + ,new ValidatorGeneratorImpl(), createTestOracle()); + } + + @Override + public TestOracle createTestOracle() { + return new VocabularyTestOracle(new RresourceRetreiverSystem(),new DetailedResultAdapterImpl()); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/transformers/StandardTestResultTransformer.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/transformers/StandardTestResultTransformer.java new file mode 100644 index 0000000000000000000000000000000000000000..e8f25a5e8ac49e1f4bb016650d62afce06a56aa6 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/transformers/StandardTestResultTransformer.java @@ -0,0 +1,42 @@ +package net.ihe.gazelle.goctests.interlay.transformers; + +import net.ihe.gazelle.goctests.application.models.TestResult; +import net.ihe.gazelle.goctests.application.specifications.SpecificationType; +import net.ihe.gazelle.goctests.interlay.utils.PrintersUtils; +import net.ihe.gazelle.goctests.interlay.exceptions.ResultTransformationException; + +public class StandardTestResultTransformer implements TestResultTransformer { + + private static final String HEADER = "============ START TEST RESULT ============"; + + private static final String FOOTER = "============ END TEST RESULT ============"; + + @Override + public void transformResult(TestResult testResult) throws ResultTransformationException { + System.out.println(testResult); + System.out.println(HEADER); + System.out.println("Test performed at: "+testResult.getFormattedValidationDate()); + System.out.println("Test Result: "+getFormattedTestResult(testResult.getOracleResult().isValid())); + System.out.println("Test Type: "+ PrintersUtils.info(testResult.getSpecificationType().getValue())); + System.out.println("Processed Rules: "+testResult.getOracleResult().getProcessed().size()); + System.out.println("Excpected Rules: "+testResult.getOracleResult().getExpectedElements().size()); + System.out.println("Missing Rules: "+getFormattedMissingRules(testResult.getOracleResult().getMissedElements().size())); + System.out.println("Test Global: "+getFormattedIsGlobal(testResult.getSpecificationType())); + System.out.println("Used CDA: "+testResult.getUsedCDA()); + System.out.println("Used BBR: "+testResult.getUsedValidator().getUsedBBR()); + System.out.println(FOOTER); + } + + private static String getFormattedTestResult(boolean passed){ + return passed? PrintersUtils.success("PASSED"): PrintersUtils.failed("FAILED"); + } + + private static String getFormattedIsGlobal(SpecificationType specificationType){ + return specificationType.equals(SpecificationType.GLOBAL)? + PrintersUtils.success("True"): PrintersUtils.failed("False"); + } + + private static String getFormattedMissingRules(int missingRules){ + return missingRules==0? PrintersUtils.success(Integer.toString(missingRules)): PrintersUtils.failed(Integer.toString(missingRules)); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/transformers/TestResultTransformer.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/transformers/TestResultTransformer.java new file mode 100644 index 0000000000000000000000000000000000000000..3bbe3360f5bdf3749157a901b3f0bc38cdfd1819 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/transformers/TestResultTransformer.java @@ -0,0 +1,10 @@ +package net.ihe.gazelle.goctests.interlay.transformers; + +import net.ihe.gazelle.goctests.application.models.TestResult; +import net.ihe.gazelle.goctests.interlay.exceptions.ResultTransformationException; + +public interface TestResultTransformer { + + + void transformResult(TestResult testResult) throws ResultTransformationException; +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/transformers/TestResultTransformerFactory.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/transformers/TestResultTransformerFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..17a16f3cdd082729899001ca5a81aa32f966038a --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/transformers/TestResultTransformerFactory.java @@ -0,0 +1,18 @@ +package net.ihe.gazelle.goctests.interlay.transformers; + +public class TestResultTransformerFactory { + + private TestResultTransformerFactory(){} + + public static TestResultTransformer createTestResultTransformer(TransformationType transformationType){ + switch (transformationType){ + case STANDARD: + return new StandardTestResultTransformer(); + case XML: + return new XMLTestResultTransformer(); + + default: + return null; + } + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/transformers/TransformationType.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/transformers/TransformationType.java new file mode 100644 index 0000000000000000000000000000000000000000..c6bebff334775b1848e5a6d38b11eaf9f6f804cf --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/transformers/TransformationType.java @@ -0,0 +1,26 @@ +package net.ihe.gazelle.goctests.interlay.transformers; + +public enum TransformationType { + + STANDARD("standard"), + XML("xml"); + + private String value; + + private TransformationType(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + public static TransformationType of(String value){ + for(TransformationType transformationType : TransformationType.values()){ + if(transformationType.getValue().equals(value)){ + return transformationType; + } + } + return null; + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/transformers/XMLTestResultTransformer.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/transformers/XMLTestResultTransformer.java new file mode 100644 index 0000000000000000000000000000000000000000..1baccbfdfaabfed0c4fa4b6fbea4b116475cb880 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/transformers/XMLTestResultTransformer.java @@ -0,0 +1,49 @@ +package net.ihe.gazelle.goctests.interlay.transformers; + +import net.ihe.gazelle.goctests.application.models.NotificationElements; +import net.ihe.gazelle.goctests.application.models.TestResult; +import net.ihe.gazelle.goctests.application.models.TestResultReport; +import net.ihe.gazelle.goctests.interlay.exceptions.ResultTransformationException; +import net.ihe.gazelle.goctests.interlay.exceptions.TestResultMarhsallException; +import net.ihe.gazelle.goctests.interlay.utils.TestResultMarshaller; + +import java.text.SimpleDateFormat; + +public class XMLTestResultTransformer implements TestResultTransformer{ + + private static final SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy-HH-mm-ss"); + + private static final String XML_EXTENSION = ".xml"; + + private static final String DASH = "-"; + + @Override + public void transformResult(TestResult testResult) throws ResultTransformationException { + + try { + String result = testResult.getOracleResult().isValid()?"PASSED":"FAILED"; + + TestResultReport report = new TestResultReport(); + report.setTestResult(result); + report.setUsedValidator(testResult.getUsedValidator()); + report.setValidationDate(testResult.getFormattedValidationDate()); + report.setSpecification(testResult.getSpecificationType().getValue()); + report.setExpectedElements(testResult.getOracleResult().getExpectedElements().size()); + report.setProcessedElements(testResult.getOracleResult().getProcessed().size()); + report.setMissedElements(new NotificationElements(testResult.getOracleResult().getMissedElements())); + report.setUnexpectedElements(new NotificationElements(testResult.getOracleResult().getUnexpectedElements())); + + StringBuilder reportFileName = new StringBuilder(testResult.getSpecificationType().getValue()) + .append(DASH) + .append(formatter.format(testResult.getValidationDate())) + .append(XML_EXTENSION); + + String savedAt = TestResultMarshaller.save(report, reportFileName.toString()); + System.out.println("Report Transformed to XML at: "+savedAt); + + } catch (TestResultMarhsallException e) { + throw new ResultTransformationException("could not save report as XML",e); + } + + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/utils/PrintersUtils.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/utils/PrintersUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..ceca613636f29f8e0996a7d823c85997da89dc4f --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/utils/PrintersUtils.java @@ -0,0 +1,35 @@ +package net.ihe.gazelle.goctests.interlay.utils; + + + +public class PrintersUtils { + + public static final String ANSI_RESET = "\u001B[0m"; + public static final String ANSI_BLACK = "\u001B[30m"; + public static final String ANSI_RED = "\u001B[31m"; + public static final String ANSI_GREEN = "\u001B[32m"; + public static final String ANSI_YELLOW = "\u001B[33m"; + public static final String ANSI_BLUE = "\u001B[34m"; + public static final String ANSI_PURPLE = "\u001B[35m"; + public static final String ANSI_CYAN = "\u001B[36m"; + public static final String ANSI_WHITE = "\u001B[37m"; + + private PrintersUtils(){} + + public static String success(String string){ + return ANSI_RESET+ANSI_GREEN+string+ANSI_RESET; + } + + public static String failed(String string){ + return ANSI_RESET+ANSI_RED+string+ANSI_RESET; + } + + public static String warning(String string){ + return ANSI_RESET+ANSI_YELLOW+string+ANSI_RESET; + } + + public static String info(String string){ + return ANSI_RESET+ANSI_BLUE+string+ANSI_RESET; + } + +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/utils/StringUtils.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/utils/StringUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..89ef8e08ee94fbe60c8088c697cbee8a39c2b55f --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/utils/StringUtils.java @@ -0,0 +1,23 @@ +package net.ihe.gazelle.goctests.interlay.utils; + +import java.util.Random; + +final public class StringUtils { + + private StringUtils(){} + + private static final Random random = new Random(); + + public static String getRandomString(int length){ + + int leftLimit = 97; // letter 'a' + int rightLimit = 122; // letter 'z' + StringBuilder buffer = new StringBuilder(length); + for (int i = 0; i < length; i++) { + int randomLimitedInt = leftLimit + (int) + (random.nextFloat() * (rightLimit - leftLimit + 1)); + buffer.append((char) randomLimitedInt); + } + return buffer.toString(); + } +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/utils/TestResultMarshaller.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/utils/TestResultMarshaller.java new file mode 100644 index 0000000000000000000000000000000000000000..0ae23b418c49abff880b4b1474269ebeb6e2d009 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/utils/TestResultMarshaller.java @@ -0,0 +1,51 @@ +package net.ihe.gazelle.goctests.interlay.utils; + +import net.ihe.gazelle.goctests.application.models.TestResultReport; +import net.ihe.gazelle.goctests.interlay.EnvironementConfiguration; +import net.ihe.gazelle.goctests.interlay.exceptions.TestResultMarhsallException; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; + +final public class TestResultMarshaller { + + private TestResultMarshaller(){} + + public static String save(TestResultReport testResultReport, String fileName, String directory) throws TestResultMarhsallException { + + + if (!Files.isDirectory(Path.of(directory))){ + throw new TestResultMarhsallException("The path "+directory+" doesn't exist or not a directory"); + } + + String reportPath = directory+"/"+fileName; + File file = new File(reportPath); + + try { + JAXBContext jaxbContext = JAXBContext.newInstance(TestResultReport.class); + Marshaller marshaller = jaxbContext.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); + marshaller.marshal(testResultReport,file); + } catch (JAXBException e) { + throw new TestResultMarhsallException("Marshalling failed",e); + } + return reportPath; + } + + + public static String save(TestResultReport testResultReport, String fileName) throws TestResultMarhsallException { + String xmlReportPath = EnvironementConfiguration.getInstance().getProperty("result.type.xmlpath"); + if(xmlReportPath == null){ + throw new TestResultMarhsallException("The XML report path is not set in application.properties file, could not marshall result"); + } + + return save(testResultReport,fileName,xmlReportPath); + + } + + +} diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/utils/ValidatorGeneratorUtils.java b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/utils/ValidatorGeneratorUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..85643139e5e6ffe27acccffc826f2115b669a3a9 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/java/net/ihe/gazelle/goctests/interlay/utils/ValidatorGeneratorUtils.java @@ -0,0 +1,44 @@ +package net.ihe.gazelle.goctests.interlay.utils; + +import net.ihe.gazelle.goctests.interlay.exceptions.ProcessExecutionException; +import net.ihe.gazelle.goctests.application.exceptions.ValidatorGenerationException; +import net.ihe.gazelle.goctests.application.models.GeneratedValidator; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.attribute.PosixFilePermission; +import java.util.EnumSet; + +final public class ValidatorGeneratorUtils { + + private ValidatorGeneratorUtils(){}; + + + /** + * This utility method makes the validator executable with POSIX Permessions for 'OWNER'. + * The method could be used to check if the generation process succeeded + * @param validator + * @throws ProcessExecutionException + * @throws ValidatorGenerationException + */ + + public static void makeGeneratedValidatorExecutable(GeneratedValidator validator) throws ProcessExecutionException, ValidatorGenerationException, IOException { + if(validator == null){ + throw new ValidatorGenerationException("Validator not defined: NULL"); + } + String validatorBinary = validator.getValidatorBinaryPath(); + Path validatorBinaryPath = Path.of(validatorBinary); + if(!Files.exists(validatorBinaryPath)){ + throw new ValidatorGenerationException("Validator binary not found at: "+validatorBinary); + } + if(Files.isExecutable(validatorBinaryPath)){ + System.out.println("INFO: Validator Binary is already executable"); + } + else{ + Files.setPosixFilePermissions(validatorBinaryPath,EnumSet.of(PosixFilePermission.OWNER_EXECUTE, PosixFilePermission.OWNER_READ)); + System.out.println("Rights updated for validator"); + } + } + +} 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 0000000000000000000000000000000000000000..bed2470c1ef2ed43c5acf104fa983d4e87ad40eb --- /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 0000000000000000000000000000000000000000..99ce50e53204fe0a87b1f113f867f3e1228a0385 --- /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 0000000000000000000000000000000000000000..385aed8d67b6a29f25f6f8ccb6449090b8cbd5a4 --- /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 0000000000000000000000000000000000000000..77df1c9d138ed31752e0e5166fa79fdeefcbd78d --- /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/context/cda_context.xml b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/context/cda_context.xml new file mode 100644 index 0000000000000000000000000000000000000000..e49922a4f43e70cc85c3f9da69f75da0d20e81fe --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/context/cda_context.xml @@ -0,0 +1,104 @@ +<?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.7"/> + <code code="29545-1" codeSystem="2.11.111.1.111111.1.1" codeSystemName="LOINC"/> + + <!-- Test Assert 3 "xpath functions" ( 5 < title.length < 30) TRUE--> + <title>CDA For Test</title> + <entry> + + <!-- Test Assert 2 "Self attribute" (@negationInd not exist or "false") TRUE--> + <act classCode="ACT" moodCode="DEF" negationInd="false"> + + <!-- Test Assert 1 "child attribute" (@code shall be "11111" OR <priorityCode /> exist) TRUE--> + <code code="11111" xsi:type="CD" /> + <!-- DON'T UNCOMENT, PART OF TEST: <priorityCode code="12345" />--> + + </act> + </entry> + </section> + </component> + <component> + <section> + <templateId root="1.1.1.1.1.1.1.1"/> + <id root="1.2.3.5.8"/> + <code code="29545-1" codeSystem="2.11.111.1.111111.1.1" codeSystemName="LOINC"/> + + <!-- Test Assert 3 "xpath functions" ( 5 < title.length < 30) TRUE--> + <title>CDA For Test</title> + <entry> + + <!-- Test Assert 2 "Self attribute" (@negationInd not exist or "false") TRUE--> + <act classCode="ACT" moodCode="DEF" negationInd="false"> + + <!-- Test Assert 1 "child attribute" (@code shall be "11111" OR <priorityCode /> exist) TRUE--> + <code code="11112" /> + <priorityCode code="12345" /> + + </act> + </entry> + </section> + </component> + <component> + <section> + <templateId root="1.1.1.1.1.1.1.1"/> + <id root="1.2.3.5.9"/> + <code code="29545-1" codeSystem="2.11.111.1.111111.1.1" codeSystemName="LOINC"/> + + <!-- Test Assert 3 "xpath functions" ( 5 < title.length < 30) FALSE (just Warning)--> + <title>Test</title> + <entry> + + <!-- Test Assert 2 "Self attribute" (@negationInd not exist or "false") FALSE--> + <act classCode="ACT" moodCode="DEF" negationInd="true"> + + <!-- Test Assert 1 "child attribute" (@code shall be "11111" OR <priorityCode /> exist) FALSE--> + <code code="11112" /> + <!-- DON'T UNCOMENT, PART OF TEST: <priorityCode code="12345" />--> + + </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/context/decor_context.xml b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/context/decor_context.xml new file mode 100644 index 0000000000000000000000000000000000000000..57e5a5e298bf339a9b5b11f4222f12be76bdffb2 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/context/decor_context.xml @@ -0,0 +1,63 @@ +<decor> + + <project id="2.16.840.1.113883.2.4.3.11.60.22" prefix="context-" defaultLanguage="en-US"> + </project> + + <rules> + <template id="1.1.1.1.1.1.1.1" name="TestContext" displayName="Test Context 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"> + + <element name="cda:code" minimumMultiplicity="1" maximumMultiplicity="1" isMandatory="true" id="2.16.840.1.113883.3.1937.99.3.9.5342"> + <item label="CONF:0004"></item> + </element> + + <element name="cda:priorityCode" minimumMultiplicity="0" 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" /> + + <attribute name="negationInd" datatype="bl" isOptional="true" > + <item label="CONF:0006"></item> + </attribute> + + <!-- ITEM ELEMENT NOT ALLOWED IN <assert /> SO USING INCREMENTED NUMBERS TO + IDENTIFY TESTS (i.e AssertX) IN BOTH BBR & CDA--> + + <!-- Test element: Assert1 HAVE THREE INSTANCES, 1st TRUE, 2nd TRUE and 3rd FALSE "child attribute" --> + <assert test="cda:code[@code='11111'] or cda:priorityCode" role="error"></assert> + + <!-- Test element: Assert2 HAVE THREE INSTANCES, 1st TRUE, 2nd TRUE and 3rd FALSE "self attribute --> + <assert test="not(@negationInd) or .[@negationInd='false']" role="error"></assert> + + </element> + <item label="CONF:0007"></item> + </element> + + <!-- Assert3 Test element: HAVE THREE INSTANCES, 1st TRUE, 2nd TRUE and 3rd FALSE "xpath functions" + ( encode '<' to < )'--> + <assert test="string-length((cda:title/text()))>5 and string-length((cda:title/text()))<30" role="warning"></assert> + </element> + </template> + </rules> +</decor> \ No newline at end of file diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/resources/context/expected_context.xml b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/context/expected_context.xml new file mode 100644 index 0000000000000000000000000000000000000000..cb4d7f5081dff010f3d185ef9af6e08fbbc2d7a5 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/context/expected_context.xml @@ -0,0 +1,463 @@ + +<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>context001</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Context Template, the element defined by /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] shall verify this requirement : string-length((cda:title/text()))>5 and string-length((cda:title/text()))<30</Description> + <Identifiant>context-TestContext-context001</Identifiant> + <Type>Context</Type> + </Note> + <Note> + <Test>context002</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Context 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>context-TestContext-context002</Identifiant> + <assertion idScheme="context" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>context003</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Context 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>context-TestContext-context003</Identifiant> + <assertion idScheme="context" assertionId="CONF:0001"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>context004</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Context 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>context-TestContext-context004</Identifiant> + <assertion idScheme="context" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>context005</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Context 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>context-TestContext-context005</Identifiant> + <assertion idScheme="context" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>context006</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Context 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>context-TestContext-context006</Identifiant> + <assertion idScheme="context" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>context007</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Context 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>context-TestContext-context007</Identifiant> + <assertion idScheme="context" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>context008</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Context 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>context-TestContext-context008</Identifiant> + <assertion idScheme="context" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>context009</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Context 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>context-TestContext-context009</Identifiant> + <assertion idScheme="context" assertionId="CONF:0002"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>context010</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Context 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>context-TestContext-context010</Identifiant> + <assertion idScheme="context" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>context011</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Context 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>context-TestContext-context011</Identifiant> + <assertion idScheme="context" assertionId="CONF:0003"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>context012</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Context Template, the element defined by /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act shall verify this requirement : cda:code[@code='11111'] or cda:priorityCode</Description> + <Identifiant>context-TestContext-context012</Identifiant> + <assertion idScheme="context" assertionId="CONF:0007"/> + <Type>Context</Type> + </Note> + <Note> + <Test>context013</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Context Template, the element defined by /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act shall verify this requirement : not(@negationInd) or .[@negationInd='false']</Description> + <Identifiant>context-TestContext-context013</Identifiant> + <assertion idScheme="context" assertionId="CONF:0007"/> + <Type>Context</Type> + </Note> + <Note> + <Test>context014</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Context 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>context-TestContext-context014</Identifiant> + <assertion idScheme="context" assertionId="CONF:0004;CONF:0007"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>context015</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Context 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>context-TestContext-context015</Identifiant> + <assertion idScheme="context" assertionId="CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>context016</Test> + <Location>/ClinicalDocument/component/structuredBody/component[0]/section</Location> + <Description>In Test Context 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>context-TestContext-context016</Identifiant> + <assertion idScheme="context" assertionId="CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>context001</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Context Template, the element defined by /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] shall verify this requirement : string-length((cda:title/text()))>5 and string-length((cda:title/text()))<30</Description> + <Identifiant>context-TestContext-context001</Identifiant> + <Type>Context</Type> + </Note> + <Note> + <Test>context002</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Context 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>context-TestContext-context002</Identifiant> + <assertion idScheme="context" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>context003</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Context 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>context-TestContext-context003</Identifiant> + <assertion idScheme="context" assertionId="CONF:0001"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>context004</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Context 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>context-TestContext-context004</Identifiant> + <assertion idScheme="context" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>context005</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Context 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>context-TestContext-context005</Identifiant> + <assertion idScheme="context" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>context006</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Context 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>context-TestContext-context006</Identifiant> + <assertion idScheme="context" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>context007</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Context 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>context-TestContext-context007</Identifiant> + <assertion idScheme="context" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>context008</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Context 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>context-TestContext-context008</Identifiant> + <assertion idScheme="context" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>context009</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Context 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>context-TestContext-context009</Identifiant> + <assertion idScheme="context" assertionId="CONF:0002"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>context010</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Context 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>context-TestContext-context010</Identifiant> + <assertion idScheme="context" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>context011</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Context 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>context-TestContext-context011</Identifiant> + <assertion idScheme="context" assertionId="CONF:0003"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>context012</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Context Template, the element defined by /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act shall verify this requirement : cda:code[@code='11111'] or cda:priorityCode</Description> + <Identifiant>context-TestContext-context012</Identifiant> + <assertion idScheme="context" assertionId="CONF:0007"/> + <Type>Context</Type> + </Note> + <Note> + <Test>context013</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Context Template, the element defined by /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act shall verify this requirement : not(@negationInd) or .[@negationInd='false']</Description> + <Identifiant>context-TestContext-context013</Identifiant> + <assertion idScheme="context" assertionId="CONF:0007"/> + <Type>Context</Type> + </Note> + <Note> + <Test>context014</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Context 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>context-TestContext-context014</Identifiant> + <assertion idScheme="context" assertionId="CONF:0004;CONF:0007"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>context015</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Context 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>context-TestContext-context015</Identifiant> + <assertion idScheme="context" assertionId="CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>context016</Test> + <Location>/ClinicalDocument/component/structuredBody/component[1]/section</Location> + <Description>In Test Context 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>context-TestContext-context016</Identifiant> + <assertion idScheme="context" assertionId="CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Warning> + <Test>context001</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Context Template, the element defined by /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1'] shall verify this requirement : string-length((cda:title/text()))>5 and string-length((cda:title/text()))<30</Description> + <Identifiant>context-TestContext-context001</Identifiant> + <Type>Context</Type> + </Warning> + <Note> + <Test>context002</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Context 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>context-TestContext-context002</Identifiant> + <assertion idScheme="context" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>context003</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Context 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>context-TestContext-context003</Identifiant> + <assertion idScheme="context" assertionId="CONF:0001"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>context004</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Context 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>context-TestContext-context004</Identifiant> + <assertion idScheme="context" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>context005</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Context 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>context-TestContext-context005</Identifiant> + <assertion idScheme="context" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>context006</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Context 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>context-TestContext-context006</Identifiant> + <assertion idScheme="context" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>context007</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Context 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>context-TestContext-context007</Identifiant> + <assertion idScheme="context" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>context008</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Context 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>context-TestContext-context008</Identifiant> + <assertion idScheme="context" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>context009</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Context 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>context-TestContext-context009</Identifiant> + <assertion idScheme="context" assertionId="CONF:0002"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>context010</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Context 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>context-TestContext-context010</Identifiant> + <assertion idScheme="context" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>context011</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Context 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>context-TestContext-context011</Identifiant> + <assertion idScheme="context" assertionId="CONF:0003"/> + <Type>Cardinality</Type> + </Note> + <Error> + <Test>context012</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Context Template, the element defined by /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act shall verify this requirement : cda:code[@code='11111'] or cda:priorityCode</Description> + <Identifiant>context-TestContext-context012</Identifiant> + <assertion idScheme="context" assertionId="CONF:0007"/> + <Type>Context</Type> + </Error> + <Error> + <Test>context013</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Context Template, the element defined by /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.1']/hl7:entry/hl7:act shall verify this requirement : not(@negationInd) or .[@negationInd='false']</Description> + <Identifiant>context-TestContext-context013</Identifiant> + <assertion idScheme="context" assertionId="CONF:0007"/> + <Type>Context</Type> + </Error> + <Note> + <Test>context014</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Context 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>context-TestContext-context014</Identifiant> + <assertion idScheme="context" assertionId="CONF:0004;CONF:0007"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>context015</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Context 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>context-TestContext-context015</Identifiant> + <assertion idScheme="context" assertionId="CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>context016</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Context 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>context-TestContext-context016</Identifiant> + <assertion idScheme="context" 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> + <Warning> + <Test>rmim052</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/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 10</ValidationDate> + <ValidationTime>02:15:49</ValidationTime> + <ValidationServiceName>Gazelle CDA Validation : context</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="TestContext"/> + </Template> + <Template validation="Report" type="POCDMT000040Section" location="/ClinicalDocument/component/structuredBody/component[1]/section"> + <templateId id="1.1.1.1.1.1.1.1" name="TestContext"/> + </Template> + <Template validation="Error" type="POCDMT000040Section" location="/ClinicalDocument/component/structuredBody/component[2]/section"> + <templateId id="1.1.1.1.1.1.1.1" name="TestContext"/> + </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 0000000000000000000000000000000000000000..94851c7ff158809b5e3fb425b355b02e2680fa0f --- /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 0000000000000000000000000000000000000000..277cacaa8e32b7f4fc3a68b1c5d8c6e06f919bb7 --- /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 0000000000000000000000000000000000000000..28df5e53ea13fc6ceea5481a8f49634d181a138e --- /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 0000000000000000000000000000000000000000..2b21717232489af7bd169173ba2dad5146c646ca --- /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 0000000000000000000000000000000000000000..3aecc0271a7cdc60eac735ed9b2e82ff135b7152 --- /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 0000000000000000000000000000000000000000..c83ca05781bf443f46ed3057db633a338f33d392 --- /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/global/cda_global.xml b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/global/cda_global.xml new file mode 100644 index 0000000000000000000000000000000000000000..bf2afaf61d880349e468587939afa4c692657ca6 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/global/cda_global.xml @@ -0,0 +1,265 @@ +<?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> + + <!-- CARDINALITY --> + <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> + + <!-- VOCABULARY --> + <component> + <section> + <templateId root="1.1.1.1.1.1.1.2"/> + <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" 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.2"/> + <id root="1.2.3.5.8"/> + <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> + + + <!-- MANDATORY --> + <component> + <section> + <templateId root="1.1.1.1.1.1.1.3"/> + <id root="1.2.3.5.9"/> + <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> + + + <!-- FIXED_VALUE --> + <component> + <section> + <templateId root="1.1.1.1.1.1.1.4"/> + <id root="1.2.3.5.10"/> + + <!-- 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.4"/> + <id root="1.2.3.5.11"/> + + <!-- 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> + + + <!-- DATATYPE --> + <component> + <section> + <templateId root="1.1.1.1.1.1.1.5"/> + <id root="1.2.3.5.12"/> + <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.5"/> + <id root="1.2.3.5.13"/> + <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> + + + <!-- CONTEXT --> + <component> + <section> + <templateId root="1.1.1.1.1.1.1.6"/> + <id root="1.2.3.5.14"/> + <code code="29545-1" codeSystem="2.11.111.1.111111.1.1" codeSystemName="LOINC"/> + + <!-- Test Assert 3 "xpath functions" ( 5 < title.length < 30) TRUE--> + <title>CDA For Test</title> + <entry> + + <!-- Test Assert 2 "Self attribute" (@negationInd not exist or "false") TRUE--> + <act classCode="ACT" moodCode="DEF" negationInd="false"> + + <!-- Test Assert 1 "child attribute" (@code shall be "11111" OR <priorityCode /> exist) TRUE--> + <code code="11111" xsi:type="CD" /> + <!-- DON'T UNCOMENT, PART OF TEST: <priorityCode code="12345" />--> + + </act> + </entry> + </section> + </component> + <component> + <section> + <templateId root="1.1.1.1.1.1.1.6"/> + <id root="1.2.3.5.15"/> + <code code="29545-1" codeSystem="2.11.111.1.111111.1.1" codeSystemName="LOINC"/> + + <!-- Test Assert 3 "xpath functions" ( 5 < title.length < 30) TRUE--> + <title>CDA For Test</title> + <entry> + + <!-- Test Assert 2 "Self attribute" (@negationInd not exist or "false") TRUE--> + <act classCode="ACT" moodCode="DEF" negationInd="false"> + + <!-- Test Assert 1 "child attribute" (@code shall be "11111" OR <priorityCode /> exist) TRUE--> + <code code="11112" /> + <priorityCode code="12345" /> + + </act> + </entry> + </section> + </component> + <component> + <section> + <templateId root="1.1.1.1.1.1.1.6"/> + <id root="1.2.3.5.16"/> + <code code="29545-1" codeSystem="2.11.111.1.111111.1.1" codeSystemName="LOINC"/> + + <!-- Test Assert 3 "xpath functions" ( 5 < title.length < 30) FALSE (just Warning)--> + <title>Test</title> + <entry> + + <!-- Test Assert 2 "Self attribute" (@negationInd not exist or "false") FALSE--> + <act classCode="ACT" moodCode="DEF" negationInd="true"> + + <!-- Test Assert 1 "child attribute" (@code shall be "11111" OR <priorityCode /> exist) FALSE--> + <code code="11112" /> + <!-- DON'T UNCOMENT, PART OF TEST: <priorityCode code="12345" />--> + + </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/global/decor_global.xml b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/global/decor_global.xml new file mode 100644 index 0000000000000000000000000000000000000000..c74ce2b7e3d71789dfcf5b87a476b7b274e93073 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/global/decor_global.xml @@ -0,0 +1,310 @@ +<decor> + + <project id="2.16.840.1.113883.2.4.3.11.60.22" prefix="global-" 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> + + <!-- CARDINALITY --> + + <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> + + <!-- VOCABULARY --> + <template id="1.1.1.1.1.1.1.2" 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.2" 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="1" id="2.16.840.1.113883.3.1937.99.3.9.6341"> + <element name="cda:act" minimumMultiplicity="1" maximumMultiplicity="*" id="2.16.840.1.113883.3.1937.99.3.9.6347"> + + <!-- 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.6342"> + <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.6343"> + <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.63414"> + <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> + + <!-- MANDATORY --> + <template id="1.1.1.1.1.1.1.3" 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.3" 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> + + + <!-- MANDATORY --> + <template id="1.1.1.1.1.1.1.4" 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.4" 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> + + + <!-- DATATYPE --> + <template id="1.1.1.1.1.1.1.5" 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.5" 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> + + + <!-- CONTEXT --> + <template id="1.1.1.1.1.1.1.6" name="TestContext" displayName="Test Context 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.6" 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"> + + <element name="cda:code" minimumMultiplicity="1" maximumMultiplicity="1" isMandatory="true" id="2.16.840.1.113883.3.1937.99.3.9.5342"> + <item label="CONF:0004"></item> + </element> + + <element name="cda:priorityCode" minimumMultiplicity="0" 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" /> + + <attribute name="negationInd" datatype="bl" isOptional="true" > + <item label="CONF:0006"></item> + </attribute> + + <!-- ITEM ELEMENT NOT ALLOWED IN <assert /> SO USING INCREMENTED NUMBERS TO + IDENTIFY TESTS (i.e AssertX) IN BOTH BBR & CDA--> + + <!-- Test element: Assert1 HAVE THREE INSTANCES, 1st TRUE, 2nd TRUE and 3rd FALSE "child attribute" --> + <assert test="cda:code[@code='11111'] or cda:priorityCode" role="error"></assert> + + <!-- Test element: Assert2 HAVE THREE INSTANCES, 1st TRUE, 2nd TRUE and 3rd FALSE "self attribute --> + <assert test="not(@negationInd) or .[@negationInd='false']" role="error"></assert> + + </element> + <item label="CONF:0007"></item> + </element> + + <!-- Assert3 Test element: HAVE THREE INSTANCES, 1st TRUE, 2nd TRUE and 3rd FALSE "xpath functions" + ( encode '<' to < )'--> + <assert test="string-length((cda:title/text()))>5 and string-length((cda:title/text()))<30" role="warning"></assert> + </element> + </template> + + </rules> +</decor> \ No newline at end of file diff --git a/hl7templates/goc-tests/goc-tests-runner/src/main/resources/global/expected_global.xml b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/global/expected_global.xml new file mode 100644 index 0000000000000000000000000000000000000000..9573fb75caf259cb1a4b1bea17c01ab4145acb48 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/global/expected_global.xml @@ -0,0 +1,1549 @@ + +<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[3]/entry/act/realmCode</Location> + <Description>In /ClinicalDocument/component/structuredBody/component/section[3]/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[3]/entry/act/typeId</Location> + <Description>In /ClinicalDocument/component/structuredBody/component/section[3]/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>global001</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>global-TestCardinality-global001</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global002</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>global-TestCardinality-global002</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global003</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>global-TestCardinality-global003</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global004</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>global-TestCardinality-global004</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global005</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>global-TestCardinality-global005</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global006</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>global-TestCardinality-global006</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>global007</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>global-TestCardinality-global007</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>global008</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>global-TestCardinality-global008</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global009</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>global-TestCardinality-global009</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global010</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>global-TestCardinality-global010</Identifiant> + <assertion idScheme="global" assertionId="CONF:0003"/> + <Type>Cardinality</Type> + </Note> + <Error> + <Test>global011</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>global-TestCardinality-global011</Identifiant> + <assertion idScheme="global" assertionId="CONF:0004;CONF:0007"/> + <Type>Cardinality</Type> + </Error> + <Note> + <Test>global012</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>global-TestCardinality-global012</Identifiant> + <assertion idScheme="global" assertionId="CONF:0005;CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global013</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>global-TestCardinality-global013</Identifiant> + <assertion idScheme="global" assertionId="CONF:0006;CONF:0007"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global014</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>global-TestCardinality-global014</Identifiant> + <assertion idScheme="global" assertionId="CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global015</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>global-TestCardinality-global015</Identifiant> + <assertion idScheme="global" assertionId="CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global016</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.2']/hl7:templateId[@root='1.1.1.1.1.1.1.2'], the attribute root SHALL be present</Description> + <Identifiant>global-TestVocabulary-global016</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global017</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.2'], the element(s) hl7:templateId[@root='1.1.1.1.1.1.1.2'] SHALL not have nullFlavor (mandatory) (Item : CONF:0001)</Description> + <Identifiant>global-TestVocabulary-global017</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global018</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.2'] SHALL contain at most ONE hl7:templateId[@root='1.1.1.1.1.1.1.2'] (Item : CONF:0001)</Description> + <Identifiant>global-TestVocabulary-global018</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global019</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.2'] SHALL contain at least ONE hl7:templateId[@root='1.1.1.1.1.1.1.2'] (Item : CONF:0001)</Description> + <Identifiant>global-TestVocabulary-global019</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global020</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.2']/hl7:code, the attribute code SHALL be present</Description> + <Identifiant>global-TestVocabulary-global020</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global021</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.2']/hl7:code, the attribute code SHALL have the value '29545-1' if present</Description> + <Identifiant>global-TestVocabulary-global021</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>global022</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.2']/hl7:code, the attribute codeSystem SHALL have the value '2.11.111.1.111111.1.1' if present</Description> + <Identifiant>global-TestVocabulary-global022</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>global023</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.2'], the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0002)</Description> + <Identifiant>global-TestVocabulary-global023</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global024</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.2'] SHALL contain at least ONE hl7:code (Item : CONF:0002)</Description> + <Identifiant>global-TestVocabulary-global024</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global025</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.2'] SHALL contain at least ONE hl7:title (Item : CONF:0003)</Description> + <Identifiant>global-TestVocabulary-global025</Identifiant> + <assertion idScheme="global" assertionId="CONF:0003"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global026</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.2']/hl7:entry/hl7:act, the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0005)</Description> + <Identifiant>global-TestVocabulary-global026</Identifiant> + <assertion idScheme="global" assertionId="CONF:0005;CONF:0006"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global027</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.2']/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>global-TestVocabulary-global027</Identifiant> + <assertion idScheme="global" assertionId="CONF:0005;CONF:0006"/> + <Type>Vocabulary</Type> + </Note> + <Note> + <Test>global028</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.2']/hl7:entry/hl7:act SHALL contain at least ONE hl7:priorityCode (Item : CONF:0006)</Description> + <Identifiant>global-TestVocabulary-global028</Identifiant> + <assertion idScheme="global" assertionId="CONF:0006"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global029</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.2']/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>global-TestVocabulary-global029</Identifiant> + <assertion idScheme="global" assertionId="CONF:0006"/> + <Type>Vocabulary</Type> + </Note> + <Note> + <Test>global030</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.2']/hl7:entry/hl7:act SHALL contain at least ONE hl7:languageCode (Item : CONF:0007)</Description> + <Identifiant>global-TestVocabulary-global030</Identifiant> + <assertion idScheme="global" assertionId="CONF:0006;CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global031</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.2']/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>global-TestVocabulary-global031</Identifiant> + <assertion idScheme="global" assertionId="CONF:0006;CONF:0007"/> + <Type>Vocabulary</Type> + </Note> + <Note> + <Test>global032</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.2']/hl7:entry SHALL contain at least ONE hl7:act</Description> + <Identifiant>global-TestVocabulary-global032</Identifiant> + <assertion idScheme="global" assertionId="CONF:0006"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global033</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.2'] SHALL contain at most ONE hl7:entry (Item : CONF:0006)</Description> + <Identifiant>global-TestVocabulary-global033</Identifiant> + <assertion idScheme="global" assertionId="CONF:0006"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global034</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.2'] SHALL contain at least ONE hl7:entry (Item : CONF:0006)</Description> + <Identifiant>global-TestVocabulary-global034</Identifiant> + <assertion idScheme="global" assertionId="CONF:0006"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global016</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Vocabulary Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.2']/hl7:templateId[@root='1.1.1.1.1.1.1.2'], the attribute root SHALL be present</Description> + <Identifiant>global-TestVocabulary-global016</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global017</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Vocabulary Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.2'], the element(s) hl7:templateId[@root='1.1.1.1.1.1.1.2'] SHALL not have nullFlavor (mandatory) (Item : CONF:0001)</Description> + <Identifiant>global-TestVocabulary-global017</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global018</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Vocabulary Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.2'] SHALL contain at most ONE hl7:templateId[@root='1.1.1.1.1.1.1.2'] (Item : CONF:0001)</Description> + <Identifiant>global-TestVocabulary-global018</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global019</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Vocabulary Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.2'] SHALL contain at least ONE hl7:templateId[@root='1.1.1.1.1.1.1.2'] (Item : CONF:0001)</Description> + <Identifiant>global-TestVocabulary-global019</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global020</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Vocabulary Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.2']/hl7:code, the attribute code SHALL be present</Description> + <Identifiant>global-TestVocabulary-global020</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global021</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Vocabulary Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.2']/hl7:code, the attribute code SHALL have the value '29545-1' if present</Description> + <Identifiant>global-TestVocabulary-global021</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>global022</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Vocabulary Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.2']/hl7:code, the attribute codeSystem SHALL have the value '2.11.111.1.111111.1.1' if present</Description> + <Identifiant>global-TestVocabulary-global022</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>global023</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Vocabulary Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.2'], the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0002)</Description> + <Identifiant>global-TestVocabulary-global023</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global024</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Vocabulary Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.2'] SHALL contain at least ONE hl7:code (Item : CONF:0002)</Description> + <Identifiant>global-TestVocabulary-global024</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global025</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Vocabulary Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.2'] SHALL contain at least ONE hl7:title (Item : CONF:0003)</Description> + <Identifiant>global-TestVocabulary-global025</Identifiant> + <assertion idScheme="global" assertionId="CONF:0003"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global026</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Vocabulary Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.2']/hl7:entry/hl7:act, the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0005)</Description> + <Identifiant>global-TestVocabulary-global026</Identifiant> + <assertion idScheme="global" assertionId="CONF:0005;CONF:0006"/> + <Type>Mandatory</Type> + </Note> + <Error> + <Test>global027</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Vocabulary Template, the code of /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.2']/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>global-TestVocabulary-global027</Identifiant> + <assertion idScheme="global" assertionId="CONF:0005;CONF:0006"/> + <Type>Vocabulary</Type> + </Error> + <Note> + <Test>global028</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Vocabulary Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.2']/hl7:entry/hl7:act SHALL contain at least ONE hl7:priorityCode (Item : CONF:0006)</Description> + <Identifiant>global-TestVocabulary-global028</Identifiant> + <assertion idScheme="global" assertionId="CONF:0006"/> + <Type>Cardinality</Type> + </Note> + <Error> + <Test>global029</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Vocabulary Template, the code of /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.2']/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>global-TestVocabulary-global029</Identifiant> + <assertion idScheme="global" assertionId="CONF:0006"/> + <Type>Vocabulary</Type> + </Error> + <Note> + <Test>global030</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Vocabulary Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.2']/hl7:entry/hl7:act SHALL contain at least ONE hl7:languageCode (Item : CONF:0007)</Description> + <Identifiant>global-TestVocabulary-global030</Identifiant> + <assertion idScheme="global" assertionId="CONF:0006;CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Error> + <Test>global031</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Vocabulary Template, the code of /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.2']/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>global-TestVocabulary-global031</Identifiant> + <assertion idScheme="global" assertionId="CONF:0006;CONF:0007"/> + <Type>Vocabulary</Type> + </Error> + <Note> + <Test>global032</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Vocabulary Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.2']/hl7:entry SHALL contain at least ONE hl7:act</Description> + <Identifiant>global-TestVocabulary-global032</Identifiant> + <assertion idScheme="global" assertionId="CONF:0006"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global033</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Vocabulary Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.2'] SHALL contain at most ONE hl7:entry (Item : CONF:0006)</Description> + <Identifiant>global-TestVocabulary-global033</Identifiant> + <assertion idScheme="global" assertionId="CONF:0006"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global034</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/section</Location> + <Description>In Test Vocabulary Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.2'] SHALL contain at least ONE hl7:entry (Item : CONF:0006)</Description> + <Identifiant>global-TestVocabulary-global034</Identifiant> + <assertion idScheme="global" assertionId="CONF:0006"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global035</Test> + <Location>/ClinicalDocument/component/structuredBody/component[3]/section</Location> + <Description>In Test Mandatory Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.3']/hl7:templateId[@root='1.1.1.1.1.1.1.3'], the attribute root SHALL be present</Description> + <Identifiant>global-TestMandatory-global035</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global036</Test> + <Location>/ClinicalDocument/component/structuredBody/component[3]/section</Location> + <Description>In Test Mandatory Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.3'], the element(s) hl7:templateId[@root='1.1.1.1.1.1.1.3'] SHALL not have nullFlavor (mandatory) (Item : CONF:0001)</Description> + <Identifiant>global-TestMandatory-global036</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global037</Test> + <Location>/ClinicalDocument/component/structuredBody/component[3]/section</Location> + <Description>In Test Mandatory Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.3'] SHALL contain at most ONE hl7:templateId[@root='1.1.1.1.1.1.1.3'] (Item : CONF:0001)</Description> + <Identifiant>global-TestMandatory-global037</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global038</Test> + <Location>/ClinicalDocument/component/structuredBody/component[3]/section</Location> + <Description>In Test Mandatory Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.3'] SHALL contain at least ONE hl7:templateId[@root='1.1.1.1.1.1.1.3'] (Item : CONF:0001)</Description> + <Identifiant>global-TestMandatory-global038</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global039</Test> + <Location>/ClinicalDocument/component/structuredBody/component[3]/section</Location> + <Description>In Test Mandatory Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.3']/hl7:code, the attribute code SHALL be present</Description> + <Identifiant>global-TestMandatory-global039</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global040</Test> + <Location>/ClinicalDocument/component/structuredBody/component[3]/section</Location> + <Description>In Test Mandatory Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.3']/hl7:code, the attribute code SHALL have the value '29545-1' if present</Description> + <Identifiant>global-TestMandatory-global040</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>global041</Test> + <Location>/ClinicalDocument/component/structuredBody/component[3]/section</Location> + <Description>In Test Mandatory Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.3']/hl7:code, the attribute codeSystem SHALL have the value '2.11.111.1.111111.1.1' if present</Description> + <Identifiant>global-TestMandatory-global041</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>global042</Test> + <Location>/ClinicalDocument/component/structuredBody/component[3]/section</Location> + <Description>In Test Mandatory Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.3'], the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0002)</Description> + <Identifiant>global-TestMandatory-global042</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global043</Test> + <Location>/ClinicalDocument/component/structuredBody/component[3]/section</Location> + <Description>In Test Mandatory Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.3'] SHALL contain at least ONE hl7:code (Item : CONF:0002)</Description> + <Identifiant>global-TestMandatory-global043</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global044</Test> + <Location>/ClinicalDocument/component/structuredBody/component[3]/section</Location> + <Description>In Test Mandatory Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.3'] SHALL contain at least ONE hl7:title (Item : CONF:0003)</Description> + <Identifiant>global-TestMandatory-global044</Identifiant> + <assertion idScheme="global" assertionId="CONF:0003"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global045</Test> + <Location>/ClinicalDocument/component/structuredBody/component[3]/section</Location> + <Description>In Test Mandatory Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.3']/hl7:entry/hl7:act SHALL contain at least ONE hl7:realmCode (Item : CONF:0004)</Description> + <Identifiant>global-TestMandatory-global045</Identifiant> + <assertion idScheme="global" assertionId="CONF:0004;CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Error> + <Test>global046</Test> + <Location>/ClinicalDocument/component/structuredBody/component[3]/section</Location> + <Description>In Test Mandatory Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.3']/hl7:entry/hl7:act, the element(s) hl7:typeId SHALL not have nullFlavor (mandatory) (Item : CONF:0005)</Description> + <Identifiant>global-TestMandatory-global046</Identifiant> + <assertion idScheme="global" assertionId="CONF:0005;CONF:0007"/> + <Type>Mandatory</Type> + </Error> + <Note> + <Test>global047</Test> + <Location>/ClinicalDocument/component/structuredBody/component[3]/section</Location> + <Description>In Test Mandatory Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.3']/hl7:entry/hl7:act SHALL contain at least ONE hl7:typeId (Item : CONF:0005)</Description> + <Identifiant>global-TestMandatory-global047</Identifiant> + <assertion idScheme="global" assertionId="CONF:0005;CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global048</Test> + <Location>/ClinicalDocument/component/structuredBody/component[3]/section</Location> + <Description>In Test Mandatory Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.3']/hl7:entry/hl7:act, the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0006)</Description> + <Identifiant>global-TestMandatory-global048</Identifiant> + <assertion idScheme="global" assertionId="CONF:0006;CONF:0007"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global049</Test> + <Location>/ClinicalDocument/component/structuredBody/component[3]/section</Location> + <Description>In Test Mandatory Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.3']/hl7:entry SHALL contain at least ONE hl7:act</Description> + <Identifiant>global-TestMandatory-global049</Identifiant> + <assertion idScheme="global" assertionId="CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global050</Test> + <Location>/ClinicalDocument/component/structuredBody/component[3]/section</Location> + <Description>In Test Mandatory Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.3'] SHALL contain at least ONE hl7:entry (Item : CONF:0007)</Description> + <Identifiant>global-TestMandatory-global050</Identifiant> + <assertion idScheme="global" assertionId="CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global051</Test> + <Location>/ClinicalDocument/component/structuredBody/component[4]/section</Location> + <Description>In Test Fixed Value Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.4']/hl7:templateId[@root='1.1.1.1.1.1.1.4'], the attribute root SHALL be present</Description> + <Identifiant>global-TestFixedVal-global051</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global052</Test> + <Location>/ClinicalDocument/component/structuredBody/component[4]/section</Location> + <Description>In Test Fixed Value Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.4'], the element(s) hl7:templateId[@root='1.1.1.1.1.1.1.4'] SHALL not have nullFlavor (mandatory) (Item : CONF:0001)</Description> + <Identifiant>global-TestFixedVal-global052</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global053</Test> + <Location>/ClinicalDocument/component/structuredBody/component[4]/section</Location> + <Description>In Test Fixed Value Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.4'] SHALL contain at most ONE hl7:templateId[@root='1.1.1.1.1.1.1.4'] (Item : CONF:0001)</Description> + <Identifiant>global-TestFixedVal-global053</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global054</Test> + <Location>/ClinicalDocument/component/structuredBody/component[4]/section</Location> + <Description>In Test Fixed Value Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.4'] SHALL contain at least ONE hl7:templateId[@root='1.1.1.1.1.1.1.4'] (Item : CONF:0001)</Description> + <Identifiant>global-TestFixedVal-global054</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global055</Test> + <Location>/ClinicalDocument/component/structuredBody/component[4]/section</Location> + <Description>In Test Fixed Value Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.4']/hl7:code, the attribute code SHALL be present</Description> + <Identifiant>global-TestFixedVal-global055</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global056</Test> + <Location>/ClinicalDocument/component/structuredBody/component[4]/section</Location> + <Description>In Test Fixed Value Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.4']/hl7:code, the attribute code SHALL have the value '29545-1' if present</Description> + <Identifiant>global-TestFixedVal-global056</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>global057</Test> + <Location>/ClinicalDocument/component/structuredBody/component[4]/section</Location> + <Description>In Test Fixed Value Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.4']/hl7:code, the attribute codeSystem SHALL have the value '2.11.111.1.111111.1.1' if present</Description> + <Identifiant>global-TestFixedVal-global057</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>global058</Test> + <Location>/ClinicalDocument/component/structuredBody/component[4]/section</Location> + <Description>In Test Fixed Value Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.4'], the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0002)</Description> + <Identifiant>global-TestFixedVal-global058</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global059</Test> + <Location>/ClinicalDocument/component/structuredBody/component[4]/section</Location> + <Description>In Test Fixed Value Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.4'] SHALL contain at least ONE hl7:code (Item : CONF:0002)</Description> + <Identifiant>global-TestFixedVal-global059</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global060</Test> + <Location>/ClinicalDocument/component/structuredBody/component[4]/section</Location> + <Description>In Test Fixed Value Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.4'] SHALL contain at least ONE hl7:title (Item : CONF:0003)</Description> + <Identifiant>global-TestFixedVal-global060</Identifiant> + <assertion idScheme="global" assertionId="CONF:0003"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global051</Test> + <Location>/ClinicalDocument/component/structuredBody/component[5]/section</Location> + <Description>In Test Fixed Value Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.4']/hl7:templateId[@root='1.1.1.1.1.1.1.4'], the attribute root SHALL be present</Description> + <Identifiant>global-TestFixedVal-global051</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global052</Test> + <Location>/ClinicalDocument/component/structuredBody/component[5]/section</Location> + <Description>In Test Fixed Value Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.4'], the element(s) hl7:templateId[@root='1.1.1.1.1.1.1.4'] SHALL not have nullFlavor (mandatory) (Item : CONF:0001)</Description> + <Identifiant>global-TestFixedVal-global052</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global053</Test> + <Location>/ClinicalDocument/component/structuredBody/component[5]/section</Location> + <Description>In Test Fixed Value Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.4'] SHALL contain at most ONE hl7:templateId[@root='1.1.1.1.1.1.1.4'] (Item : CONF:0001)</Description> + <Identifiant>global-TestFixedVal-global053</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global054</Test> + <Location>/ClinicalDocument/component/structuredBody/component[5]/section</Location> + <Description>In Test Fixed Value Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.4'] SHALL contain at least ONE hl7:templateId[@root='1.1.1.1.1.1.1.4'] (Item : CONF:0001)</Description> + <Identifiant>global-TestFixedVal-global054</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global055</Test> + <Location>/ClinicalDocument/component/structuredBody/component[5]/section</Location> + <Description>In Test Fixed Value Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.4']/hl7:code, the attribute code SHALL be present</Description> + <Identifiant>global-TestFixedVal-global055</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Error> + <Test>global056</Test> + <Location>/ClinicalDocument/component/structuredBody/component[5]/section</Location> + <Description>In Test Fixed Value Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.4']/hl7:code, the attribute code SHALL have the value '29545-1' if present</Description> + <Identifiant>global-TestFixedVal-global056</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Error> + <Note> + <Test>global057</Test> + <Location>/ClinicalDocument/component/structuredBody/component[5]/section</Location> + <Description>In Test Fixed Value Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.4']/hl7:code, the attribute codeSystem SHALL have the value '2.11.111.1.111111.1.1' if present</Description> + <Identifiant>global-TestFixedVal-global057</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>global058</Test> + <Location>/ClinicalDocument/component/structuredBody/component[5]/section</Location> + <Description>In Test Fixed Value Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.4'], the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0002)</Description> + <Identifiant>global-TestFixedVal-global058</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global059</Test> + <Location>/ClinicalDocument/component/structuredBody/component[5]/section</Location> + <Description>In Test Fixed Value Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.4'] SHALL contain at least ONE hl7:code (Item : CONF:0002)</Description> + <Identifiant>global-TestFixedVal-global059</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global060</Test> + <Location>/ClinicalDocument/component/structuredBody/component[5]/section</Location> + <Description>In Test Fixed Value Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.4'] SHALL contain at least ONE hl7:title (Item : CONF:0003)</Description> + <Identifiant>global-TestFixedVal-global060</Identifiant> + <assertion idScheme="global" assertionId="CONF:0003"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global061</Test> + <Location>/ClinicalDocument/component/structuredBody/component[6]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5']/hl7:templateId[@root='1.1.1.1.1.1.1.5'], the attribute root SHALL be present</Description> + <Identifiant>global-TestDataType-global061</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global062</Test> + <Location>/ClinicalDocument/component/structuredBody/component[6]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5'], the element(s) hl7:templateId[@root='1.1.1.1.1.1.1.5'] SHALL not have nullFlavor (mandatory) (Item : CONF:0001)</Description> + <Identifiant>global-TestDataType-global062</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global063</Test> + <Location>/ClinicalDocument/component/structuredBody/component[6]/section</Location> + <Description>In Test Datatype Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5'] SHALL contain at most ONE hl7:templateId[@root='1.1.1.1.1.1.1.5'] (Item : CONF:0001)</Description> + <Identifiant>global-TestDataType-global063</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global064</Test> + <Location>/ClinicalDocument/component/structuredBody/component[6]/section</Location> + <Description>In Test Datatype Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5'] SHALL contain at least ONE hl7:templateId[@root='1.1.1.1.1.1.1.5'] (Item : CONF:0001)</Description> + <Identifiant>global-TestDataType-global064</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global065</Test> + <Location>/ClinicalDocument/component/structuredBody/component[6]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5']/hl7:code, the attribute code SHALL be present</Description> + <Identifiant>global-TestDataType-global065</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global066</Test> + <Location>/ClinicalDocument/component/structuredBody/component[6]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5']/hl7:code, the attribute code SHALL have the value '29545-1' if present</Description> + <Identifiant>global-TestDataType-global066</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>global067</Test> + <Location>/ClinicalDocument/component/structuredBody/component[6]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5']/hl7:code, the attribute codeSystem SHALL have the value '2.11.111.1.111111.1.1' if present</Description> + <Identifiant>global-TestDataType-global067</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>global068</Test> + <Location>/ClinicalDocument/component/structuredBody/component[6]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5'], the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0002)</Description> + <Identifiant>global-TestDataType-global068</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global069</Test> + <Location>/ClinicalDocument/component/structuredBody/component[6]/section</Location> + <Description>In Test Datatype Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5'] SHALL contain at least ONE hl7:code (Item : CONF:0002)</Description> + <Identifiant>global-TestDataType-global069</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global070</Test> + <Location>/ClinicalDocument/component/structuredBody/component[6]/section</Location> + <Description>In Test Datatype Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5'] SHALL contain at least ONE hl7:title (Item : CONF:0003)</Description> + <Identifiant>global-TestDataType-global070</Identifiant> + <assertion idScheme="global" assertionId="CONF:0003"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global071</Test> + <Location>/ClinicalDocument/component/structuredBody/component[6]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5']/hl7:entry/hl7:act, the attribute negationInd SHALL be present (Item : CONF:0006)</Description> + <Identifiant>global-TestDataType-global071</Identifiant> + <assertion idScheme="global" assertionId="CONF:0006;CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global072</Test> + <Location>/ClinicalDocument/component/structuredBody/component[6]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5']/hl7:entry/hl7:act, the element(s) hl7:code SHALL be from the datatype CE (Item : CONF:0004)</Description> + <Identifiant>global-TestDataType-global072</Identifiant> + <assertion idScheme="global" assertionId="CONF:0004;CONF:0007"/> + <Type>Datatype</Type> + </Note> + <Note> + <Test>global073</Test> + <Location>/ClinicalDocument/component/structuredBody/component[6]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5']/hl7:entry/hl7:act, the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0004)</Description> + <Identifiant>global-TestDataType-global073</Identifiant> + <assertion idScheme="global" assertionId="CONF:0004;CONF:0007"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global074</Test> + <Location>/ClinicalDocument/component/structuredBody/component[6]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5']/hl7:entry/hl7:act, the element(s) hl7:priorityCode SHALL be from the datatype CV (Item : CONF:0005)</Description> + <Identifiant>global-TestDataType-global074</Identifiant> + <assertion idScheme="global" assertionId="CONF:0005;CONF:0007"/> + <Type>Datatype</Type> + </Note> + <Note> + <Test>global075</Test> + <Location>/ClinicalDocument/component/structuredBody/component[6]/section</Location> + <Description>In Test Datatype Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5']/hl7:entry/hl7:act SHALL contain at least ONE hl7:priorityCode (Item : CONF:0005)</Description> + <Identifiant>global-TestDataType-global075</Identifiant> + <assertion idScheme="global" assertionId="CONF:0005;CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global076</Test> + <Location>/ClinicalDocument/component/structuredBody/component[6]/section</Location> + <Description>In Test Datatype Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5']/hl7:entry SHALL contain at least ONE hl7:act</Description> + <Identifiant>global-TestDataType-global076</Identifiant> + <assertion idScheme="global" assertionId="CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global077</Test> + <Location>/ClinicalDocument/component/structuredBody/component[6]/section</Location> + <Description>In Test Datatype Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5'] SHALL contain at least ONE hl7:entry (Item : CONF:0007)</Description> + <Identifiant>global-TestDataType-global077</Identifiant> + <assertion idScheme="global" assertionId="CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global061</Test> + <Location>/ClinicalDocument/component/structuredBody/component[7]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5']/hl7:templateId[@root='1.1.1.1.1.1.1.5'], the attribute root SHALL be present</Description> + <Identifiant>global-TestDataType-global061</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global062</Test> + <Location>/ClinicalDocument/component/structuredBody/component[7]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5'], the element(s) hl7:templateId[@root='1.1.1.1.1.1.1.5'] SHALL not have nullFlavor (mandatory) (Item : CONF:0001)</Description> + <Identifiant>global-TestDataType-global062</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global063</Test> + <Location>/ClinicalDocument/component/structuredBody/component[7]/section</Location> + <Description>In Test Datatype Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5'] SHALL contain at most ONE hl7:templateId[@root='1.1.1.1.1.1.1.5'] (Item : CONF:0001)</Description> + <Identifiant>global-TestDataType-global063</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global064</Test> + <Location>/ClinicalDocument/component/structuredBody/component[7]/section</Location> + <Description>In Test Datatype Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5'] SHALL contain at least ONE hl7:templateId[@root='1.1.1.1.1.1.1.5'] (Item : CONF:0001)</Description> + <Identifiant>global-TestDataType-global064</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global065</Test> + <Location>/ClinicalDocument/component/structuredBody/component[7]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5']/hl7:code, the attribute code SHALL be present</Description> + <Identifiant>global-TestDataType-global065</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global066</Test> + <Location>/ClinicalDocument/component/structuredBody/component[7]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5']/hl7:code, the attribute code SHALL have the value '29545-1' if present</Description> + <Identifiant>global-TestDataType-global066</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>global067</Test> + <Location>/ClinicalDocument/component/structuredBody/component[7]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5']/hl7:code, the attribute codeSystem SHALL have the value '2.11.111.1.111111.1.1' if present</Description> + <Identifiant>global-TestDataType-global067</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>global068</Test> + <Location>/ClinicalDocument/component/structuredBody/component[7]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5'], the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0002)</Description> + <Identifiant>global-TestDataType-global068</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global069</Test> + <Location>/ClinicalDocument/component/structuredBody/component[7]/section</Location> + <Description>In Test Datatype Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5'] SHALL contain at least ONE hl7:code (Item : CONF:0002)</Description> + <Identifiant>global-TestDataType-global069</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global070</Test> + <Location>/ClinicalDocument/component/structuredBody/component[7]/section</Location> + <Description>In Test Datatype Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5'] SHALL contain at least ONE hl7:title (Item : CONF:0003)</Description> + <Identifiant>global-TestDataType-global070</Identifiant> + <assertion idScheme="global" assertionId="CONF:0003"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global071</Test> + <Location>/ClinicalDocument/component/structuredBody/component[7]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5']/hl7:entry/hl7:act, the attribute negationInd SHALL be present (Item : CONF:0006)</Description> + <Identifiant>global-TestDataType-global071</Identifiant> + <assertion idScheme="global" assertionId="CONF:0006;CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Error> + <Test>global072</Test> + <Location>/ClinicalDocument/component/structuredBody/component[7]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5']/hl7:entry/hl7:act, the element(s) hl7:code SHALL be from the datatype CE (Item : CONF:0004)</Description> + <Identifiant>global-TestDataType-global072</Identifiant> + <assertion idScheme="global" assertionId="CONF:0004;CONF:0007"/> + <Type>Datatype</Type> + </Error> + <Note> + <Test>global073</Test> + <Location>/ClinicalDocument/component/structuredBody/component[7]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5']/hl7:entry/hl7:act, the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0004)</Description> + <Identifiant>global-TestDataType-global073</Identifiant> + <assertion idScheme="global" assertionId="CONF:0004;CONF:0007"/> + <Type>Mandatory</Type> + </Note> + <Error> + <Test>global074</Test> + <Location>/ClinicalDocument/component/structuredBody/component[7]/section</Location> + <Description>In Test Datatype Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5']/hl7:entry/hl7:act, the element(s) hl7:priorityCode SHALL be from the datatype CV (Item : CONF:0005)</Description> + <Identifiant>global-TestDataType-global074</Identifiant> + <assertion idScheme="global" assertionId="CONF:0005;CONF:0007"/> + <Type>Datatype</Type> + </Error> + <Note> + <Test>global075</Test> + <Location>/ClinicalDocument/component/structuredBody/component[7]/section</Location> + <Description>In Test Datatype Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5']/hl7:entry/hl7:act SHALL contain at least ONE hl7:priorityCode (Item : CONF:0005)</Description> + <Identifiant>global-TestDataType-global075</Identifiant> + <assertion idScheme="global" assertionId="CONF:0005;CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global076</Test> + <Location>/ClinicalDocument/component/structuredBody/component[7]/section</Location> + <Description>In Test Datatype Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5']/hl7:entry SHALL contain at least ONE hl7:act</Description> + <Identifiant>global-TestDataType-global076</Identifiant> + <assertion idScheme="global" assertionId="CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global077</Test> + <Location>/ClinicalDocument/component/structuredBody/component[7]/section</Location> + <Description>In Test Datatype Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.5'] SHALL contain at least ONE hl7:entry (Item : CONF:0007)</Description> + <Identifiant>global-TestDataType-global077</Identifiant> + <assertion idScheme="global" assertionId="CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global078</Test> + <Location>/ClinicalDocument/component/structuredBody/component[8]/section</Location> + <Description>In Test Context Template, the element defined by /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6'] shall verify this requirement : string-length((cda:title/text()))>5 and string-length((cda:title/text()))<30</Description> + <Identifiant>global-TestContext-global078</Identifiant> + <Type>Context</Type> + </Note> + <Note> + <Test>global079</Test> + <Location>/ClinicalDocument/component/structuredBody/component[8]/section</Location> + <Description>In Test Context Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6']/hl7:templateId[@root='1.1.1.1.1.1.1.6'], the attribute root SHALL be present</Description> + <Identifiant>global-TestContext-global079</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global080</Test> + <Location>/ClinicalDocument/component/structuredBody/component[8]/section</Location> + <Description>In Test Context Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6'], the element(s) hl7:templateId[@root='1.1.1.1.1.1.1.6'] SHALL not have nullFlavor (mandatory) (Item : CONF:0001)</Description> + <Identifiant>global-TestContext-global080</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global081</Test> + <Location>/ClinicalDocument/component/structuredBody/component[8]/section</Location> + <Description>In Test Context Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6'] SHALL contain at most ONE hl7:templateId[@root='1.1.1.1.1.1.1.6'] (Item : CONF:0001)</Description> + <Identifiant>global-TestContext-global081</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global082</Test> + <Location>/ClinicalDocument/component/structuredBody/component[8]/section</Location> + <Description>In Test Context Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6'] SHALL contain at least ONE hl7:templateId[@root='1.1.1.1.1.1.1.6'] (Item : CONF:0001)</Description> + <Identifiant>global-TestContext-global082</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global083</Test> + <Location>/ClinicalDocument/component/structuredBody/component[8]/section</Location> + <Description>In Test Context Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6']/hl7:code, the attribute code SHALL be present</Description> + <Identifiant>global-TestContext-global083</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global084</Test> + <Location>/ClinicalDocument/component/structuredBody/component[8]/section</Location> + <Description>In Test Context Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6']/hl7:code, the attribute code SHALL have the value '29545-1' if present</Description> + <Identifiant>global-TestContext-global084</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>global085</Test> + <Location>/ClinicalDocument/component/structuredBody/component[8]/section</Location> + <Description>In Test Context Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6']/hl7:code, the attribute codeSystem SHALL have the value '2.11.111.1.111111.1.1' if present</Description> + <Identifiant>global-TestContext-global085</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>global086</Test> + <Location>/ClinicalDocument/component/structuredBody/component[8]/section</Location> + <Description>In Test Context Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6'], the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0002)</Description> + <Identifiant>global-TestContext-global086</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global087</Test> + <Location>/ClinicalDocument/component/structuredBody/component[8]/section</Location> + <Description>In Test Context Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6'] SHALL contain at least ONE hl7:code (Item : CONF:0002)</Description> + <Identifiant>global-TestContext-global087</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global088</Test> + <Location>/ClinicalDocument/component/structuredBody/component[8]/section</Location> + <Description>In Test Context Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6'] SHALL contain at least ONE hl7:title (Item : CONF:0003)</Description> + <Identifiant>global-TestContext-global088</Identifiant> + <assertion idScheme="global" assertionId="CONF:0003"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global089</Test> + <Location>/ClinicalDocument/component/structuredBody/component[8]/section</Location> + <Description>In Test Context Template, the element defined by /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6']/hl7:entry/hl7:act shall verify this requirement : cda:code[@code='11111'] or cda:priorityCode</Description> + <Identifiant>global-TestContext-global089</Identifiant> + <assertion idScheme="global" assertionId="CONF:0007"/> + <Type>Context</Type> + </Note> + <Note> + <Test>global090</Test> + <Location>/ClinicalDocument/component/structuredBody/component[8]/section</Location> + <Description>In Test Context Template, the element defined by /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6']/hl7:entry/hl7:act shall verify this requirement : not(@negationInd) or .[@negationInd='false']</Description> + <Identifiant>global-TestContext-global090</Identifiant> + <assertion idScheme="global" assertionId="CONF:0007"/> + <Type>Context</Type> + </Note> + <Note> + <Test>global091</Test> + <Location>/ClinicalDocument/component/structuredBody/component[8]/section</Location> + <Description>In Test Context Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6']/hl7:entry/hl7:act, the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0004)</Description> + <Identifiant>global-TestContext-global091</Identifiant> + <assertion idScheme="global" assertionId="CONF:0004;CONF:0007"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global092</Test> + <Location>/ClinicalDocument/component/structuredBody/component[8]/section</Location> + <Description>In Test Context Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6']/hl7:entry SHALL contain at least ONE hl7:act</Description> + <Identifiant>global-TestContext-global092</Identifiant> + <assertion idScheme="global" assertionId="CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global093</Test> + <Location>/ClinicalDocument/component/structuredBody/component[8]/section</Location> + <Description>In Test Context Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6'] SHALL contain at least ONE hl7:entry (Item : CONF:0007)</Description> + <Identifiant>global-TestContext-global093</Identifiant> + <assertion idScheme="global" assertionId="CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global078</Test> + <Location>/ClinicalDocument/component/structuredBody/component[9]/section</Location> + <Description>In Test Context Template, the element defined by /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6'] shall verify this requirement : string-length((cda:title/text()))>5 and string-length((cda:title/text()))<30</Description> + <Identifiant>global-TestContext-global078</Identifiant> + <Type>Context</Type> + </Note> + <Note> + <Test>global079</Test> + <Location>/ClinicalDocument/component/structuredBody/component[9]/section</Location> + <Description>In Test Context Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6']/hl7:templateId[@root='1.1.1.1.1.1.1.6'], the attribute root SHALL be present</Description> + <Identifiant>global-TestContext-global079</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global080</Test> + <Location>/ClinicalDocument/component/structuredBody/component[9]/section</Location> + <Description>In Test Context Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6'], the element(s) hl7:templateId[@root='1.1.1.1.1.1.1.6'] SHALL not have nullFlavor (mandatory) (Item : CONF:0001)</Description> + <Identifiant>global-TestContext-global080</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global081</Test> + <Location>/ClinicalDocument/component/structuredBody/component[9]/section</Location> + <Description>In Test Context Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6'] SHALL contain at most ONE hl7:templateId[@root='1.1.1.1.1.1.1.6'] (Item : CONF:0001)</Description> + <Identifiant>global-TestContext-global081</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global082</Test> + <Location>/ClinicalDocument/component/structuredBody/component[9]/section</Location> + <Description>In Test Context Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6'] SHALL contain at least ONE hl7:templateId[@root='1.1.1.1.1.1.1.6'] (Item : CONF:0001)</Description> + <Identifiant>global-TestContext-global082</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global083</Test> + <Location>/ClinicalDocument/component/structuredBody/component[9]/section</Location> + <Description>In Test Context Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6']/hl7:code, the attribute code SHALL be present</Description> + <Identifiant>global-TestContext-global083</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global084</Test> + <Location>/ClinicalDocument/component/structuredBody/component[9]/section</Location> + <Description>In Test Context Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6']/hl7:code, the attribute code SHALL have the value '29545-1' if present</Description> + <Identifiant>global-TestContext-global084</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>global085</Test> + <Location>/ClinicalDocument/component/structuredBody/component[9]/section</Location> + <Description>In Test Context Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6']/hl7:code, the attribute codeSystem SHALL have the value '2.11.111.1.111111.1.1' if present</Description> + <Identifiant>global-TestContext-global085</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>global086</Test> + <Location>/ClinicalDocument/component/structuredBody/component[9]/section</Location> + <Description>In Test Context Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6'], the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0002)</Description> + <Identifiant>global-TestContext-global086</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global087</Test> + <Location>/ClinicalDocument/component/structuredBody/component[9]/section</Location> + <Description>In Test Context Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6'] SHALL contain at least ONE hl7:code (Item : CONF:0002)</Description> + <Identifiant>global-TestContext-global087</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global088</Test> + <Location>/ClinicalDocument/component/structuredBody/component[9]/section</Location> + <Description>In Test Context Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6'] SHALL contain at least ONE hl7:title (Item : CONF:0003)</Description> + <Identifiant>global-TestContext-global088</Identifiant> + <assertion idScheme="global" assertionId="CONF:0003"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global089</Test> + <Location>/ClinicalDocument/component/structuredBody/component[9]/section</Location> + <Description>In Test Context Template, the element defined by /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6']/hl7:entry/hl7:act shall verify this requirement : cda:code[@code='11111'] or cda:priorityCode</Description> + <Identifiant>global-TestContext-global089</Identifiant> + <assertion idScheme="global" assertionId="CONF:0007"/> + <Type>Context</Type> + </Note> + <Note> + <Test>global090</Test> + <Location>/ClinicalDocument/component/structuredBody/component[9]/section</Location> + <Description>In Test Context Template, the element defined by /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6']/hl7:entry/hl7:act shall verify this requirement : not(@negationInd) or .[@negationInd='false']</Description> + <Identifiant>global-TestContext-global090</Identifiant> + <assertion idScheme="global" assertionId="CONF:0007"/> + <Type>Context</Type> + </Note> + <Note> + <Test>global091</Test> + <Location>/ClinicalDocument/component/structuredBody/component[9]/section</Location> + <Description>In Test Context Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6']/hl7:entry/hl7:act, the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0004)</Description> + <Identifiant>global-TestContext-global091</Identifiant> + <assertion idScheme="global" assertionId="CONF:0004;CONF:0007"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global092</Test> + <Location>/ClinicalDocument/component/structuredBody/component[9]/section</Location> + <Description>In Test Context Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6']/hl7:entry SHALL contain at least ONE hl7:act</Description> + <Identifiant>global-TestContext-global092</Identifiant> + <assertion idScheme="global" assertionId="CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global093</Test> + <Location>/ClinicalDocument/component/structuredBody/component[9]/section</Location> + <Description>In Test Context Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6'] SHALL contain at least ONE hl7:entry (Item : CONF:0007)</Description> + <Identifiant>global-TestContext-global093</Identifiant> + <assertion idScheme="global" assertionId="CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Warning> + <Test>global078</Test> + <Location>/ClinicalDocument/component/structuredBody/component[10]/section</Location> + <Description>In Test Context Template, the element defined by /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6'] shall verify this requirement : string-length((cda:title/text()))>5 and string-length((cda:title/text()))<30</Description> + <Identifiant>global-TestContext-global078</Identifiant> + <Type>Context</Type> + </Warning> + <Note> + <Test>global079</Test> + <Location>/ClinicalDocument/component/structuredBody/component[10]/section</Location> + <Description>In Test Context Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6']/hl7:templateId[@root='1.1.1.1.1.1.1.6'], the attribute root SHALL be present</Description> + <Identifiant>global-TestContext-global079</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global080</Test> + <Location>/ClinicalDocument/component/structuredBody/component[10]/section</Location> + <Description>In Test Context Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6'], the element(s) hl7:templateId[@root='1.1.1.1.1.1.1.6'] SHALL not have nullFlavor (mandatory) (Item : CONF:0001)</Description> + <Identifiant>global-TestContext-global080</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global081</Test> + <Location>/ClinicalDocument/component/structuredBody/component[10]/section</Location> + <Description>In Test Context Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6'] SHALL contain at most ONE hl7:templateId[@root='1.1.1.1.1.1.1.6'] (Item : CONF:0001)</Description> + <Identifiant>global-TestContext-global081</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global082</Test> + <Location>/ClinicalDocument/component/structuredBody/component[10]/section</Location> + <Description>In Test Context Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6'] SHALL contain at least ONE hl7:templateId[@root='1.1.1.1.1.1.1.6'] (Item : CONF:0001)</Description> + <Identifiant>global-TestContext-global082</Identifiant> + <assertion idScheme="global" assertionId="CONF:0001"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global083</Test> + <Location>/ClinicalDocument/component/structuredBody/component[10]/section</Location> + <Description>In Test Context Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6']/hl7:code, the attribute code SHALL be present</Description> + <Identifiant>global-TestContext-global083</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global084</Test> + <Location>/ClinicalDocument/component/structuredBody/component[10]/section</Location> + <Description>In Test Context Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6']/hl7:code, the attribute code SHALL have the value '29545-1' if present</Description> + <Identifiant>global-TestContext-global084</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>global085</Test> + <Location>/ClinicalDocument/component/structuredBody/component[10]/section</Location> + <Description>In Test Context Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6']/hl7:code, the attribute codeSystem SHALL have the value '2.11.111.1.111111.1.1' if present</Description> + <Identifiant>global-TestContext-global085</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Fixed value</Type> + </Note> + <Note> + <Test>global086</Test> + <Location>/ClinicalDocument/component/structuredBody/component[10]/section</Location> + <Description>In Test Context Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6'], the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0002)</Description> + <Identifiant>global-TestContext-global086</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global087</Test> + <Location>/ClinicalDocument/component/structuredBody/component[10]/section</Location> + <Description>In Test Context Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6'] SHALL contain at least ONE hl7:code (Item : CONF:0002)</Description> + <Identifiant>global-TestContext-global087</Identifiant> + <assertion idScheme="global" assertionId="CONF:0002"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global088</Test> + <Location>/ClinicalDocument/component/structuredBody/component[10]/section</Location> + <Description>In Test Context Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6'] SHALL contain at least ONE hl7:title (Item : CONF:0003)</Description> + <Identifiant>global-TestContext-global088</Identifiant> + <assertion idScheme="global" assertionId="CONF:0003"/> + <Type>Cardinality</Type> + </Note> + <Error> + <Test>global089</Test> + <Location>/ClinicalDocument/component/structuredBody/component[10]/section</Location> + <Description>In Test Context Template, the element defined by /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6']/hl7:entry/hl7:act shall verify this requirement : cda:code[@code='11111'] or cda:priorityCode</Description> + <Identifiant>global-TestContext-global089</Identifiant> + <assertion idScheme="global" assertionId="CONF:0007"/> + <Type>Context</Type> + </Error> + <Error> + <Test>global090</Test> + <Location>/ClinicalDocument/component/structuredBody/component[10]/section</Location> + <Description>In Test Context Template, the element defined by /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6']/hl7:entry/hl7:act shall verify this requirement : not(@negationInd) or .[@negationInd='false']</Description> + <Identifiant>global-TestContext-global090</Identifiant> + <assertion idScheme="global" assertionId="CONF:0007"/> + <Type>Context</Type> + </Error> + <Note> + <Test>global091</Test> + <Location>/ClinicalDocument/component/structuredBody/component[10]/section</Location> + <Description>In Test Context Template, in /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6']/hl7:entry/hl7:act, the element(s) hl7:code SHALL not have nullFlavor (mandatory) (Item : CONF:0004)</Description> + <Identifiant>global-TestContext-global091</Identifiant> + <assertion idScheme="global" assertionId="CONF:0004;CONF:0007"/> + <Type>Mandatory</Type> + </Note> + <Note> + <Test>global092</Test> + <Location>/ClinicalDocument/component/structuredBody/component[10]/section</Location> + <Description>In Test Context Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6']/hl7:entry SHALL contain at least ONE hl7:act</Description> + <Identifiant>global-TestContext-global092</Identifiant> + <assertion idScheme="global" assertionId="CONF:0007"/> + <Type>Cardinality</Type> + </Note> + <Note> + <Test>global093</Test> + <Location>/ClinicalDocument/component/structuredBody/component[10]/section</Location> + <Description>In Test Context Template, /hl7:section[hl7:templateId/@root='1.1.1.1.1.1.1.6'] SHALL contain at least ONE hl7:entry (Item : CONF:0007)</Description> + <Identifiant>global-TestContext-global093</Identifiant> + <assertion idScheme="global" 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> + <Warning> + <Test>rmim052</Test> + <Location>/ClinicalDocument/component/structuredBody/component[2]/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[3]/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[4]/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[5]/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[6]/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[7]/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[8]/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[9]/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[10]/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 10</ValidationDate> + <ValidationTime>03:20:30</ValidationTime> + <ValidationServiceName>Gazelle CDA Validation : global</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> + <Template validation="Report" type="POCDMT000040Section" location="/ClinicalDocument/component/structuredBody/component[1]/section"> + <templateId id="1.1.1.1.1.1.1.2" name="TestVocabulary"/> + </Template> + <Template validation="Error" type="POCDMT000040Section" location="/ClinicalDocument/component/structuredBody/component[2]/section"> + <templateId id="1.1.1.1.1.1.1.2" name="TestVocabulary"/> + </Template> + <Template validation="Error" type="POCDMT000040Section" location="/ClinicalDocument/component/structuredBody/component[3]/section"> + <templateId id="1.1.1.1.1.1.1.3" name="TestMandatory"/> + </Template> + <Template validation="Report" type="POCDMT000040Section" location="/ClinicalDocument/component/structuredBody/component[4]/section"> + <templateId id="1.1.1.1.1.1.1.4" name="TestFixedVal"/> + </Template> + <Template validation="Error" type="POCDMT000040Section" location="/ClinicalDocument/component/structuredBody/component[5]/section"> + <templateId id="1.1.1.1.1.1.1.4" name="TestFixedVal"/> + </Template> + <Template validation="Report" type="POCDMT000040Section" location="/ClinicalDocument/component/structuredBody/component[6]/section"> + <templateId id="1.1.1.1.1.1.1.5" name="TestDataType"/> + </Template> + <Template validation="Error" type="POCDMT000040Section" location="/ClinicalDocument/component/structuredBody/component[7]/section"> + <templateId id="1.1.1.1.1.1.1.5" name="TestDataType"/> + </Template> + <Template validation="Report" type="POCDMT000040Section" location="/ClinicalDocument/component/structuredBody/component[8]/section"> + <templateId id="1.1.1.1.1.1.1.6" name="TestContext"/> + </Template> + <Template validation="Report" type="POCDMT000040Section" location="/ClinicalDocument/component/structuredBody/component[9]/section"> + <templateId id="1.1.1.1.1.1.1.6" name="TestContext"/> + </Template> + <Template validation="Error" type="POCDMT000040Section" location="/ClinicalDocument/component/structuredBody/component[10]/section"> + <templateId id="1.1.1.1.1.1.1.6" name="TestContext"/> + </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 0000000000000000000000000000000000000000..d8a8f31766634a763ae5a3d1de5cd0d0833d5a08 --- /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 0000000000000000000000000000000000000000..254a9d2586e8bdf3c28fa5c0ce778e91d8546b42 --- /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 0000000000000000000000000000000000000000..1abc701b2b449ac595efd6ebd30dbca993fdbd68 --- /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 0000000000000000000000000000000000000000..169b3a216acd0c4e5daf1ef41ebec69173894da8 --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/main/resources/specifications.properties @@ -0,0 +1,27 @@ +global.bbr=global/decor_global.xml +global.cda=global/cda_global.xml +global.expected=global/expected_global.xml + +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=datatype/decor_datatype.xml +datatype.cda=datatype/cda_datatype.xml +datatype.expected=datatype/expected_datatype.xml + +context.bbr=context/decor_context.xml +context.cda=context/cda_context.xml +context.expected=context/expected_context.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 0000000000000000000000000000000000000000..09c297b1af114a79a36158aaf3a848bbaee5c74c --- /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 0000000000000000000000000000000000000000..cb0f746314d8c6e009d57755e69093c202a6a4aa --- /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" strength="extensible" 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 (with warning) "multiple valueSets" --> + <element name="cda:priorityCode" strength="required" 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 (with Info) "flexibility" --> + <element name="cda:languageCode" strength="preferred" 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 0000000000000000000000000000000000000000..746e027467ce190b558f44d6d1183c4d46523aae --- /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 SHOULD 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 MAY 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> + <Warning> + <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 SHOULD 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> + </Warning> + <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> + <Info> + <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 MAY 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> + </Info> + <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 10</ValidationDate> + <ValidationTime>04:37:01</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/SystemTests.java b/hl7templates/goc-tests/goc-tests-runner/src/test/java/net/ihe/gazelle/goctests/SystemTests.java new file mode 100644 index 0000000000000000000000000000000000000000..b08e9c764d22adc7bdccd969b499966ca7fbe2ed --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/test/java/net/ihe/gazelle/goctests/SystemTests.java @@ -0,0 +1,113 @@ +package net.ihe.gazelle.goctests; + +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.specifications.SpecificationType; +import net.ihe.gazelle.goctests.definitions.annotations.Covers; +import net.ihe.gazelle.goctests.definitions.annotations.TestType; +import net.ihe.gazelle.goctests.interlay.SystemTestExecutor; +import net.ihe.gazelle.goctests.interlay.exceptions.EnvironementException; +import net.ihe.gazelle.goctests.interlay.exceptions.ResultTransformationException; +import net.ihe.gazelle.goctests.interlay.exceptions.SpecificationException; +import org.junit.Ignore; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class SystemTests { + + SpecificationType specificationType; + + + @Ignore + @Test + public void globalTest() throws ReportGenerationException, TestRunnerException, SpecificationException, + EnvironementException, ResultTransformationException { + + this.specificationType = SpecificationType.GLOBAL; + runTest(); + + } + + + @Ignore + @Covers(requirements = {"GOC-001","GOC-002","GOC-003","GOC-004","GOC-025","GOC-026"}, testType = TestType.SYSTEM_TEST) + @Test + public void cardinalityTest() throws ReportGenerationException, TestRunnerException, SpecificationException, + EnvironementException, ResultTransformationException { + + this.specificationType = SpecificationType.CARDINALITY; + runTest(); + + } + + @Ignore + @Covers(requirements = {"GOC-006","GOC-027"}, testType = TestType.SYSTEM_TEST) + @Test + public void mandatoryTest() throws ReportGenerationException, TestRunnerException, SpecificationException, + EnvironementException, ResultTransformationException { + this.specificationType = SpecificationType.MANDATORY; + runTest(); + + } + + @Ignore + @Covers(requirements = {"GOC-013","GOC-017","GOC-018","GOC-036","GOC-038","GOC-039","GOC-040","GOC-041", + "GOC-121","GOC-122","GOC-123","GOC-124","GOC-145"}) + @Test + public void vocabularyTest() throws ReportGenerationException, TestRunnerException, SpecificationException, + EnvironementException, ResultTransformationException { + this.specificationType = SpecificationType.VOCABULARY; + runTest(); + + } + + @Ignore + @Covers(requirements = {"GOC-012"}, testType = TestType.SYSTEM_TEST) + @Test + public void fixedValueTest() throws ReportGenerationException, TestRunnerException, SpecificationException, + EnvironementException, ResultTransformationException { + this.specificationType = SpecificationType.FIXEDVAL; + runTest(); + + } + + @Ignore + @Covers(requirements = {"GOC-029","GOC-062","GOC-63"}, testType = TestType.SYSTEM_TEST) + @Test + public void datatypeTest() throws ReportGenerationException, TestRunnerException, SpecificationException, + EnvironementException, ResultTransformationException { + this.specificationType = SpecificationType.DATATYPE; + runTest(); + + } + + @Ignore + @Covers(requirements = {"GOC-079","GOC-082","GOC-083","GOC-084","GOC-085","GOC-086"}, testType = TestType.SYSTEM_TEST) + @Test + public void contextTest() throws ReportGenerationException, TestRunnerException, SpecificationException, + EnvironementException, ResultTransformationException { + this.specificationType = SpecificationType.CONTEXT; + runTest(); + + } + + + private void runTest() throws ReportGenerationException, TestRunnerException, + SpecificationException, EnvironementException, ResultTransformationException { + + SystemTestExecutor executor = new SystemTestExecutor(this.specificationType); + TestResult testResult = executor.execute(); + + customAssert(testResult); + } + + + private void customAssert(TestResult testResult){ + assertEquals(this.specificationType,testResult.getSpecificationType()); + assertEquals(0,testResult.getOracleResult().getMissedElements().size()); + assertEquals(0,testResult.getOracleResult().getUnexpectedElements().size()); + assertTrue(testResult.getOracleResult().isValid()); + } +} 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 0000000000000000000000000000000000000000..cb4edf4c54478300c29263ca442ed8285dc7628b --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/test/java/net/ihe/gazelle/goctests/interlay/ValidatorGeneratorTest.java @@ -0,0 +1,37 @@ +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; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.MalformedURLException; +import java.net.URL; + +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 = "[YOUR BBR PATH]"; + String output = "[YOUR CDA PATH]"; + String mvn = "[YOUR MVN PATH]"; + try { + GeneratedValidator validator = validatorGenerator.generateValidator(new URL(bbr),output,mvn); + org.junit.Assert.assertTrue(validator.getValidatorBinaryPath() != null); + System.out.println(validator); + } catch (ValidatorGenerationException | MalformedURLException e) { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/hl7templates/goc-tests/goc-tests-runner/src/test/resources/application.properties b/hl7templates/goc-tests/goc-tests-runner/src/test/resources/application.properties new file mode 100644 index 0000000000000000000000000000000000000000..219b09bffdf2ef2aaa2da1ec8da2f975a88c95aa --- /dev/null +++ b/hl7templates/goc-tests/goc-tests-runner/src/test/resources/application.properties @@ -0,0 +1,12 @@ +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 +# Please change it to your path +result.type.xmlpath=./ \ No newline at end of file diff --git a/hl7templates/goc-tests/pom.xml b/hl7templates/goc-tests/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..1e8025b9450d4c895a97a8051410b1a2665af0fb --- /dev/null +++ b/hl7templates/goc-tests/pom.xml @@ -0,0 +1,46 @@ +<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>gazelle-objects-checker</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</groupId> + <artifactId>goc-tests</artifactId> + <name>GOC Tests</name> + <version>3.0.4-SNAPSHOT</version> + + <packaging>pom</packaging> + + <modules> + <module>goc-annotations</module> + <module>goc-tests-runner</module> + </modules> + + <organization> + <name>IHE-Europe</name> + <url>https://ihe-europe.net/</url> + </organization> + <description> + This module defines System Tests for Gazelle Objects Checker based on a prototyping BBR + </description> + <issueManagement> + <system>JIRA</system> + <url>https://gazelle.ihe.net/jira/projects/GOC</url> + </issueManagement> + + <inceptionYear>2021</inceptionYear> + + <developers> + <developer> + <name>Achraf Achkari</name> + <email>achraf.achkari-begdouri@kereval.com</email> + </developer> + </developers> + + + +</project> \ No newline at end of file diff --git a/hl7templates/gocmodel-jar/pom.xml b/hl7templates/gocmodel-jar/pom.xml index ec74fd7cdeeadd8e61cb8b4290756fa3506b6c0d..5edc7683f52c30001f5034fe41eba13449426349 100644 --- a/hl7templates/gocmodel-jar/pom.xml +++ b/hl7templates/gocmodel-jar/pom.xml @@ -334,6 +334,11 @@ <artifactId>commons-io</artifactId> <version>2.6</version> </dependency> + <dependency> + <groupId>net.ihe.gazelle.goctests</groupId> + <artifactId>goc-annotations</artifactId> + <version>3.0.4-SNAPSHOT</version> + </dependency> </dependencies> </project> diff --git a/hl7templates/hl7templates-generator-jar/.gitignore b/hl7templates/hl7templates-generator-jar/.gitignore index 821f4de93b3d27c7167c63104eafd5d59b9116e5..f8ec57a9230a3854fb9fb31eb3b70101c9866213 100644 --- a/hl7templates/hl7templates-generator-jar/.gitignore +++ b/hl7templates/hl7templates-generator-jar/.gitignore @@ -15,3 +15,4 @@ /src/test/resources/out /src/test/java/net/ihe/gazelle/tempgen/ignoredTests/ +/src/it/java/net/ihe/gazelle/tempgen/lab/ diff --git a/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/RDprocessors/test/ItemsProcessorIT.java b/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/RDprocessors/test/ItemsProcessorIT.java new file mode 100644 index 0000000000000000000000000000000000000000..f9ac54e374c62b77bc2499fe1d979a19d8f11739 --- /dev/null +++ b/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/RDprocessors/test/ItemsProcessorIT.java @@ -0,0 +1,54 @@ +package net.ihe.gazelle.tempgen.RDprocessors.test; + +import net.ihe.gazelle.goc.uml.utils.PackagedElementUtil; +import net.ihe.gazelle.goc.xmm.OwnedRule; +import net.ihe.gazelle.goc.xmm.PackagedElement; +import net.ihe.gazelle.goctests.definitions.annotations.Covers; +import net.ihe.gazelle.goctests.definitions.annotations.TestType; +import net.ihe.gazelle.tempgen.action.RuleDefinitionAnalyzer; +import net.ihe.gazelle.tempgen.handler.ProblemHandler; +import net.ihe.gazelle.tempmodel.org.decor.art.model.Decor; +import net.ihe.gazelle.tempmodel.org.decor.art.model.RuleDefinition; +import net.ihe.gazelle.tempmodel.org.decor.art.utils.*; +import net.ihe.gazelle.validation.Notification; +import org.junit.Ignore; +import org.junit.Test; +import static org.junit.Assert.*; + +public class ItemsProcessorIT extends RuleDefinitionAnalyzer { + + @Ignore + @Test + public void print(){ + Decor decor = DecorMarshaller.loadDecor("src/test/resources/processors/decor_vocab_VS.xml"); + RuleDefinition firstRD = TemplateDefinitionUtil.getFirstElement(RulesUtil.getTemplates(decor.getRules()).get(0)); + RuleDefinition code = RuleDefinitionUtil.getElementByName(firstRD, "hl7:value"); + RuleDefinition observation = RuleDefinitionUtil.getElementByName(code,"hl7:observation"); + this.selectedRuleDefinition = code; + this.currentPackagedElement = PackagedElementUtil.initPackagedElement(); + this.processVocabularys(code.getVocabulary()); + + + for(OwnedRule ownedRule : this.currentPackagedElement.getOwnedRule()){ + System.out.println(ownedRule.getSpecification().getBody()); + System.out.println(ownedRule.getOwnedRuleKind().getValue()); + System.out.println(ownedRule.getOwnedRuleType().getValue()); + } + for(Notification notification : ProblemHandler.getDiagnostic()){ + System.out.println(notification.getDescription()); + } + } + + @Covers(requirements = {"GOC-021"}, testType = TestType.INTEGRATION_TEST, comment = "RuleDefinitions Coverage") + @Test + public void testProcessItem(){ + Decor decor = DecorMarshaller.loadDecor("src/test/resources/processors/decor_item.xml"); + RuleDefinition firstRD = TemplateDefinitionUtil.getFirstElement(RulesUtil.getTemplates(decor.getRules()).get(0)); + RuleDefinition value = RuleDefinitionUtil.getElementByName(firstRD, "hl7:value"); + RuleDefinitionAnalyzer rda = new RuleDefinitionAnalyzer(); + PackagedElement pe = PackagedElementUtil.initPackagedElement(); + rda.process(value,pe); + assertEquals(1,pe.getOwnedRule().size()); + assertTrue(pe.getOwnedRule().get(0).getOwnedComment().getBody().contains("(Item : CONF-test)")); + } +} diff --git a/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/RDprocessors/test/MultiplicityProcessorsIT.java b/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/RDprocessors/test/MultiplicityProcessorsIT.java new file mode 100644 index 0000000000000000000000000000000000000000..5144b029b5024e22491ba93ca61324a076077b05 --- /dev/null +++ b/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/RDprocessors/test/MultiplicityProcessorsIT.java @@ -0,0 +1,132 @@ +package net.ihe.gazelle.tempgen.RDprocessors.test; + +import net.ihe.gazelle.goc.uml.utils.PackagedElementUtil; +import net.ihe.gazelle.goc.xmm.OwnedRule; +import net.ihe.gazelle.goc.xmm.OwnedRuleKind; +import net.ihe.gazelle.goc.xmm.OwnedRuleType; +import net.ihe.gazelle.goctests.definitions.annotations.Covers; +import net.ihe.gazelle.goctests.definitions.annotations.TestType; +import net.ihe.gazelle.tempgen.action.RuleDefinitionAnalyzer; +import net.ihe.gazelle.tempmodel.org.decor.art.model.Decor; +import net.ihe.gazelle.tempmodel.org.decor.art.model.RuleDefinition; +import net.ihe.gazelle.tempmodel.org.decor.art.utils.DecorMarshaller; +import net.ihe.gazelle.tempmodel.org.decor.art.utils.RuleDefinitionUtil; +import net.ihe.gazelle.tempmodel.org.decor.art.utils.RulesUtil; +import net.ihe.gazelle.tempmodel.org.decor.art.utils.TemplateDefinitionUtil; +import org.junit.Ignore; +import org.junit.Test; +import static org.junit.Assert.assertEquals; + + +public class MultiplicityProcessorsIT extends RuleDefinitionAnalyzer { + + + + + /** + * Test with the min 0 and conformance R, expected to have a size()>1 but just a warning + */ + @Covers(requirements = {"GOC-001","GOC-028"}, testType = TestType.INTEGRATION_TEST, comment = "RuleDefintions Coverage") + @Test + public void testProcessMinimumMultiplicity_0_R(){ + Decor decor = DecorMarshaller.loadDecor("src/test/resources/processors/decor_multiplicity_0_n_R.xml"); + RuleDefinition firstRD = TemplateDefinitionUtil.getFirstElement(RulesUtil.getTemplates(decor.getRules()).get(0)); + RuleDefinition entry = RuleDefinitionUtil.getElementByName(firstRD, "hl7:entryRelationship"); + this.selectedRuleDefinition = entry; + this.currentPackagedElement = PackagedElementUtil.initPackagedElement(); + this.processMinimumMultiplicity(entry.getMinimumMultiplicity()); + assertEquals(1,this.currentPackagedElement.getOwnedRule().size()); + OwnedRule ownedRule = this.currentPackagedElement.getOwnedRule().get(0); + assertEquals("(not self.nullFlavor.oclIsUndefined()) or self.entryRelationship" + + "->select((not observation.code.code.oclIsUndefined()) " + + "and observation.code.code='48766-0')->size()>0", + ownedRule.getSpecification().getBody()); + assertEquals(OwnedRuleKind.CARDINALITY,ownedRule.getOwnedRuleKind()); + assertEquals(OwnedRuleType.WARNING,ownedRule.getOwnedRuleType()); + + } + + /** + * Test with the min 1 (or >) and conformance R, expected to have a size()>1 with an a error + */ + @Covers(requirements = {"GOC-009","GOC-028"}, testType = TestType.INTEGRATION_TEST, comment = "RuleDefintions Coverage") + @Test + public void testProcessMinimumMultiplicity_1_R(){ + Decor decor = DecorMarshaller.loadDecor("src/test/resources/processors/decor_multiplicity_1_n_R.xml"); + RuleDefinition firstRD = TemplateDefinitionUtil.getFirstElement(RulesUtil.getTemplates(decor.getRules()).get(0)); + RuleDefinition entry = RuleDefinitionUtil.getElementByName(firstRD, "hl7:entryRelationship"); + this.selectedRuleDefinition = entry; + this.currentPackagedElement = PackagedElementUtil.initPackagedElement(); + this.processMinimumMultiplicity(entry.getMinimumMultiplicity()); + assertEquals(1,this.currentPackagedElement.getOwnedRule().size()); + OwnedRule ownedRule = this.currentPackagedElement.getOwnedRule().get(0); + assertEquals("(not self.nullFlavor.oclIsUndefined()) or self.entryRelationship" + + "->select((not observation.code.code.oclIsUndefined()) " + + "and observation.code.code='48766-0')->size()>0", + ownedRule.getSpecification().getBody()); + assertEquals(OwnedRuleKind.CARDINALITY,ownedRule.getOwnedRuleKind()); + assertEquals(OwnedRuleType.ERROR,ownedRule.getOwnedRuleType()); + + } + +// @Covers(requirements = {"GOC-009"}, testType = TestType.INTEGRATION_TEST) + + /** + * The NP and C conformances are not processed by goc: GOC-010, GOC-011 + */ + @Ignore + @Test + public void testProcessMinimumMultiplicity_NP(){ + Decor decor = DecorMarshaller.loadDecor("src/test/resources/processors/decor_multiplicity_1_n_R.xml"); + RuleDefinition firstRD = TemplateDefinitionUtil.getFirstElement(RulesUtil.getTemplates(decor.getRules()).get(0)); + RuleDefinition entry = RuleDefinitionUtil.getElementByName(firstRD, "hl7:entryRelationship"); + this.selectedRuleDefinition = entry; + this.currentPackagedElement = PackagedElementUtil.initPackagedElement(); + this.processMinimumMultiplicity(entry.getMinimumMultiplicity()); + assertEquals(1,this.currentPackagedElement.getOwnedRule().size()); + OwnedRule ownedRule = this.currentPackagedElement.getOwnedRule().get(0); + assertEquals("(not self.nullFlavor.oclIsUndefined()) or self.entryRelationship" + + "->select((not observation.code.code.oclIsUndefined()) " + + "and observation.code.code='48766-0')->size()>0", + ownedRule.getSpecification().getBody()); + assertEquals(OwnedRuleKind.CARDINALITY,ownedRule.getOwnedRuleKind()); + assertEquals(OwnedRuleType.ERROR,ownedRule.getOwnedRuleType()); + + } + + @Covers(requirements = {"GOC-004"}, testType = TestType.INTEGRATION_TEST, comment = "RuleDefintions Coverage") + @Test + public void testProcessMaximumMultiplicity_n(){ + Decor decor = DecorMarshaller.loadDecor("src/test/resources/processors/decor_multiplicity_0_n_R.xml"); + RuleDefinition firstRD = TemplateDefinitionUtil.getFirstElement(RulesUtil.getTemplates(decor.getRules()).get(0)); + RuleDefinition entry = RuleDefinitionUtil.getElementByName(firstRD, "hl7:entryRelationship"); + this.selectedRuleDefinition = entry; + this.currentPackagedElement = PackagedElementUtil.initPackagedElement(); + this.processMaximumMultiplicity(entry.getMaximumMultiplicity()); + assertEquals(0,this.currentPackagedElement.getOwnedRule().size()); + + } + + @Covers(requirements = {"GOC-003","GOC-026"}, testType = TestType.INTEGRATION_TEST, comment = "RuleDefintions Coverage") + @Test + public void testProcessMaximumMultiplicity_2(){ + Decor decor = DecorMarshaller.loadDecor("src/test/resources/processors/decor_multiplicity_0_2_R.xml"); + RuleDefinition firstRD = TemplateDefinitionUtil.getFirstElement(RulesUtil.getTemplates(decor.getRules()).get(0)); + RuleDefinition entry = RuleDefinitionUtil.getElementByName(firstRD, "hl7:entryRelationship"); + this.selectedRuleDefinition = entry; + this.currentPackagedElement = PackagedElementUtil.initPackagedElement(); + this.processMaximumMultiplicity(entry.getMaximumMultiplicity()); + assertEquals(1,this.currentPackagedElement.getOwnedRule().size()); + OwnedRule ownedRule = this.currentPackagedElement.getOwnedRule().get(0); + assertEquals("self.entryRelationship->select((not observation.code.code.oclIsUndefined()) " + + "and observation.code.code='48766-0')->size()<3",ownedRule.getSpecification().getBody()); + assertEquals(OwnedRuleKind.CARDINALITY,ownedRule.getOwnedRuleKind()); + + } + + + + + + +} diff --git a/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/RDprocessors/test/VocabularyProcessorsIT.java b/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/RDprocessors/test/VocabularyProcessorsIT.java new file mode 100644 index 0000000000000000000000000000000000000000..7c897960ab56e6d20132f136f3680aeef178c207 --- /dev/null +++ b/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/RDprocessors/test/VocabularyProcessorsIT.java @@ -0,0 +1,103 @@ +package net.ihe.gazelle.tempgen.RDprocessors.test; + +import net.ihe.gazelle.goc.uml.utils.PackagedElementUtil; +import net.ihe.gazelle.goc.xmm.OwnedRule; +import net.ihe.gazelle.goc.xmm.OwnedRuleKind; +import net.ihe.gazelle.goc.xmm.OwnedRuleType; +import net.ihe.gazelle.goctests.definitions.annotations.Covers; +import net.ihe.gazelle.goctests.definitions.annotations.TestType; +import net.ihe.gazelle.tempgen.action.RuleDefinitionAnalyzer; +import net.ihe.gazelle.tempgen.handler.ProblemHandler; +import net.ihe.gazelle.tempmodel.org.decor.art.model.Decor; +import net.ihe.gazelle.tempmodel.org.decor.art.model.RuleDefinition; +import net.ihe.gazelle.tempmodel.org.decor.art.utils.DecorMarshaller; +import net.ihe.gazelle.tempmodel.org.decor.art.utils.RuleDefinitionUtil; +import net.ihe.gazelle.tempmodel.org.decor.art.utils.RulesUtil; +import net.ihe.gazelle.tempmodel.org.decor.art.utils.TemplateDefinitionUtil; +import net.ihe.gazelle.validation.Notification; +import org.junit.Ignore; +import org.junit.Test; +import static org.junit.Assert.assertEquals; + + +public class VocabularyProcessorsIT extends RuleDefinitionAnalyzer { + + @Ignore + @Test + public void print(){ + Decor decor = DecorMarshaller.loadDecor("src/test/resources/processors/decor_vocab_VS_dynamic.xml"); + RuleDefinition firstRD = TemplateDefinitionUtil.getFirstElement(RulesUtil.getTemplates(decor.getRules()).get(0)); + RuleDefinition code = RuleDefinitionUtil.getElementByName(firstRD, "hl7:value"); + RuleDefinition observation = RuleDefinitionUtil.getElementByName(code,"hl7:observation"); + this.selectedRuleDefinition = code; + this.currentPackagedElement = PackagedElementUtil.initPackagedElement(); + this.processVocabularys(code.getVocabulary()); + + + for(OwnedRule ownedRule : this.currentPackagedElement.getOwnedRule()){ + System.out.println(ownedRule.getSpecification().getBody()); + System.out.println(ownedRule.getOwnedRuleKind().getValue()); + System.out.println(ownedRule.getOwnedRuleType().getValue()); + } + for(Notification notification : ProblemHandler.getDiagnostic()){ + System.out.println(notification.getDescription()); + } + } + + + @Covers(requirements = {"GOC-012"},testType = TestType.INTEGRATION_TEST, comment = "RuleDefinitions Coverage") + @Test + public void testProcessVocabularys_FixedVal(){ + Decor decor = DecorMarshaller.loadDecor("src/test/resources/processors/decor_vocab_fixdedVal.xml"); + RuleDefinition firstRD = TemplateDefinitionUtil.getFirstElement(RulesUtil.getTemplates(decor.getRules()).get(0)); + RuleDefinition value = RuleDefinitionUtil.getElementByName(firstRD, "hl7:value"); + this.selectedRuleDefinition = value; + this.currentPackagedElement = PackagedElementUtil.initPackagedElement(); + this.processVocabularys(value.getVocabulary()); + assertEquals(1,this.currentPackagedElement.getOwnedRule().size()); + OwnedRule ownedRule = this.currentPackagedElement.getOwnedRule().get(0); + assertEquals("self.value->forAll( (not nullFlavor.oclIsUndefined()) " + + "or (((oclAsType(CS).codeSystem.oclIsUndefined()) or oclAsType(CS).codeSystem='1.2.3')))", + ownedRule.getSpecification().getBody()); + assertEquals(OwnedRuleKind.VOCABULARY, ownedRule.getOwnedRuleKind()); + assertEquals(OwnedRuleType.ERROR, ownedRule.getOwnedRuleType()); + } + + @Covers(requirements = {"GOC-013","GOC-017"},testType = TestType.INTEGRATION_TEST, comment = "RuleDefinitions Coverage") + @Test + public void testProcessVocabularys_VS(){ + Decor decor = DecorMarshaller.loadDecor("src/test/resources/processors/decor_vocab_VS.xml"); + RuleDefinition firstRD = TemplateDefinitionUtil.getFirstElement(RulesUtil.getTemplates(decor.getRules()).get(0)); + RuleDefinition value = RuleDefinitionUtil.getElementByName(firstRD, "hl7:value"); + this.selectedRuleDefinition = value; + this.currentPackagedElement = PackagedElementUtil.initPackagedElement(); + this.processVocabularys(value.getVocabulary()); + assertEquals(1,this.currentPackagedElement.getOwnedRule().size()); + OwnedRule ownedRule = this.currentPackagedElement.getOwnedRule().get(0); + assertEquals("self.value->forAll( (not nullFlavor.oclIsUndefined()) or ((not oclAsType(CS).code.oclIsUndefined()) and " + + "CommonOperationsStatic::matchesCodeToValueSet('1.3.6.1.4.1.12559.11.10.1.3.1.42.10&version=2015-01-01T01:02:02', oclAsType(CS).code)))", + ownedRule.getSpecification().getBody()); + assertEquals(OwnedRuleKind.VOCABULARY, ownedRule.getOwnedRuleKind()); + assertEquals(OwnedRuleType.ERROR, ownedRule.getOwnedRuleType()); + } + + @Covers(requirements = {"GOC-018"},testType = TestType.INTEGRATION_TEST, comment = "RuleDefinitions Coverage") + @Test + public void testProcessVocabularys_VS_dynamic(){ + Decor decor = DecorMarshaller.loadDecor("src/test/resources/processors/decor_vocab_VS_dynamic.xml"); + RuleDefinition firstRD = TemplateDefinitionUtil.getFirstElement(RulesUtil.getTemplates(decor.getRules()).get(0)); + RuleDefinition value = RuleDefinitionUtil.getElementByName(firstRD, "hl7:value"); + this.selectedRuleDefinition = value; + this.currentPackagedElement = PackagedElementUtil.initPackagedElement(); + this.processVocabularys(value.getVocabulary()); + assertEquals(1,this.currentPackagedElement.getOwnedRule().size()); + OwnedRule ownedRule = this.currentPackagedElement.getOwnedRule().get(0); + assertEquals("self.value->forAll( (not nullFlavor.oclIsUndefined()) or ((not oclAsType(CS).code.oclIsUndefined()) " + + "and CommonOperationsStatic::matchesCodeToValueSet('1.3.6.1.4.1.12559.11.10.1.3.1.42.10', oclAsType(CS).code)))", + ownedRule.getSpecification().getBody()); + assertEquals(OwnedRuleKind.VOCABULARY, ownedRule.getOwnedRuleKind()); + assertEquals(OwnedRuleType.ERROR, ownedRule.getOwnedRuleType()); + } + + +} diff --git a/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/assertions/test/XPATHValidationIT.java b/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/assertions/test/XPATHValidationIT.java index 5bb1d62c9f9729e85325a1ff99c2a866473553f6..007b3a8add30a091cd8bdae54740a1f33736d9cd 100644 --- a/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/assertions/test/XPATHValidationIT.java +++ b/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/assertions/test/XPATHValidationIT.java @@ -26,6 +26,8 @@ import static org.junit.Assert.*; public class XPATHValidationIT extends AssertAnalyzer { + // Bad cases + private Decor decorTemplate = null; // private List<TemplateDefinition> templateDefinitions = null; private TemplateDefinition currentTemplate = null; diff --git a/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/choice/test/AssertionChoicesIT.java b/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/choice/test/AssertionChoicesIT.java index 4e935896c5ea5c89c5fda1bdafed925d52a1265f..1e2d416ffb2167bb80106c3343274b576d2c8ffc 100644 --- a/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/choice/test/AssertionChoicesIT.java +++ b/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/choice/test/AssertionChoicesIT.java @@ -32,6 +32,7 @@ public class AssertionChoicesIT extends ChoiceDefinitionAnalyzer { @Before public void setUp(){ decor = DecorMarshaller.loadDecor("src/test/resources/choices/decor_assertionChoices3.xml"); +// decor = DecorMarshaller.loadDecor("src/test/resources/choices/decor_helper.xml"); decor = DecorUtil.cleanupForEffectiveDate(decor); decor = GeneralFlattenDecor.generalFlattenDecor(decor); td = RulesUtil.getTemplates(decor.getRules()).get(0); @@ -45,7 +46,7 @@ public class AssertionChoicesIT extends ChoiceDefinitionAnalyzer { public void TestPrintChoices(){ List<RuleDefinition> ruleDefinitions = ChoiceDefinitionUtil.getElements(currentChoice); for(RuleDefinition element:ruleDefinitions){ - + System.out.println(element.getName()); } assertEquals(ruleDefinitions.size(),3); } diff --git a/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/rules/analyzer/ContainMaximumMultiplicityAnalyzerIT.java b/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/rules/analyzer/ContainMaximumMultiplicityAnalyzerIT.java index 5683d9a8a221769d3f132992e63c03827c863414..91d78cbb219da25227b8ebbf297d794b1aedda52 100644 --- a/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/rules/analyzer/ContainMaximumMultiplicityAnalyzerIT.java +++ b/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/rules/analyzer/ContainMaximumMultiplicityAnalyzerIT.java @@ -1,5 +1,7 @@ package net.ihe.gazelle.tempgen.rules.analyzer; +import net.ihe.gazelle.goctests.definitions.annotations.Covers; +import net.ihe.gazelle.goctests.definitions.annotations.TestType; import net.ihe.gazelle.tempmodel.org.decor.art.model.Decor; import net.ihe.gazelle.tempmodel.org.decor.art.model.RuleDefinition; import net.ihe.gazelle.tempmodel.org.decor.art.utils.DecorMarshaller; @@ -20,6 +22,7 @@ public class ContainMaximumMultiplicityAnalyzerIT { decorTemplates = DecorMarshaller.loadDecor("src/test/resources/contain/decor_contain_ter_max.xml"); } + @Covers(requirements = {"GOC-003"}, testType = TestType.INTEGRATION_TEST) @Test public void generateOCLConstraint() { RuleDefinition firstRD = TemplateDefinitionUtil.getFirstElement(RulesUtil.getTemplates(decorTemplates.getRules()).get(0)); diff --git a/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/rules/analyzer/ContainMinimumMultiplicityAnalyzerIT.java b/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/rules/analyzer/ContainMinimumMultiplicityAnalyzerIT.java index 85dc74fe57c69cbdfbafc28f220dc18a539ccafa..632fb9716f4ac607660772629220a424aa5e25a4 100644 --- a/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/rules/analyzer/ContainMinimumMultiplicityAnalyzerIT.java +++ b/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/rules/analyzer/ContainMinimumMultiplicityAnalyzerIT.java @@ -1,5 +1,7 @@ package net.ihe.gazelle.tempgen.rules.analyzer; +import net.ihe.gazelle.goctests.definitions.annotations.Covers; +import net.ihe.gazelle.goctests.definitions.annotations.TestType; import net.ihe.gazelle.tempmodel.org.decor.art.model.Decor; import net.ihe.gazelle.tempmodel.org.decor.art.model.RuleDefinition; import net.ihe.gazelle.tempmodel.org.decor.art.utils.DecorMarshaller; @@ -20,6 +22,7 @@ public class ContainMinimumMultiplicityAnalyzerIT { decorTemplates = DecorMarshaller.loadDecor("src/test/resources/contain/decor_contain_ter.xml"); } + @Covers(requirements = {"GOC-002"}, testType = TestType.INTEGRATION_TEST) @Test public void testGenerateOCLConstraint1() { RuleDefinition firstRD = TemplateDefinitionUtil.getFirstElement(RulesUtil.getTemplates(decorTemplates.getRules()).get(0)); diff --git a/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/test/RDMandatoryIT.java b/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/test/RDMandatoryAnalyzerIT.java similarity index 61% rename from hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/test/RDMandatoryIT.java rename to hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/test/RDMandatoryAnalyzerIT.java index 2991d675d3391b1028ac1e5b3a288a919bf5f601..3d8918f2b7cc321df1f5748a0415c0684ec11892 100644 --- a/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/test/RDMandatoryIT.java +++ b/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/test/RDMandatoryAnalyzerIT.java @@ -2,7 +2,10 @@ package net.ihe.gazelle.tempgen.test; import static org.junit.Assert.assertTrue; +import net.ihe.gazelle.goctests.definitions.annotations.Covers; +import net.ihe.gazelle.goctests.definitions.annotations.TestType; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import net.ihe.gazelle.tempgen.rules.analyzer.RDMandatoryAnalyzer; @@ -18,18 +21,21 @@ import net.ihe.gazelle.tempmodel.org.decor.art.utils.TemplateDefinitionUtil; * @author Abderrazek Boufahja * */ -public class RDMandatoryIT { +public class RDMandatoryAnalyzerIT { - Decor decorTemplates = null; + Decor decorTemplatesMandatory = null; + Decor decorTemplatesNotMandatory = null; @Before public void setUp(){ - decorTemplates = DecorMarshaller.loadDecor("src/test/resources/decor_custodian.xml"); + decorTemplatesMandatory = DecorMarshaller.loadDecor("src/test/resources/decor_custodian.xml"); + decorTemplatesNotMandatory = DecorMarshaller.loadDecor("src/test/resources/decor_custodian_optional.xml"); } + @Covers(requirements = {"GOC-006","GOC-027"}, testType = TestType.INTEGRATION_TEST) @Test public void testGenerateOCLConstraint() { - RuleDefinition firstRD = TemplateDefinitionUtil.getFirstElement(RulesUtil.getTemplates(decorTemplates.getRules()).get(0)); + RuleDefinition firstRD = TemplateDefinitionUtil.getFirstElement(RulesUtil.getTemplates(decorTemplatesMandatory.getRules()).get(0)); RuleDefinition custodian = RuleDefinitionUtil.getElementByName(firstRD, "cda:custodian"); assertTrue((new RDMandatoryAnalyzer()).generateOCLConstraint(custodian).equals( "self.custodian->forAll(nullFlavor.oclIsUndefined())")); @@ -38,9 +44,24 @@ public class RDMandatoryIT { "self.custodian.assignedCustodian->forAll(nullFlavor.oclIsUndefined())")); } + + /** + * /!\ Should Covers GOC-005 but gives wrong output in the low layer, + * Behaviour correctly provided at processing time, needed "processIsMandatoryTest" to cover + */ + @Ignore + @Test + public void testGenerateOCLConstraintNotMandatory(){ + RuleDefinition firstRD = TemplateDefinitionUtil.getFirstElement(RulesUtil.getTemplates(decorTemplatesNotMandatory.getRules()).get(0)); + RuleDefinition custodian = RuleDefinitionUtil.getElementByName(firstRD, "cda:custodian"); + RuleDefinition assignedCustodian = RuleDefinitionUtil.getElementByName(custodian, "cda:assignedCustodian"); + String gen = (new RDMandatoryAnalyzer()).generateOCLConstraint(assignedCustodian); + System.out.println(gen); + } + @Test public void testGenerateCommentConstraint() { - RuleDefinition firstRD = TemplateDefinitionUtil.getFirstElement(RulesUtil.getTemplates(decorTemplates.getRules()).get(0)); + RuleDefinition firstRD = TemplateDefinitionUtil.getFirstElement(RulesUtil.getTemplates(decorTemplatesMandatory.getRules()).get(0)); RuleDefinition custodian = RuleDefinitionUtil.getElementByName(firstRD, "cda:custodian"); assertTrue((new RDMandatoryAnalyzer()).generateCommentConstraint(custodian).equals( "In US Realm Header, in /hl7:ClinicalDocument[hl7:templateId/@root='2.16.840.1.113883.10.20.22.1.1'], " diff --git a/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/test/RDMaximumMultiplicityIT.java b/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/test/RDMaximumMultiplicityAnalyzerIT.java similarity index 75% rename from hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/test/RDMaximumMultiplicityIT.java rename to hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/test/RDMaximumMultiplicityAnalyzerIT.java index 66a137323f8a3cced50ada8afd75c95026547889..d0def1ab9bd7ac145bc0389201bbb56d6a9cac86 100644 --- a/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/test/RDMaximumMultiplicityIT.java +++ b/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/test/RDMaximumMultiplicityAnalyzerIT.java @@ -2,6 +2,8 @@ package net.ihe.gazelle.tempgen.test; import static org.junit.Assert.assertTrue; +import net.ihe.gazelle.goctests.definitions.annotations.Covers; +import net.ihe.gazelle.goctests.definitions.annotations.TestType; import org.junit.Before; import org.junit.Test; @@ -18,8 +20,11 @@ import net.ihe.gazelle.tempmodel.org.decor.art.utils.TemplateDefinitionUtil; * @author Abderrazek Boufahja * */ -public class RDMaximumMultiplicityIT { - +public class RDMaximumMultiplicityAnalyzerIT { + + static final int MAX_INTEGER = 1000000000; + + Decor decorTemplates = null; @Before @@ -27,6 +32,7 @@ public class RDMaximumMultiplicityIT { decorTemplates = DecorMarshaller.loadDecor("src/test/resources/decor_obs.xml"); } + @Covers(requirements = {"GOC-003","GOC-026"}, testType = TestType.INTEGRATION_TEST) @Test public void testGenerateMaximumMultiplicityBodyConstraint1() { RuleDefinition firstRD = TemplateDefinitionUtil.getFirstElement(RulesUtil.getTemplates(decorTemplates.getRules()).get(0)); @@ -49,6 +55,17 @@ public class RDMaximumMultiplicityIT { + "observation.code.code='48766-0').observation->forAll(targetSiteCode->size()<2)")); } + + //This case figures in the oclGeneration level (low) but ignored in the processing level (high) + @Covers(requirements = {"GOC-004"}, testType = TestType.INTEGRATION_TEST) + @Test + public void testGenerateMaximumMultiplicityBodyConstraintNMulplicity(){ + RuleDefinition firstRD = TemplateDefinitionUtil.getFirstElement(RulesUtil.getTemplates(decorTemplates.getRules()).get(0)); + RuleDefinition entry = RuleDefinitionUtil.getElementByName(firstRD, "hl7:entryRelationship"); + String gen = (new RDMaximumMultiplicityAnalyzer()).generateOCLConstraint(entry); + assertTrue(gen.equals("self.entryRelationship->select((not observation.code.code.oclIsUndefined()) and observation.code.code='48766-0')->size()<"+Integer.valueOf(MAX_INTEGER+1))); + } + @Test public void testGenerateMaximumMultiplicityDescriptionRule() { RuleDefinition firstRD = TemplateDefinitionUtil.getFirstElement(RulesUtil.getTemplates(decorTemplates.getRules()).get(0)); diff --git a/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/test/RDMinimumMultiplicityAnalyzerIT.java b/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/test/RDMinimumMultiplicityAnalyzerIT.java index 362fdc73d397add421decde55720358097ee333f..fbe6d34ca25bbd2a2bfc82ada5d7ff7ac8b016c7 100644 --- a/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/test/RDMinimumMultiplicityAnalyzerIT.java +++ b/hl7templates/hl7templates-generator-jar/src/it/java/net/ihe/gazelle/tempgen/test/RDMinimumMultiplicityAnalyzerIT.java @@ -1,5 +1,6 @@ package net.ihe.gazelle.tempgen.test; +import net.ihe.gazelle.goctests.definitions.annotations.TestType; import net.ihe.gazelle.tempgen.rules.analyzer.AnalyzerEnum; import net.ihe.gazelle.tempgen.rules.analyzer.RDMinimumMultiplicityAnalyzer; import net.ihe.gazelle.tempmodel.org.decor.art.model.ChoiceDefinition; @@ -11,6 +12,7 @@ import org.junit.Test; import javax.xml.bind.JAXBException; import java.io.FileNotFoundException; +import net.ihe.gazelle.goctests.definitions.annotations.Covers; import static org.junit.Assert.assertEquals; @@ -23,8 +25,9 @@ public class RDMinimumMultiplicityAnalyzerIT { decorTemplates = DecorMarshaller.loadDecor("src/test/resources/decor_obs.xml"); } + @Covers(requirements = {"GOC-002","GOC-025"}, testType = TestType.INTEGRATION_TEST) @Test - public void testGenerateOCLConstraint1() { + public void testGenerateOCLConstraint1Test() { RuleDefinition firstRD = TemplateDefinitionUtil.getFirstElement(RulesUtil.getTemplates(decorTemplates.getRules()).get(0)); RuleDefinition entr = RuleDefinitionUtil.getElementByName(firstRD, "hl7:entryRelationship"); RuleDefinition obs = RuleDefinitionUtil.getElementByName(entr, "hl7:observation"); @@ -37,6 +40,28 @@ public class RDMinimumMultiplicityAnalyzerIT { "->reject(not nullFlavor.oclIsUndefined()).observation->forAll((not nullFlavor.oclIsUndefined()) or targetSiteCode->size()>0)", gen); } + @Covers(requirements = {"GOC-001"}, testType = TestType.INTEGRATION_TEST) + @Test + public void testGenerateOCLConstraint0Minimum(){ + Decor decorTemplates = DecorMarshaller.loadDecor("src/test/resources/decor_obs_conf_O.xml"); + RuleDefinition firstRD = TemplateDefinitionUtil.getFirstElement(RulesUtil.getTemplates(decorTemplates.getRules()).get(0)); + RuleDefinition entry = RuleDefinitionUtil.getElementByName(firstRD, "hl7:entryRelationship"); + String gen = (new RDMinimumMultiplicityAnalyzer()).generateOCLConstraint(entry); + assertEquals("(not self.nullFlavor.oclIsUndefined()) or self.entryRelationship" + + "->select((not observation.code.code.oclIsUndefined()) and observation.code.code='48766-0')->size()>0", gen); + } + + @Test + public void testGenerateOCLConfmR(){ + Decor decorTemplates = DecorMarshaller.loadDecor("src/test/resources/decor_obs_conf_R.xml"); + RuleDefinition firstRD = TemplateDefinitionUtil.getFirstElement(RulesUtil.getTemplates(decorTemplates.getRules()).get(0)); + RuleDefinition entr = RuleDefinitionUtil.getElementByName(firstRD, "hl7:entryRelationship"); +// RuleDefinition obs = RuleDefinitionUtil.getElementByName(entr, "hl7:observation"); +// RuleDefinition status = RuleDefinitionUtil.getElementByName(obs, "hl7:targetSiteCode"); + String gen = (new RDMinimumMultiplicityAnalyzer()).generateOCLConstraint(entr); + System.out.println(gen); + } + @Test public void testGenerateOCLConstraint2() throws FileNotFoundException, JAXBException { Decor decorTemplates = DecorMarshaller.loadDecor("src/test/resources/decor_obs_dist1.xml"); diff --git a/hl7templates/hl7templates-generator-jar/src/main/java/net/ihe/gazelle/tempgen/action/HL7TemplatesConverter.java b/hl7templates/hl7templates-generator-jar/src/main/java/net/ihe/gazelle/tempgen/action/HL7TemplatesConverter.java index 258b1cab1a88dd6b4d8a74722670bda73b89a7f6..1368555248a300316455860ee75d625dbcb2ae11 100644 --- a/hl7templates/hl7templates-generator-jar/src/main/java/net/ihe/gazelle/tempgen/action/HL7TemplatesConverter.java +++ b/hl7templates/hl7templates-generator-jar/src/main/java/net/ihe/gazelle/tempgen/action/HL7TemplatesConverter.java @@ -9,6 +9,7 @@ import net.ihe.gazelle.tempgen.flatten.action.RulesCleaner; import net.ihe.gazelle.tempgen.inc.action.IncludeFlattener; import net.ihe.gazelle.tempmodel.org.decor.art.model.BuildingBlockRepository; import net.ihe.gazelle.tempmodel.org.decor.art.model.Decor; +import net.ihe.gazelle.tempmodel.org.decor.art.utils.BBRResource; import net.ihe.gazelle.tempmodel.org.decor.art.utils.DecorMarshaller; import net.ihe.gazelle.tempmodel.org.decor.art.utils.DecorUtil; import org.slf4j.Logger; @@ -16,6 +17,8 @@ import org.slf4j.LoggerFactory; import javax.xml.bind.JAXBException; import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.net.URL; /** * @author Abderrazek Boufahja @@ -42,13 +45,11 @@ public class HL7TemplatesConverter { * @throws JAXBException if decor cannot be unmarshall * @return The XMI String */ - public String convertArtDecorXMI(String bbrpath, boolean ignoreTemplateIdRequirements, String templateVersionFilter) + public String convertArtDecorXMI(Decor decor, boolean ignoreTemplateIdRequirements, String templateVersionFilter) throws JAXBException { log.info("Converting BBR to UML Model"); - //TODO interface to hl7templates-model-jar - Decor decor = DecorMarshaller.loadDecor(bbrpath); //Log used BBRs if(decor != null){ @@ -94,6 +95,20 @@ public class HL7TemplatesConverter { return res; } + public String convertArtDecorXMI(String bbrpath, boolean ignoreTemplateIdRequirements, String templateVersionFilter) + throws JAXBException { + Decor decor = DecorMarshaller.loadDecor(bbrpath); + return convertArtDecorXMI(decor, ignoreTemplateIdRequirements, templateVersionFilter); + } + + public String convertArtDecorXMI(BBRResource bbrResource, boolean ignoreTemplateIdRequirements, String templateVersionFilter) + throws JAXBException { + + //TODO interface to hl7templates-model-jar + Decor decor = DecorMarshaller.loadDecor(bbrResource); + return convertArtDecorXMI(decor, ignoreTemplateIdRequirements, templateVersionFilter); + } + private Decor flattenDecor(Decor decorParam) { Decor decor = decorParam; log.info("Clean rules of the decor to flatten"); 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 3d1c8d10307045f14eb2c28edd9d88f6923e02bf..012e51e6b0e5592f5e82a0ffaabb54dba43eafa9 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-generator-jar/src/test/resources/decor_custodian_optional.xml b/hl7templates/hl7templates-generator-jar/src/test/resources/decor_custodian_optional.xml new file mode 100644 index 0000000000000000000000000000000000000000..50cb21ce3d575a6860eb04cdb76957a8fd32a3b7 --- /dev/null +++ b/hl7templates/hl7templates-generator-jar/src/test/resources/decor_custodian_optional.xml @@ -0,0 +1,39 @@ +<?xml-model href="http://art-decor.org/ADAR/rv/DECOR.xsd" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?> +<decor xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epsos="urn:epSOS:ps:ps:2010" xsi:noNamespaceSchemaLocation="http://art-decor.org/ADAR/rv/DECOR.xsd" repository="true" epsos:dummy-1="urn:epSOS:ps:ps:2010" xsi:dummy-2="http://www.w3.org/2001/XMLSchema-instance" versionDate="2015-06-09T11:03:41" versionLabel="" compilationDate="2015-06-09T11:03:41" language="en-US" deeplinkprefix="http://decor.nictiz.nl/art-decor/" deeplinkprefixservices="http://decor.nictiz.nl/decor/services/"> +<!-- + This is a compiled version of a DECOR based project. Compilation date: 2015-06-09T11:03:41 + PLEASE NOTE THAT ITS ONLY PURPOSE IS TO FACILITATE HTML AND SCHEMATRON GENERATION. HENCE THIS IS A ONE OFF FILE UNSUITED FOR ANY OTHER PURPOSE + Compilation process calls getFullDataSetTree where all inheritance of concepts from repositories is resolved + Compilation process leaves valueSet[@ref] as-is but adds, if available, the valueSet (versions) it references. These are marked with valueSet[@referencedFrom, @ident and/or @url] + Compilation process tries to find names for any OIDs referenced in the project but not yet in ids/id, and adds an entry if a name is found + Compilation process does not yet handle retrieval of referenced templates if they are not inside this project--> + <project id="2.16.840.1.113883.2.4.3.11.60.22" prefix="ccda-" defaultLanguage="en-US"> + </project> + <rules> + <!--US Realm Header--> + <template id="2.16.840.1.113883.10.20.22.1.1" name="USRealmHeader" effectiveDate="2013-01-31T00:00:00" statusCode="pending" displayName="US Realm Header"> + <desc language="en-US">This section describes constraints that apply to the header for all documents within the scope of this implementation guide. Header constraints specific to each document type are described in the appropriate document-specific section below.</desc> + <classification type="cdadocumentlevel"/> + <context path="cda:ClinicalDocument"/> + <element name="cda:ClinicalDocument"> + <element name="cda:templateId"> + <desc language="en-US">SHALL contain exactly one [1..1] templateId (CONF:5252) such that it</desc> + <item label="conf-5252"/> + <attribute name="root" value="2.16.840.1.113883.10.20.22.1.1"> + <item label="conf-10036"/> + </attribute> + <attribute name="extension" prohibited="true" /> + </element> + + <element name="cda:custodian" minimumMultiplicity="1" maximumMultiplicity="1" isMandatory="true"> + <desc language="en-US">SHALL contain exactly one [1..1] custodian (CONF:5519).</desc> + <item label="conf-5519"/> + <element name="cda:assignedCustodian" minimumMultiplicity="0" maximumMultiplicity="1" isMandatory="false"> + <desc language="en-US">This custodian SHALL contain exactly one [1..1] assignedCustodian (CONF:5520).</desc> + <item label="conf-5520"/> + </element> + </element> + </element> + </template> + </rules> +</decor> \ No newline at end of file diff --git a/hl7templates/hl7templates-generator-jar/src/test/resources/decor_obs_conf_C.xml b/hl7templates/hl7templates-generator-jar/src/test/resources/decor_obs_conf_C.xml new file mode 100644 index 0000000000000000000000000000000000000000..9e22e5764be0f82b29651ef8ba69d89352857437 --- /dev/null +++ b/hl7templates/hl7templates-generator-jar/src/test/resources/decor_obs_conf_C.xml @@ -0,0 +1,59 @@ +<?xml-model href="http://art-decor.org/ADAR/rv/DECOR.xsd" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?> +<decor xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epsos="urn:epSOS:ps:ps:2010" xsi:noNamespaceSchemaLocation="http://art-decor.org/ADAR/rv/DECOR.xsd" repository="true" epsos:dummy-1="urn:epSOS:ps:ps:2010" xsi:dummy-2="http://www.w3.org/2001/XMLSchema-instance" versionDate="2015-06-09T11:03:41" versionLabel="" compilationDate="2015-06-09T11:03:41" language="en-US" deeplinkprefix="http://decor.nictiz.nl/art-decor/" deeplinkprefixservices="http://decor.nictiz.nl/decor/services/"> +<!-- + This is a compiled version of a DECOR based project. Compilation date: 2015-06-09T11:03:41 + PLEASE NOTE THAT ITS ONLY PURPOSE IS TO FACILITATE HTML AND SCHEMATRON GENERATION. HENCE THIS IS A ONE OFF FILE UNSUITED FOR ANY OTHER PURPOSE + Compilation process calls getFullDataSetTree where all inheritance of concepts from repositories is resolved + Compilation process leaves valueSet[@ref] as-is but adds, if available, the valueSet (versions) it references. These are marked with valueSet[@referencedFrom, @ident and/or @url] + Compilation process tries to find names for any OIDs referenced in the project but not yet in ids/id, and adds an entry if a name is found + Compilation process does not yet handle retrieval of referenced templates if they are not inside this project--> + <project id="2.16.840.1.113883.2.4.3.11.60.22" prefix="ccda-" defaultLanguage="en-US"> + </project> + <rules> + <!--epSOS CDA ManufacturedProduct--> + <!--Problem Concern--> + <template id="1.3.6.1.4.1.19376.1.5.3.1.4.5.2" name="EntryProblemConcern" effectiveDate="2013-12-20T00:00:00" statusCode="draft" displayName="Problem Concern"> + <desc language="en-US"> + <p>This entry is a specialization of the Concern Entry, wherein the subject of the concern is focused on a problem. Elements shown in the example below in gray are explained in the Concern Entry. </p> + <p>Parent Template </p> + <p>The parent of this template is Concern Entry. This template is compatible with the ASTM/HL7 Continuity of Care Document template: 2.16.840.1.113883.10.20.1.27 </p> + <p>This entry has a template identifier of 1.3.6.1.4.1.19376.1.5.3.1.4.5.2, and is a subtype of the Concern Entry, and so must also conform to that specification, with the template identifier of 1.3.6.1.4.1.19376.1.5.3.1.4.5.1. These elements are required and shall be recorded exactly as shown. </p> + </desc> + <classification type="cdaentrylevel"/> + <context id="**"/> + <element name="hl7:act" conformance="R"> + <attribute name="classCode" value="ACT"/> + <attribute name="moodCode" value="EVN"/> + <element name="hl7:templateId" minimumMultiplicity="1" maximumMultiplicity="1" datatype="II" isMandatory="true" conformance="R"> + <attribute name="root" value="1.3.6.1.4.1.19376.1.5.3.1.4.5.2"/> + </element> + <!-- optional entry relationship providing more information about the concern --> + <element name="hl7:entryRelationship" minimumMultiplicity="0" maximumMultiplicity="*" conformance="R"> + <desc language="en-US">optional entry relationship providing more information about the concern. A source of information observation SHALL be the target of an entryRelationship whose value for “entryRelationship / @typeCode†SHALL be “REFR†“Refers to†2.16.840.1.113883.5.1002 ActRelationshipType STATIC. A source of information observation SHALL be represented with Observation.</desc> + <item label="CONF-524 / CONF-525"/> + <attribute name="typeCode" value="REFR" isOptional="false"/> + <element name="hl7:observation"> + <desc language="en-US">ASTM CCR requires that all data objects have a stated source (or state explicitly that the source is unknown) so that any data within the summary can be validated. The source of data may be a person, organization, reference to some other data object, etc.</desc> + <attribute classCode="OBS" isOptional="true"> + <desc language="en-US">The value for “Observation / @classCode†in a source of information observation SHALL be “OBS†2.16.840.1.113883.5.6 ActClass STATIC.</desc> + <item label="CONF-526"/> + </attribute> + <element name="hl7:code" minimumMultiplicity="1" maximumMultiplicity="1" conformance="R" datatype="CD"> + <desc language="en-US">A source of information observation SHALL contain exactly one Observation / code. The value for “Observation / code†in a source of information observation SHALL be “48766-0†“Information source†2.16.840.1.113883.6.1 LOINC STATIC.</desc> + <item label="CONF-530 / CONF-531"/> + <vocabulary code="48766-0" codeSystem="2.16.840.1.113883.6.1" displayName="Information source"/> + <attribute name="code" value="48766-0" /> + </element> + <element name="hl7:targetSiteCode" minimumMultiplicity="1" maximumMultiplicity="1" conformance="R"/> + <element name="hl7:value" datatype="CD"> + <attribute name="code"> + <item label="conf-16563"/> + <vocabulary valueSet="2.16.840.1.113883.11.20.9.41"/> + </attribute> + </element> + </element> + </element> + </element> + </template> + </rules> +</decor> \ No newline at end of file diff --git a/hl7templates/hl7templates-generator-jar/src/test/resources/decor_obs_conf_M.xml b/hl7templates/hl7templates-generator-jar/src/test/resources/decor_obs_conf_M.xml new file mode 100644 index 0000000000000000000000000000000000000000..c44c44f1dd6c765326e7f23074ea9616bd43bd3f --- /dev/null +++ b/hl7templates/hl7templates-generator-jar/src/test/resources/decor_obs_conf_M.xml @@ -0,0 +1,59 @@ +<?xml-model href="http://art-decor.org/ADAR/rv/DECOR.xsd" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?> +<decor xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epsos="urn:epSOS:ps:ps:2010" xsi:noNamespaceSchemaLocation="http://art-decor.org/ADAR/rv/DECOR.xsd" repository="true" epsos:dummy-1="urn:epSOS:ps:ps:2010" xsi:dummy-2="http://www.w3.org/2001/XMLSchema-instance" versionDate="2015-06-09T11:03:41" versionLabel="" compilationDate="2015-06-09T11:03:41" language="en-US" deeplinkprefix="http://decor.nictiz.nl/art-decor/" deeplinkprefixservices="http://decor.nictiz.nl/decor/services/"> +<!-- + This is a compiled version of a DECOR based project. Compilation date: 2015-06-09T11:03:41 + PLEASE NOTE THAT ITS ONLY PURPOSE IS TO FACILITATE HTML AND SCHEMATRON GENERATION. HENCE THIS IS A ONE OFF FILE UNSUITED FOR ANY OTHER PURPOSE + Compilation process calls getFullDataSetTree where all inheritance of concepts from repositories is resolved + Compilation process leaves valueSet[@ref] as-is but adds, if available, the valueSet (versions) it references. These are marked with valueSet[@referencedFrom, @ident and/or @url] + Compilation process tries to find names for any OIDs referenced in the project but not yet in ids/id, and adds an entry if a name is found + Compilation process does not yet handle retrieval of referenced templates if they are not inside this project--> + <project id="2.16.840.1.113883.2.4.3.11.60.22" prefix="ccda-" defaultLanguage="en-US"> + </project> + <rules> + <!--epSOS CDA ManufacturedProduct--> + <!--Problem Concern--> + <template id="1.3.6.1.4.1.19376.1.5.3.1.4.5.2" name="EntryProblemConcern" effectiveDate="2013-12-20T00:00:00" statusCode="draft" displayName="Problem Concern"> + <desc language="en-US"> + <p>This entry is a specialization of the Concern Entry, wherein the subject of the concern is focused on a problem. Elements shown in the example below in gray are explained in the Concern Entry. </p> + <p>Parent Template </p> + <p>The parent of this template is Concern Entry. This template is compatible with the ASTM/HL7 Continuity of Care Document template: 2.16.840.1.113883.10.20.1.27 </p> + <p>This entry has a template identifier of 1.3.6.1.4.1.19376.1.5.3.1.4.5.2, and is a subtype of the Concern Entry, and so must also conform to that specification, with the template identifier of 1.3.6.1.4.1.19376.1.5.3.1.4.5.1. These elements are required and shall be recorded exactly as shown. </p> + </desc> + <classification type="cdaentrylevel"/> + <context id="**"/> + <element name="hl7:act" conformance="R"> + <attribute name="classCode" value="ACT"/> + <attribute name="moodCode" value="EVN"/> + <element name="hl7:templateId" minimumMultiplicity="1" maximumMultiplicity="1" datatype="II" isMandatory="true" conformance="R"> + <attribute name="root" value="1.3.6.1.4.1.19376.1.5.3.1.4.5.2"/> + </element> + <!-- optional entry relationship providing more information about the concern --> + <element name="hl7:entryRelationship" minimumMultiplicity="0" maximumMultiplicity="*" conformance="M"> + <desc language="en-US">optional entry relationship providing more information about the concern. A source of information observation SHALL be the target of an entryRelationship whose value for “entryRelationship / @typeCode†SHALL be “REFR†“Refers to†2.16.840.1.113883.5.1002 ActRelationshipType STATIC. A source of information observation SHALL be represented with Observation.</desc> + <item label="CONF-524 / CONF-525"/> + <attribute name="typeCode" value="REFR" isOptional="false"/> + <element name="hl7:observation"> + <desc language="en-US">ASTM CCR requires that all data objects have a stated source (or state explicitly that the source is unknown) so that any data within the summary can be validated. The source of data may be a person, organization, reference to some other data object, etc.</desc> + <attribute classCode="OBS" isOptional="true"> + <desc language="en-US">The value for “Observation / @classCode†in a source of information observation SHALL be “OBS†2.16.840.1.113883.5.6 ActClass STATIC.</desc> + <item label="CONF-526"/> + </attribute> + <element name="hl7:code" minimumMultiplicity="1" maximumMultiplicity="1" conformance="R" datatype="CD"> + <desc language="en-US">A source of information observation SHALL contain exactly one Observation / code. The value for “Observation / code†in a source of information observation SHALL be “48766-0†“Information source†2.16.840.1.113883.6.1 LOINC STATIC.</desc> + <item label="CONF-530 / CONF-531"/> + <vocabulary code="48766-0" codeSystem="2.16.840.1.113883.6.1" displayName="Information source"/> + <attribute name="code" value="48766-0" /> + </element> + <element name="hl7:targetSiteCode" minimumMultiplicity="1" maximumMultiplicity="1" conformance="R"/> + <element name="hl7:value" datatype="CD"> + <attribute name="code"> + <item label="conf-16563"/> + <vocabulary valueSet="2.16.840.1.113883.11.20.9.41"/> + </attribute> + </element> + </element> + </element> + </element> + </template> + </rules> +</decor> \ No newline at end of file diff --git a/hl7templates/hl7templates-generator-jar/src/test/resources/decor_obs_conf_O.xml b/hl7templates/hl7templates-generator-jar/src/test/resources/decor_obs_conf_O.xml new file mode 100644 index 0000000000000000000000000000000000000000..ba7bdb4ad9fea744cc6b34573976cdba743a3059 --- /dev/null +++ b/hl7templates/hl7templates-generator-jar/src/test/resources/decor_obs_conf_O.xml @@ -0,0 +1,59 @@ +<?xml-model href="http://art-decor.org/ADAR/rv/DECOR.xsd" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?> +<decor xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epsos="urn:epSOS:ps:ps:2010" xsi:noNamespaceSchemaLocation="http://art-decor.org/ADAR/rv/DECOR.xsd" repository="true" epsos:dummy-1="urn:epSOS:ps:ps:2010" xsi:dummy-2="http://www.w3.org/2001/XMLSchema-instance" versionDate="2015-06-09T11:03:41" versionLabel="" compilationDate="2015-06-09T11:03:41" language="en-US" deeplinkprefix="http://decor.nictiz.nl/art-decor/" deeplinkprefixservices="http://decor.nictiz.nl/decor/services/"> +<!-- + This is a compiled version of a DECOR based project. Compilation date: 2015-06-09T11:03:41 + PLEASE NOTE THAT ITS ONLY PURPOSE IS TO FACILITATE HTML AND SCHEMATRON GENERATION. HENCE THIS IS A ONE OFF FILE UNSUITED FOR ANY OTHER PURPOSE + Compilation process calls getFullDataSetTree where all inheritance of concepts from repositories is resolved + Compilation process leaves valueSet[@ref] as-is but adds, if available, the valueSet (versions) it references. These are marked with valueSet[@referencedFrom, @ident and/or @url] + Compilation process tries to find names for any OIDs referenced in the project but not yet in ids/id, and adds an entry if a name is found + Compilation process does not yet handle retrieval of referenced templates if they are not inside this project--> + <project id="2.16.840.1.113883.2.4.3.11.60.22" prefix="ccda-" defaultLanguage="en-US"> + </project> + <rules> + <!--epSOS CDA ManufacturedProduct--> + <!--Problem Concern--> + <template id="1.3.6.1.4.1.19376.1.5.3.1.4.5.2" name="EntryProblemConcern" effectiveDate="2013-12-20T00:00:00" statusCode="draft" displayName="Problem Concern"> + <desc language="en-US"> + <p>This entry is a specialization of the Concern Entry, wherein the subject of the concern is focused on a problem. Elements shown in the example below in gray are explained in the Concern Entry. </p> + <p>Parent Template </p> + <p>The parent of this template is Concern Entry. This template is compatible with the ASTM/HL7 Continuity of Care Document template: 2.16.840.1.113883.10.20.1.27 </p> + <p>This entry has a template identifier of 1.3.6.1.4.1.19376.1.5.3.1.4.5.2, and is a subtype of the Concern Entry, and so must also conform to that specification, with the template identifier of 1.3.6.1.4.1.19376.1.5.3.1.4.5.1. These elements are required and shall be recorded exactly as shown. </p> + </desc> + <classification type="cdaentrylevel"/> + <context id="**"/> + <element name="hl7:act" conformance="R"> + <attribute name="classCode" value="ACT"/> + <attribute name="moodCode" value="EVN"/> + <element name="hl7:templateId" minimumMultiplicity="1" maximumMultiplicity="1" datatype="II" isMandatory="true" conformance="R"> + <attribute name="root" value="1.3.6.1.4.1.19376.1.5.3.1.4.5.2"/> + </element> + <!-- optional entry relationship providing more information about the concern --> + <element name="hl7:entryRelationship" minimumMultiplicity="0" maximumMultiplicity="*" conformance="R" > + <desc language="en-US">optional entry relationship providing more information about the concern. A source of information observation SHALL be the target of an entryRelationship whose value for “entryRelationship / @typeCode†SHALL be “REFR†“Refers to†2.16.840.1.113883.5.1002 ActRelationshipType STATIC. A source of information observation SHALL be represented with Observation.</desc> + <item label="CONF-524 / CONF-525"/> + <attribute name="typeCode" value="REFR" isOptional="false"/> + <element name="hl7:observation"> + <desc language="en-US">ASTM CCR requires that all data objects have a stated source (or state explicitly that the source is unknown) so that any data within the summary can be validated. The source of data may be a person, organization, reference to some other data object, etc.</desc> + <attribute classCode="OBS" isOptional="true"> + <desc language="en-US">The value for “Observation / @classCode†in a source of information observation SHALL be “OBS†2.16.840.1.113883.5.6 ActClass STATIC.</desc> + <item label="CONF-526"/> + </attribute> + <element name="hl7:code" minimumMultiplicity="1" maximumMultiplicity="1" conformance="R" datatype="CD"> + <desc language="en-US">A source of information observation SHALL contain exactly one Observation / code. The value for “Observation / code†in a source of information observation SHALL be “48766-0†“Information source†2.16.840.1.113883.6.1 LOINC STATIC.</desc> + <item label="CONF-530 / CONF-531"/> + <vocabulary code="48766-0" codeSystem="2.16.840.1.113883.6.1" displayName="Information source"/> + <attribute name="code" value="48766-0" /> + </element> + <element name="hl7:targetSiteCode" minimumMultiplicity="1" maximumMultiplicity="1" conformance="R"/> + <element name="hl7:value" datatype="CD"> + <attribute name="code"> + <item label="conf-16563"/> + <vocabulary valueSet="2.16.840.1.113883.11.20.9.41"/> + </attribute> + </element> + </element> + </element> + </element> + </template> + </rules> +</decor> \ No newline at end of file diff --git a/hl7templates/hl7templates-generator-jar/src/test/resources/decor_obs_conf_R.xml b/hl7templates/hl7templates-generator-jar/src/test/resources/decor_obs_conf_R.xml new file mode 100644 index 0000000000000000000000000000000000000000..47700aaa3ab28b2440ef13f6b454a69b87756031 --- /dev/null +++ b/hl7templates/hl7templates-generator-jar/src/test/resources/decor_obs_conf_R.xml @@ -0,0 +1,59 @@ +<?xml-model href="http://art-decor.org/ADAR/rv/DECOR.xsd" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?> +<decor xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epsos="urn:epSOS:ps:ps:2010" xsi:noNamespaceSchemaLocation="http://art-decor.org/ADAR/rv/DECOR.xsd" repository="true" epsos:dummy-1="urn:epSOS:ps:ps:2010" xsi:dummy-2="http://www.w3.org/2001/XMLSchema-instance" versionDate="2015-06-09T11:03:41" versionLabel="" compilationDate="2015-06-09T11:03:41" language="en-US" deeplinkprefix="http://decor.nictiz.nl/art-decor/" deeplinkprefixservices="http://decor.nictiz.nl/decor/services/"> +<!-- + This is a compiled version of a DECOR based project. Compilation date: 2015-06-09T11:03:41 + PLEASE NOTE THAT ITS ONLY PURPOSE IS TO FACILITATE HTML AND SCHEMATRON GENERATION. HENCE THIS IS A ONE OFF FILE UNSUITED FOR ANY OTHER PURPOSE + Compilation process calls getFullDataSetTree where all inheritance of concepts from repositories is resolved + Compilation process leaves valueSet[@ref] as-is but adds, if available, the valueSet (versions) it references. These are marked with valueSet[@referencedFrom, @ident and/or @url] + Compilation process tries to find names for any OIDs referenced in the project but not yet in ids/id, and adds an entry if a name is found + Compilation process does not yet handle retrieval of referenced templates if they are not inside this project--> + <project id="2.16.840.1.113883.2.4.3.11.60.22" prefix="ccda-" defaultLanguage="en-US"> + </project> + <rules> + <!--epSOS CDA ManufacturedProduct--> + <!--Problem Concern--> + <template id="1.3.6.1.4.1.19376.1.5.3.1.4.5.2" name="EntryProblemConcern" effectiveDate="2013-12-20T00:00:00" statusCode="draft" displayName="Problem Concern"> + <desc language="en-US"> + <p>This entry is a specialization of the Concern Entry, wherein the subject of the concern is focused on a problem. Elements shown in the example below in gray are explained in the Concern Entry. </p> + <p>Parent Template </p> + <p>The parent of this template is Concern Entry. This template is compatible with the ASTM/HL7 Continuity of Care Document template: 2.16.840.1.113883.10.20.1.27 </p> + <p>This entry has a template identifier of 1.3.6.1.4.1.19376.1.5.3.1.4.5.2, and is a subtype of the Concern Entry, and so must also conform to that specification, with the template identifier of 1.3.6.1.4.1.19376.1.5.3.1.4.5.1. These elements are required and shall be recorded exactly as shown. </p> + </desc> + <classification type="cdaentrylevel"/> + <context id="**"/> + <element name="hl7:act" conformance="R"> + <attribute name="classCode" value="ACT"/> + <attribute name="moodCode" value="EVN"/> + <element name="hl7:templateId" minimumMultiplicity="1" maximumMultiplicity="1" datatype="II" isMandatory="true" conformance="R"> + <attribute name="root" value="1.3.6.1.4.1.19376.1.5.3.1.4.5.2"/> + </element> + <!-- optional entry relationship providing more information about the concern --> + <element name="hl7:entryRelationship" minimumMultiplicity="1" maximumMultiplicity="*" conformance="R"> + <desc language="en-US">optional entry relationship providing more information about the concern. A source of information observation SHALL be the target of an entryRelationship whose value for “entryRelationship / @typeCode†SHALL be “REFR†“Refers to†2.16.840.1.113883.5.1002 ActRelationshipType STATIC. A source of information observation SHALL be represented with Observation.</desc> + <item label="CONF-524 / CONF-525"/> + <attribute name="typeCode" value="REFR" isOptional="false"/> + <element name="hl7:observation"> + <desc language="en-US">ASTM CCR requires that all data objects have a stated source (or state explicitly that the source is unknown) so that any data within the summary can be validated. The source of data may be a person, organization, reference to some other data object, etc.</desc> + <attribute classCode="OBS" isOptional="true"> + <desc language="en-US">The value for “Observation / @classCode†in a source of information observation SHALL be “OBS†2.16.840.1.113883.5.6 ActClass STATIC.</desc> + <item label="CONF-526"/> + </attribute> + <element name="hl7:code" minimumMultiplicity="1" maximumMultiplicity="1" conformance="R" datatype="CD"> + <desc language="en-US">A source of information observation SHALL contain exactly one Observation / code. The value for “Observation / code†in a source of information observation SHALL be “48766-0†“Information source†2.16.840.1.113883.6.1 LOINC STATIC.</desc> + <item label="CONF-530 / CONF-531"/> + <vocabulary code="48766-0" codeSystem="2.16.840.1.113883.6.1" displayName="Information source"/> + <attribute name="code" value="48766-0" /> + </element> + <element name="hl7:targetSiteCode" minimumMultiplicity="1" maximumMultiplicity="1" conformance="R"/> + <element name="hl7:value" datatype="CD"> + <attribute name="code"> + <item label="conf-16563"/> + <vocabulary valueSet="2.16.840.1.113883.11.20.9.41"/> + </attribute> + </element> + </element> + </element> + </element> + </template> + </rules> +</decor> \ No newline at end of file diff --git a/hl7templates/hl7templates-generator-jar/src/test/resources/processors/decor_item.xml b/hl7templates/hl7templates-generator-jar/src/test/resources/processors/decor_item.xml new file mode 100644 index 0000000000000000000000000000000000000000..21822bdc71997d9ea6c5a303cdd8b41320b08e3c --- /dev/null +++ b/hl7templates/hl7templates-generator-jar/src/test/resources/processors/decor_item.xml @@ -0,0 +1,31 @@ +<?xml-model href="http://art-decor.org/ADAR/rv/DECOR.xsd" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?> +<decor xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epsos="urn:epSOS:ps:ps:2010" xsi:noNamespaceSchemaLocation="http://art-decor.org/ADAR/rv/DECOR.xsd" repository="true" epsos:dummy-1="urn:epSOS:ps:ps:2010" xsi:dummy-2="http://www.w3.org/2001/XMLSchema-instance" versionDate="2015-06-09T11:03:41" versionLabel="" compilationDate="2015-06-09T11:03:41" language="en-US" deeplinkprefix="http://decor.nictiz.nl/art-decor/" deeplinkprefixservices="http://decor.nictiz.nl/decor/services/"> + <project id="2.16.840.1.113883.2.4.3.11.60.22" prefix="ccda-" defaultLanguage="en-US"> + </project> + <rules> + <!--Pregnancy Observation--> + <template id="1.3.6.1.4.1.19376.1.5.3.1.4.13.5" displayName="Pregnancy Observation" name="EntryPregnancyObservation" effectiveDate="2013-12-20T00:00:00" statusCode="draft"> + <classification type="cdaentrylevel"/> + <relationship type="SPEC" template="2.16.840.1.113883.10.20.1.33"/> + <context id="**"/> + <element name="hl7:observation" conformance="R"> + <element name="hl7:templateId" minimumMultiplicity="1" maximumMultiplicity="1" datatype="II.EPSOS" conformance="R" isMandatory="false"> + <attribute name="root" value="1.3.6.1.4.1.19376.1.5.3.1.4.13"/> + </element> + <element name="hl7:templateId" minimumMultiplicity="1" maximumMultiplicity="1" datatype="II.EPSOS" conformance="R" isMandatory="false"> + <attribute name="root" value="1.3.6.1.4.1.19376.1.5.3.1.4.13.5"/> + </element> + <element name="hl7:code" minimumMultiplicity="1" maximumMultiplicity="1" datatype="CD" conformance="R" isMandatory="true"> + <vocabulary valueSet="1.3.6.1.4.1.12559.11.10.1.3.1.42.9" flexibility="2015-01-01T01:02:03"/> + </element> + <element name="hl7:statusCode" minimumMultiplicity="1" maximumMultiplicity="1" datatype="CS" conformance="R"> + <vocabulary code="completed" codeSystem="2.16.840.1.113883.5.14"/> + </element> + <element name="hl7:repeatNumber" conformance="NP" /> + <element name="hl7:value" datatype="CS"> + <item label="CONF-test" /> + </element> + </element> + </template> + </rules> +</decor> \ No newline at end of file diff --git a/hl7templates/hl7templates-generator-jar/src/test/resources/processors/decor_multiplicity_0_2_R.xml b/hl7templates/hl7templates-generator-jar/src/test/resources/processors/decor_multiplicity_0_2_R.xml new file mode 100644 index 0000000000000000000000000000000000000000..4c685243d956a17590cbba97c63028baa8af324f --- /dev/null +++ b/hl7templates/hl7templates-generator-jar/src/test/resources/processors/decor_multiplicity_0_2_R.xml @@ -0,0 +1,59 @@ +<?xml-model href="http://art-decor.org/ADAR/rv/DECOR.xsd" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?> +<decor xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epsos="urn:epSOS:ps:ps:2010" xsi:noNamespaceSchemaLocation="http://art-decor.org/ADAR/rv/DECOR.xsd" repository="true" epsos:dummy-1="urn:epSOS:ps:ps:2010" xsi:dummy-2="http://www.w3.org/2001/XMLSchema-instance" versionDate="2015-06-09T11:03:41" versionLabel="" compilationDate="2015-06-09T11:03:41" language="en-US" deeplinkprefix="http://decor.nictiz.nl/art-decor/" deeplinkprefixservices="http://decor.nictiz.nl/decor/services/"> +<!-- + This is a compiled version of a DECOR based project. Compilation date: 2015-06-09T11:03:41 + PLEASE NOTE THAT ITS ONLY PURPOSE IS TO FACILITATE HTML AND SCHEMATRON GENERATION. HENCE THIS IS A ONE OFF FILE UNSUITED FOR ANY OTHER PURPOSE + Compilation process calls getFullDataSetTree where all inheritance of concepts from repositories is resolved + Compilation process leaves valueSet[@ref] as-is but adds, if available, the valueSet (versions) it references. These are marked with valueSet[@referencedFrom, @ident and/or @url] + Compilation process tries to find names for any OIDs referenced in the project but not yet in ids/id, and adds an entry if a name is found + Compilation process does not yet handle retrieval of referenced templates if they are not inside this project--> + <project id="2.16.840.1.113883.2.4.3.11.60.22" prefix="ccda-" defaultLanguage="en-US"> + </project> + <rules> + <!--epSOS CDA ManufacturedProduct--> + <!--Problem Concern--> + <template id="1.3.6.1.4.1.19376.1.5.3.1.4.5.2" name="EntryProblemConcern" effectiveDate="2013-12-20T00:00:00" statusCode="draft" displayName="Problem Concern"> + <desc language="en-US"> + <p>This entry is a specialization of the Concern Entry, wherein the subject of the concern is focused on a problem. Elements shown in the example below in gray are explained in the Concern Entry. </p> + <p>Parent Template </p> + <p>The parent of this template is Concern Entry. This template is compatible with the ASTM/HL7 Continuity of Care Document template: 2.16.840.1.113883.10.20.1.27 </p> + <p>This entry has a template identifier of 1.3.6.1.4.1.19376.1.5.3.1.4.5.2, and is a subtype of the Concern Entry, and so must also conform to that specification, with the template identifier of 1.3.6.1.4.1.19376.1.5.3.1.4.5.1. These elements are required and shall be recorded exactly as shown. </p> + </desc> + <classification type="cdaentrylevel"/> + <context id="**"/> + <element name="hl7:act" conformance="R"> + <attribute name="classCode" value="ACT"/> + <attribute name="moodCode" value="EVN"/> + <element name="hl7:templateId" minimumMultiplicity="1" maximumMultiplicity="1" datatype="II" isMandatory="true" conformance="R"> + <attribute name="root" value="1.3.6.1.4.1.19376.1.5.3.1.4.5.2"/> + </element> + <!-- optional entry relationship providing more information about the concern --> + <element name="hl7:entryRelationship" minimumMultiplicity="0" maximumMultiplicity="2" conformance="R"> + <desc language="en-US">optional entry relationship providing more information about the concern. A source of information observation SHALL be the target of an entryRelationship whose value for “entryRelationship / @typeCode†SHALL be “REFR†“Refers to†2.16.840.1.113883.5.1002 ActRelationshipType STATIC. A source of information observation SHALL be represented with Observation.</desc> + <item label="CONF-524 / CONF-525"/> + <attribute name="typeCode" value="REFR" isOptional="false"/> + <element name="hl7:observation"> + <desc language="en-US">ASTM CCR requires that all data objects have a stated source (or state explicitly that the source is unknown) so that any data within the summary can be validated. The source of data may be a person, organization, reference to some other data object, etc.</desc> + <attribute classCode="OBS" isOptional="true"> + <desc language="en-US">The value for “Observation / @classCode†in a source of information observation SHALL be “OBS†2.16.840.1.113883.5.6 ActClass STATIC.</desc> + <item label="CONF-526"/> + </attribute> + <element name="hl7:code" minimumMultiplicity="1" maximumMultiplicity="1" conformance="R" datatype="CD"> + <desc language="en-US">A source of information observation SHALL contain exactly one Observation / code. The value for “Observation / code†in a source of information observation SHALL be “48766-0†“Information source†2.16.840.1.113883.6.1 LOINC STATIC.</desc> + <item label="CONF-530 / CONF-531"/> + <vocabulary code="48766-0" codeSystem="2.16.840.1.113883.6.1" displayName="Information source"/> + <attribute name="code" value="48766-0" /> + </element> + <element name="hl7:targetSiteCode" minimumMultiplicity="1" maximumMultiplicity="1" conformance="R"/> + <element name="hl7:value" datatype="CD"> + <attribute name="code"> + <item label="conf-16563"/> + <vocabulary valueSet="2.16.840.1.113883.11.20.9.41"/> + </attribute> + </element> + </element> + </element> + </element> + </template> + </rules> +</decor> \ No newline at end of file diff --git a/hl7templates/hl7templates-generator-jar/src/test/resources/processors/decor_multiplicity_0_n_R.xml b/hl7templates/hl7templates-generator-jar/src/test/resources/processors/decor_multiplicity_0_n_R.xml new file mode 100644 index 0000000000000000000000000000000000000000..9e22e5764be0f82b29651ef8ba69d89352857437 --- /dev/null +++ b/hl7templates/hl7templates-generator-jar/src/test/resources/processors/decor_multiplicity_0_n_R.xml @@ -0,0 +1,59 @@ +<?xml-model href="http://art-decor.org/ADAR/rv/DECOR.xsd" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?> +<decor xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epsos="urn:epSOS:ps:ps:2010" xsi:noNamespaceSchemaLocation="http://art-decor.org/ADAR/rv/DECOR.xsd" repository="true" epsos:dummy-1="urn:epSOS:ps:ps:2010" xsi:dummy-2="http://www.w3.org/2001/XMLSchema-instance" versionDate="2015-06-09T11:03:41" versionLabel="" compilationDate="2015-06-09T11:03:41" language="en-US" deeplinkprefix="http://decor.nictiz.nl/art-decor/" deeplinkprefixservices="http://decor.nictiz.nl/decor/services/"> +<!-- + This is a compiled version of a DECOR based project. Compilation date: 2015-06-09T11:03:41 + PLEASE NOTE THAT ITS ONLY PURPOSE IS TO FACILITATE HTML AND SCHEMATRON GENERATION. HENCE THIS IS A ONE OFF FILE UNSUITED FOR ANY OTHER PURPOSE + Compilation process calls getFullDataSetTree where all inheritance of concepts from repositories is resolved + Compilation process leaves valueSet[@ref] as-is but adds, if available, the valueSet (versions) it references. These are marked with valueSet[@referencedFrom, @ident and/or @url] + Compilation process tries to find names for any OIDs referenced in the project but not yet in ids/id, and adds an entry if a name is found + Compilation process does not yet handle retrieval of referenced templates if they are not inside this project--> + <project id="2.16.840.1.113883.2.4.3.11.60.22" prefix="ccda-" defaultLanguage="en-US"> + </project> + <rules> + <!--epSOS CDA ManufacturedProduct--> + <!--Problem Concern--> + <template id="1.3.6.1.4.1.19376.1.5.3.1.4.5.2" name="EntryProblemConcern" effectiveDate="2013-12-20T00:00:00" statusCode="draft" displayName="Problem Concern"> + <desc language="en-US"> + <p>This entry is a specialization of the Concern Entry, wherein the subject of the concern is focused on a problem. Elements shown in the example below in gray are explained in the Concern Entry. </p> + <p>Parent Template </p> + <p>The parent of this template is Concern Entry. This template is compatible with the ASTM/HL7 Continuity of Care Document template: 2.16.840.1.113883.10.20.1.27 </p> + <p>This entry has a template identifier of 1.3.6.1.4.1.19376.1.5.3.1.4.5.2, and is a subtype of the Concern Entry, and so must also conform to that specification, with the template identifier of 1.3.6.1.4.1.19376.1.5.3.1.4.5.1. These elements are required and shall be recorded exactly as shown. </p> + </desc> + <classification type="cdaentrylevel"/> + <context id="**"/> + <element name="hl7:act" conformance="R"> + <attribute name="classCode" value="ACT"/> + <attribute name="moodCode" value="EVN"/> + <element name="hl7:templateId" minimumMultiplicity="1" maximumMultiplicity="1" datatype="II" isMandatory="true" conformance="R"> + <attribute name="root" value="1.3.6.1.4.1.19376.1.5.3.1.4.5.2"/> + </element> + <!-- optional entry relationship providing more information about the concern --> + <element name="hl7:entryRelationship" minimumMultiplicity="0" maximumMultiplicity="*" conformance="R"> + <desc language="en-US">optional entry relationship providing more information about the concern. A source of information observation SHALL be the target of an entryRelationship whose value for “entryRelationship / @typeCode†SHALL be “REFR†“Refers to†2.16.840.1.113883.5.1002 ActRelationshipType STATIC. A source of information observation SHALL be represented with Observation.</desc> + <item label="CONF-524 / CONF-525"/> + <attribute name="typeCode" value="REFR" isOptional="false"/> + <element name="hl7:observation"> + <desc language="en-US">ASTM CCR requires that all data objects have a stated source (or state explicitly that the source is unknown) so that any data within the summary can be validated. The source of data may be a person, organization, reference to some other data object, etc.</desc> + <attribute classCode="OBS" isOptional="true"> + <desc language="en-US">The value for “Observation / @classCode†in a source of information observation SHALL be “OBS†2.16.840.1.113883.5.6 ActClass STATIC.</desc> + <item label="CONF-526"/> + </attribute> + <element name="hl7:code" minimumMultiplicity="1" maximumMultiplicity="1" conformance="R" datatype="CD"> + <desc language="en-US">A source of information observation SHALL contain exactly one Observation / code. The value for “Observation / code†in a source of information observation SHALL be “48766-0†“Information source†2.16.840.1.113883.6.1 LOINC STATIC.</desc> + <item label="CONF-530 / CONF-531"/> + <vocabulary code="48766-0" codeSystem="2.16.840.1.113883.6.1" displayName="Information source"/> + <attribute name="code" value="48766-0" /> + </element> + <element name="hl7:targetSiteCode" minimumMultiplicity="1" maximumMultiplicity="1" conformance="R"/> + <element name="hl7:value" datatype="CD"> + <attribute name="code"> + <item label="conf-16563"/> + <vocabulary valueSet="2.16.840.1.113883.11.20.9.41"/> + </attribute> + </element> + </element> + </element> + </element> + </template> + </rules> +</decor> \ No newline at end of file diff --git a/hl7templates/hl7templates-generator-jar/src/test/resources/processors/decor_multiplicity_1_n_R.xml b/hl7templates/hl7templates-generator-jar/src/test/resources/processors/decor_multiplicity_1_n_R.xml new file mode 100644 index 0000000000000000000000000000000000000000..47700aaa3ab28b2440ef13f6b454a69b87756031 --- /dev/null +++ b/hl7templates/hl7templates-generator-jar/src/test/resources/processors/decor_multiplicity_1_n_R.xml @@ -0,0 +1,59 @@ +<?xml-model href="http://art-decor.org/ADAR/rv/DECOR.xsd" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?> +<decor xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epsos="urn:epSOS:ps:ps:2010" xsi:noNamespaceSchemaLocation="http://art-decor.org/ADAR/rv/DECOR.xsd" repository="true" epsos:dummy-1="urn:epSOS:ps:ps:2010" xsi:dummy-2="http://www.w3.org/2001/XMLSchema-instance" versionDate="2015-06-09T11:03:41" versionLabel="" compilationDate="2015-06-09T11:03:41" language="en-US" deeplinkprefix="http://decor.nictiz.nl/art-decor/" deeplinkprefixservices="http://decor.nictiz.nl/decor/services/"> +<!-- + This is a compiled version of a DECOR based project. Compilation date: 2015-06-09T11:03:41 + PLEASE NOTE THAT ITS ONLY PURPOSE IS TO FACILITATE HTML AND SCHEMATRON GENERATION. HENCE THIS IS A ONE OFF FILE UNSUITED FOR ANY OTHER PURPOSE + Compilation process calls getFullDataSetTree where all inheritance of concepts from repositories is resolved + Compilation process leaves valueSet[@ref] as-is but adds, if available, the valueSet (versions) it references. These are marked with valueSet[@referencedFrom, @ident and/or @url] + Compilation process tries to find names for any OIDs referenced in the project but not yet in ids/id, and adds an entry if a name is found + Compilation process does not yet handle retrieval of referenced templates if they are not inside this project--> + <project id="2.16.840.1.113883.2.4.3.11.60.22" prefix="ccda-" defaultLanguage="en-US"> + </project> + <rules> + <!--epSOS CDA ManufacturedProduct--> + <!--Problem Concern--> + <template id="1.3.6.1.4.1.19376.1.5.3.1.4.5.2" name="EntryProblemConcern" effectiveDate="2013-12-20T00:00:00" statusCode="draft" displayName="Problem Concern"> + <desc language="en-US"> + <p>This entry is a specialization of the Concern Entry, wherein the subject of the concern is focused on a problem. Elements shown in the example below in gray are explained in the Concern Entry. </p> + <p>Parent Template </p> + <p>The parent of this template is Concern Entry. This template is compatible with the ASTM/HL7 Continuity of Care Document template: 2.16.840.1.113883.10.20.1.27 </p> + <p>This entry has a template identifier of 1.3.6.1.4.1.19376.1.5.3.1.4.5.2, and is a subtype of the Concern Entry, and so must also conform to that specification, with the template identifier of 1.3.6.1.4.1.19376.1.5.3.1.4.5.1. These elements are required and shall be recorded exactly as shown. </p> + </desc> + <classification type="cdaentrylevel"/> + <context id="**"/> + <element name="hl7:act" conformance="R"> + <attribute name="classCode" value="ACT"/> + <attribute name="moodCode" value="EVN"/> + <element name="hl7:templateId" minimumMultiplicity="1" maximumMultiplicity="1" datatype="II" isMandatory="true" conformance="R"> + <attribute name="root" value="1.3.6.1.4.1.19376.1.5.3.1.4.5.2"/> + </element> + <!-- optional entry relationship providing more information about the concern --> + <element name="hl7:entryRelationship" minimumMultiplicity="1" maximumMultiplicity="*" conformance="R"> + <desc language="en-US">optional entry relationship providing more information about the concern. A source of information observation SHALL be the target of an entryRelationship whose value for “entryRelationship / @typeCode†SHALL be “REFR†“Refers to†2.16.840.1.113883.5.1002 ActRelationshipType STATIC. A source of information observation SHALL be represented with Observation.</desc> + <item label="CONF-524 / CONF-525"/> + <attribute name="typeCode" value="REFR" isOptional="false"/> + <element name="hl7:observation"> + <desc language="en-US">ASTM CCR requires that all data objects have a stated source (or state explicitly that the source is unknown) so that any data within the summary can be validated. The source of data may be a person, organization, reference to some other data object, etc.</desc> + <attribute classCode="OBS" isOptional="true"> + <desc language="en-US">The value for “Observation / @classCode†in a source of information observation SHALL be “OBS†2.16.840.1.113883.5.6 ActClass STATIC.</desc> + <item label="CONF-526"/> + </attribute> + <element name="hl7:code" minimumMultiplicity="1" maximumMultiplicity="1" conformance="R" datatype="CD"> + <desc language="en-US">A source of information observation SHALL contain exactly one Observation / code. The value for “Observation / code†in a source of information observation SHALL be “48766-0†“Information source†2.16.840.1.113883.6.1 LOINC STATIC.</desc> + <item label="CONF-530 / CONF-531"/> + <vocabulary code="48766-0" codeSystem="2.16.840.1.113883.6.1" displayName="Information source"/> + <attribute name="code" value="48766-0" /> + </element> + <element name="hl7:targetSiteCode" minimumMultiplicity="1" maximumMultiplicity="1" conformance="R"/> + <element name="hl7:value" datatype="CD"> + <attribute name="code"> + <item label="conf-16563"/> + <vocabulary valueSet="2.16.840.1.113883.11.20.9.41"/> + </attribute> + </element> + </element> + </element> + </element> + </template> + </rules> +</decor> \ No newline at end of file diff --git a/hl7templates/hl7templates-generator-jar/src/test/resources/processors/decor_multiplicity_NP.xml b/hl7templates/hl7templates-generator-jar/src/test/resources/processors/decor_multiplicity_NP.xml new file mode 100644 index 0000000000000000000000000000000000000000..3e4083d73e6f56a9e015cdc251ea34bed82f226b --- /dev/null +++ b/hl7templates/hl7templates-generator-jar/src/test/resources/processors/decor_multiplicity_NP.xml @@ -0,0 +1,59 @@ +<?xml-model href="http://art-decor.org/ADAR/rv/DECOR.xsd" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?> +<decor xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epsos="urn:epSOS:ps:ps:2010" xsi:noNamespaceSchemaLocation="http://art-decor.org/ADAR/rv/DECOR.xsd" repository="true" epsos:dummy-1="urn:epSOS:ps:ps:2010" xsi:dummy-2="http://www.w3.org/2001/XMLSchema-instance" versionDate="2015-06-09T11:03:41" versionLabel="" compilationDate="2015-06-09T11:03:41" language="en-US" deeplinkprefix="http://decor.nictiz.nl/art-decor/" deeplinkprefixservices="http://decor.nictiz.nl/decor/services/"> + <!-- + This is a compiled version of a DECOR based project. Compilation date: 2015-06-09T11:03:41 + PLEASE NOTE THAT ITS ONLY PURPOSE IS TO FACILITATE HTML AND SCHEMATRON GENERATION. HENCE THIS IS A ONE OFF FILE UNSUITED FOR ANY OTHER PURPOSE + Compilation process calls getFullDataSetTree where all inheritance of concepts from repositories is resolved + Compilation process leaves valueSet[@ref] as-is but adds, if available, the valueSet (versions) it references. These are marked with valueSet[@referencedFrom, @ident and/or @url] + Compilation process tries to find names for any OIDs referenced in the project but not yet in ids/id, and adds an entry if a name is found + Compilation process does not yet handle retrieval of referenced templates if they are not inside this project--> + <project id="2.16.840.1.113883.2.4.3.11.60.22" prefix="ccda-" defaultLanguage="en-US"> + </project> + <rules> + <!--epSOS CDA ManufacturedProduct--> + <!--Problem Concern--> + <template id="1.3.6.1.4.1.19376.1.5.3.1.4.5.2" name="EntryProblemConcern" effectiveDate="2013-12-20T00:00:00" statusCode="draft" displayName="Problem Concern"> + <desc language="en-US"> + <p>This entry is a specialization of the Concern Entry, wherein the subject of the concern is focused on a problem. Elements shown in the example below in gray are explained in the Concern Entry. </p> + <p>Parent Template </p> + <p>The parent of this template is Concern Entry. This template is compatible with the ASTM/HL7 Continuity of Care Document template: 2.16.840.1.113883.10.20.1.27 </p> + <p>This entry has a template identifier of 1.3.6.1.4.1.19376.1.5.3.1.4.5.2, and is a subtype of the Concern Entry, and so must also conform to that specification, with the template identifier of 1.3.6.1.4.1.19376.1.5.3.1.4.5.1. These elements are required and shall be recorded exactly as shown. </p> + </desc> + <classification type="cdaentrylevel"/> + <context id="**"/> + <element name="hl7:act" conformance="R"> + <attribute name="classCode" value="ACT"/> + <attribute name="moodCode" value="EVN"/> + <element name="hl7:templateId" minimumMultiplicity="1" maximumMultiplicity="1" datatype="II" isMandatory="true" conformance="R"> + <attribute name="root" value="1.3.6.1.4.1.19376.1.5.3.1.4.5.2"/> + </element> + <!-- optional entry relationship providing more information about the concern --> + <element name="hl7:entryRelationship" minimumMultiplicity="0" maximumMultiplicity="1" conformance="C"> + <desc language="en-US">optional entry relationship providing more information about the concern. A source of information observation SHALL be the target of an entryRelationship whose value for “entryRelationship / @typeCode†SHALL be “REFR†“Refers to†2.16.840.1.113883.5.1002 ActRelationshipType STATIC. A source of information observation SHALL be represented with Observation.</desc> + <item label="CONF-524 / CONF-525"/> + <attribute name="typeCode" value="REFR" isOptional="false"/> + <element name="hl7:observation"> + <desc language="en-US">ASTM CCR requires that all data objects have a stated source (or state explicitly that the source is unknown) so that any data within the summary can be validated. The source of data may be a person, organization, reference to some other data object, etc.</desc> + <attribute classCode="OBS" isOptional="true"> + <desc language="en-US">The value for “Observation / @classCode†in a source of information observation SHALL be “OBS†2.16.840.1.113883.5.6 ActClass STATIC.</desc> + <item label="CONF-526"/> + </attribute> + <element name="hl7:code" minimumMultiplicity="1" maximumMultiplicity="1" conformance="R" datatype="CD"> + <desc language="en-US">A source of information observation SHALL contain exactly one Observation / code. The value for “Observation / code†in a source of information observation SHALL be “48766-0†“Information source†2.16.840.1.113883.6.1 LOINC STATIC.</desc> + <item label="CONF-530 / CONF-531"/> + <vocabulary code="48766-0" codeSystem="2.16.840.1.113883.6.1" displayName="Information source"/> + <attribute name="code" value="48766-0" /> + </element> + <element name="hl7:targetSiteCode" minimumMultiplicity="1" maximumMultiplicity="1" conformance="R"/> + <element name="hl7:value" datatype="CD"> + <attribute name="code"> + <item label="conf-16563"/> + <vocabulary valueSet="2.16.840.1.113883.11.20.9.41"/> + </attribute> + </element> + </element> + </element> + </element> + </template> + </rules> +</decor> \ No newline at end of file diff --git a/hl7templates/hl7templates-generator-jar/src/test/resources/processors/decor_vocab_VS.xml b/hl7templates/hl7templates-generator-jar/src/test/resources/processors/decor_vocab_VS.xml new file mode 100644 index 0000000000000000000000000000000000000000..ce3947c415ad9cfd8fabc15e37ca7b1b3ac28a1c --- /dev/null +++ b/hl7templates/hl7templates-generator-jar/src/test/resources/processors/decor_vocab_VS.xml @@ -0,0 +1,31 @@ +<?xml-model href="http://art-decor.org/ADAR/rv/DECOR.xsd" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?> +<decor xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epsos="urn:epSOS:ps:ps:2010" xsi:noNamespaceSchemaLocation="http://art-decor.org/ADAR/rv/DECOR.xsd" repository="true" epsos:dummy-1="urn:epSOS:ps:ps:2010" xsi:dummy-2="http://www.w3.org/2001/XMLSchema-instance" versionDate="2015-06-09T11:03:41" versionLabel="" compilationDate="2015-06-09T11:03:41" language="en-US" deeplinkprefix="http://decor.nictiz.nl/art-decor/" deeplinkprefixservices="http://decor.nictiz.nl/decor/services/"> + <project id="2.16.840.1.113883.2.4.3.11.60.22" prefix="ccda-" defaultLanguage="en-US"> + </project> + <rules> + <!--Pregnancy Observation--> + <template id="1.3.6.1.4.1.19376.1.5.3.1.4.13.5" displayName="Pregnancy Observation" name="EntryPregnancyObservation" effectiveDate="2013-12-20T00:00:00" statusCode="draft"> + <classification type="cdaentrylevel"/> + <relationship type="SPEC" template="2.16.840.1.113883.10.20.1.33"/> + <context id="**"/> + <element name="hl7:observation" conformance="R"> + <element name="hl7:templateId" minimumMultiplicity="1" maximumMultiplicity="1" datatype="II.EPSOS" conformance="R" isMandatory="false"> + <attribute name="root" value="1.3.6.1.4.1.19376.1.5.3.1.4.13"/> + </element> + <element name="hl7:templateId" minimumMultiplicity="1" maximumMultiplicity="1" datatype="II.EPSOS" conformance="R" isMandatory="false"> + <attribute name="root" value="1.3.6.1.4.1.19376.1.5.3.1.4.13.5"/> + </element> + <element name="hl7:code" minimumMultiplicity="1" maximumMultiplicity="1" datatype="CD" conformance="R" isMandatory="true"> + <vocabulary valueSet="1.3.6.1.4.1.12559.11.10.1.3.1.42.9" flexibility="2015-01-01T01:02:03"/> + </element> + <element name="hl7:statusCode" minimumMultiplicity="1" maximumMultiplicity="1" datatype="CS" conformance="R"> + <vocabulary code="completed" codeSystem="2.16.840.1.113883.5.14"/> + </element> + <element name="hl7:repeatNumber" conformance="NP" /> + <element name="hl7:value" datatype="CS"> + <vocabulary valueSet="1.3.6.1.4.1.12559.11.10.1.3.1.42.10" flexibility="2015-01-01T01:02:02"/> + </element> + </element> + </template> + </rules> +</decor> \ No newline at end of file diff --git a/hl7templates/hl7templates-generator-jar/src/test/resources/processors/decor_vocab_VS_dynamic.xml b/hl7templates/hl7templates-generator-jar/src/test/resources/processors/decor_vocab_VS_dynamic.xml new file mode 100644 index 0000000000000000000000000000000000000000..02757018792b1d9ff8e92cf9774853907ce719b9 --- /dev/null +++ b/hl7templates/hl7templates-generator-jar/src/test/resources/processors/decor_vocab_VS_dynamic.xml @@ -0,0 +1,31 @@ +<?xml-model href="http://art-decor.org/ADAR/rv/DECOR.xsd" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?> +<decor xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epsos="urn:epSOS:ps:ps:2010" xsi:noNamespaceSchemaLocation="http://art-decor.org/ADAR/rv/DECOR.xsd" repository="true" epsos:dummy-1="urn:epSOS:ps:ps:2010" xsi:dummy-2="http://www.w3.org/2001/XMLSchema-instance" versionDate="2015-06-09T11:03:41" versionLabel="" compilationDate="2015-06-09T11:03:41" language="en-US" deeplinkprefix="http://decor.nictiz.nl/art-decor/" deeplinkprefixservices="http://decor.nictiz.nl/decor/services/"> + <project id="2.16.840.1.113883.2.4.3.11.60.22" prefix="ccda-" defaultLanguage="en-US"> + </project> + <rules> + <!--Pregnancy Observation--> + <template id="1.3.6.1.4.1.19376.1.5.3.1.4.13.5" displayName="Pregnancy Observation" name="EntryPregnancyObservation" effectiveDate="2013-12-20T00:00:00" statusCode="draft"> + <classification type="cdaentrylevel"/> + <relationship type="SPEC" template="2.16.840.1.113883.10.20.1.33"/> + <context id="**"/> + <element name="hl7:observation" conformance="R"> + <element name="hl7:templateId" minimumMultiplicity="1" maximumMultiplicity="1" datatype="II.EPSOS" conformance="R" isMandatory="false"> + <attribute name="root" value="1.3.6.1.4.1.19376.1.5.3.1.4.13"/> + </element> + <element name="hl7:templateId" minimumMultiplicity="1" maximumMultiplicity="1" datatype="II.EPSOS" conformance="R" isMandatory="false"> + <attribute name="root" value="1.3.6.1.4.1.19376.1.5.3.1.4.13.5"/> + </element> + <element name="hl7:code" minimumMultiplicity="1" maximumMultiplicity="1" datatype="CD" conformance="R" isMandatory="true"> + <vocabulary valueSet="1.3.6.1.4.1.12559.11.10.1.3.1.42.9" flexibility="2015-01-01T01:02:03"/> + </element> + <element name="hl7:statusCode" minimumMultiplicity="1" maximumMultiplicity="1" datatype="CS" conformance="R"> + <vocabulary code="completed" codeSystem="2.16.840.1.113883.5.14"/> + </element> + <element name="hl7:repeatNumber" conformance="NP" /> + <element name="hl7:value" datatype="CS"> + <vocabulary valueSet="1.3.6.1.4.1.12559.11.10.1.3.1.42.10" flexibility="dynamic"/> + </element> + </element> + </template> + </rules> +</decor> \ No newline at end of file diff --git a/hl7templates/hl7templates-generator-jar/src/test/resources/processors/decor_vocab_fixdedVal.xml b/hl7templates/hl7templates-generator-jar/src/test/resources/processors/decor_vocab_fixdedVal.xml new file mode 100644 index 0000000000000000000000000000000000000000..52ce60c208df795de3ef39e01ed3790019716ac9 --- /dev/null +++ b/hl7templates/hl7templates-generator-jar/src/test/resources/processors/decor_vocab_fixdedVal.xml @@ -0,0 +1,31 @@ +<?xml-model href="http://art-decor.org/ADAR/rv/DECOR.xsd" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?> +<decor xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epsos="urn:epSOS:ps:ps:2010" xsi:noNamespaceSchemaLocation="http://art-decor.org/ADAR/rv/DECOR.xsd" repository="true" epsos:dummy-1="urn:epSOS:ps:ps:2010" xsi:dummy-2="http://www.w3.org/2001/XMLSchema-instance" versionDate="2015-06-09T11:03:41" versionLabel="" compilationDate="2015-06-09T11:03:41" language="en-US" deeplinkprefix="http://decor.nictiz.nl/art-decor/" deeplinkprefixservices="http://decor.nictiz.nl/decor/services/"> + <project id="2.16.840.1.113883.2.4.3.11.60.22" prefix="ccda-" defaultLanguage="en-US"> + </project> + <rules> + <!--Pregnancy Observation--> + <template id="1.3.6.1.4.1.19376.1.5.3.1.4.13.5" displayName="Pregnancy Observation" name="EntryPregnancyObservation" effectiveDate="2013-12-20T00:00:00" statusCode="draft"> + <classification type="cdaentrylevel"/> + <relationship type="SPEC" template="2.16.840.1.113883.10.20.1.33"/> + <context id="**"/> + <element name="hl7:observation" conformance="R"> + <element name="hl7:templateId" minimumMultiplicity="1" maximumMultiplicity="1" datatype="II.EPSOS" conformance="R" isMandatory="false"> + <attribute name="root" value="1.3.6.1.4.1.19376.1.5.3.1.4.13"/> + </element> + <element name="hl7:templateId" minimumMultiplicity="1" maximumMultiplicity="1" datatype="II.EPSOS" conformance="R" isMandatory="false"> + <attribute name="root" value="1.3.6.1.4.1.19376.1.5.3.1.4.13.5"/> + </element> + <element name="hl7:code" minimumMultiplicity="1" maximumMultiplicity="1" datatype="CD" conformance="R" isMandatory="true"> + <vocabulary valueSet="1.3.6.1.4.1.12559.11.10.1.3.1.42.9" flexibility="2015-01-01T01:02:03"/> + </element> + <element name="hl7:statusCode" minimumMultiplicity="1" maximumMultiplicity="1" datatype="CS" conformance="R"> + <vocabulary code="completed" codeSystem="2.16.840.1.113883.5.14"/> + </element> + <element name="hl7:repeatNumber" conformance="NP" /> + <element name="hl7:value" datatype="CS"> + <vocabulary codeSystem="1.2.3"/> + </element> + </element> + </template> + </rules> +</decor> \ No newline at end of file diff --git a/hl7templates/hl7templates-model-jar/src/main/java/net/ihe/gazelle/tempmodel/org/decor/art/utils/BBRResource.java b/hl7templates/hl7templates-model-jar/src/main/java/net/ihe/gazelle/tempmodel/org/decor/art/utils/BBRResource.java new file mode 100644 index 0000000000000000000000000000000000000000..d98b14c49543beb9e8e981175a39363298a4b6ee --- /dev/null +++ b/hl7templates/hl7templates-model-jar/src/main/java/net/ihe/gazelle/tempmodel/org/decor/art/utils/BBRResource.java @@ -0,0 +1,6 @@ +package net.ihe.gazelle.tempmodel.org.decor.art.utils; + +public interface BBRResource { + + Object getResource(); +} diff --git a/hl7templates/hl7templates-model-jar/src/main/java/net/ihe/gazelle/tempmodel/org/decor/art/utils/DecorMarshaller.java b/hl7templates/hl7templates-model-jar/src/main/java/net/ihe/gazelle/tempmodel/org/decor/art/utils/DecorMarshaller.java index f105aaca5947c9be0e4d7c76bdd099797bcb1db4..f400c8038dfdf459d410284750923f15c061b98f 100644 --- a/hl7templates/hl7templates-model-jar/src/main/java/net/ihe/gazelle/tempmodel/org/decor/art/utils/DecorMarshaller.java +++ b/hl7templates/hl7templates-model-jar/src/main/java/net/ihe/gazelle/tempmodel/org/decor/art/utils/DecorMarshaller.java @@ -29,13 +29,35 @@ public final class DecorMarshaller { private static Logger log = LoggerFactory.getLogger(DecorMarshaller.class); private DecorMarshaller() {} - - public static Decor loadDecor(InputStream is) throws JAXBException { - JAXBContext jc = JAXBContext.newInstance(Decor.class); - Unmarshaller u = jc.createUnmarshaller(); - Decor res = (Decor) u.unmarshal(is); - updateDecorContent(res); - return res; + + public static Decor loadDecor(BBRResource bbrResource){ + if(bbrResource instanceof PathBBRResource){ + String bbrpath = (String) bbrResource.getResource(); + return loadDecor(bbrpath); + } + else if(bbrResource instanceof StreamBBRResource) { + URL bbrurl = (URL) bbrResource.getResource(); + try { + return loadDecor(bbrurl.openStream()); + } catch (IOException e) { + log.error("Cannot open stream from URL",e); + } + } + return null; + } + + public static Decor loadDecor(InputStream is) { + try { + JAXBContext jc = JAXBContext.newInstance(Decor.class); + Unmarshaller u = jc.createUnmarshaller(); + Decor res = (Decor) u.unmarshal(is); + updateDecorContent(res); + return res; + } + catch (JAXBException e){ + log.error("Error to parse decor",e); + return null; + } } public static Decor loadDecor(String path) { @@ -57,8 +79,6 @@ public final class DecorMarshaller { return loadDecor(is); } catch (IOException e) { log.error("Error to load decor from url : " + path, e); - } catch (JAXBException e){ - log.error("Error to parse decor",e); }finally { if (is != null) { try { diff --git a/hl7templates/hl7templates-model-jar/src/main/java/net/ihe/gazelle/tempmodel/org/decor/art/utils/PathBBRResource.java b/hl7templates/hl7templates-model-jar/src/main/java/net/ihe/gazelle/tempmodel/org/decor/art/utils/PathBBRResource.java new file mode 100644 index 0000000000000000000000000000000000000000..697ed539b9e6bfcfb39edaf18347dafacb723273 --- /dev/null +++ b/hl7templates/hl7templates-model-jar/src/main/java/net/ihe/gazelle/tempmodel/org/decor/art/utils/PathBBRResource.java @@ -0,0 +1,18 @@ +package net.ihe.gazelle.tempmodel.org.decor.art.utils; + +import net.ihe.gazelle.tempmodel.org.decor.art.utils.BBRResource; + +public class PathBBRResource implements BBRResource { + + private String bbrPath; + + public PathBBRResource(String bbrPath) { + this.bbrPath = bbrPath; + } + + + @Override + public Object getResource() { + return bbrPath; + } +} diff --git a/hl7templates/hl7templates-model-jar/src/main/java/net/ihe/gazelle/tempmodel/org/decor/art/utils/StreamBBRResource.java b/hl7templates/hl7templates-model-jar/src/main/java/net/ihe/gazelle/tempmodel/org/decor/art/utils/StreamBBRResource.java new file mode 100644 index 0000000000000000000000000000000000000000..e83a50f9bb04d5d3ad58d69087351be1314eae7b --- /dev/null +++ b/hl7templates/hl7templates-model-jar/src/main/java/net/ihe/gazelle/tempmodel/org/decor/art/utils/StreamBBRResource.java @@ -0,0 +1,19 @@ +package net.ihe.gazelle.tempmodel.org.decor.art.utils; + +import net.ihe.gazelle.tempmodel.org.decor.art.utils.BBRResource; + +import java.net.URL; + +public class StreamBBRResource implements BBRResource { + + private URL url; + + public StreamBBRResource(URL url) { + this.url = url; + } + + @Override + public Object getResource() { + return url; + } +} diff --git a/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/adapters/UMLModelGenerator.java b/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/adapters/UMLModelGenerator.java index e56aa17bada24376ab231d042138b35b5e3e4946..c4a652ad8f5ab3ebedad89a96b8f44a9d89bb795 100644 --- a/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/adapters/UMLModelGenerator.java +++ b/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/adapters/UMLModelGenerator.java @@ -1,18 +1,18 @@ package net.ihe.gazelle.lib.hl7templatespackager.adapters; -import net.ihe.gazelle.lib.hl7templatespackager.application.GOCLogger; -import net.ihe.gazelle.lib.hl7templatespackager.application.ValidatorConfiguration; -import net.ihe.gazelle.lib.hl7templatespackager.application.ModelGenerator; -import net.ihe.gazelle.lib.hl7templatespackager.application.Workspace; +import net.ihe.gazelle.lib.hl7templatespackager.application.*; import net.ihe.gazelle.lib.hl7templatespackager.application.exception.ModelGenerationException; import net.ihe.gazelle.tempgen.action.GenerationProperties; import net.ihe.gazelle.tempgen.action.HL7TemplatesConverter; +import net.ihe.gazelle.tempmodel.org.decor.art.utils.BBRResource; +import net.ihe.gazelle.tempmodel.org.decor.art.utils.PathBBRResource; import org.apache.commons.io.FileUtils; import org.slf4j.LoggerFactory; import javax.xml.bind.JAXBException; import java.io.File; import java.io.IOException; +import java.net.URL; /** * This class allows to generate UML models from a given ValidatorConfiguration @@ -82,8 +82,11 @@ public class UMLModelGenerator implements ModelGenerator { File outUmlModelPath = new File( workpacePath + File.separator + validatorConfiguration.getProjectNaming().getProjectName() + VALIDATOR_JAR_SUFFIX + File.separator + "model" + File.separator + validatorConfiguration.getProjectNaming().getProjectName() + ".uml"); try { - String umlModelForBBR = templatesConverter.convertArtDecorXMI(validatorConfiguration.getBbrPath(), - validatorConfiguration.ignoreTemplateIdRequirements(), validatorConfiguration.getTemplateVersionFilter()); + BBRResource bbrResource = validatorConfiguration.getBbrResource(); + boolean ignoreTemplateIdRequirements = validatorConfiguration.ignoreTemplateIdRequirements(); + String tempalteVersionFilter = validatorConfiguration.getTemplateVersionFilter(); + String umlModelForBBR; + umlModelForBBR = templatesConverter.convertArtDecorXMI(bbrResource, ignoreTemplateIdRequirements, tempalteVersionFilter); log.info("ValidatorConfiguration converted to UML."); FileUtils.writeStringToFile(outUmlModelPath, umlModelForBBR, "UTF-8"); log.warn("Generated UML Model is saved at: "+outUmlModelPath); @@ -92,6 +95,8 @@ public class UMLModelGenerator implements ModelGenerator { throw new ModelGenerationException("Cannot convert ValidatorConfiguration to UML model !", e); } catch (IOException e){ throw new ModelGenerationException("Cannot write model in target file ! (" + outUmlModelPath.getAbsolutePath() + ")", e); + } catch (ClassCastException e){ + throw new ModelGenerationException("BBRResource not defined",e); } } } diff --git a/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/adapters/ValueSetExtractorImpl.java b/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/adapters/ValueSetExtractorImpl.java index 15802767b1d3595357841956c1322626d709ed63..c402161b0b4bf84d55ddc4e7ee3e86ed0820868c 100644 --- a/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/adapters/ValueSetExtractorImpl.java +++ b/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/adapters/ValueSetExtractorImpl.java @@ -1,14 +1,17 @@ package net.ihe.gazelle.lib.hl7templatespackager.adapters; +import net.ihe.gazelle.tempmodel.org.decor.art.utils.BBRResource; import net.ihe.gazelle.lib.hl7templatespackager.application.ValidatorConfiguration; import net.ihe.gazelle.lib.hl7templatespackager.application.ValueSetExtractor; import net.ihe.gazelle.lib.hl7templatespackager.application.Workspace; import net.ihe.gazelle.lib.hl7templatespackager.application.exception.ValueSetExtractionException; import net.ihe.gazelle.tempmodel.org.decor.art.model.Decor; import net.ihe.gazelle.tempmodel.org.decor.art.utils.DecorMarshaller; +import net.ihe.gazelle.tempmodel.org.decor.art.utils.PathBBRResource; import java.io.File; import java.io.IOException; +import java.net.URL; /** * This class extracts the value-sets from a ValidatorConfiguration into a target generated validator project. @@ -62,7 +65,8 @@ public class ValueSetExtractorImpl implements ValueSetExtractor { * @throws ValueSetExtractionException when Value-sets cannot be correctly extracted from ValidatorConfiguration. */ public void extractValueSets(Workspace workspace, ValidatorConfiguration validatorConfiguration) throws ValueSetExtractionException{ - Decor decor = DecorMarshaller.loadDecor(validatorConfiguration.getBbrPath()); + BBRResource bbrResource = validatorConfiguration.getBbrResource(); + Decor decor = DecorMarshaller.loadDecor(bbrResource); File outputFile = new File(getWorkspaceRoot() + workspace.getName() + File.separator + validatorConfiguration.getProjectNaming().getProjectName() + "-validator-jar/src/main/resources/valresources/valueSets/"); try { diff --git a/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/application/ProjectNaming.java b/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/application/ProjectNaming.java index c236c4a3224f4c39b57b2066ab1086bae6386bcc..b351af3c70b301ad81764db535441e2bdd41e8cc 100644 --- a/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/application/ProjectNaming.java +++ b/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/application/ProjectNaming.java @@ -1,9 +1,14 @@ package net.ihe.gazelle.lib.hl7templatespackager.application; +import net.ihe.gazelle.tempmodel.org.decor.art.utils.PathBBRResource; +import net.ihe.gazelle.tempmodel.org.decor.art.utils.StreamBBRResource; import net.ihe.gazelle.tempgen.flatten.action.ProjectFlattenProc; import net.ihe.gazelle.tempmodel.org.decor.art.model.Decor; +import net.ihe.gazelle.tempmodel.org.decor.art.utils.BBRResource; import net.ihe.gazelle.tempmodel.org.decor.art.utils.DecorMarshaller; +import java.net.URL; + /** * This class is responsible for the extraction of the name from the ValidatorConfiguration. * It will then be able to generate alternative names used for example in artifact generation from the archetype (upper case, capitalized, etc). @@ -24,10 +29,11 @@ public class ProjectNaming { * It will extract a name from it, which will be used to generate the corresponding validator. * @param bbrPath : path to the ValidatorConfiguration used for the generation */ - ProjectNaming(String bbrPath){ - this.projectName = extractProjectName(bbrPath); + ProjectNaming(BBRResource bbrResource) { + this.projectName = extractProjectName(bbrResource); } + /** * Getter for the project name held by the instance. * @return Value of the projectName property in {@link java.lang.String} @@ -79,12 +85,23 @@ public class ProjectNaming { * Extract the name of the project from the ValidatorConfiguration found at path given in parameter. * @param bbrPath path to the BRR from which the project name will be extracted */ - private String extractProjectName(String bbrPath) { - Decor decor = DecorMarshaller.loadDecor(bbrPath); + private String extractProjectName(Decor decor) { String projectName = ProjectFlattenProc.flattenPrefix(decor.getProject().getPrefix()); if (projectName.endsWith("-")) { projectName = projectName.substring(0, projectName.length()-1); } return projectName; } + + private String extractProjectName(String bbrPath){ + Decor decor = DecorMarshaller.loadDecor(bbrPath); + return extractProjectName(decor); + } + + private String extractProjectName(BBRResource bbrResource) { + Decor decor = DecorMarshaller.loadDecor(bbrResource); + return extractProjectName(decor); + } + + } diff --git a/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/application/ValidatorConfiguration.java b/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/application/ValidatorConfiguration.java index f91ee6fc6fb4b77ee62e07094caa8492892a38cd..0b76abf10fe7047bc921e355f7ee247c8e974774 100644 --- a/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/application/ValidatorConfiguration.java +++ b/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/application/ValidatorConfiguration.java @@ -1,6 +1,8 @@ package net.ihe.gazelle.lib.hl7templatespackager.application; +import net.ihe.gazelle.tempmodel.org.decor.art.utils.BBRResource; + /** * This class holds the information about the ValidatorConfiguration used for the generation as well as all options for the generation. * @@ -8,13 +10,16 @@ package net.ihe.gazelle.lib.hl7templatespackager.application; */ public class ValidatorConfiguration { - private String bbrPath; + private BBRResource bbrResource; private String templateVersionFilter; private Boolean ignoreTemplateIdRequirements; private Boolean ignoreCdaBasicRequirements; private String serviceName; private ProjectNaming projectNaming; + @Deprecated + private String bbrPath; + /** * Base constructor for the class. */ @@ -31,14 +36,18 @@ public class ValidatorConfiguration { * @param ignoreCdaBasicRequirements : if true, no rules will be generated on CDA Basic requirements in the validator * @param serviceName : service name that will be used in validation reports */ - public ValidatorConfiguration(String bbrPath, String templateVersionFilter, Boolean ignoreTemplateIdRequirements, + public ValidatorConfiguration(BBRResource bbrResource, String templateVersionFilter, Boolean ignoreTemplateIdRequirements, Boolean ignoreCdaBasicRequirements, String serviceName) { - setBbrPath(bbrPath); + this.bbrResource = bbrResource; setTemplateVersionFilter(templateVersionFilter); setIgnoreTemplateIdRequirements(ignoreTemplateIdRequirements); setIgnoreCdaBasicRequirements(ignoreCdaBasicRequirements); setServiceName(serviceName); - projectNaming = new ProjectNaming(bbrPath); + projectNaming = new ProjectNaming(bbrResource); + } + + public BBRResource getBbrResource() { + return bbrResource; } /** @@ -66,6 +75,7 @@ public class ValidatorConfiguration { } } + /** * Getter for the bbrPath property. * diff --git a/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/application/exception/GenerationException.java b/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/application/exception/GenerationException.java new file mode 100644 index 0000000000000000000000000000000000000000..77d315e9021e8e7de9a77555d792f949253cbe70 --- /dev/null +++ b/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/application/exception/GenerationException.java @@ -0,0 +1,12 @@ +package net.ihe.gazelle.lib.hl7templatespackager.application.exception; + +public class GenerationException extends Exception{ + + public GenerationException(String message) { + super(message); + } + + public GenerationException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/peripherals/GOCEntry.java b/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/peripherals/GOCEntry.java new file mode 100644 index 0000000000000000000000000000000000000000..647811556b4e28367a0991dae0444e6468a4bbb6 --- /dev/null +++ b/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/peripherals/GOCEntry.java @@ -0,0 +1,6 @@ +package net.ihe.gazelle.lib.hl7templatespackager.peripherals; + +public interface GOCEntry { + + void runGOC(String args[]); +} diff --git a/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/peripherals/GOCExecutor.java b/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/peripherals/GOCExecutor.java new file mode 100644 index 0000000000000000000000000000000000000000..bec38a80ec95756b754210dbd77b2afdb7a65575 --- /dev/null +++ b/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/peripherals/GOCExecutor.java @@ -0,0 +1,134 @@ +package net.ihe.gazelle.lib.hl7templatespackager.peripherals; + +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 net.ihe.gazelle.tempmodel.org.decor.art.utils.BBRResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.text.SimpleDateFormat; +import java.util.Date; + +public class GOCExecutor { + + private static Logger log = null; + + private String generationDate; + + private String outputFile; + + private String hl7Resources; + + private String hl7Conf; + + private static final SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy-HH-mm-ss"); + + public GOCExecutor(String outputFile, String hl7Resources, String hl7Conf) { + this.outputFile = outputFile; + this.hl7Resources = hl7Resources; + this.hl7Conf = hl7Conf; + } + + public GOCExecutor(String outputFile){ + this.outputFile = outputFile; + } + + public ValidatorConfiguration execute(BBRResource bbrResource, String mvnExecPath){ + return execute(bbrResource,mvnExecPath,null,false,false,null); + } + + public ValidatorConfiguration execute(BBRResource bbrResource,String mvnExecPath, + String versionLabel, Boolean ignoreTemplateIdRequirements, + Boolean ignoreCdaBasicRequirements, String serviceName) { + + try{ + addSubDirectoryToOutput("/validator"); + + // initialize log variable + initLog(); + GOCLogger gocLogger = new GOCLoggerImpl(getWorkspaceRoot(), generationDate); + + ProcessExecutor processExecutor = new ProcessExecutorBash(gocLogger); + + //check environement configuration + EnvironementChecker environementChecker = new EnvironementCheckerImpl(); + environementChecker.checkMVNPath(mvnExecPath,processExecutor); + environementChecker.checkJavaVersion(); + + + this.hl7Resources = this.hl7Resources==null? + getWorkspaceRoot()+"/hl7templates-resources":this.hl7Resources; + + this.hl7Conf = this.hl7Conf == null ? "cdabasic":this.hl7Conf; + + EnvironementConfiguration.setSystemVariables("HL7TEMP_CDACONFFOLDERNAME",hl7Conf, + "HL7TEMP_RESOURCES_PATH",this.hl7Resources,"JAVA_EXEC",System.getProperty("java.home")+"/bin/java"); + + EnvironementConfiguration.configure(); + + log.info("Generation started at : {}",this.generationDate); + log.info("Workspace root is : {}",getWorkspaceRoot()); + log.info("Workspace name is : {}",getWorkspaceName()); + + GOCPackager packager = new GOCPackagerFactory().createGOCPackager(getWorkspaceRoot(), mvnExecPath, this.generationDate, + gocLogger, processExecutor); + + ValidatorConfiguration validatorConfiguration = new ValidatorConfiguration(bbrResource, versionLabel, + ignoreTemplateIdRequirements, ignoreCdaBasicRequirements, + serviceName); + + packager.packageBBRToGOCValidationTool(new Workspace(getWorkspaceName()),validatorConfiguration); + + return validatorConfiguration; + + } + catch (EnvironementException e){ + log.error("Problem in environement configuration",e); + } + catch (PackagerProcessException e){ + log.error("Problem during packaging validator",e); + } + + return null; + } + + /** + * initialize log4j used variable before start logging<br> + * And set the generationDate field<br> + * <b>Variable name:</b> <i>${generationDate}</i><br> + * <b>Usage:</b> as a system property + */ + private void initLog(){ + this.generationDate = this.formatter.format(new Date()); + System.setProperty("generationDate",this.generationDate); + System.setProperty("workspaceRoot",getWorkspaceRoot()); + log = LoggerFactory.getLogger(HL7Templates2GOC.class); + } + + /** + * Method to add sub-directories to the provided output path + * To encapsulate validator and logs in one directory + * Provide empty string to use the old behavior + * @param subDirectory sub-directorie(s), started with '/' + */ + private void addSubDirectoryToOutput(String subDirectory){ + if(subDirectory == null){ + subDirectory = ""; + } + this.outputFile = this.outputFile + subDirectory; + } + + private String getWorkspaceName() { + return this.outputFile.substring(this.outputFile.lastIndexOf("/") + 1); + } + + private String getWorkspaceRoot() { + return this.outputFile.substring(0, this.outputFile.lastIndexOf("/") + 1); + } + + public String getGenerationDate() { + return generationDate; + } +} 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 1f513f9a5699039f5da1fbba4fe46e302b51e7b2..4890756bcd536abab940de92899756836593438f 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 99bb6aa4f7874cb637d8676551746470a1988405..3b241060d148693390c276ac2b4df14fce33bbb6 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 @@ -1,48 +1,27 @@ package net.ihe.gazelle.lib.hl7templatespackager.peripherals; -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 net.ihe.gazelle.tempmodel.org.decor.art.utils.PathBBRResource; 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.text.SimpleDateFormat; -import java.util.Date; +public class HL7Templates2GOC implements GOCEntry { -public class HL7Templates2GOC { - - private static Logger log = null; static final String DOCUMENTATION_STRING = "\nHL7Templates2GOC -out outputFolder -bbr buildBlockRepositoryURL"; - private static final SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy-HH-mm-ss"); - @Option(name = "-out", metaVar = "outputFile", usage = "Output folder", required = true) private String outputFile; - @Option(name = "-in", metaVar = "inputFile", usage = "Input folder", required = false) - private String inputFile; - @Option(name = "-bbr", metaVar = "bbr", usage = "Output folder", required = true) private String bbr; @Option(name = "-serviceName", metaVar = "serviceName", usage = "Validation Service Name", required = false) private String serviceName; - @Option(name = "-prop", metaVar = "properties", usage = "Path to customized java imports file", required = false) - private String properties; - @Option(name = "-mvn", metaVar = "mvn", usage = "maven executable path", required = false) private String mvnExecPath = "mvn"; - @Option(name = "-notoverride", usage = "Not override the modelDefinition.xml file", required = false) - @Deprecated - private Boolean notOverride = false; - @Option(name = "-ignoreTemplateIdRequirements", usage = "ignore TemplateId Requirements when generating the constraints (useful for C-CDA " + "validation tools)", required = false) private Boolean ignoreTemplateIdRequirements = false; @@ -54,31 +33,27 @@ public class HL7Templates2GOC { @Option(name = "-versionLabel", metaVar = "versionLabel", usage = "versionLabel that will be used during the generation", required = false) private String versionLabel; - @Option(name = "-rootClassName", metaVar = "rootClassName", usage = "Root Class Name", required = false) - private String rootClassName; - @Option(name = "-HL7TEMP_CDACONFFOLDERNAME", metaVar = "hl7temp_cdaconffoldername", usage = "hl7temp cda conf folder name", required = false) private String HL7TEMP_CDACONFFOLDERNAME = "cdabasic"; @Option(name="-HL7TEMP_RESOURCES_PATH", metaVar = "HL7TEMP_RESOURCES_PATH", usage = "path to hl7templates resources folder", required = false) private String HL7TEMP_RESOURCES_PATH; + @Deprecated + @Option(name = "-rootClassName", metaVar = "rootClassName", usage = "Root Class Name", required = false) + private String rootClassName; - private String generationDate; + @Option(name = "-notoverride", usage = "Not override the modelDefinition.xml file", required = false) + @Deprecated + private Boolean notOverride = false; - /** - * @return the rootClassName - */ - public String getRootClassName() { - return rootClassName; - } + @Option(name = "-prop", metaVar = "properties", usage = "Path to customized java imports file", required = false) + @Deprecated + private String properties; - /** - * @param rootClassName the rootClassName to set - */ - public void setRootClassName(String rootClassName) { - this.rootClassName = rootClassName; - } + @Deprecated + @Option(name = "-in", metaVar = "inputFile", usage = "Input folder", required = false) + private String inputFile; public String getVersionLabel() { return versionLabel; @@ -130,38 +105,6 @@ public class HL7Templates2GOC { this.mvnExecPath = mvnExecPath; } - public String getInputFile() { - if (inputFile == null) { - inputFile = getOutputFile() + "/archetypes/"; - } - return inputFile; - } - - public void setInputFile(String inputFile) { - this.inputFile = inputFile; - } - - public String getProperties() { - if (properties == null) { - properties = getOutputFile() + "/archetypes/conf.properties"; - } - return properties; - } - - public void setProperties(String properties) { - this.properties = properties; - } - - @Deprecated - public Boolean getNotOverride() { - return notOverride; - } - - @Deprecated - public void setNotOverride(Boolean notOverride) { - this.notOverride = notOverride; - } - public String getOutputFile() { return outputFile; } @@ -195,91 +138,81 @@ public class HL7Templates2GOC { } - public void execute(String[] args) { - CmdLineParser parser = new CmdLineParser(this); - try { - parser.parseArgument(args); + @Deprecated + public String getInputFile() { + if (inputFile == null) { + inputFile = getOutputFile() + "/archetypes/"; + } + return inputFile; + } - addSubDirectoryToOutput("/validator"); + @Deprecated + public void setInputFile(String inputFile) { + this.inputFile = inputFile; + } - // initialize log variable - initLog(); - GOCLogger gocLogger = new GOCLoggerImpl(getWorkspaceRoot(getOutputFile()), generationDate); + @Deprecated + public String getProperties() { + if (properties == null) { + properties = getOutputFile() + "/archetypes/conf.properties"; + } + return properties; + } - ProcessExecutor processExecutor = new ProcessExecutorBash(gocLogger); + @Deprecated + public void setProperties(String properties) { + this.properties = properties; + } - //check environement configuration - EnvironementChecker environementChecker = new EnvironementCheckerImpl(); - environementChecker.checkMVNPath(mvnExecPath,processExecutor); - environementChecker.checkJavaVersion(); + @Deprecated + public Boolean getNotOverride() { + return notOverride; + } + @Deprecated + public void setNotOverride(Boolean notOverride) { + this.notOverride = notOverride; + } - HL7TEMP_RESOURCES_PATH = HL7TEMP_RESOURCES_PATH==null? - getWorkspaceRoot(outputFile)+"/hl7templates-resources":HL7TEMP_RESOURCES_PATH; + /** + * @return the rootClassName + */ + @Deprecated + public String getRootClassName() { + return rootClassName; + } - EnvironementConfiguration.setSystemVariables("HL7TEMP_CDACONFFOLDERNAME",HL7TEMP_CDACONFFOLDERNAME, - "HL7TEMP_RESOURCES_PATH",HL7TEMP_RESOURCES_PATH,"JAVA_EXEC",System.getProperty("java.home")+"/bin/java"); + /** + * @param rootClassName the rootClassName to set + */ + @Deprecated + public void setRootClassName(String rootClassName) { + this.rootClassName = rootClassName; + } - EnvironementConfiguration.configure(); - log.info("Generation started at : "+generationDate); - log.info("Workspace root is : " + getWorkspaceRoot(getOutputFile())); - log.info("Workspace name is : " + getWorkspaceName(getOutputFile())); + @Override + public void runGOC(String[] args) { + CmdLineParser parser = new CmdLineParser(this); + try { + parser.parseArgument(args); - GOCPackager packager = new GOCPackagerFactory().createGOCPackager(getWorkspaceRoot(getOutputFile()), mvnExecPath, generationDate, - gocLogger, processExecutor); + GOCExecutor gocExecutor = new GOCExecutor(outputFile, HL7TEMP_RESOURCES_PATH,HL7TEMP_CDACONFFOLDERNAME); + gocExecutor.execute(new PathBBRResource(bbr),mvnExecPath,versionLabel, + ignoreTemplateIdRequirements,ignoreCdaBasicRequirements, serviceName); - packager.packageBBRToGOCValidationTool(new Workspace(getWorkspaceName(getOutputFile())), - new ValidatorConfiguration(getBbr(), getVersionLabel(), getIgnoreTemplateIdRequirements(), getIgnoreCdaBasicRequirements(), - getServiceName())); } catch (CmdLineException e) { - System.out.println("Exception in the execution of command line"); + System.err.println("Exception in the execution of command line"); e.printStackTrace(); - } catch (PackagerProcessException e) { - log.error("Exception during packaging process", e); - } catch (EnvironementException e) { - log.error("A problem in the environement configuration",e); } - } - - /** - * initialize log4j used variable before start logging<br> - * And set the generationDate field<br> - * <b>Variable name:</b> <i>${generationDate}</i><br> - * <b>Usage:</b> as a system property - */ - private void initLog(){ - this.generationDate = this.formatter.format(new Date()); - System.setProperty("generationDate",this.generationDate); - System.setProperty("workspaceRoot",getWorkspaceRoot(getOutputFile())); - log = LoggerFactory.getLogger(HL7Templates2GOC.class); - } - - private String getWorkspaceName(String outpuFilePath) { - return getOutputFile().substring(getOutputFile().lastIndexOf("/") + 1); - } - private String getWorkspaceRoot(String outpuFilePath) { - return getOutputFile().substring(0, getOutputFile().lastIndexOf("/") + 1); } - /** - * Method to add sub-directories to the provided output path - * To encapsulate validator and logs in one directory - * Provide empty string to use the old behavior - * @param subDirectory sub-directorie(s), started with '/' - */ - private void addSubDirectoryToOutput(String subDirectory){ - if(subDirectory == null){ - subDirectory = ""; - } - this.outputFile = this.outputFile + subDirectory; - } public static void main(String[] args) { HL7Templates2GOC hl7Templates2GOC = new HL7Templates2GOC(); - hl7Templates2GOC.execute(args); + hl7Templates2GOC.runGOC(args); } } diff --git a/hl7templates/hl7templates-packager-jar/src/test/java/net/ihe/gazelle/lib/hl7templatespackager/application/GOCPackgerTest.java b/hl7templates/hl7templates-packager-jar/src/test/java/net/ihe/gazelle/lib/hl7templatespackager/application/GOCPackgerTest.java index e8a65afd3a9080339912ff6e20fe641fd37b8765..4218b37df446ba456dd7e6a166a29dc4c2ab910d 100644 --- a/hl7templates/hl7templates-packager-jar/src/test/java/net/ihe/gazelle/lib/hl7templatespackager/application/GOCPackgerTest.java +++ b/hl7templates/hl7templates-packager-jar/src/test/java/net/ihe/gazelle/lib/hl7templatespackager/application/GOCPackgerTest.java @@ -1,5 +1,6 @@ package net.ihe.gazelle.lib.hl7templatespackager.application; +import net.ihe.gazelle.tempmodel.org.decor.art.utils.PathBBRResource; import net.ihe.gazelle.lib.hl7templatespackager.peripherals.GOCLoggerImpl; import net.ihe.gazelle.lib.hl7templatespackager.peripherals.GOCPackagerFactory; import net.ihe.gazelle.lib.hl7templatespackager.peripherals.ProcessExecutorBash; @@ -33,6 +34,6 @@ public class GOCPackgerTest { Files.createDirectories(path); //notOverride set to false because new resources are retrieved with an anonymous workspace so we need to replace it - packager.packageBBRToGOCValidationTool(new Workspace(folderOutput), new ValidatorConfiguration(bbrPath, "2.1", false,false, serviceName)); + packager.packageBBRToGOCValidationTool(new Workspace(folderOutput), new ValidatorConfiguration(new PathBBRResource(bbrPath), "2.1", false,false, serviceName)); } } diff --git a/pom.xml b/pom.xml index 023f5c62c4d8226a9396602edff7d532d1fdfd01..005a2891180a082c31fa42393da36e3cfbf697f7 100644 --- a/pom.xml +++ b/pom.xml @@ -71,20 +71,36 @@ <module>hl7templates/hl7templates-api-jar</module> <module>hl7templates/hl7templates-generator-jar</module> <module>hl7templates/hl7templates-packager-jar</module> + <module>hl7templates/goc-tests</module> </modules> <build> <plugins> <plugin> + + <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>3.8.0</version> + <version>3.8.1</version> <configuration> - <compilerVersion>11</compilerVersion> - <fork>true</fork> <source>11</source> <target>11</target> + <annotationProcessors> + <annotationProcessor> + net.ihe.gazelle.goctests.definitions.application.processors.CoverageProcessor + </annotationProcessor> + </annotationProcessors> </configuration> + <dependencies> + + <dependency> + <groupId>org.glassfish.jaxb</groupId> + <artifactId>jaxb-runtime</artifactId> + <version>2.3.1</version> + <scope>runtime</scope> + </dependency> + </dependencies> </plugin> + <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> @@ -182,7 +198,7 @@ <outputDirectory>${basedir}/target/</outputDirectory> <resources> <resource> - <directory>hl7templates/hl7templates-packager-jar/target</directory> + <directory>${basedir}/hl7templates/hl7templates-packager-jar/target</directory> <includes> <include>**/*.jar</include> <include>**/*.sh</include>