From 4e3e21219ecfcb46f5aa6485d4c3999dc1ec71af Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Sat, 22 Feb 2020 08:06:58 +1100 Subject: [PATCH 01/10] Release new version 4.2.2 --- org.hl7.fhir.convertors/pom.xml | 2 +- org.hl7.fhir.dstu2/pom.xml | 2 +- org.hl7.fhir.dstu2016may/pom.xml | 2 +- org.hl7.fhir.dstu3/pom.xml | 2 +- org.hl7.fhir.r4/pom.xml | 2 +- org.hl7.fhir.r5/pom.xml | 2 +- org.hl7.fhir.utilities/pom.xml | 2 +- org.hl7.fhir.validation.cli/pom.xml | 2 +- org.hl7.fhir.validation/pom.xml | 2 +- pom.xml | 2 +- release.bat | 4 ++-- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/org.hl7.fhir.convertors/pom.xml b/org.hl7.fhir.convertors/pom.xml index 5c649e4d0..1dbc3794b 100644 --- a/org.hl7.fhir.convertors/pom.xml +++ b/org.hl7.fhir.convertors/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 4.2.1-SNAPSHOT + 4.2.2-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.dstu2/pom.xml b/org.hl7.fhir.dstu2/pom.xml index 3c705db6b..e2164f76d 100644 --- a/org.hl7.fhir.dstu2/pom.xml +++ b/org.hl7.fhir.dstu2/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 4.2.1-SNAPSHOT + 4.2.2-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.dstu2016may/pom.xml b/org.hl7.fhir.dstu2016may/pom.xml index ea1b38b12..6cd61f2e1 100644 --- a/org.hl7.fhir.dstu2016may/pom.xml +++ b/org.hl7.fhir.dstu2016may/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 4.2.1-SNAPSHOT + 4.2.2-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.dstu3/pom.xml b/org.hl7.fhir.dstu3/pom.xml index 3e686f37e..05e28bf9f 100644 --- a/org.hl7.fhir.dstu3/pom.xml +++ b/org.hl7.fhir.dstu3/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 4.2.1-SNAPSHOT + 4.2.2-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.r4/pom.xml b/org.hl7.fhir.r4/pom.xml index 20eb4eba7..28a8c16d3 100644 --- a/org.hl7.fhir.r4/pom.xml +++ b/org.hl7.fhir.r4/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 4.2.1-SNAPSHOT + 4.2.2-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.r5/pom.xml b/org.hl7.fhir.r5/pom.xml index 0839333cb..5d0304f6e 100644 --- a/org.hl7.fhir.r5/pom.xml +++ b/org.hl7.fhir.r5/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 4.2.1-SNAPSHOT + 4.2.2-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.utilities/pom.xml b/org.hl7.fhir.utilities/pom.xml index 4628abe6e..adae327b5 100644 --- a/org.hl7.fhir.utilities/pom.xml +++ b/org.hl7.fhir.utilities/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 4.2.1-SNAPSHOT + 4.2.2-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.validation.cli/pom.xml b/org.hl7.fhir.validation.cli/pom.xml index 4f8ba0a69..c1d18a95e 100644 --- a/org.hl7.fhir.validation.cli/pom.xml +++ b/org.hl7.fhir.validation.cli/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 4.2.1-SNAPSHOT + 4.2.2-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.validation/pom.xml b/org.hl7.fhir.validation/pom.xml index d5a27d6e5..df071a9c9 100644 --- a/org.hl7.fhir.validation/pom.xml +++ b/org.hl7.fhir.validation/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 4.2.1-SNAPSHOT + 4.2.2-SNAPSHOT ../pom.xml diff --git a/pom.xml b/pom.xml index a52e6ec7a..117a49ea9 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ each other. It is fine to bump the point version of this POM without affecting HAPI FHIR. --> - 4.2.1-SNAPSHOT + 4.2.2-SNAPSHOT 4.2.0 diff --git a/release.bat b/release.bat index 426233189..91876cd7f 100644 --- a/release.bat +++ b/release.bat @@ -1,7 +1,7 @@ @echo off -set oldver=4.1.63 -set newver=4.2.1 +set oldver=4.2.1 +set newver=4.2.2 echo .. echo ========================================================================= From a732847f58801356e314ba69fc7c59e449697be7 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Mon, 24 Feb 2020 12:12:09 +1100 Subject: [PATCH 02/10] fix for NPE in an IG --- .../java/org/hl7/fhir/r5/utils/FHIRPathEngine.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java index 5581e0c32..2616da0f1 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java @@ -3334,10 +3334,12 @@ public class FHIRPathEngine { Base res = null; if (s.startsWith("#")) { Property p = context.rootResource.getChildByName("contained"); - for (Base c : p.getValues()) { - if (chompHash(s).equals(chompHash(c.getIdBase()))) { - res = c; - break; + if (p != null) { + for (Base c : p.getValues()) { + if (chompHash(s).equals(chompHash(c.getIdBase()))) { + res = c; + break; + } } } } else if (hostServices != null) { From 0bd6a4a7eb4093bf1cacfa494e8463899044d3f7 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Mon, 24 Feb 2020 12:17:34 +1100 Subject: [PATCH 03/10] more NPE fixes --- .../java/org/hl7/fhir/r5/context/BaseWorkerContext.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java index b1699a90e..b7d119827 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java @@ -758,7 +758,11 @@ public abstract class BaseWorkerContext implements IWorkerContext { @SuppressWarnings("unchecked") @Override public T fetchResourceWithException(Class class_, String uri) throws FHIRException { - if (class_ == StructureDefinition.class) + if (uri == null) { + return null; + } + + if (class_ == StructureDefinition.class) uri = ProfileUtilities.sdNs(uri, getOverrideVersionNs()); synchronized (lock) { From be38cc8e580af23c58e59a6d2ee34541ff8f043f Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Mon, 24 Feb 2020 12:18:14 +1100 Subject: [PATCH 04/10] updates for version conversion routines --- .../convertors/VersionConvertor_10_30.java | 53 +++++++++---------- .../conv10_30/SearchParameter10_30.java | 38 +++++++------ .../conv10_40/SearchParameter10_40.java | 38 +++++++------ .../instancevalidator/InstanceValidator.java | 2 +- 4 files changed, 61 insertions(+), 70 deletions(-) diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_30.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_30.java index 8f9ec2b0c..4cdd96124 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_30.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_30.java @@ -2685,38 +2685,33 @@ public class VersionConvertor_10_30 { return null; org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.SearchParamTypeEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case NUMBER: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.NUMBER); - break; - case DATE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.DATE); - break; - case STRING: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.STRING); - break; - case TOKEN: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.TOKEN); - break; - case REFERENCE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.REFERENCE); - break; - case COMPOSITE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.COMPOSITE); - break; - case QUANTITY: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.QUANTITY); - break; - case URI: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.URI); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.NULL); - break; - } + tgt.setValue(convertSearchParamType(src.getValue())); return tgt; } + static public org.hl7.fhir.dstu3.model.Enumerations.SearchParamType convertSearchParamType(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType src) throws FHIRException { + switch(src) { + case NUMBER: + return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.NUMBER; + case DATE: + return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.DATE; + case STRING: + return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.STRING; + case TOKEN: + return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.TOKEN; + case REFERENCE: + return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.REFERENCE; + case COMPOSITE: + return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.COMPOSITE; + case QUANTITY: + return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.QUANTITY; + case URI: + return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.URI; + default: + return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.NULL; + } + } + static public org.hl7.fhir.dstu2.model.Enumeration convertSearchParamType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { if (src == null || src.isEmpty()) return null; diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_30/SearchParameter10_30.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_30/SearchParameter10_30.java index 618153b58..58d0c72a7 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_30/SearchParameter10_30.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_30/SearchParameter10_30.java @@ -105,29 +105,27 @@ public class SearchParameter10_30 { return null; org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageTypeEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case NORMAL: - tgt.setValue(org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType.NORMAL); - break; - case PHONETIC: - tgt.setValue(org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType.PHONETIC); - break; - case NEARBY: - tgt.setValue(org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType.NEARBY); - break; - case DISTANCE: - tgt.setValue(org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType.DISTANCE); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType.OTHER); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType.NULL); - break; - } + tgt.setValue(convertXPathUsageType(src.getValue())); return tgt; } + static public org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType convertXPathUsageType(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType src) throws FHIRException { + switch(src) { + case NORMAL: + return org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType.NORMAL; + case PHONETIC: + return org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType.PHONETIC; + case NEARBY: + return org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType.NEARBY; + case DISTANCE: + return org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType.DISTANCE; + case OTHER: + return org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType.OTHER; + default: + return org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType.NULL; + } + } + static public org.hl7.fhir.dstu3.model.Enumeration convertXPathUsageType(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { if (src == null || src.isEmpty()) return null; diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_40/SearchParameter10_40.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_40/SearchParameter10_40.java index 8ab80942c..ed38627cc 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_40/SearchParameter10_40.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_40/SearchParameter10_40.java @@ -105,29 +105,27 @@ public class SearchParameter10_40 { return null; org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.SearchParameter.XPathUsageTypeEnumFactory()); VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case NORMAL: - tgt.setValue(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NORMAL); - break; - case PHONETIC: - tgt.setValue(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.PHONETIC); - break; - case NEARBY: - tgt.setValue(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NEARBY); - break; - case DISTANCE: - tgt.setValue(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.DISTANCE); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.OTHER); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NULL); - break; - } + tgt.setValue(convertXPathUsageType(src.getValue())); return tgt; } + static public org.hl7.fhir.r4.model.SearchParameter.XPathUsageType convertXPathUsageType(org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType src) { + switch(src) { + case NORMAL: + return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NORMAL; + case PHONETIC: + return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.PHONETIC; + case NEARBY: + return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NEARBY; + case DISTANCE: + return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.DISTANCE; + case OTHER: + return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.OTHER; + default: + return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NULL; + } + } + static public org.hl7.fhir.dstu2.model.Enumeration convertXPathUsageType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { if (src == null || src.isEmpty()) return null; diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/InstanceValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/InstanceValidator.java index fa8e4c459..2e5f1e30e 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/InstanceValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/InstanceValidator.java @@ -152,7 +152,7 @@ import ca.uhn.fhir.util.ObjectUtil; /** * Thinking of using this in a java program? Don't! - * You should use one of the wrappers instead. Either in HAPI, or use ValidationEngine + * You should use one of the wrappers instead. Either in HAPI, or use ValidationEngine, or NativeHostServices *

* Validation todo: * - support @default slices From 99a266b0d6989ef616e06617e2820e9b876a3ccc Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Mon, 24 Feb 2020 16:06:28 +1100 Subject: [PATCH 05/10] fix bug with template inheritance --- .../main/java/org/hl7/fhir/utilities/cache/NpmPackage.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java index d58520549..e1ecfedbc 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java @@ -219,9 +219,9 @@ public class NpmPackage { } loadSubFolders(res, dir.getAbsolutePath(), f); } else { - NpmPackageFolder folder = res.new NpmPackageFolder("package/$root"); + NpmPackageFolder folder = res.new NpmPackageFolder(Utilities.path("package", "$root")); folder.folder = dir; - res.folders.put("package/$root", folder); + res.folders.put(Utilities.path("package", "$root"), folder); } } } From 3a1d621f653f43e3da722e69df6683a62ee2732e Mon Sep 17 00:00:00 2001 From: markiantorno Date: Mon, 24 Feb 2020 15:30:34 -0500 Subject: [PATCH 06/10] reorg package structure --- org.hl7.fhir.validation.cli/pom.xml | 2 +- .../hl7/fhir/{r5 => }/validation/BaseValidator.java | 2 +- .../fhir/{r5 => }/validation/NativeHostServices.java | 2 +- .../fhir/{r5 => }/validation/ValidationEngine.java | 4 ++-- .../org/hl7/fhir/{r5 => }/validation/Validator.java | 10 ++-------- .../org/hl7/fhir/{r5 => }/validation/VersionUtil.java | 2 +- .../{r5 => }/validation/XVerExtensionManager.java | 3 +-- .../hl7/fhir/{r5 => }/validation/XmlValidator.java | 2 +- .../codesystem}/CodeSystemValidator.java | 3 ++- .../instance}/EnableWhenEvaluator.java | 4 ++-- .../instance}/InstanceValidator.java | 11 +++++------ .../instance}/InstanceValidatorFactory.java | 2 +- .../instance}/utils/ChildIterator.java | 4 ++-- .../instance}/utils/ElementInfo.java | 2 +- .../instance}/utils/EntrySummary.java | 3 +-- .../instance}/utils/IndexedElement.java | 2 +- .../instance}/utils/ResolvedReference.java | 4 ++-- .../instance}/utils/ResourceValidationTracker.java | 2 +- .../instance}/utils/ValidatorHostContext.java | 2 +- .../profile}/ProfileValidator.java | 3 ++- .../fhir/validation/tests/CDAValidationTestCase.java | 3 +-- .../validation/tests/NativeHostServiceTester.java | 4 +--- .../fhir/validation/tests/ProfileComparisonTests.java | 6 +----- .../fhir/validation/tests/TransformationTests.java | 2 +- .../fhir/validation/tests/ValidationEngineTests.java | 4 +--- .../fhir/validation/tests/ValidationTestSuite.java | 4 ++-- 26 files changed, 38 insertions(+), 54 deletions(-) rename org.hl7.fhir.validation/src/main/java/org/hl7/fhir/{r5 => }/validation/BaseValidator.java (99%) rename org.hl7.fhir.validation/src/main/java/org/hl7/fhir/{r5 => }/validation/NativeHostServices.java (99%) rename org.hl7.fhir.validation/src/main/java/org/hl7/fhir/{r5 => }/validation/ValidationEngine.java (99%) rename org.hl7.fhir.validation/src/main/java/org/hl7/fhir/{r5 => }/validation/Validator.java (99%) rename org.hl7.fhir.validation/src/main/java/org/hl7/fhir/{r5 => }/validation/VersionUtil.java (98%) rename org.hl7.fhir.validation/src/main/java/org/hl7/fhir/{r5 => }/validation/XVerExtensionManager.java (98%) rename org.hl7.fhir.validation/src/main/java/org/hl7/fhir/{r5 => }/validation/XmlValidator.java (99%) rename org.hl7.fhir.validation/src/main/java/org/hl7/fhir/{r5/validation => validation/codesystem}/CodeSystemValidator.java (95%) rename org.hl7.fhir.validation/src/main/java/org/hl7/fhir/{r5/validation => validation/instance}/EnableWhenEvaluator.java (99%) rename org.hl7.fhir.validation/src/main/java/org/hl7/fhir/{r5/validation/instancevalidator => validation/instance}/InstanceValidator.java (99%) rename org.hl7.fhir.validation/src/main/java/org/hl7/fhir/{r5/validation/instancevalidator => validation/instance}/InstanceValidatorFactory.java (95%) rename org.hl7.fhir.validation/src/main/java/org/hl7/fhir/{r5/validation/instancevalidator => validation/instance}/utils/ChildIterator.java (95%) rename org.hl7.fhir.validation/src/main/java/org/hl7/fhir/{r5/validation/instancevalidator => validation/instance}/utils/ElementInfo.java (97%) rename org.hl7.fhir.validation/src/main/java/org/hl7/fhir/{r5/validation/instancevalidator => validation/instance}/utils/EntrySummary.java (87%) rename org.hl7.fhir.validation/src/main/java/org/hl7/fhir/{r5/validation/instancevalidator => validation/instance}/utils/IndexedElement.java (93%) rename org.hl7.fhir.validation/src/main/java/org/hl7/fhir/{r5/validation/instancevalidator => validation/instance}/utils/ResolvedReference.java (91%) rename org.hl7.fhir.validation/src/main/java/org/hl7/fhir/{r5/validation/instancevalidator => validation/instance}/utils/ResourceValidationTracker.java (96%) rename org.hl7.fhir.validation/src/main/java/org/hl7/fhir/{r5/validation/instancevalidator => validation/instance}/utils/ValidatorHostContext.java (98%) rename org.hl7.fhir.validation/src/main/java/org/hl7/fhir/{r5/validation => validation/profile}/ProfileValidator.java (98%) diff --git a/org.hl7.fhir.validation.cli/pom.xml b/org.hl7.fhir.validation.cli/pom.xml index c1d18a95e..9846469f8 100644 --- a/org.hl7.fhir.validation.cli/pom.xml +++ b/org.hl7.fhir.validation.cli/pom.xml @@ -88,7 +88,7 @@ true - org.hl7.fhir.r5.validation.Validator + org.hl7.fhir.validation.Validator diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/BaseValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/BaseValidator.java similarity index 99% rename from org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/BaseValidator.java rename to org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/BaseValidator.java index 81735d662..6327a9e4f 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/BaseValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/BaseValidator.java @@ -1,4 +1,4 @@ -package org.hl7.fhir.r5.validation; +package org.hl7.fhir.validation; /*- * #%L diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/NativeHostServices.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/NativeHostServices.java similarity index 99% rename from org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/NativeHostServices.java rename to org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/NativeHostServices.java index 1570889b3..9cfecbbf3 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/NativeHostServices.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/NativeHostServices.java @@ -1,4 +1,4 @@ -package org.hl7.fhir.r5.validation; +package org.hl7.fhir.validation; /*- * #%L diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/ValidationEngine.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java similarity index 99% rename from org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/ValidationEngine.java rename to org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java index 411244049..7c38815a1 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/ValidationEngine.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java @@ -1,4 +1,4 @@ -package org.hl7.fhir.r5.validation; +package org.hl7.fhir.validation; import org.apache.commons.io.IOUtils; import org.hl7.fhir.convertors.*; @@ -22,7 +22,7 @@ import org.hl7.fhir.r5.terminologies.ConceptMapEngine; import org.hl7.fhir.r5.utils.*; import org.hl7.fhir.r5.utils.IResourceValidator.*; import org.hl7.fhir.r5.utils.StructureMapUtilities.ITransformerServices; -import org.hl7.fhir.r5.validation.instancevalidator.InstanceValidator; +import org.hl7.fhir.validation.instance.InstanceValidator; import org.hl7.fhir.utilities.IniFile; import org.hl7.fhir.utilities.TextFile; import org.hl7.fhir.utilities.Utilities; diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/Validator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/Validator.java similarity index 99% rename from org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/Validator.java rename to org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/Validator.java index 9b7bce8d2..3b0913127 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/Validator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/Validator.java @@ -1,4 +1,4 @@ -package org.hl7.fhir.r5.validation; +package org.hl7.fhir.validation; /*- * #%L @@ -49,13 +49,8 @@ POSSIBILITY OF SUCH DAMAGE. */ import java.awt.Desktop; -import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.URL; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -85,14 +80,13 @@ import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.model.StructureDefinition; import org.hl7.fhir.r5.utils.KeyGenerator; import org.hl7.fhir.r5.utils.ToolingExtensions; -import org.hl7.fhir.r5.validation.ValidationEngine.ScanOutputItem; +import org.hl7.fhir.validation.ValidationEngine.ScanOutputItem; import org.hl7.fhir.utilities.TextFile; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.VersionUtilities; import org.hl7.fhir.utilities.cache.PackageCacheManager; import org.hl7.fhir.utilities.cache.ToolsVersion; import org.hl7.fhir.utilities.validation.ValidationMessage; -import org.hl7.fhir.utilities.xhtml.XhtmlComposer; /** * A executable class that will validate one or more FHIR resources against diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/VersionUtil.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/VersionUtil.java similarity index 98% rename from org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/VersionUtil.java rename to org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/VersionUtil.java index b4ad10a4c..ea94e1f8e 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/VersionUtil.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/VersionUtil.java @@ -1,4 +1,4 @@ -package org.hl7.fhir.r5.validation; +package org.hl7.fhir.validation; /* * #%L diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/XVerExtensionManager.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/XVerExtensionManager.java similarity index 98% rename from org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/XVerExtensionManager.java rename to org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/XVerExtensionManager.java index 10f67a116..ef658c4de 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/XVerExtensionManager.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/XVerExtensionManager.java @@ -1,4 +1,4 @@ -package org.hl7.fhir.r5.validation; +package org.hl7.fhir.validation; import java.io.IOException; import java.util.Date; @@ -16,7 +16,6 @@ import org.hl7.fhir.r5.model.StructureDefinition.ExtensionContextType; import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind; import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule; import org.hl7.fhir.r5.model.UriType; -import org.hl7.fhir.r5.validation.XVerExtensionManager.XVerExtensionStatus; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.VersionUtilities; import org.hl7.fhir.utilities.json.JsonTrackingParser; diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/XmlValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/XmlValidator.java similarity index 99% rename from org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/XmlValidator.java rename to org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/XmlValidator.java index 5f87599b1..bd5619e2b 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/XmlValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/XmlValidator.java @@ -1,4 +1,4 @@ -package org.hl7.fhir.r5.validation; +package org.hl7.fhir.validation; /*- * #%L diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/CodeSystemValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/codesystem/CodeSystemValidator.java similarity index 95% rename from org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/CodeSystemValidator.java rename to org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/codesystem/CodeSystemValidator.java index 28adbb0be..492a113a7 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/CodeSystemValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/codesystem/CodeSystemValidator.java @@ -1,4 +1,4 @@ -package org.hl7.fhir.r5.validation; +package org.hl7.fhir.validation.codesystem; /*- * #%L @@ -30,6 +30,7 @@ import org.hl7.fhir.r5.model.CodeSystem; import org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent; import org.hl7.fhir.utilities.validation.ValidationMessage; import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType; +import org.hl7.fhir.validation.BaseValidator; public class CodeSystemValidator extends BaseValidator { diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/EnableWhenEvaluator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/EnableWhenEvaluator.java similarity index 99% rename from org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/EnableWhenEvaluator.java rename to org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/EnableWhenEvaluator.java index 468b09647..03ec83379 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/EnableWhenEvaluator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/EnableWhenEvaluator.java @@ -1,4 +1,4 @@ -package org.hl7.fhir.r5.validation; +package org.hl7.fhir.validation.instance; /*- * #%L @@ -28,7 +28,7 @@ import org.hl7.fhir.r5.elementmodel.Element; import org.hl7.fhir.r5.model.*; import org.hl7.fhir.r5.model.Questionnaire.*; import org.hl7.fhir.r5.utils.FHIRPathEngine; -import org.hl7.fhir.r5.validation.instancevalidator.utils.ValidatorHostContext; +import org.hl7.fhir.validation.instance.utils.ValidatorHostContext; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/InstanceValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java similarity index 99% rename from org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/InstanceValidator.java rename to org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java index 2e5f1e30e..93b597899 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/InstanceValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java @@ -1,4 +1,4 @@ -package org.hl7.fhir.r5.validation.instancevalidator; +package org.hl7.fhir.validation.instance; /*- * #%L @@ -126,11 +126,9 @@ import org.hl7.fhir.r5.utils.FHIRPathEngine; import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext; import org.hl7.fhir.r5.utils.IResourceValidator; import org.hl7.fhir.r5.utils.ToolingExtensions; -import org.hl7.fhir.r5.validation.BaseValidator; -import org.hl7.fhir.r5.validation.EnableWhenEvaluator; -import org.hl7.fhir.r5.validation.EnableWhenEvaluator.QStack; -import org.hl7.fhir.r5.validation.XVerExtensionManager; -import org.hl7.fhir.r5.validation.instancevalidator.utils.*; +import org.hl7.fhir.validation.BaseValidator; +import org.hl7.fhir.validation.instance.EnableWhenEvaluator.QStack; +import org.hl7.fhir.validation.XVerExtensionManager; import org.hl7.fhir.utilities.CommaSeparatedStringBuilder; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.Utilities.DecimalStatus; @@ -142,6 +140,7 @@ import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType; import org.hl7.fhir.utilities.validation.ValidationMessage.Source; import org.hl7.fhir.utilities.xhtml.NodeType; import org.hl7.fhir.utilities.xhtml.XhtmlNode; +import org.hl7.fhir.validation.instance.utils.*; import org.w3c.dom.Document; import com.google.gson.Gson; diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/InstanceValidatorFactory.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidatorFactory.java similarity index 95% rename from org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/InstanceValidatorFactory.java rename to org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidatorFactory.java index 90ef501a3..547bf02af 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/InstanceValidatorFactory.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidatorFactory.java @@ -1,4 +1,4 @@ -package org.hl7.fhir.r5.validation.instancevalidator; +package org.hl7.fhir.validation.instance; import org.hl7.fhir.exceptions.FHIRException; diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/utils/ChildIterator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/utils/ChildIterator.java similarity index 95% rename from org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/utils/ChildIterator.java rename to org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/utils/ChildIterator.java index 09e35d78c..5dd0f832f 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/utils/ChildIterator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/utils/ChildIterator.java @@ -1,7 +1,7 @@ -package org.hl7.fhir.r5.validation.instancevalidator.utils; +package org.hl7.fhir.validation.instance.utils; import org.hl7.fhir.r5.elementmodel.Element; -import org.hl7.fhir.r5.validation.instancevalidator.InstanceValidator; +import org.hl7.fhir.validation.instance.InstanceValidator; import org.hl7.fhir.utilities.Utilities; public class ChildIterator { diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/utils/ElementInfo.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/utils/ElementInfo.java similarity index 97% rename from org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/utils/ElementInfo.java rename to org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/utils/ElementInfo.java index b3f7b69b6..15a5f2ce0 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/utils/ElementInfo.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/utils/ElementInfo.java @@ -1,4 +1,4 @@ -package org.hl7.fhir.r5.validation.instancevalidator.utils; +package org.hl7.fhir.validation.instance.utils; import org.hl7.fhir.r5.elementmodel.Element; import org.hl7.fhir.r5.model.ElementDefinition; diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/utils/EntrySummary.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/utils/EntrySummary.java similarity index 87% rename from org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/utils/EntrySummary.java rename to org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/utils/EntrySummary.java index 8457ead30..05bb76098 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/utils/EntrySummary.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/utils/EntrySummary.java @@ -1,7 +1,6 @@ -package org.hl7.fhir.r5.validation.instancevalidator.utils; +package org.hl7.fhir.validation.instance.utils; import org.hl7.fhir.r5.elementmodel.Element; -import org.hl7.fhir.r5.validation.instancevalidator.InstanceValidator; import java.util.ArrayList; import java.util.List; diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/utils/IndexedElement.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/utils/IndexedElement.java similarity index 93% rename from org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/utils/IndexedElement.java rename to org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/utils/IndexedElement.java index feeb9d505..d103c3ce7 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/utils/IndexedElement.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/utils/IndexedElement.java @@ -1,4 +1,4 @@ -package org.hl7.fhir.r5.validation.instancevalidator.utils; +package org.hl7.fhir.validation.instance.utils; import org.hl7.fhir.r5.elementmodel.Element; diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/utils/ResolvedReference.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/utils/ResolvedReference.java similarity index 91% rename from org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/utils/ResolvedReference.java rename to org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/utils/ResolvedReference.java index 7c619cd09..4066e1d2a 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/utils/ResolvedReference.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/utils/ResolvedReference.java @@ -1,8 +1,8 @@ -package org.hl7.fhir.r5.validation.instancevalidator.utils; +package org.hl7.fhir.validation.instance.utils; import org.hl7.fhir.r5.elementmodel.Element; import org.hl7.fhir.r5.model.StructureDefinition; -import org.hl7.fhir.r5.validation.instancevalidator.InstanceValidator; +import org.hl7.fhir.validation.instance.InstanceValidator; public class ResolvedReference { diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/utils/ResourceValidationTracker.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/utils/ResourceValidationTracker.java similarity index 96% rename from org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/utils/ResourceValidationTracker.java rename to org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/utils/ResourceValidationTracker.java index 92962c578..7d48a1c9b 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/utils/ResourceValidationTracker.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/utils/ResourceValidationTracker.java @@ -1,4 +1,4 @@ -package org.hl7.fhir.r5.validation.instancevalidator.utils; +package org.hl7.fhir.validation.instance.utils; import org.hl7.fhir.r5.model.StructureDefinition; import org.hl7.fhir.utilities.validation.ValidationMessage; diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/utils/ValidatorHostContext.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/utils/ValidatorHostContext.java similarity index 98% rename from org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/utils/ValidatorHostContext.java rename to org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/utils/ValidatorHostContext.java index 5eb22397c..c823fd570 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/instancevalidator/utils/ValidatorHostContext.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/utils/ValidatorHostContext.java @@ -1,4 +1,4 @@ -package org.hl7.fhir.r5.validation.instancevalidator.utils; +package org.hl7.fhir.validation.instance.utils; import org.hl7.fhir.r5.elementmodel.Element; import org.hl7.fhir.r5.model.StructureDefinition; diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/ProfileValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/profile/ProfileValidator.java similarity index 98% rename from org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/ProfileValidator.java rename to org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/profile/ProfileValidator.java index 53ae98d3d..e1fb8a787 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/ProfileValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/profile/ProfileValidator.java @@ -1,4 +1,4 @@ -package org.hl7.fhir.r5.validation; +package org.hl7.fhir.validation.profile; /*- * #%L @@ -34,6 +34,7 @@ import org.hl7.fhir.r5.utils.FHIRPathEngine; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.validation.ValidationMessage; import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType; +import org.hl7.fhir.validation.BaseValidator; public class ProfileValidator extends BaseValidator { diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/CDAValidationTestCase.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/CDAValidationTestCase.java index eabbe5e92..c1735254a 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/CDAValidationTestCase.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/CDAValidationTestCase.java @@ -2,8 +2,7 @@ package org.hl7.fhir.validation.tests; import org.hl7.fhir.r4.context.SimpleWorkerContext; import org.hl7.fhir.r5.test.utils.TestingUtilities; -import org.hl7.fhir.r5.validation.Validator; -import org.hl7.fhir.validation.tests.utilities.TestUtilities; +import org.hl7.fhir.validation.Validator; import org.junit.Test; public class CDAValidationTestCase { diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/NativeHostServiceTester.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/NativeHostServiceTester.java index ba3403355..539e1d7ce 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/NativeHostServiceTester.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/NativeHostServiceTester.java @@ -2,9 +2,7 @@ package org.hl7.fhir.validation.tests; import org.hl7.fhir.r5.elementmodel.Manager.FhirFormat; import org.hl7.fhir.r5.test.utils.TestingUtilities; -import org.hl7.fhir.r5.validation.NativeHostServices; -import org.hl7.fhir.utilities.TextFile; -import org.hl7.fhir.validation.tests.utilities.TestUtilities; +import org.hl7.fhir.validation.NativeHostServices; import org.junit.Test; public class NativeHostServiceTester { diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ProfileComparisonTests.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ProfileComparisonTests.java index 3b4f475e3..c2607a462 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ProfileComparisonTests.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ProfileComparisonTests.java @@ -1,19 +1,15 @@ package org.hl7.fhir.validation.tests; -import java.awt.Desktop; import java.io.File; import java.util.UUID; import org.hl7.fhir.r5.conformance.ProfileComparer; import org.hl7.fhir.r5.model.FhirPublication; -import org.hl7.fhir.r5.model.OperationOutcome; import org.hl7.fhir.r5.model.StructureDefinition; import org.hl7.fhir.r5.utils.KeyGenerator; -import org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent; import org.hl7.fhir.r5.test.utils.TestingUtilities; -import org.hl7.fhir.r5.validation.ValidationEngine; +import org.hl7.fhir.validation.ValidationEngine; import org.hl7.fhir.validation.tests.utilities.TestUtilities; -import org.junit.Assert; import org.junit.Test; public class ProfileComparisonTests { diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/TransformationTests.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/TransformationTests.java index 0b36ed297..e695dd8b5 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/TransformationTests.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/TransformationTests.java @@ -3,7 +3,7 @@ package org.hl7.fhir.validation.tests; import java.io.File; import org.hl7.fhir.r4.test.utils.TestingUtilities; -import org.hl7.fhir.r5.validation.Validator; +import org.hl7.fhir.validation.Validator; import org.hl7.fhir.utilities.Utilities; import org.junit.Test; diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationEngineTests.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationEngineTests.java index 54b270906..4c662240b 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationEngineTests.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationEngineTests.java @@ -1,6 +1,5 @@ package org.hl7.fhir.validation.tests; -import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -10,8 +9,7 @@ import org.hl7.fhir.r5.model.OperationOutcome; import org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity; import org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent; import org.hl7.fhir.r5.test.utils.TestingUtilities; -import org.hl7.fhir.r5.validation.ValidationEngine; -import org.hl7.fhir.utilities.Utilities; +import org.hl7.fhir.validation.ValidationEngine; import org.hl7.fhir.validation.tests.utilities.TestUtilities; import org.junit.Assert; import org.junit.Test; diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTestSuite.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTestSuite.java index 7b694f755..331a37715 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTestSuite.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTestSuite.java @@ -26,8 +26,8 @@ import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext; import org.hl7.fhir.r5.utils.IResourceValidator; import org.hl7.fhir.r5.utils.IResourceValidator.IValidatorResourceFetcher; import org.hl7.fhir.r5.utils.IResourceValidator.ReferenceValidationPolicy; -import org.hl7.fhir.r5.validation.instancevalidator.InstanceValidator; -import org.hl7.fhir.r5.validation.ValidationEngine; +import org.hl7.fhir.validation.instance.InstanceValidator; +import org.hl7.fhir.validation.ValidationEngine; import org.hl7.fhir.utilities.TextFile; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.VersionUtilities; From 52246a8ce5f9574dcd77885bd36c3a2e950af7bd Mon Sep 17 00:00:00 2001 From: markiantorno Date: Mon, 24 Feb 2020 15:38:18 -0500 Subject: [PATCH 07/10] cleanup --- .../instance/EnableWhenEvaluator.java | 149 +++++++++--------- .../validation/profile/ProfileValidator.java | 1 - 2 files changed, 71 insertions(+), 79 deletions(-) diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/EnableWhenEvaluator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/EnableWhenEvaluator.java index 03ec83379..77e5495da 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/EnableWhenEvaluator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/EnableWhenEvaluator.java @@ -9,9 +9,9 @@ package org.hl7.fhir.validation.instance; * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -35,7 +35,6 @@ import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; /** * Evaluates Questionnaire.item.enableWhen against a QuestionnaireResponse. * Ignores possible modifierExtensions and extensions. - * */ public class EnableWhenEvaluator { public static final String LINKID_ELEMENT = "linkId"; @@ -46,26 +45,29 @@ public class EnableWhenEvaluator { public static class QuestionnaireAnswerPair { private QuestionnaireItemComponent q; private Element a; - + public QuestionnaireAnswerPair(QuestionnaireItemComponent q, Element a) { super(); this.q = q; this.a = a; } + public QuestionnaireItemComponent getQ() { return q; } + public Element getA() { return a; } - + } + public static class QStack extends ArrayList { private static final long serialVersionUID = 1L; private Questionnaire q; private Element a; - + public QStack(Questionnaire q, Element a) { super(); this.q = q; @@ -97,40 +99,30 @@ public class EnableWhenEvaluator { /** * Evaluation result of enableWhen condition - * - * @param enabled - * Evaluation result - * @param linkId - * LinkId of the questionnaire item - * @param enableWhenCondition - * Evaluated enableWhen condition - * @param responseItem - * item in QuestionnaireResponse + * + * @param enabled Evaluation result + * @param enableWhenCondition Evaluated enableWhen condition */ public EnableWhenResult(boolean enabled, QuestionnaireItemEnableWhenComponent enableWhenCondition) { - this.enabled = enabled; - this.enableWhenCondition = enableWhenCondition; + this.enabled = enabled; + this.enableWhenCondition = enableWhenCondition; } public boolean isEnabled() { - return enabled; + return enabled; } public QuestionnaireItemEnableWhenComponent getEnableWhenCondition() { - return enableWhenCondition; + return enableWhenCondition; } -} + } + /** * the stack contains a set of QR items that represent the tree of the QR being validated, each tagged with the definition of the item from the Q for the QR being validated - * - * the itembeing validated is in the context of the stack. For root items, the stack is empty. - * + *

+ * the itembeing validated is in the context of the stack. For root items, the stack is empty. + *

* The context Questionnaire and QuestionnaireResponse are always available - * - * @param questionnaireItem - * @param questionnaireResponse - * @param qstack - * @return */ public boolean isQuestionEnabled(ValidatorHostContext hostContext, QuestionnaireItemComponent qitem, QStack qstack, FHIRPathEngine engine) { if (hasExpressionExtension(qitem)) { @@ -138,22 +130,22 @@ public class EnableWhenEvaluator { ExpressionNode node = engine.parse(expr); return engine.evaluateToBoolean(hostContext, qstack.a, qstack.a, qstack.a, node); } - + if (!qitem.hasEnableWhen()) { return true; } - + List evaluationResults = qitem.getEnableWhen() - .stream() - .map(enableCondition -> evaluateCondition(enableCondition, qitem, qstack)) - .collect(Collectors.toList()); + .stream() + .map(enableCondition -> evaluateCondition(enableCondition, qitem, qstack)) + .collect(Collectors.toList()); return checkConditionResults(evaluationResults, qitem); } private boolean hasExpressionExtension(QuestionnaireItemComponent qitem) { return qitem.hasExtension("http://phr.kanta.fi/StructureDefinition/fiphr-ext-questionnaire-enablewhen") || // finnish extension - qitem.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-enableWhenExpression"); // sdc extension + qitem.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-enableWhenExpression"); // sdc extension } private String getExpression(QuestionnaireItemComponent qitem) { @@ -164,17 +156,18 @@ public class EnableWhenEvaluator { if ("text/fhirpath".equals(expr.getLanguage())) { return expr.getExpression(); } else { - throw new FHIRException("Unsupported language '"+expr.getLanguage()+"' for enableWhen extension http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-enableWhenExpression"); + throw new FHIRException("Unsupported language '" + expr.getLanguage() + "' for enableWhen extension http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-enableWhenExpression"); } } throw new Error("How did you get here?"); } - public boolean checkConditionResults(List evaluationResults, QuestionnaireItemComponent questionnaireItem) { - if ((questionnaireItem.hasEnableBehavior() && questionnaireItem.getEnableBehavior() == EnableWhenBehavior.ANY) || evaluationResults.size() == 1){ + public boolean checkConditionResults(List evaluationResults, QuestionnaireItemComponent questionnaireItem) { + if ((questionnaireItem.hasEnableBehavior() && questionnaireItem.getEnableBehavior() == EnableWhenBehavior.ANY) || evaluationResults.size() == 1) { return evaluationResults.stream().anyMatch(EnableWhenResult::isEnabled); - } if (questionnaireItem.hasEnableBehavior() && questionnaireItem.getEnableBehavior() == EnableWhenBehavior.ALL){ + } + if (questionnaireItem.hasEnableBehavior() && questionnaireItem.getEnableBehavior() == EnableWhenBehavior.ALL) { return evaluationResults.stream().allMatch(EnableWhenResult::isEnabled); } //TODO: Throw exception? enableBehavior is mandatory when there are multiple conditions @@ -183,18 +176,18 @@ public class EnableWhenEvaluator { protected EnableWhenResult evaluateCondition(QuestionnaireItemEnableWhenComponent enableCondition, QuestionnaireItemComponent qitem, QStack qstack) { - List answerItems = findQuestionAnswers(qstack, qitem, enableCondition); + List answerItems = findQuestionAnswers(qstack, qitem, enableCondition); QuestionnaireItemOperator operator = enableCondition.getOperator(); - if (operator == QuestionnaireItemOperator.EXISTS){ + if (operator == QuestionnaireItemOperator.EXISTS) { DataType answer = enableCondition.getAnswer(); - if (!(answer instanceof BooleanType)){ - throw new UnprocessableEntityException("Exists-operator requires answerBoolean"); + if (!(answer instanceof BooleanType)) { + throw new UnprocessableEntityException("Exists-operator requires answerBoolean"); } - return new EnableWhenResult(((BooleanType)answer).booleanValue() != answerItems.isEmpty(), enableCondition); - } + return new EnableWhenResult(((BooleanType) answer).booleanValue() != answerItems.isEmpty(), enableCondition); + } boolean result = answerItems - .stream() - .anyMatch(answer -> evaluateAnswer(answer, enableCondition.getAnswer(), enableCondition.getOperator())); + .stream() + .anyMatch(answer -> evaluateAnswer(answer, enableCondition.getAnswer(), enableCondition.getOperator())); return new EnableWhenResult(result, enableCondition); } @@ -235,71 +228,71 @@ public class EnableWhenEvaluator { } if (!actualAnswer.getClass().equals(expectedAnswer.getClass())) { throw new UnprocessableEntityException("Expected answer and actual answer have incompatible types"); - } + } if (expectedAnswer instanceof Coding) { - return compareCodingAnswer((Coding)expectedAnswer, (Coding)actualAnswer, questionnaireItemOperator); + return compareCodingAnswer((Coding) expectedAnswer, (Coding) actualAnswer, questionnaireItemOperator); } else if ((expectedAnswer instanceof PrimitiveType)) { - return comparePrimitiveAnswer((PrimitiveType)actualAnswer, (PrimitiveType)expectedAnswer, questionnaireItemOperator); + return comparePrimitiveAnswer((PrimitiveType) actualAnswer, (PrimitiveType) expectedAnswer, questionnaireItemOperator); } else if (expectedAnswer instanceof Quantity) { - return compareQuantityAnswer((Quantity)actualAnswer, (Quantity)expectedAnswer, questionnaireItemOperator); + return compareQuantityAnswer((Quantity) actualAnswer, (Quantity) expectedAnswer, questionnaireItemOperator); } // TODO: Attachment, reference? throw new UnprocessableEntityException("Unimplemented answer type: " + expectedAnswer.getClass()); } - private boolean compareQuantityAnswer(Quantity actualAnswer, Quantity expectedAnswer, QuestionnaireItemOperator questionnaireItemOperator) { + private boolean compareQuantityAnswer(Quantity actualAnswer, Quantity expectedAnswer, QuestionnaireItemOperator questionnaireItemOperator) { return compareComparable(actualAnswer.getValue(), expectedAnswer.getValue(), questionnaireItemOperator); } - private boolean comparePrimitiveAnswer(PrimitiveType actualAnswer, PrimitiveType expectedAnswer, QuestionnaireItemOperator questionnaireItemOperator) { - if (actualAnswer.getValue() instanceof Comparable){ - return compareComparable((Comparable)actualAnswer.getValue(), (Comparable) expectedAnswer.getValue(), questionnaireItemOperator); - } else if (questionnaireItemOperator == QuestionnaireItemOperator.EQUAL){ + private boolean comparePrimitiveAnswer(PrimitiveType actualAnswer, PrimitiveType expectedAnswer, QuestionnaireItemOperator questionnaireItemOperator) { + if (actualAnswer.getValue() instanceof Comparable) { + return compareComparable((Comparable) actualAnswer.getValue(), (Comparable) expectedAnswer.getValue(), questionnaireItemOperator); + } else if (questionnaireItemOperator == QuestionnaireItemOperator.EQUAL) { return actualAnswer.equalsShallow(expectedAnswer); - } else if (questionnaireItemOperator == QuestionnaireItemOperator.NOT_EQUAL){ + } else if (questionnaireItemOperator == QuestionnaireItemOperator.NOT_EQUAL) { return !actualAnswer.equalsShallow(expectedAnswer); } throw new UnprocessableEntityException("Bad operator for PrimitiveType comparison"); } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) private boolean compareComparable(Comparable actual, Comparable expected, - QuestionnaireItemOperator questionnaireItemOperator) { + QuestionnaireItemOperator questionnaireItemOperator) { int result = actual.compareTo(expected); - if (questionnaireItemOperator == QuestionnaireItemOperator.EQUAL){ + if (questionnaireItemOperator == QuestionnaireItemOperator.EQUAL) { return result == 0; - } else if (questionnaireItemOperator == QuestionnaireItemOperator.NOT_EQUAL){ + } else if (questionnaireItemOperator == QuestionnaireItemOperator.NOT_EQUAL) { return result != 0; - } else if (questionnaireItemOperator == QuestionnaireItemOperator.GREATER_OR_EQUAL){ + } else if (questionnaireItemOperator == QuestionnaireItemOperator.GREATER_OR_EQUAL) { return result >= 0; - } else if (questionnaireItemOperator == QuestionnaireItemOperator.LESS_OR_EQUAL){ + } else if (questionnaireItemOperator == QuestionnaireItemOperator.LESS_OR_EQUAL) { return result <= 0; - } else if (questionnaireItemOperator == QuestionnaireItemOperator.LESS_THAN){ + } else if (questionnaireItemOperator == QuestionnaireItemOperator.LESS_THAN) { return result < 0; - } else if (questionnaireItemOperator == QuestionnaireItemOperator.GREATER_THAN){ + } else if (questionnaireItemOperator == QuestionnaireItemOperator.GREATER_THAN) { return result > 0; } - throw new UnprocessableEntityException("Bad operator for PrimitiveType comparison: "+questionnaireItemOperator.toCode()); + throw new UnprocessableEntityException("Bad operator for PrimitiveType comparison: " + questionnaireItemOperator.toCode()); } /** * Recursively look for answers to questions with the given link id, working upwards given the context - * + *

* For discussion about this, see https://chat.fhir.org/#narrow/stream/179255-questionnaire/topic/enable-when - * - - given sourceQ - question that contains the enableWhen reference and targetQ - question that the enableWhen references in the Q and also sourceA - answer for sourceQ and targetA - answer for targetQ in the QR - - work up from sourceQ until you find the Q group that also contains targetQ - this is groupQ - - work up from sourceA until you find the QR group that matches groupQ - this is groupA - - any targetA in groupA are input for the enableWhen decision + *

+ * - given sourceQ - question that contains the enableWhen reference and targetQ - question that the enableWhen references in the Q and also sourceA - answer for sourceQ and targetA - answer for targetQ in the QR + * - work up from sourceQ until you find the Q group that also contains targetQ - this is groupQ + * - work up from sourceA until you find the QR group that matches groupQ - this is groupA + * - any targetA in groupA are input for the enableWhen decision */ private List findQuestionAnswers(QStack qstack, QuestionnaireItemComponent sourceQ, QuestionnaireItemEnableWhenComponent ew) { QuestionnaireItemComponent targetQ = qstack.getQ().getQuestion(ew.getQuestion()); - if (targetQ != null) { + if (targetQ != null) { QuestionnaireItemComponent groupQ = qstack.getQ().getCommonGroup(sourceQ, targetQ); if (groupQ == null) { // root is Q itself return findOnItem(qstack.getA(), ew.getQuestion()); @@ -341,16 +334,16 @@ public class EnableWhenEvaluator { private List extractAnswer(Element item) { return item.getChildrenByName(ANSWER_ELEMENT) - .stream() - .flatMap(c -> c.getChildren().stream()) - .collect(Collectors.toList()); + .stream() + .flatMap(c -> c.getChildren().stream()) + .collect(Collectors.toList()); } private boolean compareCodingAnswer(Coding expectedAnswer, Coding actualAnswer, QuestionnaireItemOperator questionnaireItemOperator) { boolean result = compareSystems(expectedAnswer, actualAnswer) && compareCodes(expectedAnswer, actualAnswer); - if (questionnaireItemOperator == QuestionnaireItemOperator.EQUAL){ + if (questionnaireItemOperator == QuestionnaireItemOperator.EQUAL) { return result == true; - } else if (questionnaireItemOperator == QuestionnaireItemOperator.NOT_EQUAL){ + } else if (questionnaireItemOperator == QuestionnaireItemOperator.NOT_EQUAL) { return result == false; } throw new UnprocessableEntityException("Bad operator for Coding comparison"); @@ -378,7 +371,7 @@ public class EnableWhenEvaluator { private boolean hasLinkId(Element item, String linkId) { Element linkIdChild = item.getNamedChild(LINKID_ELEMENT); - if (linkIdChild != null && linkIdChild.getValue().equals(linkId)){ + if (linkIdChild != null && linkIdChild.getValue().equals(linkId)) { return true; } return false; diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/profile/ProfileValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/profile/ProfileValidator.java index e1fb8a787..054adb258 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/profile/ProfileValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/profile/ProfileValidator.java @@ -20,7 +20,6 @@ package org.hl7.fhir.validation.profile; * #L% */ - import java.util.ArrayList; import java.util.Hashtable; import java.util.List; From 2edc09d297d35113f5b7e1e383b029f9210bc38b Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Tue, 25 Feb 2020 08:10:57 +1100 Subject: [PATCH 08/10] calculate URL when possible --- .../main/java/org/hl7/fhir/utilities/cache/PackageClient.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageClient.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageClient.java index 220a1bb40..df04013bb 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageClient.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageClient.java @@ -38,6 +38,9 @@ public class PackageClient { this.fhirVersion = fhirVersion; this.description = description; this.url = url; + if (url == null && id != null && version != null) { + url = Utilities.pathURL(address, id, version); + } this.canonical = canonical; } public String getId() { From 66b855c540890982cd5e5b333693310463ee9eec Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Tue, 25 Feb 2020 09:24:58 +1100 Subject: [PATCH 09/10] clean up validator --- .../fhir/validation/NativeHostServices.java | 2 +- .../hl7/fhir/validation/ValidationEngine.java | 1 - .../org/hl7/fhir/validation/XmlValidator.java | 228 ------------------ 3 files changed, 1 insertion(+), 230 deletions(-) delete mode 100644 org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/XmlValidator.java diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/NativeHostServices.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/NativeHostServices.java index 9cfecbbf3..43f06a752 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/NativeHostServices.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/NativeHostServices.java @@ -67,7 +67,7 @@ import com.google.gson.JsonObject; * This class allows you to host the java validator in another service, and use the services it has in a wider context. The way it works is - put the jar in your class path -- Find the class org.hl7.fhir.r5.validation.NativeHostServices or org.hl7.fhir.dstu3.validation.NativeHostServices +- Find the class org.hl7.fhir.validation.NativeHostServices - call init(path) where path refers to one of the definitions files from the main build (e.g. definitions.xml.zip) - required, do only once, do before anything else - call load(path) where path refers to the igpack.zip produced by the ig publisher (do this once for each IG you care about) - call connectToTxSvc(url) where the url is your terminology service of choice (can be http://tx.fhir.org/r4 or /r3) diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java index 7c38815a1..69b434d3a 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java @@ -1102,7 +1102,6 @@ public class ValidationEngine implements IValidatorResourceFetcher { } private void validateXmlSchema(String location, List messages) throws FileNotFoundException, IOException, SAXException { - XmlValidator xml = new XmlValidator(messages, loadSchemas(), loadTransforms()); messages.add(new ValidationMessage(Source.InstanceValidator, IssueType.INFORMATIONAL, location, "XML Schema Validation is not done yet", IssueSeverity.INFORMATION)); } diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/XmlValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/XmlValidator.java deleted file mode 100644 index bd5619e2b..000000000 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/XmlValidator.java +++ /dev/null @@ -1,228 +0,0 @@ -package org.hl7.fhir.validation; - -/*- - * #%L - * org.hl7.fhir.validation - * %% - * Copyright (C) 2014 - 2019 Health Level 7 - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ - - -import org.hl7.fhir.exceptions.FHIRException; -import org.hl7.fhir.utilities.*; -import org.hl7.fhir.utilities.Logger.LogMessageType; -import org.hl7.fhir.utilities.validation.ValidationMessage; -import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity; -import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType; -import org.hl7.fhir.utilities.validation.ValidationMessage.Source; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; -import org.w3c.dom.ls.LSInput; -import org.w3c.dom.ls.LSResourceResolver; -import org.xml.sax.ErrorHandler; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; - -import javax.xml.XMLConstants; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.stream.StreamSource; -import javax.xml.validation.Schema; -import javax.xml.validation.SchemaFactory; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class XmlValidator { - - private Schema schema; - private Map schemas; - private Map transforms; - private List errors; - private Logger logger; - - public XmlValidator(List errors, Map schemas, Map transforms) throws FileNotFoundException, IOException, SAXException { - this.errors = errors; - this.schemas = schemas; - this.transforms = transforms; - load(); - } - - public XmlValidator(List validationErrors, String srcDir, String xsltDir, String[] schemaNames) throws FileNotFoundException, IOException, SAXException { - loadTransforms(xsltDir); - loadSchemas(srcDir, schemaNames); - load(); - } - - private void load() throws SAXException { - int c = 0; - for (String s : schemas.keySet()) - if (s.endsWith(".xsd")) - c++; - StreamSource[] sources = new StreamSource[c]; - int i = 0; - for (String s : schemas.keySet()) { - if (s.endsWith(".xsd")) { - sources[i] = new StreamSource(new ByteArrayInputStream(schemas.get(s)), s); - i++; - } - } - SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - schemaFactory.setErrorHandler(new MyErrorHandler(errors, null)); - schemaFactory.setResourceResolver(new MyResourceResolver()); - schema = schemaFactory.newSchema(sources); - } - - private void loadTransforms(String xsltDir) throws FileNotFoundException, IOException { - Map res = new HashMap(); - for (String s : new File(xsltDir).list()) { - if (s.endsWith(".xslt")) - res.put(s, TextFile.fileToBytes(Utilities.path(xsltDir, s))); - } - this.transforms = res; - } - - private void loadSchemas(String dir, String[] names) throws FileNotFoundException, IOException { - Map res = new HashMap(); - for (String s : new File(dir).list()) { - if (s.endsWith(".sch")) - res.put(s, TextFile.fileToBytes(Utilities.path(dir, s))); - boolean ok = false; - for (String b : names) - ok = ok || b.equals(s); - if (ok) - res.put(s, TextFile.fileToBytes(Utilities.path(dir, s))); - } - this.schemas = res; - } - - public Element checkBySchema(String fileToCheck, boolean wantThrow) throws FileNotFoundException, SAXException, IOException, ParserConfigurationException, FHIRException { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setNamespaceAware(true); - factory.setValidating(false); - factory.setSchema(schema); - DocumentBuilder builder = factory.newDocumentBuilder(); - MyErrorHandler err = new MyErrorHandler(errors, fileToCheck); - builder.setErrorHandler(err); - CSFileInputStream f = new CSFileInputStream(new CSFile(fileToCheck)); - Document doc = builder.parse(f); - if (wantThrow && err.getErrors().size() > 0) - throw new FHIRException("File " + fileToCheck + " failed schema validation"); - return doc.getDocumentElement(); - } - - public void checkBySchematron(String filename, String sch, boolean wantThrow) throws IOException, ParserConfigurationException, SAXException, FileNotFoundException, FHIRException { - DocumentBuilderFactory factory; - DocumentBuilder builder; - Document doc; - byte[] out = null; - try { - out = XsltUtilities.saxonTransform(transforms, schemas.get(sch), transforms.get("iso_svrl_for_xslt2.xsl")); - out = XsltUtilities.saxonTransform(transforms, TextFile.fileToBytes(filename), out); - } catch (Throwable e) { - errors.add(new ValidationMessage(Source.InstanceValidator, IssueType.STRUCTURE, -1, -1, filename + ":" + sch, e.getMessage(), IssueSeverity.ERROR)); - if (wantThrow) - throw new FHIRException("Error validating " + filename + " with schematrons", e); - } - - factory = DocumentBuilderFactory.newInstance(); - factory.setNamespaceAware(true); - builder = factory.newDocumentBuilder(); - doc = builder.parse(new ByteArrayInputStream(out)); - NodeList nl = doc.getDocumentElement().getElementsByTagNameNS("http://purl.oclc.org/dsdl/svrl", "failed-assert"); - if (nl.getLength() > 0) { - logger.log("Schematron Validation Failed for " + filename, LogMessageType.Error); - for (int i = 0; i < nl.getLength(); i++) { - Element e = (Element) nl.item(i); - logger.log(" @" + e.getAttribute("location") + ": " + e.getTextContent(), LogMessageType.Error); - errors.add(new ValidationMessage(Source.InstanceValidator, IssueType.STRUCTURE, -1, -1, filename + ":" + e.getAttribute("location"), e.getTextContent(), IssueSeverity.ERROR)); - } - if (wantThrow) - throw new FHIRException("Schematron Validation Failed for " + filename); - } - } - - public class MyErrorHandler implements ErrorHandler { - - private List errors = new ArrayList(); - private List list; - private String path; - - public MyErrorHandler(List list, String path) { - this.list = list; - this.path = path; - } - - @Override - public void error(SAXParseException arg0) throws SAXException { - if (list != null) - list.add(new ValidationMessage(Source.InstanceValidator, IssueType.STRUCTURE, arg0.getLineNumber(), arg0.getColumnNumber(), path == null ? arg0.getSystemId() : path, arg0.getMessage(), IssueSeverity.ERROR)); - if (logger != null) - logger.log("error: " + arg0.toString(), LogMessageType.Error); - errors.add(arg0.toString()); - } - - @Override - public void fatalError(SAXParseException arg0) throws SAXException { - if (list != null) - list.add(new ValidationMessage(Source.InstanceValidator, IssueType.STRUCTURE, arg0.getLineNumber(), arg0.getColumnNumber(), path == null ? arg0.getSystemId() : path, arg0.getMessage(), IssueSeverity.FATAL)); - if (logger != null) - logger.log("fatal error: " + arg0.toString(), LogMessageType.Error); - } - - @Override - public void warning(SAXParseException arg0) throws SAXException { - if (list != null) - list.add(new ValidationMessage(Source.InstanceValidator, IssueType.STRUCTURE, arg0.getLineNumber(), arg0.getColumnNumber(), path == null ? arg0.getSystemId() : path, arg0.getMessage(), IssueSeverity.WARNING)); - } - - public List getErrors() { - return errors; - } - - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } - } - - public class MyResourceResolver implements LSResourceResolver { - - @Override - public LSInput resolveResource(final String type, final String namespaceURI, final String publicId, String systemId, final String baseURI) { - try { - if (!schemas.containsKey(systemId)) - return null; - return new SchemaInputSource(new ByteArrayInputStream(schemas.get(systemId)), publicId, systemId, namespaceURI); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - } - - -} From f1dc0e57541be53b3f976bf7286d872dd3d658a2 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Tue, 25 Feb 2020 09:25:56 +1100 Subject: [PATCH 10/10] Release new version 4.2.3 --- org.hl7.fhir.convertors/pom.xml | 2 +- org.hl7.fhir.dstu2/pom.xml | 2 +- org.hl7.fhir.dstu2016may/pom.xml | 2 +- org.hl7.fhir.dstu3/pom.xml | 2 +- org.hl7.fhir.r4/pom.xml | 2 +- org.hl7.fhir.r5/pom.xml | 2 +- org.hl7.fhir.utilities/pom.xml | 2 +- org.hl7.fhir.validation.cli/pom.xml | 2 +- org.hl7.fhir.validation/pom.xml | 2 +- pom.xml | 2 +- release.bat | 4 ++-- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/org.hl7.fhir.convertors/pom.xml b/org.hl7.fhir.convertors/pom.xml index 1dbc3794b..44f1561eb 100644 --- a/org.hl7.fhir.convertors/pom.xml +++ b/org.hl7.fhir.convertors/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 4.2.2-SNAPSHOT + 4.2.3-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.dstu2/pom.xml b/org.hl7.fhir.dstu2/pom.xml index e2164f76d..3d1359628 100644 --- a/org.hl7.fhir.dstu2/pom.xml +++ b/org.hl7.fhir.dstu2/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 4.2.2-SNAPSHOT + 4.2.3-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.dstu2016may/pom.xml b/org.hl7.fhir.dstu2016may/pom.xml index 6cd61f2e1..3860925ed 100644 --- a/org.hl7.fhir.dstu2016may/pom.xml +++ b/org.hl7.fhir.dstu2016may/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 4.2.2-SNAPSHOT + 4.2.3-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.dstu3/pom.xml b/org.hl7.fhir.dstu3/pom.xml index 05e28bf9f..9c9bf14db 100644 --- a/org.hl7.fhir.dstu3/pom.xml +++ b/org.hl7.fhir.dstu3/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 4.2.2-SNAPSHOT + 4.2.3-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.r4/pom.xml b/org.hl7.fhir.r4/pom.xml index 28a8c16d3..b35910da6 100644 --- a/org.hl7.fhir.r4/pom.xml +++ b/org.hl7.fhir.r4/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 4.2.2-SNAPSHOT + 4.2.3-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.r5/pom.xml b/org.hl7.fhir.r5/pom.xml index 5d0304f6e..5e15bd691 100644 --- a/org.hl7.fhir.r5/pom.xml +++ b/org.hl7.fhir.r5/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 4.2.2-SNAPSHOT + 4.2.3-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.utilities/pom.xml b/org.hl7.fhir.utilities/pom.xml index adae327b5..8fec8d5f6 100644 --- a/org.hl7.fhir.utilities/pom.xml +++ b/org.hl7.fhir.utilities/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 4.2.2-SNAPSHOT + 4.2.3-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.validation.cli/pom.xml b/org.hl7.fhir.validation.cli/pom.xml index 9846469f8..66d657b1a 100644 --- a/org.hl7.fhir.validation.cli/pom.xml +++ b/org.hl7.fhir.validation.cli/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 4.2.2-SNAPSHOT + 4.2.3-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.validation/pom.xml b/org.hl7.fhir.validation/pom.xml index df071a9c9..2ec87b9e1 100644 --- a/org.hl7.fhir.validation/pom.xml +++ b/org.hl7.fhir.validation/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 4.2.2-SNAPSHOT + 4.2.3-SNAPSHOT ../pom.xml diff --git a/pom.xml b/pom.xml index 117a49ea9..cef42f11a 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ each other. It is fine to bump the point version of this POM without affecting HAPI FHIR. --> - 4.2.2-SNAPSHOT + 4.2.3-SNAPSHOT 4.2.0 diff --git a/release.bat b/release.bat index 91876cd7f..0017128e6 100644 --- a/release.bat +++ b/release.bat @@ -1,7 +1,7 @@ @echo off -set oldver=4.2.1 -set newver=4.2.2 +set oldver=4.2.2 +set newver=4.2.3 echo .. echo =========================================================================