From 0c54716066486925a6314128b77bb0294e711015 Mon Sep 17 00:00:00 2001 From: dotasek Date: Fri, 11 Feb 2022 10:32:13 -0500 Subject: [PATCH 01/50] Ignore META-INF while unpacking dependencies --- org.hl7.fhir.validation.cli/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.hl7.fhir.validation.cli/pom.xml b/org.hl7.fhir.validation.cli/pom.xml index 85e5a66fc..e02906b57 100644 --- a/org.hl7.fhir.validation.cli/pom.xml +++ b/org.hl7.fhir.validation.cli/pom.xml @@ -76,7 +76,7 @@ unpack-dependencies - **/module-info.class,META-INF/*.SF,META-INF/*.DSA,META-INF/*.RSA + **/module-info.class,META-INF/* ${project.build.directory}/classes false true From 1b5e5b8e729603e40a8004ec20bc55a6e8ee2ab5 Mon Sep 17 00:00:00 2001 From: dotasek Date: Tue, 15 Feb 2022 16:51:13 -0500 Subject: [PATCH 02/50] Update RELEASE_NOTES.md --- RELEASE_NOTES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 7b06c6ab5..b09a26425 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -4,4 +4,4 @@ ## Other code changes -* no changes \ No newline at end of file +* Ignore META-INF contents from other dependencies while building Validator jar From 9e693b6a0380c5c3106f15cc463f7103ea3061d9 Mon Sep 17 00:00:00 2001 From: markiantorno Date: Sat, 19 Feb 2022 22:00:05 +0000 Subject: [PATCH 03/50] Updating version to: 5.6.36-SNAPSHOT and incrementing test cases dependency. --- RELEASE_NOTES.md | 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.r4b/pom.xml | 2 +- org.hl7.fhir.r5/pom.xml | 2 +- org.hl7.fhir.report/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 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 16e5152e8..7b06c6ab5 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -4,4 +4,4 @@ ## Other code changes -* fix various rendering issues from core spec +* no changes \ No newline at end of file diff --git a/org.hl7.fhir.convertors/pom.xml b/org.hl7.fhir.convertors/pom.xml index e31ec043f..b7e9b7c4b 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 - 5.6.35 + 5.6.36-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.dstu2/pom.xml b/org.hl7.fhir.dstu2/pom.xml index 93f5679c5..965bd6303 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 - 5.6.35 + 5.6.36-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.dstu2016may/pom.xml b/org.hl7.fhir.dstu2016may/pom.xml index 697d2a970..09ca59c33 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 - 5.6.35 + 5.6.36-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.dstu3/pom.xml b/org.hl7.fhir.dstu3/pom.xml index 25569ca06..955fa25a8 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 - 5.6.35 + 5.6.36-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.r4/pom.xml b/org.hl7.fhir.r4/pom.xml index f4d43de96..3e994e138 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 - 5.6.35 + 5.6.36-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.r4b/pom.xml b/org.hl7.fhir.r4b/pom.xml index a06b23830..5dead0ec1 100644 --- a/org.hl7.fhir.r4b/pom.xml +++ b/org.hl7.fhir.r4b/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.6.35 + 5.6.36-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.r5/pom.xml b/org.hl7.fhir.r5/pom.xml index d31503c1b..80d6e7ddb 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 - 5.6.35 + 5.6.36-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.report/pom.xml b/org.hl7.fhir.report/pom.xml index a486a788a..0f88a6e0c 100644 --- a/org.hl7.fhir.report/pom.xml +++ b/org.hl7.fhir.report/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.6.35 + 5.6.36-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.utilities/pom.xml b/org.hl7.fhir.utilities/pom.xml index 0ecab94eb..1a29a4afc 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 - 5.6.35 + 5.6.36-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.validation.cli/pom.xml b/org.hl7.fhir.validation.cli/pom.xml index 062c66791..e0f1e65ec 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 - 5.6.35 + 5.6.36-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.validation/pom.xml b/org.hl7.fhir.validation/pom.xml index 45006315e..0a789daa7 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 - 5.6.35 + 5.6.36-SNAPSHOT ../pom.xml diff --git a/pom.xml b/pom.xml index 9da7768a4..0c6484eb3 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ HAPI FHIR --> org.hl7.fhir.core - 5.6.35 + 5.6.36-SNAPSHOT pom From ab329c8c63b099a0c1b8f2bc9ecbe2e80aebb9bf Mon Sep 17 00:00:00 2001 From: Bryn Rhodes Date: Mon, 21 Feb 2022 15:05:42 -0700 Subject: [PATCH 04/50] Added a Liquid template resolver to narrative generation to support include resolution in the publisher --- .../org/hl7/fhir/r5/renderers/LiquidRenderer.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/LiquidRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/LiquidRenderer.java index 78893a2b4..81f1051d1 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/LiquidRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/LiquidRenderer.java @@ -32,12 +32,26 @@ public class LiquidRenderer extends ResourceRenderer { this.rcontext = rcontext; this.liquidTemplate = liquidTemplate; } + + private class LiquidRendererIncludeResolver implements LiquidEngine.ILiquidEngineIncludeResolver { + public LiquidRendererIncludeResolver(RenderingContext context) { + this.context = context; + } + + private RenderingContext context; + + @Override + public String fetchInclude(LiquidEngine engine, String name) { + return context.getTemplateProvider().findTemplate(name); + } + } @Override public boolean render(XhtmlNode x, Resource r) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome { LiquidEngine engine = new LiquidEngine(context.getWorker(), context.getServices()); XhtmlNode xn; try { + engine.setIncludeResolver(new LiquidRendererIncludeResolver(context.getTemplateProvider())); LiquidDocument doc = engine.parse(liquidTemplate, "template"); String html = engine.evaluate(doc, r, rcontext); xn = new XhtmlParser().parseFragment(html); From 5cc8dd7974dc479ee711ae66b9a7a4a02d4375ed Mon Sep 17 00:00:00 2001 From: dotasek Date: Wed, 23 Feb 2022 19:02:45 -0500 Subject: [PATCH 05/50] Fix incorrect fromCode for R4/DSTU2 --- .../src/main/java/org/hl7/fhir/r4/model/FhirPublication.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/FhirPublication.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/FhirPublication.java index bc8dfe581..6ccf8fd4b 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/FhirPublication.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/FhirPublication.java @@ -49,7 +49,7 @@ public enum FhirPublication { R4; public static FhirPublication fromCode(String v) { - if (VersionUtilities.isR4Ver(v)) + if (VersionUtilities.isR2Ver(v)) return FhirPublication.DSTU2; if ("1.0".equals(v)) return FhirPublication.DSTU2; From 5544460d20194a12d9d1c7cec396489e518dce12 Mon Sep 17 00:00:00 2001 From: Bryn Rhodes Date: Wed, 23 Feb 2022 19:44:21 -0700 Subject: [PATCH 06/50] Added documentation --- .../main/java/org/hl7/fhir/r5/renderers/LiquidRenderer.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/LiquidRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/LiquidRenderer.java index 81f1051d1..739773801 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/LiquidRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/LiquidRenderer.java @@ -33,6 +33,10 @@ public class LiquidRenderer extends ResourceRenderer { this.liquidTemplate = liquidTemplate; } + /** + * This class provides an implementation of the ILiquidEngineIncludeResolver that makes use of the + * template provider available in the rendering context to support resolving includes. + */ private class LiquidRendererIncludeResolver implements LiquidEngine.ILiquidEngineIncludeResolver { public LiquidRendererIncludeResolver(RenderingContext context) { this.context = context; From 8212604250fefb42a69421d76e88fde306d8c033 Mon Sep 17 00:00:00 2001 From: Bryn Rhodes Date: Wed, 23 Feb 2022 20:09:17 -0700 Subject: [PATCH 07/50] Fix missing argument --- .../src/main/java/org/hl7/fhir/r5/renderers/LiquidRenderer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/LiquidRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/LiquidRenderer.java index 739773801..856855a26 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/LiquidRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/LiquidRenderer.java @@ -46,7 +46,7 @@ public class LiquidRenderer extends ResourceRenderer { @Override public String fetchInclude(LiquidEngine engine, String name) { - return context.getTemplateProvider().findTemplate(name); + return context.getTemplateProvider().findTemplate(context, name); } } From 778738d3ac644911183e446b0832caab975dbdb3 Mon Sep 17 00:00:00 2001 From: Bryn Rhodes Date: Wed, 23 Feb 2022 20:20:38 -0700 Subject: [PATCH 08/50] Fix constructor argument --- .../src/main/java/org/hl7/fhir/r5/renderers/LiquidRenderer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/LiquidRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/LiquidRenderer.java index 856855a26..bc8eb4caa 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/LiquidRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/LiquidRenderer.java @@ -55,7 +55,7 @@ public class LiquidRenderer extends ResourceRenderer { LiquidEngine engine = new LiquidEngine(context.getWorker(), context.getServices()); XhtmlNode xn; try { - engine.setIncludeResolver(new LiquidRendererIncludeResolver(context.getTemplateProvider())); + engine.setIncludeResolver(new LiquidRendererIncludeResolver(context)); LiquidDocument doc = engine.parse(liquidTemplate, "template"); String html = engine.evaluate(doc, r, rcontext); xn = new XhtmlParser().parseFragment(html); From c5b3e022a422a9a7f79f244989fa38a8a0cdfc9e Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Fri, 25 Feb 2022 13:07:07 +1100 Subject: [PATCH 09/50] fix bug where inactive codes always put in expansions, and add unit tests for this --- .../fhir/r5/context/BaseWorkerContext.java | 3 +- .../r5/context/CanonicalResourceManager.java | 3 + .../hl7/fhir/r5/context/IWorkerContext.java | 2 +- .../org/hl7/fhir/r5/model/Enumerations.java | 18 +- .../fhir/r5/renderers/ValueSetRenderer.java | 2 +- .../r5/terminologies/CodeSystemUtilities.java | 2 +- .../terminologies/ValueSetExpanderSimple.java | 81 +++++---- .../fhir/r5/test/utils/TestingUtilities.java | 2 + .../r5/context/SimpleWorkerContextTests.java | 35 ++-- .../r5/context/TerminologyCacheTests.java | 32 ++-- .../fhir/r5/context/TestPackageLoader.java | 46 +++++ .../fhir/r5/formats/FormatUtilitiesTest.java | 11 +- .../r5/model/Base64BinaryTypeNullTest.java | 1 - .../fhir/r5/model/BooleanTypeNullTest.java | 1 - .../fhir/r5/model/CanonicalTypeNullTest.java | 1 - .../hl7/fhir/r5/model/CodeTypeNullTest.java | 1 - .../fhir/r5/model/DateTimeTypeNullTest.java | 1 - .../hl7/fhir/r5/model/DateTypeNullTest.java | 1 - .../fhir/r5/model/DecimalTypeNullTest.java | 1 - .../org/hl7/fhir/r5/model/IdTypeNullTest.java | 1 - .../fhir/r5/model/InstantTypeNullTest.java | 1 - .../fhir/r5/model/IntegerTypeNullTest.java | 1 - .../fhir/r5/model/MarkdownTypeNullTest.java | 1 - .../hl7/fhir/r5/model/OidTypeNullTest.java | 1 - .../r5/model/PositiveIntTypeNullTest.java | 1 - .../hl7/fhir/r5/model/StringTypeNullTest.java | 1 - .../hl7/fhir/r5/model/TimeTypeNullTest.java | 1 - .../r5/model/UnsignedIntTypeNullTest.java | 1 - .../hl7/fhir/r5/model/UriTypeNullTest.java | 1 - .../hl7/fhir/r5/model/UrlTypeNullTest.java | 1 - .../hl7/fhir/r5/model/UuidTypeNullTest.java | 1 - .../org/hl7/fhir/r5/test/FHIRPathTests.java | 1 - .../r5/test/NarrativeGenerationTests.java | 16 -- .../fhir/r5/test/NarrativeGeneratorTests.java | 4 - .../fhir/r5/test/ProfileUtilitiesTests.java | 6 +- .../hl7/fhir/r5/test/ResourceCopyTests.java | 4 +- .../fhir/r5/test/ResourceRoundTripTests.java | 2 - .../org/hl7/fhir/r5/test/ResourceTests.java | 4 +- .../fhir/r5/test/SnapShotGenerationTests.java | 47 +---- .../r5/test/StructureMapUtilitiesTest.java | 8 +- .../java/org/hl7/fhir/r5/test/VocabTests.java | 162 ++++++++++++++++++ .../org/hl7/fhir/r5/utils/FHIRLexerTest.java | 2 - .../utils/client/FHIRToolingClientTest.java | 29 +++- .../client/network/ClientHeadersTest.java | 7 +- .../r5/utils/client/network/ClientTest.java | 29 ++-- .../network/FhirRequestBuilderTest.java | 12 +- .../org/hl7/fhir/utilities/UtilitiesTest.java | 6 +- .../instance/type/BundleValidator.java | 2 +- pom.xml | 2 +- 49 files changed, 391 insertions(+), 208 deletions(-) create mode 100644 org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/TestPackageLoader.java create mode 100644 org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/VocabTests.java 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 4ae77cd7c..9114a51b9 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 @@ -666,10 +666,11 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte @Override - public ValueSetExpansionOutcome expandVS(ConceptSetComponent inc, boolean hierarchical) throws TerminologyServiceException { + public ValueSetExpansionOutcome expandVS(ConceptSetComponent inc, boolean hierarchical, boolean noInactive) throws TerminologyServiceException { ValueSet vs = new ValueSet(); vs.setStatus(PublicationStatus.ACTIVE); vs.setCompose(new ValueSetComposeComponent()); + vs.getCompose().setInactive(!noInactive); vs.getCompose().getInclude().add(inc); CacheToken cacheToken = txCache.generateExpandToken(vs, hierarchical); ValueSetExpansionOutcome res; diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/CanonicalResourceManager.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/CanonicalResourceManager.java index a781cc776..34da6eb7a 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/CanonicalResourceManager.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/CanonicalResourceManager.java @@ -124,6 +124,9 @@ public class CanonicalResourceManager { if (resource == null) { @SuppressWarnings("unchecked") T1 res = (T1) proxy.getResource(); + if (res == null) { + throw new Error("Proxy loading a resource from "+packageInfo+" failed and returned null"); + } synchronized (this) { resource = res; } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/IWorkerContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/IWorkerContext.java index ae95c7b40..242856766 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/IWorkerContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/IWorkerContext.java @@ -547,7 +547,7 @@ public interface IWorkerContext { * @return * @throws FHIRException */ - ValueSetExpansionOutcome expandVS(ConceptSetComponent inc, boolean hierarchical) throws TerminologyServiceException; + ValueSetExpansionOutcome expandVS(ConceptSetComponent inc, boolean hierarchical, boolean noInactive) throws TerminologyServiceException; Locale getLocale(); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Enumerations.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Enumerations.java index d153c5280..64de74462 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Enumerations.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Enumerations.java @@ -6924,9 +6924,9 @@ The primary difference between a medicationusage and a medicationadministration return _4_1_0; if ("4.2.0".equals(codeString)) return _4_2_0; - if ("4.3.0-snapshot1".equals(codeString)) + if ("4.3.0-snapshot1".equalsIgnoreCase(codeString)) return _4_3_0SNAPSHOT1; - if ("4.3.0-cibuild".equals(codeString)) + if ("4.3.0-cibuild".equalsIgnoreCase(codeString)) return _4_3_0CIBUILD; if ("4.4.0".equals(codeString)) return _4_4_0; @@ -6934,9 +6934,9 @@ The primary difference between a medicationusage and a medicationadministration return _4_5_0; if ("4.6.0".equals(codeString)) return _4_6_0; - if ("5.0.0-snapshot1".equals(codeString)) + if ("5.0.0-snapshot1".equalsIgnoreCase(codeString)) return _5_0_0SNAPSHOT1; - if ("5.0.0-cibuild".equals(codeString)) + if ("5.0.0-cibuild".equalsIgnoreCase(codeString)) return _5_0_0CIBUILD; throw new FHIRException("Unknown FHIRVersion code '"+codeString+"'"); } @@ -7158,7 +7158,7 @@ public String toCode(int len) { public boolean isR4B() { - return toCode().startsWith("4.1"); + return toCode().startsWith("4.1") ||toCode().startsWith("4.3"); } // end addition @@ -7219,9 +7219,9 @@ public String toCode(int len) { return FHIRVersion._4_1_0; if ("4.2.0".equals(codeString)) return FHIRVersion._4_2_0; - if ("4.3.0-snapshot1".equals(codeString)) + if ("4.3.0-snapshot1".equalsIgnoreCase(codeString)) return FHIRVersion._4_3_0SNAPSHOT1; - if ("4.3.0-cibuild".equals(codeString)) + if ("4.3.0-cibuild".equalsIgnoreCase(codeString)) return FHIRVersion._4_3_0CIBUILD; if ("4.4.0".equals(codeString)) return FHIRVersion._4_4_0; @@ -7229,9 +7229,9 @@ public String toCode(int len) { return FHIRVersion._4_5_0; if ("4.6.0".equals(codeString)) return FHIRVersion._4_6_0; - if ("5.0.0-snapshot1".equals(codeString)) + if ("5.0.0-snapshot1".equalsIgnoreCase(codeString)) return FHIRVersion._5_0_0SNAPSHOT1; - if ("5.0.0-cibuild".equals(codeString)) + if ("5.0.0-cibuild".equalsIgnoreCase(codeString)) return FHIRVersion._5_0_0CIBUILD; throw new IllegalArgumentException("Unknown FHIRVersion code '"+codeString+"'"); } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ValueSetRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ValueSetRenderer.java index 869a19907..04df5e4c1 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ValueSetRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ValueSetRenderer.java @@ -1165,7 +1165,7 @@ public class ValueSetRenderer extends TerminologyRenderer { ValueSetExpansionComponent vse = null; if (!context.isNoSlowLookup() && !getContext().getWorker().hasCache()) { try { - ValueSetExpansionOutcome vso = getContext().getWorker().expandVS(inc, false); + ValueSetExpansionOutcome vso = getContext().getWorker().expandVS(inc, false, false); ValueSet valueset = vso.getValueset(); if (valueset == null) throw new TerminologyServiceException("Error Expanding ValueSet: "+vso.getError()); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/CodeSystemUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/CodeSystemUtilities.java index b64be0281..5d8cea6a5 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/CodeSystemUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/CodeSystemUtilities.java @@ -249,7 +249,7 @@ public class CodeSystemUtilities { public static boolean isInactive(CodeSystem cs, ConceptDefinitionComponent def) throws FHIRException { for (ConceptPropertyComponent p : def.getProperty()) { if ("status".equals(p.getCode()) && p.hasValueStringType()) - return "inactive".equals(p.getValueStringType()); + return "inactive".equals(p.getValueStringType().primitiveValue()) || "retired".equals(p.getValueStringType().primitiveValue()); } return false; } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetExpanderSimple.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetExpanderSimple.java index bd45f5cac..1bfe96ff6 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetExpanderSimple.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetExpanderSimple.java @@ -108,6 +108,8 @@ import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionParameterComponent; import org.hl7.fhir.r5.utils.ToolingExtensions; import org.hl7.fhir.utilities.Utilities; +import com.google.errorprone.annotations.NoAllocation; + public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetExpander { public class PropertyFilter implements IConceptFilter { @@ -201,10 +203,15 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx maxExpansionSize = theMaxExpansionSize; } - private ValueSetExpansionContainsComponent addCode(String system, String code, String display, ValueSetExpansionContainsComponent parent, List designations, Parameters expParams, boolean isAbstract, boolean inactive, List filters) { + private ValueSetExpansionContainsComponent addCode(String system, String code, String display, ValueSetExpansionContainsComponent parent, List designations, Parameters expParams, + boolean isAbstract, boolean inactive, List filters, boolean noInactive) { if (filters != null && !filters.isEmpty() && !filterContainsCode(filters, system, code)) return null; + if (noInactive && inactive) { + return null; + } + ValueSetExpansionContainsComponent n = new ValueSet.ValueSetExpansionContainsComponent(); n.setSystem(system); n.setCode(code); @@ -267,12 +274,12 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx return null; } - private void addCodeAndDescendents(ValueSetExpansionContainsComponent focus, ValueSetExpansionContainsComponent parent, Parameters expParams, List filters) throws FHIRException { + private void addCodeAndDescendents(ValueSetExpansionContainsComponent focus, ValueSetExpansionContainsComponent parent, Parameters expParams, List filters, boolean noInactive) throws FHIRException { focus.checkNoModifiers("Expansion.contains", "expanding"); ValueSetExpansionContainsComponent np = addCode(focus.getSystem(), focus.getCode(), focus.getDisplay(), parent, - convert(focus.getDesignation()), expParams, focus.getAbstract(), focus.getInactive(), filters); + convert(focus.getDesignation()), expParams, focus.getAbstract(), focus.getInactive(), filters, noInactive); for (ValueSetExpansionContainsComponent c : focus.getContains()) - addCodeAndDescendents(focus, np, expParams, filters); + addCodeAndDescendents(focus, np, expParams, filters, noInactive); } private List convert(List designations) { @@ -287,7 +294,7 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx return list; } - private void addCodeAndDescendents(CodeSystem cs, String system, ConceptDefinitionComponent def, ValueSetExpansionContainsComponent parent, Parameters expParams, List filters, ConceptDefinitionComponent exclusion, IConceptFilter filterFunc) throws FHIRException { + private void addCodeAndDescendents(CodeSystem cs, String system, ConceptDefinitionComponent def, ValueSetExpansionContainsComponent parent, Parameters expParams, List filters, ConceptDefinitionComponent exclusion, IConceptFilter filterFunc, boolean noInactive) throws FHIRException { def.checkNoModifiers("Code in Code System", "expanding"); if (exclusion != null) { if (exclusion.getCode().equals(def.getCode())) @@ -298,30 +305,30 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx boolean abs = CodeSystemUtilities.isNotSelectable(cs, def); boolean inc = CodeSystemUtilities.isInactive(cs, def); if ((includeAbstract || !abs) && filterFunc.includeConcept(cs, def)) { - np = addCode(system, def.getCode(), def.getDisplay(), parent, def.getDesignation(), expParams, abs, inc, filters); + np = addCode(system, def.getCode(), def.getDisplay(), parent, def.getDesignation(), expParams, abs, inc, filters, noInactive); } for (ConceptDefinitionComponent c : def.getConcept()) { - addCodeAndDescendents(cs, system, c, np, expParams, filters, exclusion, filterFunc); + addCodeAndDescendents(cs, system, c, np, expParams, filters, exclusion, filterFunc, noInactive); } if (def.hasUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK)) { List children = (List) def.getUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK); for (ConceptDefinitionComponent c : children) - addCodeAndDescendents(cs, system, c, np, expParams, filters, exclusion, filterFunc); + addCodeAndDescendents(cs, system, c, np, expParams, filters, exclusion, filterFunc, noInactive); } } else { for (ConceptDefinitionComponent c : def.getConcept()) { - addCodeAndDescendents(cs, system, c, null, expParams, filters, exclusion, filterFunc); + addCodeAndDescendents(cs, system, c, null, expParams, filters, exclusion, filterFunc, noInactive); } if (def.hasUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK)) { List children = (List) def.getUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK); for (ConceptDefinitionComponent c : children) - addCodeAndDescendents(cs, system, c, null, expParams, filters, exclusion, filterFunc); + addCodeAndDescendents(cs, system, c, null, expParams, filters, exclusion, filterFunc, noInactive); } } } - private void addCodes(ValueSetExpansionComponent expand, List params, Parameters expParams, List filters) throws ETooCostly, FHIRException { + private void addCodes(ValueSetExpansionComponent expand, List params, Parameters expParams, List filters, boolean noInactive) throws ETooCostly, FHIRException { if (expand != null) { if (expand.getContains().size() > maxExpansionSize) throw failCostly("Too many codes to display (>" + Integer.toString(expand.getContains().size()) + ")"); @@ -330,7 +337,7 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx params.add(p); } - copyImportContains(expand.getContains(), null, expParams, filters); + copyImportContains(expand.getContains(), null, expParams, filters, noInactive); } } @@ -354,7 +361,7 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx CodeSystem cs = context.fetchCodeSystem(exc.getSystem()); if ((cs == null || cs.getContent() != CodeSystemContentMode.COMPLETE) && context.supportsSystem(exc.getSystem())) { - ValueSetExpansionOutcome vse = context.expandVS(exc, false); + ValueSetExpansionOutcome vse = context.expandVS(exc, false, false); ValueSet valueset = vse.getValueset(); if (valueset == null) throw failTSE("Error Expanding ValueSet: "+vse.getError()); @@ -474,11 +481,11 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx first = false; else canBeHeirarchy = false; - includeCodes(inc, exp, expParams, canBeHeirarchy, extensions); + includeCodes(inc, exp, expParams, canBeHeirarchy, compose.hasInactive() && !compose.getInactive(), extensions); } } - private ValueSet importValueSet(String value, ValueSetExpansionComponent exp, Parameters expParams) throws ETooCostly, TerminologyServiceException, FileNotFoundException, IOException, FHIRFormatError { + private ValueSet importValueSet(String value, ValueSetExpansionComponent exp, Parameters expParams, boolean noInactive) throws ETooCostly, TerminologyServiceException, FileNotFoundException, IOException, FHIRFormatError { if (value == null) throw fail("unable to find value set with no identity"); ValueSet vs = context.fetchResource(ValueSet.class, value); @@ -489,6 +496,10 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx throw fail("Unable to find imported value set " + value); } } + if (noInactive) { + expParams = expParams.copy(); + expParams.addParameter("activeOnly", true); + } ValueSetExpansionOutcome vso = new ValueSetExpanderSimple(context, allErrors).expand(vs, expParams); if (vso.getError() != null) { addErrors(vso.getAllErrors()); @@ -543,19 +554,19 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx } } - private void copyImportContains(List list, ValueSetExpansionContainsComponent parent, Parameters expParams, List filter) throws FHIRException { + private void copyImportContains(List list, ValueSetExpansionContainsComponent parent, Parameters expParams, List filter, boolean noInactive) throws FHIRException { for (ValueSetExpansionContainsComponent c : list) { c.checkNoModifiers("Imported Expansion in Code System", "expanding"); - ValueSetExpansionContainsComponent np = addCode(c.getSystem(), c.getCode(), c.getDisplay(), parent, null, expParams, c.getAbstract(), c.getInactive(), filter); - copyImportContains(c.getContains(), np, expParams, filter); + ValueSetExpansionContainsComponent np = addCode(c.getSystem(), c.getCode(), c.getDisplay(), parent, null, expParams, c.getAbstract(), c.getInactive(), filter, noInactive); + copyImportContains(c.getContains(), np, expParams, filter, noInactive); } } - private void includeCodes(ConceptSetComponent inc, ValueSetExpansionComponent exp, Parameters expParams, boolean heirarchical, List extensions) throws ETooCostly, FileNotFoundException, IOException, FHIRException { + private void includeCodes(ConceptSetComponent inc, ValueSetExpansionComponent exp, Parameters expParams, boolean heirarchical, boolean noInactive, List extensions) throws ETooCostly, FileNotFoundException, IOException, FHIRException { inc.checkNoModifiers("Compose.include", "expanding"); List imports = new ArrayList(); for (UriType imp : inc.getValueSet()) { - imports.add(importValueSet(imp.getValue(), exp, expParams)); + imports.add(importValueSet(imp.getValue(), exp, expParams, noInactive)); } if (!inc.hasSystem()) { @@ -564,19 +575,19 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx ValueSet base = imports.get(0); imports.remove(0); base.checkNoModifiers("Imported ValueSet", "expanding"); - copyImportContains(base.getExpansion().getContains(), null, expParams, imports); + copyImportContains(base.getExpansion().getContains(), null, expParams, imports, noInactive); } else { CodeSystem cs = context.fetchCodeSystem(inc.getSystem()); if (isServerSide(inc.getSystem()) || (cs == null || (cs.getContent() != CodeSystemContentMode.COMPLETE && cs.getContent() != CodeSystemContentMode.FRAGMENT))) { - doServerIncludeCodes(inc, heirarchical, exp, imports, expParams, extensions); + doServerIncludeCodes(inc, heirarchical, exp, imports, expParams, extensions, noInactive); } else { - doInternalIncludeCodes(inc, exp, expParams, imports, cs); + doInternalIncludeCodes(inc, exp, expParams, imports, cs, noInactive); } } } - private void doServerIncludeCodes(ConceptSetComponent inc, boolean heirarchical, ValueSetExpansionComponent exp, List imports, Parameters expParams, List extensions) throws FHIRException { - ValueSetExpansionOutcome vso = context.expandVS(inc, heirarchical); + private void doServerIncludeCodes(ConceptSetComponent inc, boolean heirarchical, ValueSetExpansionComponent exp, List imports, Parameters expParams, List extensions, boolean noInactive) throws FHIRException { + ValueSetExpansionOutcome vso = context.expandVS(inc, heirarchical, noInactive); if (vso.getError() != null) { throw failTSE("Unable to expand imported value set: " + vso.getError()); } @@ -599,7 +610,7 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx } } for (ValueSetExpansionContainsComponent cc : vs.getExpansion().getContains()) { - addCodeAndDescendents(cc, null, expParams, imports); + addCodeAndDescendents(cc, null, expParams, imports, noInactive); } } @@ -612,7 +623,7 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx return false; } - public void doInternalIncludeCodes(ConceptSetComponent inc, ValueSetExpansionComponent exp, Parameters expParams, List imports, CodeSystem cs) throws NoTerminologyServiceException, TerminologyServiceException, FHIRException { + public void doInternalIncludeCodes(ConceptSetComponent inc, ValueSetExpansionComponent exp, Parameters expParams, List imports, CodeSystem cs, boolean noInactive) throws NoTerminologyServiceException, TerminologyServiceException, FHIRException { if (cs == null) { if (context.isNoTerminologyServer()) throw failTSE("Unable to find code system " + inc.getSystem().toString()); @@ -629,7 +640,7 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx if (inc.getConcept().size() == 0 && inc.getFilter().size() == 0) { // special case - add all the code system for (ConceptDefinitionComponent def : cs.getConcept()) { - addCodeAndDescendents(cs, inc.getSystem(), def, null, expParams, imports, null, new AllConceptsFilter()); + addCodeAndDescendents(cs, inc.getSystem(), def, null, expParams, imports, null, new AllConceptsFilter(), noInactive); } if (cs.getContent() == CodeSystemContentMode.FRAGMENT) { addFragmentWarning(exp, cs); @@ -658,7 +669,7 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx } else { inactive = CodeSystemUtilities.isInactive(cs, def); } - addCode(inc.getSystem(), c.getCode(), !Utilities.noString(c.getDisplay()) ? c.getDisplay() : def == null ? null : def.getDisplay(), null, convertDesignations(c.getDesignation()), expParams, false, inactive, imports); + addCode(inc.getSystem(), c.getCode(), !Utilities.noString(c.getDisplay()) ? c.getDisplay() : def == null ? null : def.getDisplay(), null, convertDesignations(c.getDesignation()), expParams, false, inactive, imports, noInactive); } } if (inc.getFilter().size() > 1) { @@ -675,14 +686,14 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx ConceptDefinitionComponent def = getConceptForCode(cs.getConcept(), fc.getValue()); if (def == null) throw failTSE("Code '" + fc.getValue() + "' not found in system '" + inc.getSystem() + "'"); - addCodeAndDescendents(cs, inc.getSystem(), def, null, expParams, imports, null, new AllConceptsFilter()); + addCodeAndDescendents(cs, inc.getSystem(), def, null, expParams, imports, null, new AllConceptsFilter(), noInactive); } else if ("concept".equals(fc.getProperty()) && fc.getOp() == FilterOperator.ISNOTA) { // special: all codes in the target code system that are not under the value ConceptDefinitionComponent defEx = getConceptForCode(cs.getConcept(), fc.getValue()); if (defEx == null) throw failTSE("Code '" + fc.getValue() + "' not found in system '" + inc.getSystem() + "'"); for (ConceptDefinitionComponent def : cs.getConcept()) { - addCodeAndDescendents(cs, inc.getSystem(), def, null, expParams, imports, defEx, new AllConceptsFilter()); + addCodeAndDescendents(cs, inc.getSystem(), def, null, expParams, imports, defEx, new AllConceptsFilter(), noInactive); } } else if ("concept".equals(fc.getProperty()) && fc.getOp() == FilterOperator.DESCENDENTOF) { // special: all codes in the target code system under the value @@ -690,11 +701,11 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx if (def == null) throw failTSE("Code '" + fc.getValue() + "' not found in system '" + inc.getSystem() + "'"); for (ConceptDefinitionComponent c : def.getConcept()) - addCodeAndDescendents(cs, inc.getSystem(), c, null, expParams, imports, null, new AllConceptsFilter()); + addCodeAndDescendents(cs, inc.getSystem(), c, null, expParams, imports, null, new AllConceptsFilter(), noInactive); if (def.hasUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK)) { List children = (List) def.getUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK); for (ConceptDefinitionComponent c : children) - addCodeAndDescendents(cs, inc.getSystem(), c, null, expParams, imports, null, new AllConceptsFilter()); + addCodeAndDescendents(cs, inc.getSystem(), c, null, expParams, imports, null, new AllConceptsFilter(), noInactive); } } else if ("display".equals(fc.getProperty()) && fc.getOp() == FilterOperator.EQUAL) { @@ -705,13 +716,13 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx if (isNotBlank(def.getDisplay()) && isNotBlank(fc.getValue())) { if (def.getDisplay().contains(fc.getValue())) { addCode(inc.getSystem(), def.getCode(), def.getDisplay(), null, def.getDesignation(), expParams, CodeSystemUtilities.isNotSelectable(cs, def), CodeSystemUtilities.isInactive(cs, def), - imports); + imports, noInactive); } } } } else if (isDefinedProperty(cs, fc.getProperty())) { for (ConceptDefinitionComponent def : cs.getConcept()) { - addCodeAndDescendents(cs, inc.getSystem(), def, null, expParams, imports, null, new PropertyFilter(fc, getPropertyDefinition(cs, fc.getProperty()))); + addCodeAndDescendents(cs, inc.getSystem(), def, null, expParams, imports, null, new PropertyFilter(fc, getPropertyDefinition(cs, fc.getProperty())), noInactive); } } else { throw fail("Search by property[" + fc.getProperty() + "] and op[" + fc.getOp() + "] is not supported yet"); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/test/utils/TestingUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/test/utils/TestingUtilities.java index 78af02088..a6636f734 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/test/utils/TestingUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/test/utils/TestingUtilities.java @@ -108,12 +108,14 @@ public class TestingUtilities extends BaseTestingUtilities { public static SimpleWorkerContext getWorkerContext(NpmPackage npmPackage) throws Exception { SimpleWorkerContext swc = new SimpleWorkerContext.SimpleWorkerContextBuilder().withUserAgent(TestConstants.USER_AGENT).withTerminologyCachePath(TestConstants.TX_CACHE).fromPackage(npmPackage); TerminologyCache.setCacheErrors(true); + swc.setAllowLoadingDuplicates(true); return swc; } public static SimpleWorkerContext getWorkerContext(NpmPackage npmPackage, IWorkerContext.IContextResourceLoader loader) throws Exception { SimpleWorkerContext swc = new SimpleWorkerContext.SimpleWorkerContextBuilder().withUserAgent(TestConstants.USER_AGENT).withTerminologyCachePath(TestConstants.TX_CACHE).fromPackage(npmPackage, loader); TerminologyCache.setCacheErrors(true); + swc.setAllowLoadingDuplicates(true); return swc; } diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/SimpleWorkerContextTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/SimpleWorkerContextTests.java index a032328fc..cd951de9e 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/SimpleWorkerContextTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/SimpleWorkerContextTests.java @@ -1,13 +1,31 @@ package org.hl7.fhir.r5.context; -import org.hl7.fhir.r5.model.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.argThat; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; + +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +import org.hl7.fhir.r5.model.CapabilityStatement; +import org.hl7.fhir.r5.model.CodeableConcept; +import org.hl7.fhir.r5.model.Coding; +import org.hl7.fhir.r5.model.Enumerations; +import org.hl7.fhir.r5.model.Parameters; +import org.hl7.fhir.r5.model.TerminologyCapabilities; +import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.terminologies.TerminologyClient; import org.hl7.fhir.r5.terminologies.ValueSetCheckerSimple; import org.hl7.fhir.r5.terminologies.ValueSetExpander; import org.hl7.fhir.r5.terminologies.ValueSetExpanderSimple; import org.hl7.fhir.r5.utils.validation.ValidationContextCarrier; import org.hl7.fhir.utilities.ToolingClientLogger; -import org.hl7.fhir.utilities.graphql.Value; import org.hl7.fhir.utilities.validation.ValidationOptions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -18,15 +36,6 @@ import org.mockito.Mockito; import org.mockito.Spy; import org.mockito.junit.jupiter.MockitoExtension; -import java.io.IOException; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.*; - @ExtendWith(MockitoExtension.class) public class SimpleWorkerContextTests { @@ -256,7 +265,7 @@ public class SimpleWorkerContextTests { Mockito.doReturn(cacheToken).when(terminologyCache).generateExpandToken(argThat(new ValueSetMatcher(vs)),eq(true)); Mockito.doReturn(expectedExpansionResult).when(terminologyCache).getExpansion(cacheToken); - ValueSetExpander.ValueSetExpansionOutcome actualExpansionResult = context.expandVS(inc, true); + ValueSetExpander.ValueSetExpansionOutcome actualExpansionResult = context.expandVS(inc, true, false); assertEquals(expectedExpansionResult, actualExpansionResult); @@ -285,7 +294,7 @@ public class SimpleWorkerContextTests { Mockito.doReturn(expectedValueSet).when(terminologyClient).expandValueset(argThat(new ValueSetMatcher(vs)), argThat(new ParametersMatcher(pInWithDependentResources)), eq(params)); - ValueSetExpander.ValueSetExpansionOutcome actualExpansionResult = context.expandVS(inc, true); + ValueSetExpander.ValueSetExpansionOutcome actualExpansionResult = context.expandVS(inc, true, false); assertEquals(expectedValueSet, actualExpansionResult.getValueset()); diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/TerminologyCacheTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/TerminologyCacheTests.java index 665c0fe21..57fbcbcd9 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/TerminologyCacheTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/TerminologyCacheTests.java @@ -1,15 +1,9 @@ package org.hl7.fhir.r5.context; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; -import org.hl7.fhir.r5.formats.IParser; -import org.hl7.fhir.r5.model.*; -import org.hl7.fhir.r5.terminologies.ValueSetExpander; -import org.hl7.fhir.utilities.validation.ValidationMessage; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; import java.io.IOException; @@ -25,8 +19,22 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.Stream; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.mock; +import org.hl7.fhir.r5.formats.IParser; +import org.hl7.fhir.r5.model.CanonicalResource; +import org.hl7.fhir.r5.model.CapabilityStatement; +import org.hl7.fhir.r5.model.CodeableConcept; +import org.hl7.fhir.r5.model.Coding; +import org.hl7.fhir.r5.model.TerminologyCapabilities; +import org.hl7.fhir.r5.model.ValueSet; +import org.hl7.fhir.r5.terminologies.ValueSetExpander; +import org.hl7.fhir.utilities.validation.ValidationMessage; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; public class TerminologyCacheTests { diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/TestPackageLoader.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/TestPackageLoader.java new file mode 100644 index 000000000..17c1a4724 --- /dev/null +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/TestPackageLoader.java @@ -0,0 +1,46 @@ +package org.hl7.fhir.r5.context; + +import java.io.IOException; +import java.io.InputStream; + +import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.r5.context.IWorkerContext.IContextResourceLoader; +import org.hl7.fhir.r5.formats.JsonParser; +import org.hl7.fhir.r5.formats.XmlParser; +import org.hl7.fhir.r5.model.Bundle; +import org.hl7.fhir.r5.model.Resource; +import org.hl7.fhir.utilities.npm.NpmPackage; + +public class TestPackageLoader implements IContextResourceLoader { + + private String[] types; + + public TestPackageLoader(String[] types) { + this.types = types; + } + + @Override + public Bundle loadBundle(InputStream stream, boolean isJson) throws FHIRException, IOException { + return null; + } + + @Override + public Resource loadResource(InputStream stream, boolean isJson) throws FHIRException, IOException { + return isJson ? new JsonParser().parse(stream) : new XmlParser().parse(stream); + } + + @Override + public String[] getTypes() { + return types; + } + + @Override + public String getResourcePath(Resource resource) { + return null; + } + + @Override + public IContextResourceLoader getNewLoader(NpmPackage npm) { + return this; + } +} diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/formats/FormatUtilitiesTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/formats/FormatUtilitiesTest.java index b7ab1d337..c9a1358ec 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/formats/FormatUtilitiesTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/formats/FormatUtilitiesTest.java @@ -1,14 +1,11 @@ package org.hl7.fhir.r5.formats; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; - import java.util.stream.Stream; -import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; class FormatUtilitiesTest { diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/Base64BinaryTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/Base64BinaryTypeNullTest.java index 0723e2dea..8ff29d60d 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/Base64BinaryTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/Base64BinaryTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.Base64BinaryType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/BooleanTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/BooleanTypeNullTest.java index 996407241..2b9581f4f 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/BooleanTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/BooleanTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.BooleanType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/CanonicalTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/CanonicalTypeNullTest.java index 769329872..54a56d768 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/CanonicalTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/CanonicalTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.CanonicalType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/CodeTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/CodeTypeNullTest.java index 894a576cb..93d640a96 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/CodeTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/CodeTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.CodeType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/DateTimeTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/DateTimeTypeNullTest.java index b4d2e17db..0a95c80de 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/DateTimeTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/DateTimeTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.DateTimeType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/DateTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/DateTypeNullTest.java index 6681a8995..5b4015d87 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/DateTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/DateTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.DateType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/DecimalTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/DecimalTypeNullTest.java index ca8881c54..6efbb92c3 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/DecimalTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/DecimalTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.DecimalType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/IdTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/IdTypeNullTest.java index b7680ac05..d91fbe21c 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/IdTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/IdTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.IdType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/InstantTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/InstantTypeNullTest.java index d9c5f0dce..b303ec222 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/InstantTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/InstantTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.InstantType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/IntegerTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/IntegerTypeNullTest.java index 3fe977703..58555803b 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/IntegerTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/IntegerTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.IntegerType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/MarkdownTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/MarkdownTypeNullTest.java index 1b2013d48..28e9a1848 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/MarkdownTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/MarkdownTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.MarkdownType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/OidTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/OidTypeNullTest.java index 3ef231f5c..d02a9f483 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/OidTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/OidTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.OidType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/PositiveIntTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/PositiveIntTypeNullTest.java index 7dab39822..3cdbff26b 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/PositiveIntTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/PositiveIntTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.PositiveIntType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/StringTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/StringTypeNullTest.java index abcf5ceeb..4176484a6 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/StringTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/StringTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.StringType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/TimeTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/TimeTypeNullTest.java index a5b7ac07b..34355d75c 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/TimeTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/TimeTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.TimeType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UnsignedIntTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UnsignedIntTypeNullTest.java index 328f8f332..db28b9aec 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UnsignedIntTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UnsignedIntTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.UnsignedIntType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UriTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UriTypeNullTest.java index 5f11135cf..695b2d81c 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UriTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UriTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.UriType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UrlTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UrlTypeNullTest.java index dbf171c7c..9c9e8efde 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UrlTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UrlTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.UrlType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UuidTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UuidTypeNullTest.java index 51ac87cfd..2f2534211 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UuidTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UuidTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.UuidType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/FHIRPathTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/FHIRPathTests.java index 7fe3a1645..2b8ef374d 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/FHIRPathTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/FHIRPathTests.java @@ -25,7 +25,6 @@ import org.hl7.fhir.r5.model.Quantity; import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.model.TypeDetails; import org.hl7.fhir.r5.model.ValueSet; -import org.hl7.fhir.r5.test.FHIRPathTests.TestResultType; import org.hl7.fhir.r5.test.utils.TestingUtilities; import org.hl7.fhir.r5.utils.FHIRPathEngine; import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/NarrativeGenerationTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/NarrativeGenerationTests.java index f2e3ee3df..2a25ab3de 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/NarrativeGenerationTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/NarrativeGenerationTests.java @@ -1,51 +1,35 @@ package org.hl7.fhir.r5.test; -import java.io.BufferedReader; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.FileReader; import java.io.IOException; import java.time.ZoneId; -import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; import java.util.stream.Stream; import javax.xml.parsers.ParserConfigurationException; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.SystemUtils; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRFormatError; import org.hl7.fhir.r5.context.IWorkerContext; import org.hl7.fhir.r5.elementmodel.Manager; import org.hl7.fhir.r5.elementmodel.Manager.FhirFormat; -import org.hl7.fhir.r5.formats.IParser.OutputStyle; import org.hl7.fhir.r5.formats.JsonParser; import org.hl7.fhir.r5.formats.XmlParser; import org.hl7.fhir.r5.model.Base; -import org.hl7.fhir.r5.model.DomainResource; -import org.hl7.fhir.r5.model.Questionnaire; import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.renderers.RendererFactory; -import org.hl7.fhir.r5.renderers.ResourceRenderer; import org.hl7.fhir.r5.renderers.utils.ElementWrappers; import org.hl7.fhir.r5.renderers.utils.RenderingContext; import org.hl7.fhir.r5.renderers.utils.RenderingContext.ITypeParser; -import org.hl7.fhir.r5.renderers.utils.RenderingContext.QuestionnaireRendererMode; import org.hl7.fhir.r5.renderers.utils.RenderingContext.ResourceRendererMode; -import org.hl7.fhir.r5.test.NarrativeGenerationTests.TestTypeParser; import org.hl7.fhir.r5.test.utils.TestingUtilities; import org.hl7.fhir.utilities.TerminologyServiceOptions; import org.hl7.fhir.utilities.TextFile; import org.hl7.fhir.utilities.xhtml.XhtmlComposer; import org.hl7.fhir.utilities.xhtml.XhtmlNode; -import org.hl7.fhir.utilities.xhtml.XhtmlParser; import org.hl7.fhir.utilities.xml.XMLUtil; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/NarrativeGeneratorTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/NarrativeGeneratorTests.java index e48ff819e..4a92d9c93 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/NarrativeGeneratorTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/NarrativeGeneratorTests.java @@ -5,11 +5,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.time.ZoneId; -import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; -import java.time.format.FormatStyle; -import java.util.Locale; -import java.util.TimeZone; import org.hl7.fhir.exceptions.DefinitionException; import org.hl7.fhir.exceptions.FHIRException; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ProfileUtilitiesTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ProfileUtilitiesTests.java index d1bf6def0..fcaca80cb 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ProfileUtilitiesTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ProfileUtilitiesTests.java @@ -1,5 +1,8 @@ package org.hl7.fhir.r5.test; +import java.util.ArrayList; +import java.util.List; + import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.r5.conformance.ProfileUtilities; import org.hl7.fhir.r5.model.Base; @@ -13,9 +16,6 @@ import org.hl7.fhir.utilities.validation.ValidationMessage; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import java.util.ArrayList; -import java.util.List; - public class ProfileUtilitiesTests { // /** diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceCopyTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceCopyTests.java index e333626d1..9e702ccb7 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceCopyTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceCopyTests.java @@ -1,5 +1,7 @@ package org.hl7.fhir.r5.test; +import java.io.IOException; + import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.r5.model.Enumerations; import org.hl7.fhir.r5.model.Extension; @@ -7,8 +9,6 @@ import org.hl7.fhir.r5.model.Observation; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import java.io.IOException; - public class ResourceCopyTests { diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceRoundTripTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceRoundTripTests.java index a3620607b..f69340efb 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceRoundTripTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceRoundTripTests.java @@ -19,7 +19,6 @@ import org.hl7.fhir.r5.formats.IParser.OutputStyle; import org.hl7.fhir.r5.formats.JsonParser; import org.hl7.fhir.r5.formats.XmlParser; import org.hl7.fhir.r5.model.Bundle; -import org.hl7.fhir.r5.model.DateTimeType; import org.hl7.fhir.r5.model.DomainResource; import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.renderers.RendererFactory; @@ -27,7 +26,6 @@ import org.hl7.fhir.r5.renderers.utils.RenderingContext; import org.hl7.fhir.r5.renderers.utils.RenderingContext.ResourceRendererMode; import org.hl7.fhir.r5.test.utils.TestingUtilities; import org.hl7.fhir.r5.utils.EOperationOutcome; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; public class ResourceRoundTripTests { diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceTests.java index 1bdd2815f..f4d97151a 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceTests.java @@ -1,6 +1,8 @@ package org.hl7.fhir.r5.test; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/SnapShotGenerationTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/SnapShotGenerationTests.java index 8c06c149a..1d2c4c96f 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/SnapShotGenerationTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/SnapShotGenerationTests.java @@ -4,7 +4,6 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; -import java.io.InputStream; import java.util.ArrayList; import java.util.List; import java.util.stream.Stream; @@ -19,28 +18,27 @@ import org.hl7.fhir.exceptions.FHIRFormatError; import org.hl7.fhir.exceptions.PathEngineException; import org.hl7.fhir.r5.conformance.ProfileUtilities; import org.hl7.fhir.r5.conformance.ProfileUtilities.ProfileKnowledgeProvider; -import org.hl7.fhir.r5.context.IWorkerContext.IContextResourceLoader; +import org.hl7.fhir.r5.context.TestPackageLoader; import org.hl7.fhir.r5.formats.IParser.OutputStyle; import org.hl7.fhir.r5.formats.JsonParser; import org.hl7.fhir.r5.formats.XmlParser; import org.hl7.fhir.r5.model.Base; -import org.hl7.fhir.r5.model.Bundle; import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent; import org.hl7.fhir.r5.model.ExpressionNode.CollectionStatus; import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.model.StructureDefinition; import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind; import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule; +import org.hl7.fhir.r5.model.TypeDetails; +import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.renderers.RendererFactory; import org.hl7.fhir.r5.renderers.utils.RenderingContext; import org.hl7.fhir.r5.renderers.utils.RenderingContext.ResourceRendererMode; -import org.hl7.fhir.r5.model.TypeDetails; -import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.test.utils.TestingUtilities; import org.hl7.fhir.r5.utils.FHIRPathEngine; import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext; -import org.hl7.fhir.r5.utils.validation.IResourceValidator; import org.hl7.fhir.r5.utils.XVerExtensionManager; +import org.hl7.fhir.r5.utils.validation.IResourceValidator; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.npm.CommonPackages; import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager; @@ -60,41 +58,6 @@ import org.xml.sax.SAXException; public class SnapShotGenerationTests { - public class TestLoader implements IContextResourceLoader { - - private String[] types; - - public TestLoader(String[] types) { - this.types = types; - } - - @Override - public Bundle loadBundle(InputStream stream, boolean isJson) throws FHIRException, IOException { - return null; - } - - @Override - public Resource loadResource(InputStream stream, boolean isJson) throws FHIRException, IOException { - return null; - } - - @Override - public String[] getTypes() { - return types; - } - - @Override - public String getResourcePath(Resource resource) { - return null; - } - - @Override - public IContextResourceLoader getNewLoader(NpmPackage npm) { - return this; - } - - } - public enum TestFetchMode { INPUT, OUTPUT, @@ -549,7 +512,7 @@ public class SnapShotGenerationTests { pu.setIds(test.getSource(), false); if (!TestingUtilities.context().hasPackage(CommonPackages.ID_XVER, CommonPackages.VER_XVER)) { NpmPackage npm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION).loadPackage(CommonPackages.ID_XVER, CommonPackages.VER_XVER); - TestingUtilities.context().loadFromPackage(npm, new TestLoader(new String[]{"StructureDefinition"}), new String[]{"StructureDefinition"}); + TestingUtilities.context().loadFromPackage(npm, new TestPackageLoader(new String[]{"StructureDefinition"}), new String[]{"StructureDefinition"}); } pu.setXver(new XVerExtensionManager(TestingUtilities.context())); if (test.isSort()) { diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/StructureMapUtilitiesTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/StructureMapUtilitiesTest.java index 65602d1eb..5cc6871c8 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/StructureMapUtilitiesTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/StructureMapUtilitiesTest.java @@ -1,5 +1,8 @@ package org.hl7.fhir.r5.test; +import java.io.IOException; +import java.util.List; + import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.r5.context.SimpleWorkerContext; import org.hl7.fhir.r5.model.Base; @@ -7,17 +10,14 @@ import org.hl7.fhir.r5.model.Coding; import org.hl7.fhir.r5.model.StructureMap; import org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetComponent; import org.hl7.fhir.r5.test.utils.TestingUtilities; -import org.hl7.fhir.r5.utils.structuremap.StructureMapUtilities; import org.hl7.fhir.r5.utils.structuremap.ITransformerServices; +import org.hl7.fhir.r5.utils.structuremap.StructureMapUtilities; import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager; import org.hl7.fhir.utilities.npm.ToolsVersion; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import java.io.IOException; -import java.util.List; - public class StructureMapUtilitiesTest implements ITransformerServices { static private SimpleWorkerContext context; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/VocabTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/VocabTests.java new file mode 100644 index 000000000..0cb27a1b4 --- /dev/null +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/VocabTests.java @@ -0,0 +1,162 @@ +package org.hl7.fhir.r5.test; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Stream; + +import javax.xml.parsers.ParserConfigurationException; + +import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.exceptions.FHIRFormatError; +import org.hl7.fhir.r5.context.IWorkerContext; +import org.hl7.fhir.r5.context.TestPackageLoader; +import org.hl7.fhir.r5.formats.IParser.OutputStyle; +import org.hl7.fhir.r5.formats.JsonParser; +import org.hl7.fhir.r5.formats.XmlParser; +import org.hl7.fhir.r5.model.Base; +import org.hl7.fhir.r5.model.Resource; +import org.hl7.fhir.r5.model.ValueSet; +import org.hl7.fhir.r5.renderers.utils.RenderingContext.ITypeParser; +import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome; +import org.hl7.fhir.r5.test.utils.TestingUtilities; +import org.hl7.fhir.utilities.TextFile; +import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager; +import org.hl7.fhir.utilities.npm.NpmPackage; +import org.hl7.fhir.utilities.npm.ToolsVersion; +import org.hl7.fhir.utilities.xml.XMLUtil; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.xml.sax.SAXException; + +public class VocabTests { + + public enum TestType { + Expansion; + } + + public class TestTypeParser implements ITypeParser { + + @Override + public Base parseType(String xml, String type) throws FHIRFormatError, IOException, FHIRException { + return new org.hl7.fhir.r5.formats.XmlParser().parseType(xml, type); + } + } + + private static IWorkerContext context; + + public static class TestDetails { + private String id; + private Map parameters = new HashMap<>(); + private String source; + private String target; + private TestType type; + + + public TestDetails(Element test) { + super(); + id = test.getAttribute("id"); + source = XMLUtil.getNamedChildValue(test, "source"); + target = XMLUtil.getNamedChildValue(test, "target"); + type = TestType.Expansion; + } + + public String getId() { + return id; + } + + public Map getParameters() { + return parameters; + } + + public String getSource() { + return source; + } + + public String getTarget() { + return target; + } + + public TestType getType() { + return type; + } + + } + + public static Stream data() throws ParserConfigurationException, IOException, FHIRFormatError, SAXException { + Document tests = XMLUtil.parseToDom(TestingUtilities.loadTestResource("r5", "vocab", "manifest.xml")); + Element test = XMLUtil.getFirstChild(tests.getDocumentElement()); + List objects = new ArrayList<>(); + while (test != null && test.getNodeName().equals("test")) { + TestDetails t = new TestDetails(test); + objects.add(Arguments.of(t.getId(), t)); + test = XMLUtil.getNextSibling(test); + } + return objects.stream(); + } + + @BeforeAll + public static void setUp() throws FileNotFoundException, FHIRException, IOException { + context = TestingUtilities.context(); + if (!context.hasPackage("hl7.terminology", null)) { + + NpmPackage utg = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION).loadPackage("hl7.terminology"); + System.out.println("Loading THO: "+utg.name()+"#"+utg.version()); + context.loadFromPackage(utg, new TestPackageLoader(new String[]{"CodeSystem", "ValueSet"})); + } + } + + @ParameterizedTest(name = "{index}: file {0}") + @MethodSource("data") + public void test(String id, TestDetails test) throws Exception { + + Resource source; + if (test.getSource().endsWith(".json")) { + source = (Resource) new JsonParser().parse(TestingUtilities.loadTestResourceStream("r5", "vocab", test.getSource())); + } else { + source = (Resource) new XmlParser().parse(TestingUtilities.loadTestResourceStream("r5", "vocab", test.getSource())); + } + + Resource target; + if (test.getTarget().endsWith(".json")) { + target = (Resource) new JsonParser().parse(TestingUtilities.loadTestResourceStream("r5", "vocab", test.getTarget())); + } else { + target = (Resource) new XmlParser().parse(TestingUtilities.loadTestResourceStream("r5", "vocab", test.getTarget())); + } + + if (test.getType() == TestType.Expansion) { + testExpansion(test, (ValueSet) source, (ValueSet) target); + } else { + Assertions.fail("not done yet"); + } + + + } + + private void testExpansion(TestDetails test, ValueSet sourceVS, ValueSet targetVS) throws Exception { + ValueSetExpansionOutcome outcome = context.expandVS(sourceVS, false, test.getParameters().containsKey("hierarchical")); + if (outcome.isOk()) { + outcome.getValueset().getExpansion().setIdentifier(null); + outcome.getValueset().getExpansion().setTimestamp(null); + String target = new XmlParser().setOutputStyle(OutputStyle.PRETTY).composeString(targetVS); + String output = new XmlParser().setOutputStyle(OutputStyle.PRETTY).composeString(outcome.getValueset()); + String tfn = TestingUtilities.tempFile("vocab", test.getId() + ".target.html"); + String ofn = TestingUtilities.tempFile("vocab", test.getId() + ".output.html"); + TextFile.stringToFile(target, tfn); + TextFile.stringToFile(output, ofn); + String msg = TestingUtilities.checkXMLIsSame(ofn, tfn); + Assertions.assertTrue(msg == null, "Output does not match expected: "+msg); + } else { + Assertions.fail("Expansion Failed: "+outcome.getError()); + } + } + +} \ No newline at end of file diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/FHIRLexerTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/FHIRLexerTest.java index 771c53348..73637fcde 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/FHIRLexerTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/FHIRLexerTest.java @@ -4,8 +4,6 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; - class FHIRLexerTest { @Test @DisplayName("Test that a 'null' current value returns 'false' when FHIRLexer.isConstant() is called, and not NPE.") diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/FHIRToolingClientTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/FHIRToolingClientTest.java index cc352cbc1..66370d072 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/FHIRToolingClientTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/FHIRToolingClientTest.java @@ -1,9 +1,22 @@ package org.hl7.fhir.r5.utils.client; -import okhttp3.Headers; -import okhttp3.Request; -import okhttp3.internal.http2.Header; -import org.hl7.fhir.r5.model.*; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Arrays; + +import org.hl7.fhir.r5.model.Bundle; +import org.hl7.fhir.r5.model.CapabilityStatement; +import org.hl7.fhir.r5.model.Enumerations; +import org.hl7.fhir.r5.model.IdType; +import org.hl7.fhir.r5.model.Observation; +import org.hl7.fhir.r5.model.OperationOutcome; +import org.hl7.fhir.r5.model.Patient; +import org.hl7.fhir.r5.model.Quantity; +import org.hl7.fhir.r5.model.Reference; +import org.hl7.fhir.r5.model.Resource; +import org.hl7.fhir.r5.model.TerminologyCapabilities; import org.hl7.fhir.r5.utils.client.network.Client; import org.hl7.fhir.r5.utils.client.network.ResourceRequest; import org.junit.jupiter.api.Assertions; @@ -13,11 +26,9 @@ import org.mockito.ArgumentCaptor; import org.mockito.ArgumentMatchers; import org.mockito.Mockito; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Arrays; +import okhttp3.Headers; +import okhttp3.Request; +import okhttp3.internal.http2.Header; class FHIRToolingClientTest { diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/ClientHeadersTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/ClientHeadersTest.java index 239c67069..7f102bf73 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/ClientHeadersTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/ClientHeadersTest.java @@ -1,14 +1,15 @@ package org.hl7.fhir.r5.utils.client.network; -import okhttp3.internal.http2.Header; +import java.util.Arrays; +import java.util.List; + import org.hl7.fhir.exceptions.FHIRException; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import java.util.Arrays; -import java.util.List; +import okhttp3.internal.http2.Header; class ClientHeadersTest { diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/ClientTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/ClientTest.java index cfca89294..a9e5657ae 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/ClientTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/ClientTest.java @@ -1,21 +1,30 @@ package org.hl7.fhir.r5.utils.client.network; -import okhttp3.HttpUrl; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; -import okhttp3.mockwebserver.RecordedRequest; -import org.hl7.fhir.r5.context.HTMLClientLogger; -import org.hl7.fhir.r5.formats.JsonParser; -import org.hl7.fhir.r5.model.*; -import org.junit.jupiter.api.*; -import org.mockito.Mockito; - import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.util.Random; import java.util.concurrent.TimeUnit; +import org.hl7.fhir.r5.context.HTMLClientLogger; +import org.hl7.fhir.r5.formats.JsonParser; +import org.hl7.fhir.r5.model.Address; +import org.hl7.fhir.r5.model.Enumerations; +import org.hl7.fhir.r5.model.HumanName; +import org.hl7.fhir.r5.model.Patient; +import org.hl7.fhir.r5.model.Resource; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.mockito.Mockito; + +import okhttp3.HttpUrl; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; + @TestInstance(TestInstance.Lifecycle.PER_CLASS) class ClientTest { diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/FhirRequestBuilderTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/FhirRequestBuilderTest.java index f7723339a..b56909bdd 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/FhirRequestBuilderTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/FhirRequestBuilderTest.java @@ -1,17 +1,15 @@ package org.hl7.fhir.r5.utils.client.network; -import okhttp3.Headers; -import okhttp3.OkHttpClient; -import okhttp3.Request; +import java.util.List; +import java.util.Map; + import org.hl7.fhir.r5.model.OperationOutcome; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import java.util.HashMap; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import okhttp3.Headers; +import okhttp3.Request; class FhirRequestBuilderTest { diff --git a/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/UtilitiesTest.java b/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/UtilitiesTest.java index dc403a90e..c4486ac72 100644 --- a/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/UtilitiesTest.java +++ b/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/UtilitiesTest.java @@ -39,7 +39,11 @@ class UtilitiesTest { @Test @DisplayName("Test Utilities.path maps temp directory correctly") public void testTempDirPath() throws IOException { - Assertions.assertEquals(Utilities.path("[tmp]", TEST_TXT), getTempDirectory() + TEST_TXT); + if (ToolGlobalSettings.hasTempPath()) { + Assertions.assertEquals(Utilities.path("[tmp]", TEST_TXT), ToolGlobalSettings.getTempPath() +File.separator+ TEST_TXT); + } else { + Assertions.assertEquals(Utilities.path("[tmp]", TEST_TXT), getTempDirectory() + TEST_TXT); + } } @Test diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/BundleValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/BundleValidator.java index 2ab7ab597..68238431a 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/BundleValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/BundleValidator.java @@ -27,7 +27,7 @@ import org.hl7.fhir.validation.instance.utils.IndexedElement; import org.hl7.fhir.validation.instance.utils.NodeStack; import org.hl7.fhir.validation.instance.utils.ValidatorHostContext; -public class BundleValidator extends BaseValidator{ +public class BundleValidator extends BaseValidator { public final static String URI_REGEX3 = "((http|https)://([A-Za-z0-9\\\\\\.\\:\\%\\$]*\\/)*)?(Account|ActivityDefinition|AllergyIntolerance|AdverseEvent|Appointment|AppointmentResponse|AuditEvent|Basic|Binary|BodySite|Bundle|CapabilityStatement|CarePlan|CareTeam|ChargeItem|Claim|ClaimResponse|ClinicalImpression|CodeSystem|Communication|CommunicationRequest|CompartmentDefinition|Composition|ConceptMap|Condition (aka Problem)|Consent|Contract|Coverage|DataElement|DetectedIssue|Device|DeviceComponent|DeviceMetric|DeviceRequest|DeviceUseStatement|DiagnosticReport|DocumentManifest|DocumentReference|EligibilityRequest|EligibilityResponse|Encounter|Endpoint|EnrollmentRequest|EnrollmentResponse|EpisodeOfCare|ExpansionProfile|ExplanationOfBenefit|FamilyMemberHistory|Flag|Goal|GraphDefinition|Group|GuidanceResponse|HealthcareService|ImagingManifest|ImagingStudy|Immunization|ImmunizationRecommendation|ImplementationGuide|Library|Linkage|List|Location|Measure|MeasureReport|Media|Medication|MedicationAdministration|MedicationDispense|MedicationRequest|MedicationStatement|MessageDefinition|MessageHeader|NamingSystem|NutritionOrder|Observation|OperationDefinition|OperationOutcome|Organization|Parameters|Patient|PaymentNotice|PaymentReconciliation|Person|PlanDefinition|Practitioner|PractitionerRole|Procedure|ProcedureRequest|ProcessRequest|ProcessResponse|Provenance|Questionnaire|QuestionnaireResponse|ReferralRequest|RelatedPerson|RequestGroup|ResearchStudy|ResearchSubject|RiskAssessment|Schedule|SearchParameter|Sequence|ServiceDefinition|Slot|Specimen|StructureDefinition|StructureMap|Subscription|Substance|SupplyDelivery|SupplyRequest|Task|TestScript|TestReport|ValueSet|VisionPrescription)\\/[A-Za-z0-9\\-\\.]{1,64}(\\/_history\\/[A-Za-z0-9\\-\\.]{1,64})?"; private String serverBase; private InstanceValidator validator; diff --git a/pom.xml b/pom.xml index 0c6484eb3..264c9fa92 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 5.4.0 - 1.1.89 + 1.1.90-SNAPSHOT 5.7.1 1.7.1 3.0.0-M5 From 92160a844953e1253cc0b706f6f1b1f7c053464a Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Fri, 25 Feb 2022 13:09:04 +1100 Subject: [PATCH 10/50] set up release --- RELEASE_NOTES.md | 4 ++-- pom.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 7b06c6ab5..9e749e05c 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,7 +1,7 @@ ## Validator Changes -* no changes +* No changes ## Other code changes -* no changes \ No newline at end of file +* fix expansions where inactive = false (was wrongly including inactive codes) \ No newline at end of file diff --git a/pom.xml b/pom.xml index 264c9fa92..8645fc553 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 5.4.0 - 1.1.90-SNAPSHOT + 1.1.90 5.7.1 1.7.1 3.0.0-M5 From 474fc014c426137a0454b60051c64f34e8bb7b0c Mon Sep 17 00:00:00 2001 From: Mark Iantorno Date: Fri, 25 Feb 2022 02:36:33 +0000 Subject: [PATCH 11/50] Updating test case dependency to v1.1.90 ***NO_CI*** --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0c6484eb3..8645fc553 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 5.4.0 - 1.1.89 + 1.1.90 5.7.1 1.7.1 3.0.0-M5 From baac4ac1a8ac581b41d84833a7a39debe1dea1f6 Mon Sep 17 00:00:00 2001 From: dotasek Date: Fri, 25 Feb 2022 11:25:27 -0500 Subject: [PATCH 12/50] Fix + initial test --- .../hl7/fhir/dstu3/utils/FHIRPathEngine.java | 2 +- .../hl7/fhir/dstu3/utils/FhirPathTests.java | 49 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/utils/FhirPathTests.java diff --git a/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/utils/FHIRPathEngine.java b/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/utils/FHIRPathEngine.java index 7794fc858..54191747f 100644 --- a/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/utils/FHIRPathEngine.java +++ b/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/utils/FHIRPathEngine.java @@ -2219,7 +2219,7 @@ public class FHIRPathEngine { if (!Utilities.noString(f)) { - if (exp.getParameters().size() != 2) { + if (exp.getParameters().size() == 2) { String t = convertToString(execute(context, focus, exp.getParameters().get(0), true)); String r = convertToString(execute(context, focus, exp.getParameters().get(1), true)); diff --git a/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/utils/FhirPathTests.java b/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/utils/FhirPathTests.java new file mode 100644 index 000000000..800668cc6 --- /dev/null +++ b/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/utils/FhirPathTests.java @@ -0,0 +1,49 @@ +package org.hl7.fhir.dstu3.utils; + + +import org.hl7.fhir.dstu3.context.IWorkerContext; +import org.hl7.fhir.dstu3.model.Base; +import org.hl7.fhir.dstu3.model.ExpressionNode; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +public class FhirPathTests { + + @Mock + IWorkerContext iWorkerContext; + + @Mock + Object appContext; + + @Mock + Base resource; + + @Mock + Base base; + + @Test + public void testFuncReplaceParamSize() { + FHIRPathEngine engine = Mockito.spy(new FHIRPathEngine(iWorkerContext)); + + ExpressionNode expressionNode = new ExpressionNode(0); + expressionNode.setKind(ExpressionNode.Kind.Function); + expressionNode.setFunction(ExpressionNode.Function.Replace); + + ExpressionNode expressionNodeB = new ExpressionNode(1); + expressionNodeB.setKind(ExpressionNode.Kind.Function); + expressionNodeB.setFunction(ExpressionNode.Function.Empty); + + ExpressionNode expressionNodeC = new ExpressionNode(2); + expressionNodeC.setKind(ExpressionNode.Kind.Function); + expressionNodeC.setFunction(ExpressionNode.Function.Empty); + + expressionNode.getParameters().add(expressionNodeB); + expressionNode.getParameters().add(expressionNodeC); + engine.evaluate(appContext, resource, base, expressionNode); + + } +} \ No newline at end of file From f2e9f1247be9e581a3580303db7b5c22bb13b442 Mon Sep 17 00:00:00 2001 From: dotasek Date: Fri, 25 Feb 2022 13:11:24 -0500 Subject: [PATCH 13/50] Add assertions to test case --- .../org/hl7/fhir/dstu3/utils/FhirPathTests.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/utils/FhirPathTests.java b/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/utils/FhirPathTests.java index 800668cc6..f595e238a 100644 --- a/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/utils/FhirPathTests.java +++ b/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/utils/FhirPathTests.java @@ -1,15 +1,22 @@ package org.hl7.fhir.dstu3.utils; - import org.hl7.fhir.dstu3.context.IWorkerContext; import org.hl7.fhir.dstu3.model.Base; import org.hl7.fhir.dstu3.model.ExpressionNode; +import org.hl7.fhir.dstu3.model.StringType; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.times; + @ExtendWith(MockitoExtension.class) public class FhirPathTests { @@ -43,7 +50,12 @@ public class FhirPathTests { expressionNode.getParameters().add(expressionNodeB); expressionNode.getParameters().add(expressionNodeC); - engine.evaluate(appContext, resource, base, expressionNode); + List result = engine.evaluate(appContext, resource, base, expressionNode); + assertEquals(1, result.size()); + Base onlyResult = result.get(0); + assertTrue(onlyResult instanceof StringType); + assertEquals("base", ((StringType)result.get(0)).asStringValue()); + Mockito.verify(engine, times(2)).convertToString(any()); } } \ No newline at end of file From f32895da6717e780635af89d1780a8cbaeb59c70 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Sat, 26 Feb 2022 06:21:14 +1100 Subject: [PATCH 14/50] Fix ValueSet presentation --- .../main/java/org/hl7/fhir/r5/renderers/ValueSetRenderer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ValueSetRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ValueSetRenderer.java index 04df5e4c1..3e07a1819 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ValueSetRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ValueSetRenderer.java @@ -213,7 +213,7 @@ public class ValueSetRenderer extends TerminologyRenderer { XhtmlNode t = x.table( "codes"); XhtmlNode tr = t.tr(); if (doLevel) - tr.td().b().tx("Lvl"); + tr.td().b().tx("Level"); tr.td().attribute("style", "white-space:nowrap").b().tx("Code"); if (doSystem) tr.td().b().tx("System"); @@ -242,7 +242,7 @@ public class ValueSetRenderer extends TerminologyRenderer { addMapHeaders(tr, maps); for (ValueSetExpansionContainsComponent c : vs.getExpansion().getContains()) { - addExpansionRowToTable(t, c, 0, doLevel, doSystem, doDefinition, maps, allCS, langs, doLangs); + addExpansionRowToTable(t, c, 1, doLevel, doSystem, doDefinition, maps, allCS, langs, doLangs); } // now, build observed languages From c918f724eef527a369f6b320358e1b68ddf66deb Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Sat, 26 Feb 2022 06:22:42 +1100 Subject: [PATCH 15/50] fix problem missing profiles on references in discriminators --- .../org/hl7/fhir/r5/utils/FHIRPathEngine.java | 24 +++++++++++++++---- .../instance/InstanceValidator.java | 10 +++++--- .../test/resources/txCache/3.0.2/snomed.cache | 9 +++++++ 3 files changed, 36 insertions(+), 7 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 1239685a8..7bbee529c 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 @@ -235,6 +235,13 @@ public class FHIRPathEngine { } return res; } + public boolean hasType(String tn) { + if (type != null) { + return tn.equals(type); + } else { + return element.hasType(tn); + } + } } private IWorkerContext worker; private IEvaluationContext hostServices; @@ -5472,7 +5479,7 @@ public class FHIRPathEngine { * @throws PathEngineException * @throws DefinitionException */ - public TypedElementDefinition evaluateDefinition(ExpressionNode expr, StructureDefinition profile, TypedElementDefinition element, StructureDefinition source) throws DefinitionException { + public TypedElementDefinition evaluateDefinition(ExpressionNode expr, StructureDefinition profile, TypedElementDefinition element, StructureDefinition source, boolean dontWalkIntoReferences) throws DefinitionException { StructureDefinition sd = profile; TypedElementDefinition focus = null; boolean okToNotResolve = false; @@ -5584,10 +5591,19 @@ public class FHIRPathEngine { } else { throw makeException(expr, I18nConstants.FHIRPATH_DISCRIMINATOR_CANT_FIND, expr.toString(), source.getUrl(), element.getElement().getId(), profile.getUrl()); } - } else if (expr.getInner() == null) { - return focus; } else { - return evaluateDefinition(expr.getInner(), sd, focus, profile); + // gdg 26-02-2022. If we're walking towards a resolve() and we're on a reference, and we try to walk into the reference + // then we don't do that. .resolve() is allowed on the Reference.reference, but the target of the reference will be defined + // on the Reference, not the reference.reference. + ExpressionNode next = expr.getInner(); + if (dontWalkIntoReferences && focus.hasType("Reference") && next != null && next.getKind() == Kind.Name && next.getName().equals("reference")) { + next = next.getInner(); + } + if (next == null) { + return focus; + } else { + return evaluateDefinition(next, sd, focus, profile, dontWalkIntoReferences); + } } } diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java index fdc6782d5..54c748c7a 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java @@ -3405,13 +3405,17 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat return elements; } + boolean dontFollowReference = false; + if (removeResolve) { // if we're doing profile slicing, we don't want to walk into the last resolve.. we need the profile on the source not the target if (discriminator.equals("resolve()")) { elements.add(element); return elements; } - if (discriminator.endsWith(".resolve()")) + if (discriminator.endsWith(".resolve()")) { discriminator = discriminator.substring(0, discriminator.length() - 10); + dontFollowReference = true; + } } TypedElementDefinition ted = null; @@ -3424,7 +3428,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat throw new FHIRException(context.formatMessage(I18nConstants.DISCRIMINATOR_BAD_PATH, e.getMessage(), fp), e); } long t2 = System.nanoTime(); - ted = fpe.evaluateDefinition(expr, profile, new TypedElementDefinition(element), srcProfile); + ted = fpe.evaluateDefinition(expr, profile, new TypedElementDefinition(element), srcProfile, dontFollowReference); timeTracker.sd(t2); if (ted != null) elements.add(ted.getElement()); @@ -3449,7 +3453,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat } expr = fpe.parse(fp); t2 = System.nanoTime(); - ted = fpe.evaluateDefinition(expr, profile, new TypedElementDefinition(element), srcProfile); + ted = fpe.evaluateDefinition(expr, profile, new TypedElementDefinition(element), srcProfile, dontFollowReference); timeTracker.sd(t2); if (ted != null) elements.add(ted.getElement()); diff --git a/org.hl7.fhir.validation/src/test/resources/txCache/3.0.2/snomed.cache b/org.hl7.fhir.validation/src/test/resources/txCache/3.0.2/snomed.cache index 054313479..4d4ad75b9 100644 --- a/org.hl7.fhir.validation/src/test/resources/txCache/3.0.2/snomed.cache +++ b/org.hl7.fhir.validation/src/test/resources/txCache/3.0.2/snomed.cache @@ -343,3 +343,12 @@ v: { "system" : "http://snomed.info/sct" } ------------------------------------------------------------------------------------- +{"code" : { + "system" : "http://snomed.info/sct", + "code" : "11181000146103" +}, "valueSet" :null, "lang":"null", "useServer":"true", "useClient":"true", "guessSystem":"false", "valueSetMode":"ALL_CHECKS", "versionFlexible":"false"}#### +v: { + "severity" : "error", + "error" : "Unable to find code 11181000146103 in http://snomed.info/sct (version http://snomed.info/sct/900000000000207008/version/20210731); The code \"11181000146103\" is not valid in the system http://snomed.info/sct; The code provided (http://snomed.info/sct#11181000146103) is not valid in the value set 'All codes known to the system' (from http://tx.fhir.org/r3)" +} +------------------------------------------------------------------------------------- From a5060d9475d0b2c828433fe60947196798dcb40f Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Sat, 26 Feb 2022 06:42:43 +1100 Subject: [PATCH 16/50] fix failing JUnit test --- .../main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 7bbee529c..2f2cbad89 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 @@ -239,7 +239,12 @@ public class FHIRPathEngine { if (type != null) { return tn.equals(type); } else { - return element.hasType(tn); + for (TypeRefComponent t : element.getType()) { + if (tn.equals(t.getCode())) { + return true; + } + } + return false; } } } From 6975397675cfef4dad9efea2af7717bb6a7196cf Mon Sep 17 00:00:00 2001 From: dotasek Date: Fri, 25 Feb 2022 15:36:04 -0500 Subject: [PATCH 17/50] Fix breaking SimpleWorkerContextTests --- .../java/org/hl7/fhir/r5/context/SimpleWorkerContextTests.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/SimpleWorkerContextTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/SimpleWorkerContextTests.java index cd951de9e..78d5dfa4d 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/SimpleWorkerContextTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/SimpleWorkerContextTests.java @@ -260,6 +260,7 @@ public class SimpleWorkerContextTests { ValueSet vs = new ValueSet(); vs.setStatus(Enumerations.PublicationStatus.ACTIVE); vs.setCompose(new ValueSet.ValueSetComposeComponent()); + vs.getCompose().setInactive(true); vs.getCompose().getInclude().add(inc); Mockito.doReturn(cacheToken).when(terminologyCache).generateExpandToken(argThat(new ValueSetMatcher(vs)),eq(true)); @@ -282,6 +283,7 @@ public class SimpleWorkerContextTests { ValueSet vs = new ValueSet(); vs.setStatus(Enumerations.PublicationStatus.ACTIVE); vs.setCompose(new ValueSet.ValueSetComposeComponent()); + vs.getCompose().setInactive(true); vs.getCompose().getInclude().add(inc); Mockito.doReturn(cacheToken).when(terminologyCache).generateExpandToken(argThat(new ValueSetMatcher(vs)),eq(true)); From df89ca1df30bf2de1009d3b4ab516bcced2c5224 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Sat, 26 Feb 2022 08:09:15 +1100 Subject: [PATCH 18/50] remdering work --- .../hl7/fhir/r5/renderers/DataRenderer.java | 74 ++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/DataRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/DataRenderer.java index 1af3777b9..28a8361f7 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/DataRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/DataRenderer.java @@ -30,6 +30,7 @@ import org.hl7.fhir.r5.context.IWorkerContext; import org.hl7.fhir.r5.context.IWorkerContext.ValidationResult; import org.hl7.fhir.r5.model.Address; import org.hl7.fhir.r5.model.Annotation; +import org.hl7.fhir.r5.model.BackboneType; import org.hl7.fhir.r5.model.Base; import org.hl7.fhir.r5.model.BaseDateTimeType; import org.hl7.fhir.r5.model.CanonicalResource; @@ -48,6 +49,7 @@ import org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem; import org.hl7.fhir.r5.model.DataType; import org.hl7.fhir.r5.model.DateTimeType; import org.hl7.fhir.r5.model.DateType; +import org.hl7.fhir.r5.model.ElementDefinition; import org.hl7.fhir.r5.model.Enumeration; import org.hl7.fhir.r5.model.Expression; import org.hl7.fhir.r5.model.Extension; @@ -357,8 +359,78 @@ public class DataRenderer extends Renderer { return value.primitiveValue(); } + // -- 6. General purpose extension rendering ---------------------------------------------- - // -- 5. Data type Rendering ---------------------------------------------- + public boolean hasRenderableExtensions(DataType element) { + for (Extension ext : element.getExtension()) { + if (canRender(ext)) { + return true; + } + } + return false; + } + + public boolean hasRenderableExtensions(BackboneType element) { + for (Extension ext : element.getExtension()) { + if (canRender(ext)) { + return true; + } + } + return element.hasModifierExtension(); + } + + private String getExtensionLabel(Extension ext) { + StructureDefinition sd = context.getWorker().fetchResource(StructureDefinition.class, ext.getUrl()); + if (sd != null && ext.getValue().isPrimitive() && sd.hasSnapshot()) { + for (ElementDefinition ed : sd.getSnapshot().getElement()) { + if (Utilities.existsInList(ed.getPath(), "Extension", "Extension.value") && ed.hasLabel()) { + return ed.getLabel(); + } + } + } + return null; + } + + private boolean canRender(Extension ext) { + return getExtensionLabel(ext) != null; + } + + public void renderExtensionsInList(XhtmlNode ul, DataType element) throws FHIRFormatError, DefinitionException, IOException { + for (Extension ext : element.getExtension()) { + if (canRender(ext)) { + String lbl = getExtensionLabel(ext); + XhtmlNode li = ul.li(); + li.tx(lbl); + render(li, ext.getValue()); + } + } + } + + public void renderExtensionsInList(XhtmlNode ul, BackboneType element) throws FHIRFormatError, DefinitionException, IOException { + for (Extension ext : element.getModifierExtension()) { + if (canRender(ext)) { + String lbl = getExtensionLabel(ext); + XhtmlNode li = ul.li(); + li = li.b(); + li.tx(lbl); + render(li, ext.getValue()); + } else { + // somehow have to do better than this + XhtmlNode li = ul.li(); + li.b().tx("WARNING: Unrenderable Modifier Extension!"); + } + } + for (Extension ext : element.getExtension()) { + if (canRender(ext)) { + String lbl = getExtensionLabel(ext); + XhtmlNode li = ul.li(); + li.tx(lbl); + render(li, ext.getValue()); + } + } + } + + // -- 6. Data type Rendering ---------------------------------------------- public static String display(IWorkerContext context, DataType type) { return new DataRenderer(new RenderingContext(context, null, null, "http://hl7.org/fhir/R4", "", null, ResourceRendererMode.END_USER)).display(type); From 17bf21ecf85259a429d2805fe7eab430106211c2 Mon Sep 17 00:00:00 2001 From: markiantorno Date: Sat, 26 Feb 2022 04:42:17 +0000 Subject: [PATCH 19/50] Release: v5.6.36 ## Validator Changes * No changes ## Other code changes * fix expansions where inactive = false (was wrongly including inactive codes) ***NO_CI*** --- 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.r4b/pom.xml | 2 +- org.hl7.fhir.r5/pom.xml | 2 +- org.hl7.fhir.report/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 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/org.hl7.fhir.convertors/pom.xml b/org.hl7.fhir.convertors/pom.xml index b7e9b7c4b..0590ebdf3 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 - 5.6.36-SNAPSHOT + 5.6.36 ../pom.xml diff --git a/org.hl7.fhir.dstu2/pom.xml b/org.hl7.fhir.dstu2/pom.xml index 965bd6303..2e4c69bdb 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 - 5.6.36-SNAPSHOT + 5.6.36 ../pom.xml diff --git a/org.hl7.fhir.dstu2016may/pom.xml b/org.hl7.fhir.dstu2016may/pom.xml index 09ca59c33..90bde88c6 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 - 5.6.36-SNAPSHOT + 5.6.36 ../pom.xml diff --git a/org.hl7.fhir.dstu3/pom.xml b/org.hl7.fhir.dstu3/pom.xml index 955fa25a8..8fd2328d0 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 - 5.6.36-SNAPSHOT + 5.6.36 ../pom.xml diff --git a/org.hl7.fhir.r4/pom.xml b/org.hl7.fhir.r4/pom.xml index 3e994e138..cf8b2b689 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 - 5.6.36-SNAPSHOT + 5.6.36 ../pom.xml diff --git a/org.hl7.fhir.r4b/pom.xml b/org.hl7.fhir.r4b/pom.xml index 5dead0ec1..2e0009077 100644 --- a/org.hl7.fhir.r4b/pom.xml +++ b/org.hl7.fhir.r4b/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.6.36-SNAPSHOT + 5.6.36 ../pom.xml diff --git a/org.hl7.fhir.r5/pom.xml b/org.hl7.fhir.r5/pom.xml index 80d6e7ddb..44fc05cb0 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 - 5.6.36-SNAPSHOT + 5.6.36 ../pom.xml diff --git a/org.hl7.fhir.report/pom.xml b/org.hl7.fhir.report/pom.xml index 0f88a6e0c..776879077 100644 --- a/org.hl7.fhir.report/pom.xml +++ b/org.hl7.fhir.report/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.6.36-SNAPSHOT + 5.6.36 ../pom.xml diff --git a/org.hl7.fhir.utilities/pom.xml b/org.hl7.fhir.utilities/pom.xml index 1a29a4afc..65531a4e1 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 - 5.6.36-SNAPSHOT + 5.6.36 ../pom.xml diff --git a/org.hl7.fhir.validation.cli/pom.xml b/org.hl7.fhir.validation.cli/pom.xml index e0f1e65ec..b3b60ef45 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 - 5.6.36-SNAPSHOT + 5.6.36 ../pom.xml diff --git a/org.hl7.fhir.validation/pom.xml b/org.hl7.fhir.validation/pom.xml index 0a789daa7..58e5e4d2d 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 - 5.6.36-SNAPSHOT + 5.6.36 ../pom.xml diff --git a/pom.xml b/pom.xml index 8645fc553..a6c821a40 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ HAPI FHIR --> org.hl7.fhir.core - 5.6.36-SNAPSHOT + 5.6.36 pom From 4909286a4bc3bf73467f9815f3f2bb937ffced8e Mon Sep 17 00:00:00 2001 From: markiantorno Date: Sat, 26 Feb 2022 05:00:46 +0000 Subject: [PATCH 20/50] Updating version to: 5.6.37-SNAPSHOT and incrementing test cases dependency. --- RELEASE_NOTES.md | 4 ++-- 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.r4b/pom.xml | 2 +- org.hl7.fhir.r5/pom.xml | 2 +- org.hl7.fhir.report/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 +- 13 files changed, 14 insertions(+), 14 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 9e749e05c..7b06c6ab5 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,7 +1,7 @@ ## Validator Changes -* No changes +* no changes ## Other code changes -* fix expansions where inactive = false (was wrongly including inactive codes) \ No newline at end of file +* no changes \ No newline at end of file diff --git a/org.hl7.fhir.convertors/pom.xml b/org.hl7.fhir.convertors/pom.xml index 0590ebdf3..4a8f14076 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 - 5.6.36 + 5.6.37-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.dstu2/pom.xml b/org.hl7.fhir.dstu2/pom.xml index 2e4c69bdb..e31fd4a19 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 - 5.6.36 + 5.6.37-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.dstu2016may/pom.xml b/org.hl7.fhir.dstu2016may/pom.xml index 90bde88c6..7bb4e757d 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 - 5.6.36 + 5.6.37-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.dstu3/pom.xml b/org.hl7.fhir.dstu3/pom.xml index 8fd2328d0..f2da5a89d 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 - 5.6.36 + 5.6.37-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.r4/pom.xml b/org.hl7.fhir.r4/pom.xml index cf8b2b689..b5a55706f 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 - 5.6.36 + 5.6.37-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.r4b/pom.xml b/org.hl7.fhir.r4b/pom.xml index 2e0009077..5ed3f9ff0 100644 --- a/org.hl7.fhir.r4b/pom.xml +++ b/org.hl7.fhir.r4b/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.6.36 + 5.6.37-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.r5/pom.xml b/org.hl7.fhir.r5/pom.xml index 44fc05cb0..34bd8e422 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 - 5.6.36 + 5.6.37-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.report/pom.xml b/org.hl7.fhir.report/pom.xml index 776879077..0de887735 100644 --- a/org.hl7.fhir.report/pom.xml +++ b/org.hl7.fhir.report/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.6.36 + 5.6.37-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.utilities/pom.xml b/org.hl7.fhir.utilities/pom.xml index 65531a4e1..11840b91e 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 - 5.6.36 + 5.6.37-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.validation.cli/pom.xml b/org.hl7.fhir.validation.cli/pom.xml index b3b60ef45..be9782aed 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 - 5.6.36 + 5.6.37-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.validation/pom.xml b/org.hl7.fhir.validation/pom.xml index 58e5e4d2d..ba7b4fbde 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 - 5.6.36 + 5.6.37-SNAPSHOT ../pom.xml diff --git a/pom.xml b/pom.xml index a6c821a40..cfce9bbe8 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ HAPI FHIR --> org.hl7.fhir.core - 5.6.36 + 5.6.37-SNAPSHOT pom From 27732602e368d4c2667ffd96618a5ce283882297 Mon Sep 17 00:00:00 2001 From: dotasek Date: Tue, 1 Mar 2022 17:03:17 -0500 Subject: [PATCH 21/50] Extract package-id when default id unavailable --- .../main/java/org/hl7/fhir/utilities/npm/PackageClient.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/PackageClient.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/PackageClient.java index 35f3788b5..c8f492194 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/PackageClient.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/PackageClient.java @@ -222,6 +222,11 @@ public class PackageClient { version = v; fVersion = e.getAsJsonArray("fhir-version").get(0).getAsString(); url = JSONUtil.str(e, "url"); + + String npmPackage = JSONUtil.str(e, "package"); + if (npmPackage != null && id == null) { + id = npmPackage.substring(0, npmPackage.indexOf("#")); + } } } } From cb7cfe9141b2bcfecca16c34318af2a77e20b9f6 Mon Sep 17 00:00:00 2001 From: dotasek Date: Wed, 2 Mar 2022 09:43:41 -0500 Subject: [PATCH 22/50] Refactor for testing, add tests --- .../hl7/fhir/utilities/npm/PackageClient.java | 75 ++++++++++--------- .../fhir/utilities/npm/PackageClientTest.java | 44 +++++++++++ .../npm/PackageClient-baseTestCase.json | 16 ++++ .../npm/PackageClient-testCaseWithId.json | 17 +++++ 4 files changed, 116 insertions(+), 36 deletions(-) create mode 100644 org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/npm/PackageClientTest.java create mode 100644 org.hl7.fhir.utilities/src/test/resources/npm/PackageClient-baseTestCase.json create mode 100644 org.hl7.fhir.utilities/src/test/resources/npm/PackageClient-testCaseWithId.json diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/PackageClient.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/PackageClient.java index c8f492194..90914dc27 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/PackageClient.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/PackageClient.java @@ -16,7 +16,6 @@ import java.io.ByteArrayInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import java.net.URL; import java.util.ArrayList; import java.util.Collections; import java.util.Date; @@ -192,47 +191,51 @@ public class PackageClient { } } + protected PackageInfo getPackageInfoFromJSON(JsonObject o, String name, String canonical, String fhirVersion) { + String id = JSONUtil.str(o, "npm-name"); + String pname = JSONUtil.str(o, "name"); + String pcanonical = JSONUtil.str(o, "canonical"); + String description = JSONUtil.str(o, "description"); + boolean ok = true; + if (ok && !Utilities.noString(name)) { + ok = (pname != null && pname.contains(name)) || (description != null && description.contains(name)) || (id != null && id.contains(name)); + } + if (ok && !Utilities.noString(canonical)) { + ok = pcanonical.contains(canonical); + } + String version = null; + String fVersion = null; + String url = null; + + if (ok) { + // if we can find something... + for (JsonObject e : JSONUtil.objects(o, "editions")) { + if (fhirVersion == null || fhirVersion.equals(JSONUtil.str(e, "fhir-version"))) { + String v = JSONUtil.str(e, "ig-version"); + if (version == null || VersionUtilities.isThisOrLater(version, v)) { + version = v; + fVersion = e.getAsJsonArray("fhir-version").get(0).getAsString(); + url = JSONUtil.str(e, "url"); + + String npmPackage = JSONUtil.str(e, "package"); + if (npmPackage != null && id == null) { + id = npmPackage.substring(0, npmPackage.indexOf("#")); + } + } + } + } + } + return new PackageInfo(id, version, fVersion, description, url, pcanonical, address); + } public List listFromRegistry(String name, String canonical, String fhirVersion) throws IOException { List result = new ArrayList<>(); JsonObject packages = JsonTrackingParser.fetchJson("https://raw.githubusercontent.com/FHIR/ig-registry/master/fhir-ig-list.json?nocache=" + System.currentTimeMillis()); for (JsonObject o : JSONUtil.objects(packages, "guides")) { if (o.has("canonical")) { - String id = JSONUtil.str(o, "npm-name"); - String pname = JSONUtil.str(o, "name"); - String pcanonical = JSONUtil.str(o, "canonical"); - String description = JSONUtil.str(o, "description"); - boolean ok = true; - if (ok && !Utilities.noString(name)) { - ok = (pname != null && pname.contains(name)) || (description != null && description.contains(name)) || (id != null && id.contains(name)); - } - if (ok && !Utilities.noString(canonical)) { - ok = pcanonical.contains(canonical); - } - String version = null; - String fVersion = null; - String url = null; - - if (ok) { - // if we can find something... - for (JsonObject e : JSONUtil.objects(o, "editions")) { - if (fhirVersion == null || fhirVersion.equals(JSONUtil.str(e, "fhir-version"))) { - String v = JSONUtil.str(e, "ig-version"); - if (version == null || VersionUtilities.isThisOrLater(version, v)) { - version = v; - fVersion = e.getAsJsonArray("fhir-version").get(0).getAsString(); - url = JSONUtil.str(e, "url"); - - String npmPackage = JSONUtil.str(e, "package"); - if (npmPackage != null && id == null) { - id = npmPackage.substring(0, npmPackage.indexOf("#")); - } - } - } - } - } - if (version != null) { - result.add(new PackageInfo(id, version, fVersion, description, url, pcanonical, address)); + final PackageInfo packageInfo = getPackageInfoFromJSON(o, name, canonical, fhirVersion); + if (packageInfo.getVersion() != null) { + result.add(packageInfo); } } } diff --git a/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/npm/PackageClientTest.java b/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/npm/PackageClientTest.java new file mode 100644 index 000000000..85f230636 --- /dev/null +++ b/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/npm/PackageClientTest.java @@ -0,0 +1,44 @@ +package org.hl7.fhir.utilities.npm; + +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import java.nio.file.Files; +import java.nio.file.Paths; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class PackageClientTest { + + PackageClient packageClient = new PackageClient(PackageClient.PRIMARY_SERVER); + + private void assertExpectedFields(final PackageInfo packageInfo) { + assertEquals("dummy.package", packageInfo.getId()); + assertEquals("1.2.3", packageInfo.getVersion()); + assertEquals("4.5.6", packageInfo.getFhirVersion()); + assertEquals("Dummy description", + packageInfo.getDescription()); + assertEquals("https://d.e.f", packageInfo.getUrl()); + assertEquals("https://a.b.c", packageInfo.getCanonical()); + } + + @Test + @DisplayName("test getting package from JSON works") + public void getPackageInfoFromJSONTest() throws java.io.IOException{ + final JsonObject jsonObject = new Gson().fromJson(Files.newBufferedReader(Paths.get("src", "test", "resources", "npm", "PackageClient-baseTestCase.json")), JsonObject.class); + final PackageInfo packageInfo = packageClient.getPackageInfoFromJSON(jsonObject, null, null, null); + + assertExpectedFields(packageInfo); + } + + @Test + @DisplayName("test getting package from JSON works") + public void getPackageInfoWithIdFromJSONTest() throws java.io.IOException { + final JsonObject jsonObject = new Gson().fromJson(Files.newBufferedReader(Paths.get("src", "test", "resources", "npm", "PackageClient-testCaseWithId.json")), JsonObject.class); + final PackageInfo packageInfo = packageClient.getPackageInfoFromJSON(jsonObject, null, null, null); + + assertExpectedFields(packageInfo); + } +} diff --git a/org.hl7.fhir.utilities/src/test/resources/npm/PackageClient-baseTestCase.json b/org.hl7.fhir.utilities/src/test/resources/npm/PackageClient-baseTestCase.json new file mode 100644 index 000000000..1b53ff834 --- /dev/null +++ b/org.hl7.fhir.utilities/src/test/resources/npm/PackageClient-baseTestCase.json @@ -0,0 +1,16 @@ +{ + "name": "Pan-Canadian Patient Summary", + "description": "Dummy description", + "canonical": "https://a.b.c", + "editions": [ + { + "name": "Dummy name", + "ig-version": "1.2.3", + "package": "dummy.package#1.2.3", + "fhir-version": [ + "4.5.6" + ], + "url": "https://d.e.f" + } + ] +} \ No newline at end of file diff --git a/org.hl7.fhir.utilities/src/test/resources/npm/PackageClient-testCaseWithId.json b/org.hl7.fhir.utilities/src/test/resources/npm/PackageClient-testCaseWithId.json new file mode 100644 index 000000000..363503e75 --- /dev/null +++ b/org.hl7.fhir.utilities/src/test/resources/npm/PackageClient-testCaseWithId.json @@ -0,0 +1,17 @@ +{ + "name": "Pan-Canadian Patient Summary", + "description": "Dummy description", + "canonical": "https://a.b.c", + "npm-name": "dummy.package", + "editions": [ + { + "name": "Dummy name", + "ig-version": "1.2.3", + "package": "not.a.dummy.package#1.2.3", + "fhir-version": [ + "4.5.6" + ], + "url": "https://d.e.f" + } + ] +} \ No newline at end of file From 4f652bceeec9db25d74bb27dbe1ee77eeae9959c Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Thu, 3 Mar 2022 07:43:09 +1100 Subject: [PATCH 23/50] more presenting extensions when rendering. --- .../hl7/fhir/r5/model/ElementDefinition.java | 4 + .../hl7/fhir/r5/renderers/DataRenderer.java | 74 ++++++++++++++++++- .../xhtml/HierarchicalTableGenerator.java | 5 ++ 3 files changed, 79 insertions(+), 4 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/ElementDefinition.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/ElementDefinition.java index 247f3085a..43d47d795 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/ElementDefinition.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/ElementDefinition.java @@ -11568,6 +11568,10 @@ When pattern[x] is used to constrain a complex object, it means that each proper public boolean isInlineType() { return getType().size() == 1 && Utilities.existsInList(getType().get(0).getCode(), "Element", "BackboneElement"); + } + + public boolean prohibited() { + return "0".equals(getMax()); } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/DataRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/DataRenderer.java index 28a8361f7..8c56701df 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/DataRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/DataRenderer.java @@ -383,7 +383,7 @@ public class DataRenderer extends Renderer { StructureDefinition sd = context.getWorker().fetchResource(StructureDefinition.class, ext.getUrl()); if (sd != null && ext.getValue().isPrimitive() && sd.hasSnapshot()) { for (ElementDefinition ed : sd.getSnapshot().getElement()) { - if (Utilities.existsInList(ed.getPath(), "Extension", "Extension.value") && ed.hasLabel()) { + if (Utilities.existsInList(ed.getPath(), "Extension", "Extension.value[x]") && ed.hasLabel()) { return ed.getLabel(); } } @@ -401,6 +401,7 @@ public class DataRenderer extends Renderer { String lbl = getExtensionLabel(ext); XhtmlNode li = ul.li(); li.tx(lbl); + li.tx(": "); render(li, ext.getValue()); } } @@ -413,6 +414,7 @@ public class DataRenderer extends Renderer { XhtmlNode li = ul.li(); li = li.b(); li.tx(lbl); + li.tx(": "); render(li, ext.getValue()); } else { // somehow have to do better than this @@ -425,11 +427,69 @@ public class DataRenderer extends Renderer { String lbl = getExtensionLabel(ext); XhtmlNode li = ul.li(); li.tx(lbl); + li.tx(": "); render(li, ext.getValue()); } } } + public void renderExtensionsInText(XhtmlNode div, DataType element, String sep) throws FHIRFormatError, DefinitionException, IOException { + boolean first = true; + for (Extension ext : element.getExtension()) { + if (canRender(ext)) { + if (first) { + first = false; + } else { + div.tx(sep); + div.tx(" "); + } + + String lbl = getExtensionLabel(ext); + div.tx(lbl); + div.tx(": "); + render(div, ext.getValue()); + } + } + } + + public void renderExtensionsInList(XhtmlNode div, BackboneType element, String sep) throws FHIRFormatError, DefinitionException, IOException { + boolean first = true; + for (Extension ext : element.getModifierExtension()) { + if (first) { + first = false; + } else { + div.tx(sep); + div.tx(" "); + } + if (canRender(ext)) { + String lbl = getExtensionLabel(ext); + XhtmlNode b = div.b(); + b.tx(lbl); + b.tx(": "); + render(div, ext.getValue()); + } else { + // somehow have to do better than this + div.b().tx("WARNING: Unrenderable Modifier Extension!"); + } + } + for (Extension ext : element.getExtension()) { + if (canRender(ext)) { + if (first) { + first = false; + } else { + div.tx(sep); + div.tx(" "); + } + + String lbl = getExtensionLabel(ext); + div.tx(lbl); + div.tx(": "); + render(div, ext.getValue()); + } + } + + } + // -- 6. Data type Rendering ---------------------------------------------- public static String display(IWorkerContext context, DataType type) { @@ -938,11 +998,11 @@ public class DataRenderer extends Renderer { return s; } - protected void renderCodeableConcept(XhtmlNode x, CodeableConcept cc) { + protected void renderCodeableConcept(XhtmlNode x, CodeableConcept cc) throws FHIRFormatError, DefinitionException, IOException { renderCodeableConcept(x, cc, false); } - protected void renderCodeableReference(XhtmlNode x, CodeableReference e, boolean showCodeDetails) { + protected void renderCodeableReference(XhtmlNode x, CodeableReference e, boolean showCodeDetails) throws FHIRFormatError, DefinitionException, IOException { if (e.hasConcept()) { renderCodeableConcept(x, e.getConcept(), showCodeDetails); } @@ -951,7 +1011,7 @@ public class DataRenderer extends Renderer { } } - protected void renderCodeableConcept(XhtmlNode x, CodeableConcept cc, boolean showCodeDetails) { + protected void renderCodeableConcept(XhtmlNode x, CodeableConcept cc, boolean showCodeDetails) throws FHIRFormatError, DefinitionException, IOException { if (cc.isEmpty()) { return; } @@ -1007,6 +1067,12 @@ public class DataRenderer extends Renderer { sp.tx(" \""+c.getDisplay()+"\""); } } + if (hasRenderableExtensions(cc)) { + if (!first) { + sp.tx("; "); + } + renderExtensionsInText(sp, cc, ";"); + } sp.tx(")"); } else { diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xhtml/HierarchicalTableGenerator.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xhtml/HierarchicalTableGenerator.java index 18412cee5..9552a95fa 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xhtml/HierarchicalTableGenerator.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xhtml/HierarchicalTableGenerator.java @@ -403,6 +403,11 @@ public class HierarchicalTableGenerator extends TranslatingUtilities { pieces.add(p); return p; } + public Piece addText(String text) { + Piece p = new Piece(null, text, null); + pieces.add(p); + return p; + } public String text() { StringBuilder b = new StringBuilder(); for (Piece p : pieces) From 64aed90f1e0961db1d4ffe0b2aa4b6088e2635a0 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Thu, 3 Mar 2022 07:43:43 +1100 Subject: [PATCH 24/50] fix handling of xver extensions with choice sub-extensions --- .../main/java/org/hl7/fhir/r5/utils/XVerExtensionManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/XVerExtensionManager.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/XVerExtensionManager.java index 5d7a69a4f..7d27c4782 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/XVerExtensionManager.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/XVerExtensionManager.java @@ -123,12 +123,12 @@ public class XVerExtensionManager { populateTypes(path, val, verSource, verTarget); } else if (path.has("elements")) { for (JsonElement i : path.getAsJsonArray("elements")) { - String s = i.getAsString(); + String s = i.getAsString().replace("[x]", ""); sd.getDifferential().addElement().setPath("Extension.extension").setSliceName(s); sd.getDifferential().addElement().setPath("Extension.extension.extension").setMax("0"); sd.getDifferential().addElement().setPath("Extension.extension.url").setFixed(new UriType(s)); ElementDefinition val = sd.getDifferential().addElement().setPath("Extension.extension.value[x]").setMin(1); - JsonObject elt = root.getAsJsonObject(e+"."+s); + JsonObject elt = root.getAsJsonObject(e+"."+i.getAsString()); if (!elt.has("types")) { throw new FHIRException("Internal error - nested elements not supported yet"); } From 6f57013f98f620a76594f11ebc54171c93c7dbc0 Mon Sep 17 00:00:00 2001 From: dotasek Date: Thu, 3 Mar 2022 16:19:39 -0500 Subject: [PATCH 25/50] Fix intermittent failures in NarrativeGenerationTests --- .../fhir/r5/context/SimpleWorkerContext.java | 2 +- .../fhir/r5/test/utils/TestingUtilities.java | 50 ++++++++++++------- .../hl7/fhir/r5/test/CDARoundTripTests.java | 2 +- .../org/hl7/fhir/r5/test/FHIRPathTests.java | 4 +- .../hl7/fhir/r5/test/GraphQLEngineTests.java | 2 +- .../hl7/fhir/r5/test/LiquidEngineTests.java | 2 +- .../r5/test/NarrativeGenerationTests.java | 2 +- .../fhir/r5/test/NarrativeGeneratorTests.java | 2 +- .../fhir/r5/test/OpenApiGeneratorTest.java | 2 +- .../fhir/r5/test/ProfileUtilitiesTests.java | 20 ++++---- .../fhir/r5/test/ResourceRoundTripTests.java | 6 +-- .../hl7/fhir/r5/test/ShexGeneratorTests.java | 4 +- .../fhir/r5/test/SnapShotGenerationTests.java | 50 +++++++++---------- .../java/org/hl7/fhir/r5/test/VocabTests.java | 8 ++- .../hl7/fhir/r5/test/misc/ResourceTest.java | 6 +-- .../comparison/tests/ComparisonTests.java | 2 +- .../tests/SnapShotGenerationXTests.java | 4 +- .../validation/tests/ValidationTests.java | 20 ++++---- 18 files changed, 103 insertions(+), 85 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/SimpleWorkerContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/SimpleWorkerContext.java index 53a371c13..239b43c25 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/SimpleWorkerContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/SimpleWorkerContext.java @@ -239,7 +239,7 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon public SimpleWorkerContext fromPackage(NpmPackage pi, IContextResourceLoader loader) throws IOException, FHIRException { SimpleWorkerContext context = getSimpleWorkerContextInstance(); - context.setAllowLoadingDuplicates(true); + context.setAllowLoadingDuplicates(allowLoadingDuplicates); context.version = pi.getNpm().get("version").getAsString(); context.loadFromPackage(pi, loader); context.finishLoading(); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/test/utils/TestingUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/test/utils/TestingUtilities.java index a6636f734..8459d7869 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/test/utils/TestingUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/test/utils/TestingUtilities.java @@ -75,11 +75,23 @@ public class TestingUtilities extends BaseTestingUtilities { static public Map fcontexts; - public static IWorkerContext context() { - return context("4.0.1"); + final static public String DEFAULT_CONTEXT_VERSION = "4.0.1"; + + /** Get an existing instantiation of a WorkerContext if available + * + * This uses the DEFAULT_CONTEXT_VERSION + * */ + public static IWorkerContext getSharedWorkerContext() { + return getSharedWorkerContext(DEFAULT_CONTEXT_VERSION); } - public static IWorkerContext context(String version) { + /** + * Get an existing instantiation of a WorkerContext if available + * + * @param version FHIR Version to get context for + * @return + */ + public static IWorkerContext getSharedWorkerContext(String version) { if ("4.5.0".equals(version)) { version = "4.4.0"; // temporary work around } @@ -89,33 +101,35 @@ public class TestingUtilities extends BaseTestingUtilities { fcontexts = new HashMap<>(); } if (!fcontexts.containsKey(v)) { - FilesystemPackageCacheManager pcm; - try { - pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION); - IWorkerContext fcontext = getWorkerContext(pcm.loadPackage(VersionUtilities.packageForVersion(version), version)); - fcontext.setUcumService(new UcumEssenceService(TestingUtilities.loadTestResourceStream("ucum", "ucum-essence.xml"))); - fcontext.setExpansionProfile(new Parameters()); -// ((SimpleWorkerContext) fcontext).connectToTSServer(new TerminologyClientR5("http://tx.fhir.org/r4"), null); + IWorkerContext fcontext = getWorkerContext(version); fcontexts.put(v, fcontext); - } catch (Exception e) { - e.printStackTrace(); - throw new Error(e); - } } return fcontexts.get(v); } + public static IWorkerContext getWorkerContext(String version) { + FilesystemPackageCacheManager pcm; + try { + pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION); + IWorkerContext fcontext = getWorkerContext(pcm.loadPackage(VersionUtilities.packageForVersion(version), version)); + fcontext.setUcumService(new UcumEssenceService(TestingUtilities.loadTestResourceStream("ucum", "ucum-essence.xml"))); + fcontext.setExpansionProfile(new Parameters()); + return fcontext; + } catch (Exception e) { + e.printStackTrace(); + throw new Error(e); + } + } + public static SimpleWorkerContext getWorkerContext(NpmPackage npmPackage) throws Exception { - SimpleWorkerContext swc = new SimpleWorkerContext.SimpleWorkerContextBuilder().withUserAgent(TestConstants.USER_AGENT).withTerminologyCachePath(TestConstants.TX_CACHE).fromPackage(npmPackage); + SimpleWorkerContext swc = new SimpleWorkerContext.SimpleWorkerContextBuilder().withAllowLoadingDuplicates(true).withUserAgent(TestConstants.USER_AGENT).withTerminologyCachePath(TestConstants.TX_CACHE).fromPackage(npmPackage); TerminologyCache.setCacheErrors(true); - swc.setAllowLoadingDuplicates(true); return swc; } public static SimpleWorkerContext getWorkerContext(NpmPackage npmPackage, IWorkerContext.IContextResourceLoader loader) throws Exception { - SimpleWorkerContext swc = new SimpleWorkerContext.SimpleWorkerContextBuilder().withUserAgent(TestConstants.USER_AGENT).withTerminologyCachePath(TestConstants.TX_CACHE).fromPackage(npmPackage, loader); + SimpleWorkerContext swc = new SimpleWorkerContext.SimpleWorkerContextBuilder().withAllowLoadingDuplicates(true).withUserAgent(TestConstants.USER_AGENT).withTerminologyCachePath(TestConstants.TX_CACHE).fromPackage(npmPackage, loader); TerminologyCache.setCacheErrors(true); - swc.setAllowLoadingDuplicates(true); return swc; } diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/CDARoundTripTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/CDARoundTripTests.java index 54980ff21..aea3837e8 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/CDARoundTripTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/CDARoundTripTests.java @@ -257,7 +257,7 @@ public class CDARoundTripTests { value.setValue("öé"); ByteArrayOutputStream baosXml = new ByteArrayOutputStream(); - Manager.compose(TestingUtilities.context(), xml, baosXml, FhirFormat.XML, OutputStyle.PRETTY, null); + Manager.compose(TestingUtilities.getSharedWorkerContext(), xml, baosXml, FhirFormat.XML, OutputStyle.PRETTY, null); String cdaSerialised = baosXml.toString("UTF-8"); Assertions.assertTrue(cdaSerialised.indexOf("öé") > 0); } diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/FHIRPathTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/FHIRPathTests.java index 2b8ef374d..d1f6d8aa4 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/FHIRPathTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/FHIRPathTests.java @@ -93,7 +93,7 @@ public class FHIRPathTests { @Override public ValueSet resolveValueSet(Object appContext, String url) { - return TestingUtilities.context().fetchResource(ValueSet.class, url); + return TestingUtilities.getSharedWorkerContext().fetchResource(ValueSet.class, url); } } @@ -103,7 +103,7 @@ public class FHIRPathTests { @BeforeAll public static void setUp() { - fp = new FHIRPathEngine(TestingUtilities.context()); + fp = new FHIRPathEngine(TestingUtilities.getSharedWorkerContext()); } public static Stream data() throws ParserConfigurationException, SAXException, IOException { diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/GraphQLEngineTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/GraphQLEngineTests.java index fa66313d6..fa20643d6 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/GraphQLEngineTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/GraphQLEngineTests.java @@ -65,7 +65,7 @@ public class GraphQLEngineTests implements IGraphQLStorageServices { stream = TestingUtilities.loadTestResourceStream("r5", parts[0].toLowerCase()+"-"+parts[1].toLowerCase()+".xml"); } - GraphQLEngine gql = new GraphQLEngine(TestingUtilities.context()); + GraphQLEngine gql = new GraphQLEngine(TestingUtilities.getSharedWorkerContext()); gql.setServices(this); if (stream != null) gql.setFocus(new XmlParser().parse(stream)); diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/LiquidEngineTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/LiquidEngineTests.java index 19e31dad6..d1ee8f0f4 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/LiquidEngineTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/LiquidEngineTests.java @@ -37,7 +37,7 @@ public class LiquidEngineTests implements ILiquidEngineIncludeResolver { @BeforeEach public void setUp() throws Exception { - engine = new LiquidEngine(TestingUtilities.context(), null); + engine = new LiquidEngine(TestingUtilities.getSharedWorkerContext(), null); engine.setIncludeResolver(this); } diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/NarrativeGenerationTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/NarrativeGenerationTests.java index 2a25ab3de..bfb77e3cb 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/NarrativeGenerationTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/NarrativeGenerationTests.java @@ -103,7 +103,7 @@ public class NarrativeGenerationTests { @BeforeAll public static void setUp() { - context = TestingUtilities.context(); + context = TestingUtilities.getSharedWorkerContext(); } @ParameterizedTest(name = "{index}: file {0}") diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/NarrativeGeneratorTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/NarrativeGeneratorTests.java index 4a92d9c93..eef9b272b 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/NarrativeGeneratorTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/NarrativeGeneratorTests.java @@ -34,7 +34,7 @@ public class NarrativeGeneratorTests { @BeforeAll public static void setUp() throws FHIRException { - rc = new RenderingContext(TestingUtilities.context(), null, null, "http://hl7.org/fhir", "", null, ResourceRendererMode.END_USER); + rc = new RenderingContext(TestingUtilities.getSharedWorkerContext(), null, null, "http://hl7.org/fhir", "", null, ResourceRendererMode.END_USER); } @Test diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/OpenApiGeneratorTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/OpenApiGeneratorTest.java index bcd667980..f43ede9be 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/OpenApiGeneratorTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/OpenApiGeneratorTest.java @@ -32,7 +32,7 @@ public class OpenApiGeneratorTest { public void run(InputStream sfn, String dfn) throws IOException, FHIRFormatError, FileNotFoundException { CapabilityStatement cs = (CapabilityStatement) new JsonParser().parse(sfn); Writer oa = new Writer(new FileOutputStream(dfn)); - OpenApiGenerator gen = new OpenApiGenerator(TestingUtilities.context(), cs, oa); + OpenApiGenerator gen = new OpenApiGenerator(TestingUtilities.getSharedWorkerContext(), cs, oa); gen.generate("test-lic", "http://spdx.org/licenses/test-lic.html"); oa.commit(); } diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ProfileUtilitiesTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ProfileUtilitiesTests.java index fcaca80cb..e5a62e947 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ProfileUtilitiesTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ProfileUtilitiesTests.java @@ -29,13 +29,13 @@ public class ProfileUtilitiesTests { public void testSimple() throws FHIRException { StructureDefinition focus = new StructureDefinition(); - StructureDefinition base = TestingUtilities.context().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Patient").copy(); + StructureDefinition base = TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Patient").copy(); focus.setUrl(Utilities.makeUuidUrn()); focus.setBaseDefinition(base.getUrl()); focus.setType("Patient"); focus.setDerivation(TypeDerivationRule.CONSTRAINT); List messages = new ArrayList<>(); - new ProfileUtilities(TestingUtilities.context(), messages, null).generateSnapshot(base, focus, focus.getUrl(), "http://test.org/test", "Simple Test"); + new ProfileUtilities(TestingUtilities.getSharedWorkerContext(), messages, null).generateSnapshot(base, focus, focus.getUrl(), "http://test.org/test", "Simple Test"); boolean ok = base.getSnapshot().getElement().size() == focus.getSnapshot().getElement().size(); for (int i = 0; i < base.getSnapshot().getElement().size(); i++) { @@ -70,13 +70,13 @@ public class ProfileUtilitiesTests { // */ @Test public void testSimple2() { - StructureDefinition base = TestingUtilities.context().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/ValueSet").copy(); + StructureDefinition base = TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/ValueSet").copy(); StructureDefinition focus = base.copy(); focus.setUrl(Utilities.makeUuidUrn()); focus.setSnapshot(null); focus.setDifferential(null); List messages = new ArrayList<>(); - new ProfileUtilities(TestingUtilities.context(), messages, null).generateSnapshot(base, focus, focus.getUrl(), "http://test.org", "Simple Test"); + new ProfileUtilities(TestingUtilities.getSharedWorkerContext(), messages, null).generateSnapshot(base, focus, focus.getUrl(), "http://test.org", "Simple Test"); boolean ok = base.getSnapshot().getElement().size() == focus.getSnapshot().getElement().size(); for (int i = 0; i < base.getSnapshot().getElement().size(); i++) { @@ -110,7 +110,7 @@ public class ProfileUtilitiesTests { @Test void testCardinalityChange() { StructureDefinition focus = new StructureDefinition(); - StructureDefinition base = TestingUtilities.context().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Patient").copy(); + StructureDefinition base = TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Patient").copy(); focus.setUrl(Utilities.makeUuidUrn()); focus.setBaseDefinition(base.getUrl()); focus.setType(base.getType()); @@ -119,7 +119,7 @@ public class ProfileUtilitiesTests { id.setPath("Patient.identifier"); id.setMin(1); List messages = new ArrayList<>(); - new ProfileUtilities(TestingUtilities.context(), messages, null).generateSnapshot(base, focus, focus.getUrl(), "http://test.org", "Simple Test"); + new ProfileUtilities(TestingUtilities.getSharedWorkerContext(), messages, null).generateSnapshot(base, focus, focus.getUrl(), "http://test.org", "Simple Test"); boolean ok = base.getSnapshot().getElement().size() == focus.getSnapshot().getElement().size(); for (int i = 0; i < base.getSnapshot().getElement().size(); i++) { @@ -155,7 +155,7 @@ public class ProfileUtilitiesTests { void testMinValueChange() { // Given StructureDefinition focus = new StructureDefinition(); - StructureDefinition base = TestingUtilities.context().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Appointment").copy(); + StructureDefinition base = TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Appointment").copy(); focus.setUrl(Utilities.makeUuidUrn()); focus.setBaseDefinition(base.getUrl()); focus.setType(base.getType()); @@ -165,7 +165,7 @@ public class ProfileUtilitiesTests { id.setMinValue(new IntegerType(1)); List messages = new ArrayList<>(); // When - new ProfileUtilities(TestingUtilities.context(), messages, null).generateSnapshot(base, focus, focus.getUrl(), "http://test.org", "Simple Test"); + new ProfileUtilities(TestingUtilities.getSharedWorkerContext(), messages, null).generateSnapshot(base, focus, focus.getUrl(), "http://test.org", "Simple Test"); // Then boolean ok = base.getSnapshot().getElement().size() == focus.getSnapshot().getElement().size(); for (int i = 0; i < base.getSnapshot().getElement().size(); i++) { @@ -202,7 +202,7 @@ public class ProfileUtilitiesTests { void testMaxValueChange() { // Given StructureDefinition focus = new StructureDefinition(); - StructureDefinition base = TestingUtilities.context().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Appointment").copy(); + StructureDefinition base = TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Appointment").copy(); focus.setUrl(Utilities.makeUuidUrn()); focus.setBaseDefinition(base.getUrl()); focus.setType(base.getType()); @@ -212,7 +212,7 @@ public class ProfileUtilitiesTests { id.setMaxValue(new IntegerType(1)); List messages = new ArrayList<>(); // When - new ProfileUtilities(TestingUtilities.context(), messages, null).generateSnapshot(base, focus, focus.getUrl(), "http://test.org", "Simple Test"); + new ProfileUtilities(TestingUtilities.getSharedWorkerContext(), messages, null).generateSnapshot(base, focus, focus.getUrl(), "http://test.org", "Simple Test"); // Then boolean ok = base.getSnapshot().getElement().size() == focus.getSnapshot().getElement().size(); for (int i = 0; i < base.getSnapshot().getElement().size(); i++) { diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceRoundTripTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceRoundTripTests.java index f69340efb..fb25a400e 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceRoundTripTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceRoundTripTests.java @@ -33,7 +33,7 @@ public class ResourceRoundTripTests { @Test public void test() throws IOException, FHIRException, EOperationOutcome { DomainResource res = (DomainResource) new XmlParser().parse(TestingUtilities.loadTestResourceStream("r5", "unicode.xml")); - RenderingContext rc = new RenderingContext(TestingUtilities.context(), null, null, "http://hl7.org/fhir", "", null, ResourceRendererMode.END_USER); + RenderingContext rc = new RenderingContext(TestingUtilities.getSharedWorkerContext(), null, null, "http://hl7.org/fhir", "", null, ResourceRendererMode.END_USER); RendererFactory.factory(res, rc).render(res); IOUtils.copy(TestingUtilities.loadTestResourceStream("r5", "unicode.xml"), new FileOutputStream(TestingUtilities.tempFile("gen", "unicode.xml"))); new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(TestingUtilities.tempFile("gen", "unicode.out.xml")), res); @@ -64,7 +64,7 @@ public class ResourceRoundTripTests { * verify that umlaut like äö etc are not encoded in UTF-8 in attributes */ public void testSerializeUmlaut() throws IOException { - Element xml = Manager.parseSingle(TestingUtilities.context(), TestingUtilities.loadTestResourceStream("r5", "unicode.xml"), + Element xml = Manager.parseSingle(TestingUtilities.getSharedWorkerContext(), TestingUtilities.loadTestResourceStream("r5", "unicode.xml"), FhirFormat.XML); List concept = xml.getChildrenByName("concept"); assertTrue(concept!=null && concept.size()==1); @@ -72,7 +72,7 @@ public class ResourceRoundTripTests { assertTrue(code!=null && code.size()==1); code.get(0).setValue("ö"); ByteArrayOutputStream baosXml = new ByteArrayOutputStream(); - Manager.compose(TestingUtilities.context(), xml, baosXml, FhirFormat.XML, OutputStyle.PRETTY, null); + Manager.compose(TestingUtilities.getSharedWorkerContext(), xml, baosXml, FhirFormat.XML, OutputStyle.PRETTY, null); String cdaSerialised = baosXml.toString("UTF-8"); assertTrue(cdaSerialised.indexOf("ö")>0); } diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ShexGeneratorTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ShexGeneratorTests.java index 23b076d84..26a3b3408 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ShexGeneratorTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ShexGeneratorTests.java @@ -18,12 +18,12 @@ import org.junit.jupiter.api.Test; public class ShexGeneratorTests { private void doTest(String name) throws FileNotFoundException, IOException, FHIRException, UcumException { - StructureDefinition sd = TestingUtilities.context().fetchResource(StructureDefinition.class, ProfileUtilities.sdNs(name, null)); + StructureDefinition sd = TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, ProfileUtilities.sdNs(name, null)); if (sd == null) { throw new FHIRException("StructuredDefinition for " + name + "was null"); } Path outPath = FileSystems.getDefault().getPath(System.getProperty("java.io.tmpdir"), name.toLowerCase() + ".shex"); - TextFile.stringToFile(new ShExGenerator(TestingUtilities.context()).generate(HTMLLinkPolicy.NONE, sd), outPath.toString()); + TextFile.stringToFile(new ShExGenerator(TestingUtilities.getSharedWorkerContext()).generate(HTMLLinkPolicy.NONE, sd), outPath.toString()); } @Test diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/SnapShotGenerationTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/SnapShotGenerationTests.java index 1d2c4c96f..2155fb195 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/SnapShotGenerationTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/SnapShotGenerationTests.java @@ -211,13 +211,13 @@ public class SnapShotGenerationTests { @Override public boolean isDatatype(String name) { - StructureDefinition sd = TestingUtilities.context().fetchTypeDefinition(name); + StructureDefinition sd = TestingUtilities.getSharedWorkerContext().fetchTypeDefinition(name); return (sd != null) && (sd.getDerivation() == TypeDerivationRule.SPECIALIZATION) && (sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE || sd.getKind() == StructureDefinitionKind.COMPLEXTYPE); } @Override public boolean isResource(String typeSimple) { - StructureDefinition sd = TestingUtilities.context().fetchTypeDefinition(typeSimple); + StructureDefinition sd = TestingUtilities.getSharedWorkerContext().fetchTypeDefinition(typeSimple); return (sd != null) && (sd.getDerivation() == TypeDerivationRule.SPECIALIZATION) && (sd.getKind() == StructureDefinitionKind.RESOURCE); } @@ -249,7 +249,7 @@ public class SnapShotGenerationTests { @Override public String getLinkForProfile(StructureDefinition profile, String url) { - StructureDefinition sd = TestingUtilities.context().fetchResource(StructureDefinition.class, url); + StructureDefinition sd = TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, url); if (sd == null) return url + "|" + url; else @@ -275,15 +275,15 @@ public class SnapShotGenerationTests { public Resource fetchFixture(String id) { TestFetchMode mode = TestFetchMode.INPUT; if (id.equals("patient")) - return TestingUtilities.context().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Patient"); + return TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Patient"); if (id.equals("valueset")) - return TestingUtilities.context().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/ValueSet"); + return TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/ValueSet"); if (id.equals("organization")) - return TestingUtilities.context().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Organization"); + return TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Organization"); if (id.equals("operationoutcome")) - return TestingUtilities.context().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/OperationOutcome"); + return TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/OperationOutcome"); if (id.equals("parameters")) - return TestingUtilities.context().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Parameters"); + return TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Parameters"); if (id.contains("-")) { String[] p = id.split("\\-"); @@ -339,7 +339,7 @@ public class SnapShotGenerationTests { @Override public TypeDetails checkFunction(Object appContext, String functionName, List parameters) throws PathEngineException { if ("fixture".equals(functionName)) - return new TypeDetails(CollectionStatus.SINGLETON, TestingUtilities.context().getResourceNamesAsSet()); + return new TypeDetails(CollectionStatus.SINGLETON, TestingUtilities.getSharedWorkerContext().getResourceNamesAsSet()); return null; } @@ -366,7 +366,7 @@ public class SnapShotGenerationTests { @Override public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException { - IResourceValidator val = TestingUtilities.context().newValidator(); + IResourceValidator val = TestingUtilities.getSharedWorkerContext().newValidator(); List valerrors = new ArrayList(); if (item instanceof Resource) { val.validate(appContext, valerrors, (Resource) item, url); @@ -404,7 +404,7 @@ public class SnapShotGenerationTests { @BeforeAll public static void setUp() { - fp = new FHIRPathEngine(TestingUtilities.context()); + fp = new FHIRPathEngine(TestingUtilities.getSharedWorkerContext()); } public static Stream data() throws ParserConfigurationException, IOException, FHIRFormatError, SAXException { @@ -462,7 +462,7 @@ public class SnapShotGenerationTests { private void testSort(TestDetails test, SnapShotGenerationTestsContext context) throws DefinitionException, FHIRException, IOException { StructureDefinition base = getSD(test.getSource().getBaseDefinition(), context); test.setOutput(test.getSource().copy()); - ProfileUtilities pu = new ProfileUtilities(TestingUtilities.context(), null, null); + ProfileUtilities pu = new ProfileUtilities(TestingUtilities.getSharedWorkerContext(), null, null); pu.setIds(test.getSource(), false); List errors = new ArrayList(); pu.sortDifferential(base, test.getOutput(), test.getOutput().getUrl(), errors, false); @@ -476,17 +476,17 @@ public class SnapShotGenerationTests { private void testGen(boolean fail, TestDetails test, SnapShotGenerationTestsContext context) throws Exception { if (!Utilities.noString(test.register)) { List messages = new ArrayList(); - ProfileUtilities pu = new ProfileUtilities(TestingUtilities.context(), messages, null); + ProfileUtilities pu = new ProfileUtilities(TestingUtilities.getSharedWorkerContext(), messages, null); pu.setNewSlicingProcessing(true); for (StructureDefinition sd : test.included) { pu.setIds(sd, false); } for (StructureDefinition sd : test.included) { - if (!TestingUtilities.context().hasResource(StructureDefinition.class, sd.getUrl())) { - TestingUtilities.context().cacheResource(sd); + if (!TestingUtilities.getSharedWorkerContext().hasResource(StructureDefinition.class, sd.getUrl())) { + TestingUtilities.getSharedWorkerContext().cacheResource(sd); } } - StructureDefinition base = TestingUtilities.context().fetchResource(StructureDefinition.class, test.included.get(0).getBaseDefinition()); + StructureDefinition base = TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, test.included.get(0).getBaseDefinition()); if (base != null) { pu.generateSnapshot(base, test.included.get(0), test.included.get(0).getUrl(), "http://test.org/profile", test.included.get(0).getName()); } @@ -505,16 +505,16 @@ public class SnapShotGenerationTests { throw new Exception("URL mismatch on base: " + base.getUrl() + " wanting " + test.getSource().getBaseDefinition()); StructureDefinition output = test.getSource().copy(); - ProfileUtilities pu = new ProfileUtilities(TestingUtilities.context(), messages, new TestPKP()); + ProfileUtilities pu = new ProfileUtilities(TestingUtilities.getSharedWorkerContext(), messages, new TestPKP()); pu.setNewSlicingProcessing(test.isNewSliceProcessing()); pu.setThrowException(false); pu.setDebug(test.isDebug()); pu.setIds(test.getSource(), false); - if (!TestingUtilities.context().hasPackage(CommonPackages.ID_XVER, CommonPackages.VER_XVER)) { + if (!TestingUtilities.getSharedWorkerContext().hasPackage(CommonPackages.ID_XVER, CommonPackages.VER_XVER)) { NpmPackage npm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION).loadPackage(CommonPackages.ID_XVER, CommonPackages.VER_XVER); - TestingUtilities.context().loadFromPackage(npm, new TestPackageLoader(new String[]{"StructureDefinition"}), new String[]{"StructureDefinition"}); + TestingUtilities.getSharedWorkerContext().loadFromPackage(npm, new TestPackageLoader(new String[]{"StructureDefinition"}), new String[]{"StructureDefinition"}); } - pu.setXver(new XVerExtensionManager(TestingUtilities.context())); + pu.setXver(new XVerExtensionManager(TestingUtilities.getSharedWorkerContext())); if (test.isSort()) { List errors = new ArrayList(); int lastCount = output.getDifferential().getElement().size(); @@ -539,14 +539,14 @@ public class SnapShotGenerationTests { throw e; } if (output.getDifferential().hasElement()) { - RenderingContext rc = new RenderingContext(TestingUtilities.context(), null, null, "http://hl7.org/fhir", "", null, ResourceRendererMode.END_USER); + RenderingContext rc = new RenderingContext(TestingUtilities.getSharedWorkerContext(), null, null, "http://hl7.org/fhir", "", null, ResourceRendererMode.END_USER); rc.setDestDir(Utilities.path("[tmp]", "snapshot")); - rc.setProfileUtilities(new ProfileUtilities(TestingUtilities.context(), null, new TestPKP())); + rc.setProfileUtilities(new ProfileUtilities(TestingUtilities.getSharedWorkerContext(), null, new TestPKP())); RendererFactory.factory(output, rc).render(output); } if (!fail) { test.output = output; - TestingUtilities.context().cacheResource(output); + TestingUtilities.getSharedWorkerContext().cacheResource(output); File dst = new File(TestingUtilities.tempFile("snapshot", test.getId() + "-expected.xml")); if (dst.exists()) dst.delete(); @@ -563,14 +563,14 @@ public class SnapShotGenerationTests { private StructureDefinition getSD(String url, SnapShotGenerationTestsContext context) throws DefinitionException, FHIRException, IOException { StructureDefinition sd = context.getByUrl(url); if (sd == null) { - sd = TestingUtilities.context().fetchResource(StructureDefinition.class, url); + sd = TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, url); } if (sd == null) { throw new DefinitionException("Unable to find profile "+url); } if (!sd.hasSnapshot()) { StructureDefinition base = getSD(sd.getBaseDefinition(), context); - ProfileUtilities pu = new ProfileUtilities(TestingUtilities.context(), messages, new TestPKP()); + ProfileUtilities pu = new ProfileUtilities(TestingUtilities.getSharedWorkerContext(), messages, new TestPKP()); pu.setNewSlicingProcessing(true); List errors = new ArrayList(); pu.sortDifferential(base, sd, url, errors, false); diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/VocabTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/VocabTests.java index 0cb27a1b4..cdbf4fe9e 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/VocabTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/VocabTests.java @@ -24,6 +24,7 @@ import org.hl7.fhir.r5.renderers.utils.RenderingContext.ITypeParser; import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome; import org.hl7.fhir.r5.test.utils.TestingUtilities; import org.hl7.fhir.utilities.TextFile; +import org.hl7.fhir.utilities.VersionUtilities; import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager; import org.hl7.fhir.utilities.npm.NpmPackage; import org.hl7.fhir.utilities.npm.ToolsVersion; @@ -104,8 +105,11 @@ public class VocabTests { } @BeforeAll - public static void setUp() throws FileNotFoundException, FHIRException, IOException { - context = TestingUtilities.context(); + public static void setUp() throws FHIRException, IOException { + /* Do NOT get a shared worker context from Testing Utilities or else the terminology package loaded below + will appear in tests where it causes failures. + */ + context = TestingUtilities.getWorkerContext(VersionUtilities.getMajMin(TestingUtilities.DEFAULT_CONTEXT_VERSION)); if (!context.hasPackage("hl7.terminology", null)) { NpmPackage utg = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION).loadPackage("hl7.terminology"); diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/misc/ResourceTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/misc/ResourceTest.java index f4233fcb2..dcde38c41 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/misc/ResourceTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/misc/ResourceTest.java @@ -86,9 +86,9 @@ public class ResourceTest { } public Element testEM() throws Exception { - Element resource = Manager.parseSingle(TestingUtilities.context(), new FileInputStream(source), isJson() ? FhirFormat.JSON : FhirFormat.XML); - Manager.compose(TestingUtilities.context(), resource, new FileOutputStream(source.getAbsoluteFile()+".out.json"), FhirFormat.JSON, OutputStyle.PRETTY, null); - Manager.compose(TestingUtilities.context(), resource, new FileOutputStream(source.getAbsoluteFile()+".out.json"), FhirFormat.XML, OutputStyle.PRETTY, null); + Element resource = Manager.parseSingle(TestingUtilities.getSharedWorkerContext(), new FileInputStream(source), isJson() ? FhirFormat.JSON : FhirFormat.XML); + Manager.compose(TestingUtilities.getSharedWorkerContext(), resource, new FileOutputStream(source.getAbsoluteFile()+".out.json"), FhirFormat.JSON, OutputStyle.PRETTY, null); + Manager.compose(TestingUtilities.getSharedWorkerContext(), resource, new FileOutputStream(source.getAbsoluteFile()+".out.json"), FhirFormat.XML, OutputStyle.PRETTY, null); return resource; } diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/comparison/tests/ComparisonTests.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/comparison/tests/ComparisonTests.java index 82017d2e6..75d82d6bf 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/comparison/tests/ComparisonTests.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/comparison/tests/ComparisonTests.java @@ -108,7 +108,7 @@ public class ComparisonTests { if (context == null) { System.out.println("---- Load R5 ----------------------------------------------------------------"); - context = TestingUtilities.context(); + context = TestingUtilities.getSharedWorkerContext(); FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION); NpmPackage npm = pcm.loadPackage("hl7.fhir.us.core#3.1.0"); BaseWorkerContext bc = (BaseWorkerContext) context; diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/conversion/tests/SnapShotGenerationXTests.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/conversion/tests/SnapShotGenerationXTests.java index d5896e537..1be3ec956 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/conversion/tests/SnapShotGenerationXTests.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/conversion/tests/SnapShotGenerationXTests.java @@ -522,9 +522,9 @@ public class SnapShotGenerationXTests { throw e; } if (output.getDifferential().hasElement()) { - RenderingContext rc = new RenderingContext(TestingUtilities.context(), null, null, "http://hl7.org/fhir", "", null, ResourceRendererMode.END_USER); + RenderingContext rc = new RenderingContext(TestingUtilities.getSharedWorkerContext(), null, null, "http://hl7.org/fhir", "", null, ResourceRendererMode.END_USER); rc.setDestDir(makeTempDir()); - rc.setProfileUtilities(new ProfileUtilities(TestingUtilities.context(), null, new TestPKP())); + rc.setProfileUtilities(new ProfileUtilities(TestingUtilities.getSharedWorkerContext(), null, new TestPKP())); RendererFactory.factory(output, rc).render(output); } if (!fail) { diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTests.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTests.java index 3a79d370e..e5cf2d30b 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTests.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTests.java @@ -350,9 +350,9 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe public StructureDefinition loadProfile(String filename, String contents, List messages) throws IOException, FHIRFormatError, FileNotFoundException, FHIRException, DefinitionException { StructureDefinition sd = (StructureDefinition) loadResource(filename, contents); - ProfileUtilities pu = new ProfileUtilities(TestingUtilities.context(version), messages, null); + ProfileUtilities pu = new ProfileUtilities(TestingUtilities.getSharedWorkerContext(version), messages, null); if (!sd.hasSnapshot()) { - StructureDefinition base = TestingUtilities.context(version).fetchResource(StructureDefinition.class, sd.getBaseDefinition()); + StructureDefinition base = TestingUtilities.getSharedWorkerContext(version).fetchResource(StructureDefinition.class, sd.getBaseDefinition()); pu.generateSnapshot(base, sd, sd.getUrl(), null, sd.getTitle()); // (debugging) new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", sd.getId()+".xml")), sd); } @@ -360,7 +360,7 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe if (r instanceof StructureDefinition) { StructureDefinition childSd = (StructureDefinition) r; if (!childSd.hasSnapshot()) { - StructureDefinition base = TestingUtilities.context(version).fetchResource(StructureDefinition.class, childSd.getBaseDefinition()); + StructureDefinition base = TestingUtilities.getSharedWorkerContext(version).fetchResource(StructureDefinition.class, childSd.getBaseDefinition()); pu.generateSnapshot(base, childSd, childSd.getUrl(), null, childSd.getTitle()); } } @@ -427,7 +427,7 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe } } } - if (!TestingUtilities.context(version).isNoTerminologyServer() || !focus.has("tx-dependent")) { + if (!TestingUtilities.getSharedWorkerContext(version).isNoTerminologyServer() || !focus.has("tx-dependent")) { Assert.assertEquals("Test " + name + (profile == null ? "" : " profile: "+ profile) + ": Expected " + Integer.toString(java.get("errorCount").getAsInt()) + " errors, but found " + Integer.toString(ec) + ".", java.get("errorCount").getAsInt(), ec); if (java.has("warningCount")) { Assert.assertEquals( "Test " + name + (profile == null ? "" : " profile: "+ profile) + ": Expected " + Integer.toString(java.get("warningCount").getAsInt()) + " warnings, but found " + Integer.toString(wc) + ".", java.get("warningCount").getAsInt(), wc); @@ -501,18 +501,18 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe public Element fetch(IResourceValidator validator, Object appContext, String url) throws FHIRFormatError, DefinitionException, IOException, FHIRException { Element res = null; if (url.equals("Patient/test")) { - res = new ObjectConverter(TestingUtilities.context(version)).convert(new Patient()); + res = new ObjectConverter(TestingUtilities.getSharedWorkerContext(version)).convert(new Patient()); } else if (TestingUtilities.findTestResource("validator", url.replace("/", "-").toLowerCase() + ".json")) { - res = Manager.makeParser(TestingUtilities.context(version), FhirFormat.JSON).parseSingle(TestingUtilities.loadTestResourceStream("validator", url.replace("/", "-").toLowerCase() + ".json")); + res = Manager.makeParser(TestingUtilities.getSharedWorkerContext(version), FhirFormat.JSON).parseSingle(TestingUtilities.loadTestResourceStream("validator", url.replace("/", "-").toLowerCase() + ".json")); } else if (TestingUtilities.findTestResource("validator", url.replace("/", "-").toLowerCase() + ".xml")) { - res = Manager.makeParser(TestingUtilities.context(version), FhirFormat.XML).parseSingle(TestingUtilities.loadTestResourceStream("validator", url.replace("/", "-").toLowerCase() + ".xml")); + res = Manager.makeParser(TestingUtilities.getSharedWorkerContext(version), FhirFormat.XML).parseSingle(TestingUtilities.loadTestResourceStream("validator", url.replace("/", "-").toLowerCase() + ".xml")); } if (res == null && url.contains("/")) { String tail = url.substring(url.indexOf("/") + 1); if (TestingUtilities.findTestResource("validator", tail.replace("/", "-").toLowerCase() + ".json")) { - res = Manager.makeParser(TestingUtilities.context(version), FhirFormat.JSON).parseSingle(TestingUtilities.loadTestResourceStream("validator", tail.replace("/", "-").toLowerCase() + ".json")); + res = Manager.makeParser(TestingUtilities.getSharedWorkerContext(version), FhirFormat.JSON).parseSingle(TestingUtilities.loadTestResourceStream("validator", tail.replace("/", "-").toLowerCase() + ".json")); } else if (TestingUtilities.findTestResource("validator", tail.replace("/", "-").toLowerCase() + ".xml")) { - res = Manager.makeParser(TestingUtilities.context(version), FhirFormat.XML).parseSingle(TestingUtilities.loadTestResourceStream("validator", tail.replace("/", "-").toLowerCase() + ".xml")); + res = Manager.makeParser(TestingUtilities.getSharedWorkerContext(version), FhirFormat.XML).parseSingle(TestingUtilities.loadTestResourceStream("validator", tail.replace("/", "-").toLowerCase() + ".xml")); } } return res; @@ -558,7 +558,7 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe @Override public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException { - IResourceValidator val = TestingUtilities.context(version).newValidator(); + IResourceValidator val = TestingUtilities.getSharedWorkerContext(version).newValidator(); List valerrors = new ArrayList(); if (item instanceof Resource) { val.validate(appContext, valerrors, (Resource) item, url); From 65853819d3b4a3d2a0fe557a3b3acf82f98ba4cd Mon Sep 17 00:00:00 2001 From: Lloyd McKenzie Date: Fri, 4 Mar 2022 10:03:55 -0700 Subject: [PATCH 26/50] Hit this bug when handling resource expansions for an STU3 IG. This code would never have worked, so apparently nothing called it before now. --- .../org/hl7/fhir/convertors/txClient/TerminologyClientR3.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/txClient/TerminologyClientR3.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/txClient/TerminologyClientR3.java index 27082bd05..b2c8220a7 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/txClient/TerminologyClientR3.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/txClient/TerminologyClientR3.java @@ -72,7 +72,7 @@ public class TerminologyClientR3 implements TerminologyClient { @Override public ValueSet expandValueset(ValueSet vs, Parameters p, Map params) throws FHIRException { org.hl7.fhir.dstu3.model.ValueSet vs2 = (org.hl7.fhir.dstu3.model.ValueSet) VersionConvertorFactory_30_50.convertResource(vs); - org.hl7.fhir.dstu3.model.ExpansionProfile p2 = (org.hl7.fhir.dstu3.model.ExpansionProfile) VersionConvertorFactory_30_50.convertResource(p); + org.hl7.fhir.dstu3.model.Parameters p2 = (org.hl7.fhir.dstu3.model.Parameters) VersionConvertorFactory_30_50.convertResource(p); vs2 = client.expandValueset(vs2, p2, params); // todo: second parameter return (ValueSet) VersionConvertorFactory_30_50.convertResource(vs2); } From 8df7938f3e50fd773974d17bf25c5a2b317f4a13 Mon Sep 17 00:00:00 2001 From: dotasek Date: Fri, 4 Mar 2022 13:06:44 -0500 Subject: [PATCH 27/50] Update RELEASE_NOTES.md ***NO_CI*** --- RELEASE_NOTES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 7b06c6ab5..20bd38a65 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -4,4 +4,4 @@ ## Other code changes -* no changes \ No newline at end of file +* Fix to r5 TestingUtilities to allow NarrativeGenerationTests to pass. From a5302b8934c9a95fd0a3af5c0793789ce0007a9b Mon Sep 17 00:00:00 2001 From: Lloyd McKenzie Date: Fri, 4 Mar 2022 21:55:31 -0700 Subject: [PATCH 28/50] Fix XML escaping to not escape single-quotes - because our XML serializer always wraps attributes in double-quotes, making escaping unnecessary. --- .../src/main/java/org/hl7/fhir/utilities/xml/XMLUtil.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/XMLUtil.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/XMLUtil.java index 9e0ad4116..34ba270a5 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/XMLUtil.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/XMLUtil.java @@ -273,9 +273,9 @@ public class XMLUtil { for (int i = 0; i < rawContent.length(); i++) { char ch = rawContent.charAt(i); - if (ch == '\'') - sb.append("'"); - else if (ch == '&') + // We don't escape ' because our code always spits out attributes surrounded by "", which means + // it's not necessary to escape ' - and it's *much* less ugly and more bandwidth-efficient when we don't. + if (ch == '&') sb.append("&"); else if (ch == '"') sb.append("""); From ca91cfad1a7aaa7433f6cc229eda8a3131d60e3d Mon Sep 17 00:00:00 2001 From: Lloyd McKenzie Date: Fri, 4 Mar 2022 21:56:27 -0700 Subject: [PATCH 29/50] When running in Eclipse, the version comes in as upper-case, and the enum comparison needs it to be lower-case, so fold it to be that way. --- .../org/hl7/fhir/r5/model/Enumerations.java | 483 +++++++++--------- 1 file changed, 243 insertions(+), 240 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Enumerations.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Enumerations.java index d153c5280..7728bc7ca 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Enumerations.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Enumerations.java @@ -6874,71 +6874,72 @@ The primary difference between a medicationusage and a medicationadministration public static FHIRVersion fromCode(String codeString) throws FHIRException { if (codeString == null || "".equals(codeString)) return null; - if ("0.01".equals(codeString)) - return _0_01; - if ("0.05".equals(codeString)) - return _0_05; - if ("0.06".equals(codeString)) - return _0_06; - if ("0.11".equals(codeString)) - return _0_11; - if ("0.0.80".equals(codeString)) - return _0_0_80; - if ("0.0.81".equals(codeString)) - return _0_0_81; - if ("0.0.82".equals(codeString)) - return _0_0_82; - if ("0.4.0".equals(codeString)) - return _0_4_0; - if ("0.5.0".equals(codeString)) - return _0_5_0; - if ("1.0.0".equals(codeString)) - return _1_0_0; - if ("1.0.1".equals(codeString)) - return _1_0_1; - if ("1.0.2".equals(codeString)) - return _1_0_2; - if ("1.1.0".equals(codeString)) - return _1_1_0; - if ("1.4.0".equals(codeString)) - return _1_4_0; - if ("1.6.0".equals(codeString)) - return _1_6_0; - if ("1.8.0".equals(codeString)) - return _1_8_0; - if ("3.0.0".equals(codeString)) - return _3_0_0; - if ("3.0.1".equals(codeString)) - return _3_0_1; - if ("3.0.2".equals(codeString)) - return _3_0_2; - if ("3.3.0".equals(codeString)) - return _3_3_0; - if ("3.5.0".equals(codeString)) - return _3_5_0; - if ("4.0.0".equals(codeString)) - return _4_0_0; - if ("4.0.1".equals(codeString)) - return _4_0_1; - if ("4.1.0".equals(codeString)) - return _4_1_0; - if ("4.2.0".equals(codeString)) - return _4_2_0; - if ("4.3.0-snapshot1".equals(codeString)) - return _4_3_0SNAPSHOT1; - if ("4.3.0-cibuild".equals(codeString)) - return _4_3_0CIBUILD; - if ("4.4.0".equals(codeString)) - return _4_4_0; - if ("4.5.0".equals(codeString)) - return _4_5_0; - if ("4.6.0".equals(codeString)) - return _4_6_0; - if ("5.0.0-snapshot1".equals(codeString)) - return _5_0_0SNAPSHOT1; - if ("5.0.0-cibuild".equals(codeString)) - return _5_0_0CIBUILD; - throw new FHIRException("Unknown FHIRVersion code '"+codeString+"'"); + codeString = codeString.toLowerCase(); + if ("0.01".equals(codeString)) + return _0_01; + if ("0.05".equals(codeString)) + return _0_05; + if ("0.06".equals(codeString)) + return _0_06; + if ("0.11".equals(codeString)) + return _0_11; + if ("0.0.80".equals(codeString)) + return _0_0_80; + if ("0.0.81".equals(codeString)) + return _0_0_81; + if ("0.0.82".equals(codeString)) + return _0_0_82; + if ("0.4.0".equals(codeString)) + return _0_4_0; + if ("0.5.0".equals(codeString)) + return _0_5_0; + if ("1.0.0".equals(codeString)) + return _1_0_0; + if ("1.0.1".equals(codeString)) + return _1_0_1; + if ("1.0.2".equals(codeString)) + return _1_0_2; + if ("1.1.0".equals(codeString)) + return _1_1_0; + if ("1.4.0".equals(codeString)) + return _1_4_0; + if ("1.6.0".equals(codeString)) + return _1_6_0; + if ("1.8.0".equals(codeString)) + return _1_8_0; + if ("3.0.0".equals(codeString)) + return _3_0_0; + if ("3.0.1".equals(codeString)) + return _3_0_1; + if ("3.0.2".equals(codeString)) + return _3_0_2; + if ("3.3.0".equals(codeString)) + return _3_3_0; + if ("3.5.0".equals(codeString)) + return _3_5_0; + if ("4.0.0".equals(codeString)) + return _4_0_0; + if ("4.0.1".equals(codeString)) + return _4_0_1; + if ("4.1.0".equals(codeString)) + return _4_1_0; + if ("4.2.0".equals(codeString)) + return _4_2_0; + if ("4.3.0-snapshot1".equals(codeString)) + return _4_3_0SNAPSHOT1; + if ("4.3.0-cibuild".equals(codeString)) + return _4_3_0CIBUILD; + if ("4.4.0".equals(codeString)) + return _4_4_0; + if ("4.5.0".equals(codeString)) + return _4_5_0; + if ("4.6.0".equals(codeString)) + return _4_6_0; + if ("5.0.0-snapshot1".equals(codeString)) + return _5_0_0SNAPSHOT1; + if ("5.0.0-cibuild".equals(codeString)) + return _5_0_0CIBUILD; + throw new FHIRException("Unknown FHIRVersion code '"+codeString+"'"); } public String toCode() { switch (this) { @@ -7104,51 +7105,52 @@ public String toCode(int len) { public static boolean isValidCode(String codeString) { if (codeString == null || "".equals(codeString)) return false; - if ("0.01".equals(codeString)) - return true; - if ("0.05".equals(codeString)) - return true; - if ("0.06".equals(codeString)) - return true; - if ("0.11".equals(codeString)) - return true; - if ("0.0.80".equals(codeString)) - return true; - if ("0.0.81".equals(codeString)) - return true; - if ("0.0.82".equals(codeString)) - return true; - if ("0.4.0".equals(codeString)) - return true; - if ("0.5.0".equals(codeString)) - return true; - if ("1.0.0".equals(codeString)) - return true; - if ("1.0.1".equals(codeString)) - return true; - if ("1.0.2".equals(codeString)) - return true; - if ("1.1.0".equals(codeString)) - return true; - if ("1.4.0".equals(codeString)) - return true; - if ("1.6.0".equals(codeString)) - return true; - if ("1.8.0".equals(codeString)) - return true; - if ("3.0.0".equals(codeString)) - return true; - if ("3.0.1".equals(codeString)) - return true; - if ("3.3.0".equals(codeString)) - return true; - if ("3.5.0".equals(codeString)) - return true; - if ("4.0.0".equals(codeString)) - return true; - if ("4.2.0".equals(codeString)) - return true; - return false; + codeString = codeString.toLowerCase(); + if ("0.01".equals(codeString)) + return true; + if ("0.05".equals(codeString)) + return true; + if ("0.06".equals(codeString)) + return true; + if ("0.11".equals(codeString)) + return true; + if ("0.0.80".equals(codeString)) + return true; + if ("0.0.81".equals(codeString)) + return true; + if ("0.0.82".equals(codeString)) + return true; + if ("0.4.0".equals(codeString)) + return true; + if ("0.5.0".equals(codeString)) + return true; + if ("1.0.0".equals(codeString)) + return true; + if ("1.0.1".equals(codeString)) + return true; + if ("1.0.2".equals(codeString)) + return true; + if ("1.1.0".equals(codeString)) + return true; + if ("1.4.0".equals(codeString)) + return true; + if ("1.6.0".equals(codeString)) + return true; + if ("1.8.0".equals(codeString)) + return true; + if ("3.0.0".equals(codeString)) + return true; + if ("3.0.1".equals(codeString)) + return true; + if ("3.3.0".equals(codeString)) + return true; + if ("3.5.0".equals(codeString)) + return true; + if ("4.0.0".equals(codeString)) + return true; + if ("4.2.0".equals(codeString)) + return true; + return false; } @Override @@ -7169,71 +7171,72 @@ public String toCode(int len) { if (codeString == null || "".equals(codeString)) if (codeString == null || "".equals(codeString)) return null; - if ("0.01".equals(codeString)) - return FHIRVersion._0_01; - if ("0.05".equals(codeString)) - return FHIRVersion._0_05; - if ("0.06".equals(codeString)) - return FHIRVersion._0_06; - if ("0.11".equals(codeString)) - return FHIRVersion._0_11; - if ("0.0.80".equals(codeString)) - return FHIRVersion._0_0_80; - if ("0.0.81".equals(codeString)) - return FHIRVersion._0_0_81; - if ("0.0.82".equals(codeString)) - return FHIRVersion._0_0_82; - if ("0.4.0".equals(codeString)) - return FHIRVersion._0_4_0; - if ("0.5.0".equals(codeString)) - return FHIRVersion._0_5_0; - if ("1.0.0".equals(codeString)) - return FHIRVersion._1_0_0; - if ("1.0.1".equals(codeString)) - return FHIRVersion._1_0_1; - if ("1.0.2".equals(codeString)) - return FHIRVersion._1_0_2; - if ("1.1.0".equals(codeString)) - return FHIRVersion._1_1_0; - if ("1.4.0".equals(codeString)) - return FHIRVersion._1_4_0; - if ("1.6.0".equals(codeString)) - return FHIRVersion._1_6_0; - if ("1.8.0".equals(codeString)) - return FHIRVersion._1_8_0; - if ("3.0.0".equals(codeString)) - return FHIRVersion._3_0_0; - if ("3.0.1".equals(codeString)) - return FHIRVersion._3_0_1; - if ("3.0.2".equals(codeString)) - return FHIRVersion._3_0_2; - if ("3.3.0".equals(codeString)) - return FHIRVersion._3_3_0; - if ("3.5.0".equals(codeString)) - return FHIRVersion._3_5_0; - if ("4.0.0".equals(codeString)) - return FHIRVersion._4_0_0; - if ("4.0.1".equals(codeString)) - return FHIRVersion._4_0_1; - if ("4.1.0".equals(codeString)) - return FHIRVersion._4_1_0; - if ("4.2.0".equals(codeString)) - return FHIRVersion._4_2_0; - if ("4.3.0-snapshot1".equals(codeString)) - return FHIRVersion._4_3_0SNAPSHOT1; - if ("4.3.0-cibuild".equals(codeString)) - return FHIRVersion._4_3_0CIBUILD; - if ("4.4.0".equals(codeString)) - return FHIRVersion._4_4_0; - if ("4.5.0".equals(codeString)) - return FHIRVersion._4_5_0; - if ("4.6.0".equals(codeString)) - return FHIRVersion._4_6_0; - if ("5.0.0-snapshot1".equals(codeString)) - return FHIRVersion._5_0_0SNAPSHOT1; - if ("5.0.0-cibuild".equals(codeString)) - return FHIRVersion._5_0_0CIBUILD; - throw new IllegalArgumentException("Unknown FHIRVersion code '"+codeString+"'"); + codeString = codeString.toLowerCase(); + if ("0.01".equals(codeString)) + return FHIRVersion._0_01; + if ("0.05".equals(codeString)) + return FHIRVersion._0_05; + if ("0.06".equals(codeString)) + return FHIRVersion._0_06; + if ("0.11".equals(codeString)) + return FHIRVersion._0_11; + if ("0.0.80".equals(codeString)) + return FHIRVersion._0_0_80; + if ("0.0.81".equals(codeString)) + return FHIRVersion._0_0_81; + if ("0.0.82".equals(codeString)) + return FHIRVersion._0_0_82; + if ("0.4.0".equals(codeString)) + return FHIRVersion._0_4_0; + if ("0.5.0".equals(codeString)) + return FHIRVersion._0_5_0; + if ("1.0.0".equals(codeString)) + return FHIRVersion._1_0_0; + if ("1.0.1".equals(codeString)) + return FHIRVersion._1_0_1; + if ("1.0.2".equals(codeString)) + return FHIRVersion._1_0_2; + if ("1.1.0".equals(codeString)) + return FHIRVersion._1_1_0; + if ("1.4.0".equals(codeString)) + return FHIRVersion._1_4_0; + if ("1.6.0".equals(codeString)) + return FHIRVersion._1_6_0; + if ("1.8.0".equals(codeString)) + return FHIRVersion._1_8_0; + if ("3.0.0".equals(codeString)) + return FHIRVersion._3_0_0; + if ("3.0.1".equals(codeString)) + return FHIRVersion._3_0_1; + if ("3.0.2".equals(codeString)) + return FHIRVersion._3_0_2; + if ("3.3.0".equals(codeString)) + return FHIRVersion._3_3_0; + if ("3.5.0".equals(codeString)) + return FHIRVersion._3_5_0; + if ("4.0.0".equals(codeString)) + return FHIRVersion._4_0_0; + if ("4.0.1".equals(codeString)) + return FHIRVersion._4_0_1; + if ("4.1.0".equals(codeString)) + return FHIRVersion._4_1_0; + if ("4.2.0".equals(codeString)) + return FHIRVersion._4_2_0; + if ("4.3.0-snapshot1".equals(codeString)) + return FHIRVersion._4_3_0SNAPSHOT1; + if ("4.3.0-cibuild".equals(codeString)) + return FHIRVersion._4_3_0CIBUILD; + if ("4.4.0".equals(codeString)) + return FHIRVersion._4_4_0; + if ("4.5.0".equals(codeString)) + return FHIRVersion._4_5_0; + if ("4.6.0".equals(codeString)) + return FHIRVersion._4_6_0; + if ("5.0.0-snapshot1".equals(codeString)) + return FHIRVersion._5_0_0SNAPSHOT1; + if ("5.0.0-cibuild".equals(codeString)) + return FHIRVersion._5_0_0CIBUILD; + throw new IllegalArgumentException("Unknown FHIRVersion code '"+codeString+"'"); } public Enumeration fromType(Base code) throws FHIRException { if (code == null) @@ -7243,71 +7246,71 @@ public String toCode(int len) { String codeString = ((PrimitiveType) code).asStringValue(); if (codeString == null || "".equals(codeString)) return null; - if ("0.01".equals(codeString)) - return new Enumeration(this, FHIRVersion._0_01); - if ("0.05".equals(codeString)) - return new Enumeration(this, FHIRVersion._0_05); - if ("0.06".equals(codeString)) - return new Enumeration(this, FHIRVersion._0_06); - if ("0.11".equals(codeString)) - return new Enumeration(this, FHIRVersion._0_11); - if ("0.0.80".equals(codeString)) - return new Enumeration(this, FHIRVersion._0_0_80); - if ("0.0.81".equals(codeString)) - return new Enumeration(this, FHIRVersion._0_0_81); - if ("0.0.82".equals(codeString)) - return new Enumeration(this, FHIRVersion._0_0_82); - if ("0.4.0".equals(codeString)) - return new Enumeration(this, FHIRVersion._0_4_0); - if ("0.5.0".equals(codeString)) - return new Enumeration(this, FHIRVersion._0_5_0); - if ("1.0.0".equals(codeString)) - return new Enumeration(this, FHIRVersion._1_0_0); - if ("1.0.1".equals(codeString)) - return new Enumeration(this, FHIRVersion._1_0_1); - if ("1.0.2".equals(codeString)) - return new Enumeration(this, FHIRVersion._1_0_2); - if ("1.1.0".equals(codeString)) - return new Enumeration(this, FHIRVersion._1_1_0); - if ("1.4.0".equals(codeString)) - return new Enumeration(this, FHIRVersion._1_4_0); - if ("1.6.0".equals(codeString)) - return new Enumeration(this, FHIRVersion._1_6_0); - if ("1.8.0".equals(codeString)) - return new Enumeration(this, FHIRVersion._1_8_0); - if ("3.0.0".equals(codeString)) - return new Enumeration(this, FHIRVersion._3_0_0); - if ("3.0.1".equals(codeString)) - return new Enumeration(this, FHIRVersion._3_0_1); - if ("3.0.2".equals(codeString)) - return new Enumeration(this, FHIRVersion._3_0_2); - if ("3.3.0".equals(codeString)) - return new Enumeration(this, FHIRVersion._3_3_0); - if ("3.5.0".equals(codeString)) - return new Enumeration(this, FHIRVersion._3_5_0); - if ("4.0.0".equals(codeString)) - return new Enumeration(this, FHIRVersion._4_0_0); - if ("4.0.1".equals(codeString)) - return new Enumeration(this, FHIRVersion._4_0_1); - if ("4.1.0".equals(codeString)) - return new Enumeration(this, FHIRVersion._4_1_0); - if ("4.2.0".equals(codeString)) - return new Enumeration(this, FHIRVersion._4_2_0); - if ("4.3.0-snapshot1".equals(codeString)) - return new Enumeration(this, FHIRVersion._4_3_0SNAPSHOT1); - if ("4.3.0-cibuild".equals(codeString)) - return new Enumeration(this, FHIRVersion._4_3_0CIBUILD); - if ("4.4.0".equals(codeString)) - return new Enumeration(this, FHIRVersion._4_4_0); - if ("4.5.0".equals(codeString)) - return new Enumeration(this, FHIRVersion._4_5_0); - if ("4.6.0".equals(codeString)) - return new Enumeration(this, FHIRVersion._4_6_0); - if ("5.0.0-snapshot1".equals(codeString)) - return new Enumeration(this, FHIRVersion._5_0_0SNAPSHOT1); - if ("5.0.0-cibuild".equals(codeString)) - return new Enumeration(this, FHIRVersion._5_0_0CIBUILD); - throw new FHIRException("Unknown FHIRVersion code '"+codeString+"'"); + if ("0.01".equals(codeString)) + return new Enumeration(this, FHIRVersion._0_01); + if ("0.05".equals(codeString)) + return new Enumeration(this, FHIRVersion._0_05); + if ("0.06".equals(codeString)) + return new Enumeration(this, FHIRVersion._0_06); + if ("0.11".equals(codeString)) + return new Enumeration(this, FHIRVersion._0_11); + if ("0.0.80".equals(codeString)) + return new Enumeration(this, FHIRVersion._0_0_80); + if ("0.0.81".equals(codeString)) + return new Enumeration(this, FHIRVersion._0_0_81); + if ("0.0.82".equals(codeString)) + return new Enumeration(this, FHIRVersion._0_0_82); + if ("0.4.0".equals(codeString)) + return new Enumeration(this, FHIRVersion._0_4_0); + if ("0.5.0".equals(codeString)) + return new Enumeration(this, FHIRVersion._0_5_0); + if ("1.0.0".equals(codeString)) + return new Enumeration(this, FHIRVersion._1_0_0); + if ("1.0.1".equals(codeString)) + return new Enumeration(this, FHIRVersion._1_0_1); + if ("1.0.2".equals(codeString)) + return new Enumeration(this, FHIRVersion._1_0_2); + if ("1.1.0".equals(codeString)) + return new Enumeration(this, FHIRVersion._1_1_0); + if ("1.4.0".equals(codeString)) + return new Enumeration(this, FHIRVersion._1_4_0); + if ("1.6.0".equals(codeString)) + return new Enumeration(this, FHIRVersion._1_6_0); + if ("1.8.0".equals(codeString)) + return new Enumeration(this, FHIRVersion._1_8_0); + if ("3.0.0".equals(codeString)) + return new Enumeration(this, FHIRVersion._3_0_0); + if ("3.0.1".equals(codeString)) + return new Enumeration(this, FHIRVersion._3_0_1); + if ("3.0.2".equals(codeString)) + return new Enumeration(this, FHIRVersion._3_0_2); + if ("3.3.0".equals(codeString)) + return new Enumeration(this, FHIRVersion._3_3_0); + if ("3.5.0".equals(codeString)) + return new Enumeration(this, FHIRVersion._3_5_0); + if ("4.0.0".equals(codeString)) + return new Enumeration(this, FHIRVersion._4_0_0); + if ("4.0.1".equals(codeString)) + return new Enumeration(this, FHIRVersion._4_0_1); + if ("4.1.0".equals(codeString)) + return new Enumeration(this, FHIRVersion._4_1_0); + if ("4.2.0".equals(codeString)) + return new Enumeration(this, FHIRVersion._4_2_0); + if ("4.3.0-snapshot1".equals(codeString)) + return new Enumeration(this, FHIRVersion._4_3_0SNAPSHOT1); + if ("4.3.0-cibuild".equals(codeString)) + return new Enumeration(this, FHIRVersion._4_3_0CIBUILD); + if ("4.4.0".equals(codeString)) + return new Enumeration(this, FHIRVersion._4_4_0); + if ("4.5.0".equals(codeString)) + return new Enumeration(this, FHIRVersion._4_5_0); + if ("4.6.0".equals(codeString)) + return new Enumeration(this, FHIRVersion._4_6_0); + if ("5.0.0-snapshot1".equals(codeString)) + return new Enumeration(this, FHIRVersion._5_0_0SNAPSHOT1); + if ("5.0.0-cibuild".equals(codeString)) + return new Enumeration(this, FHIRVersion._5_0_0CIBUILD); + throw new FHIRException("Unknown FHIRVersion code '"+codeString+"'"); } public String toCode(FHIRVersion code) { if (code == FHIRVersion._0_01) From 9f01f7c9f22b8ae5fe83856dd215523cec79141e Mon Sep 17 00:00:00 2001 From: Lloyd McKenzie Date: Fri, 4 Mar 2022 21:58:17 -0700 Subject: [PATCH 30/50] Per FHIR-31722 and FHIR-34453, ensure that CodeableReference and RatioRange aren't allowed in extensions Parameters, etc. in R4B --- .../main/java/org/hl7/fhir/r5/utils/TypesUtilities.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/TypesUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/TypesUtilities.java index 22c7f7706..84bd15995 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/TypesUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/TypesUtilities.java @@ -132,7 +132,9 @@ public class TypesUtilities { res.add(new WildcardInformation("Annotation", TypeClassification.DATATYPE)); res.add(new WildcardInformation("Attachment", TypeClassification.DATATYPE)); res.add(new WildcardInformation("CodeableConcept", TypeClassification.DATATYPE)); - res.add(new WildcardInformation("CodeableReference", TypeClassification.DATATYPE)); + if (!VersionUtilities.isR4BVer(version)) { + res.add(new WildcardInformation("CodeableReference", TypeClassification.DATATYPE)); + } res.add(new WildcardInformation("Coding", TypeClassification.DATATYPE)); res.add(new WildcardInformation("ContactPoint", TypeClassification.DATATYPE)); res.add(new WildcardInformation("Count", TypeClassification.DATATYPE)); @@ -145,7 +147,9 @@ public class TypesUtilities { res.add(new WildcardInformation("Quantity", TypeClassification.DATATYPE)); res.add(new WildcardInformation("Range", TypeClassification.DATATYPE)); res.add(new WildcardInformation("Ratio", TypeClassification.DATATYPE)); - res.add(new WildcardInformation("RatioRange", TypeClassification.DATATYPE)); + if (!VersionUtilities.isR4BVer(version)) { + res.add(new WildcardInformation("RatioRange", TypeClassification.DATATYPE)); + } res.add(new WildcardInformation("Reference", " - a reference to another resource", TypeClassification.DATATYPE)); res.add(new WildcardInformation("SampledData", TypeClassification.DATATYPE)); res.add(new WildcardInformation("Signature", TypeClassification.DATATYPE)); From bb06bae4e645b8b5de163be5ffef39b2696c00f2 Mon Sep 17 00:00:00 2001 From: dotasek Date: Mon, 7 Mar 2022 16:02:00 -0500 Subject: [PATCH 31/50] Apply uniform capitalization requirements for JSON --- .../java/org/hl7/fhir/utilities/npm/PackageClient.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/PackageClient.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/PackageClient.java index 90914dc27..789e65a44 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/PackageClient.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/PackageClient.java @@ -81,10 +81,10 @@ public class PackageClient { if (versions != null) { for (String v : sorted(versions.keySet())) { JsonObject obj = versions.getAsJsonObject(v); - res.add(new PackageInfo(JSONUtil.str(obj, "name"), - JSONUtil.str(obj, "version"), - JSONUtil.str(obj, "FhirVersion"), - JSONUtil.str(obj, "description"), + res.add(new PackageInfo(JSONUtil.str(obj, "Name", "name"), + JSONUtil.str(obj, "Version", "version"), + JSONUtil.str(obj, "FhirVersion", "fhirVersion"), + JSONUtil.str(obj, "Description", "description"), JSONUtil.str(obj, "url"), JSONUtil.str(obj, "canonical"), address)); From cc983073cdc1dbdf032edfd43dc67f5830ecd6a7 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Tue, 8 Mar 2022 13:19:19 +1100 Subject: [PATCH 32/50] more cross version extensions --- RELEASE_NOTES.md | 9 ++++++++- .../java/org/hl7/fhir/r5/utils/XVerExtensionManager.java | 6 ------ .../java/org/hl7/fhir/utilities/npm/CommonPackages.java | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 7b06c6ab5..c689c8032 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -4,4 +4,11 @@ ## Other code changes -* no changes \ No newline at end of file +* no changes + +more presenting extensions when rendering. +4f652bc +fix handling of xver extensions with choice sub-extensions + + Get package id from 'package' field when 'npm-package' unavailable + \ No newline at end of file diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/XVerExtensionManager.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/XVerExtensionManager.java index 7d27c4782..2b435782d 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/XVerExtensionManager.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/XVerExtensionManager.java @@ -50,9 +50,6 @@ public class XVerExtensionManager { return XVerExtensionStatus.Invalid; } String v = url.substring(20, 23); - if ("5.0".equals(v)) { - v = "4.6"; // for now - } String e = url.substring(54); if (!lists.containsKey(v)) { if (context.getBinaries().containsKey("xver-paths-"+v+".json")) { @@ -86,9 +83,6 @@ public class XVerExtensionManager { public StructureDefinition makeDefinition(String url) { String verSource = url.substring(20, 23); - if ("5.0".equals(verSource)) { - verSource = "4.6"; // for now - } String verTarget = VersionUtilities.getMajMin(context.getVersion()); String e = url.substring(54); JsonObject root = lists.get(verSource); diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/CommonPackages.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/CommonPackages.java index 284cabed8..6394384b3 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/CommonPackages.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/CommonPackages.java @@ -3,7 +3,7 @@ package org.hl7.fhir.utilities.npm; public class CommonPackages { public static final String ID_XVER = "hl7.fhir.xver-extensions"; - public static final String VER_XVER = "0.0.8"; + public static final String VER_XVER = "0.0.9"; public static final String ID_PUBPACK = "hl7.fhir.pubpack"; public static final String VER_PUBPACK = "0.0.9"; From d7754a321f30bb647c603c231b2fcdaf24828e44 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 9 Mar 2022 17:36:39 +1100 Subject: [PATCH 33/50] Fix snapshot generation - always populate constraint source properly --- .../fhir/r5/conformance/ProfileUtilities.java | 15 +++++++++ .../fhir/r5/test/ProfileUtilitiesTests.java | 31 +++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java index 26aeb35e0..55caa008f 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java @@ -1091,6 +1091,7 @@ public class ProfileUtilities extends TranslatingUtilities { ElementDefinition outcome = updateURLs(url, webUrl, currentBase.copy()); outcome.setPath(fixedPathDest(contextPathDst, outcome.getPath(), redirector, contextPathSrc)); updateFromBase(outcome, currentBase); + updateConstraintSources(outcome, srcSD.getUrl()); markDerived(outcome); if (resultPathBase == null) resultPathBase = outcome.getPath(); @@ -1927,6 +1928,15 @@ public class ProfileUtilities extends TranslatingUtilities { return res; } + private void updateConstraintSources(ElementDefinition ed, String url) { + for (ElementDefinitionConstraintComponent c : ed.getConstraint()) { + if (!c.hasSource()) { + c.setSource(url); + } + } + + } + private Set getListOfTypes(ElementDefinition e) { Set result = new HashSet<>(); for (TypeRefComponent t : e.getType()) { @@ -2422,6 +2432,11 @@ public class ProfileUtilities extends TranslatingUtilities { StructureDefinition sd = null; if (type.hasProfile()) { sd = context.fetchResource(StructureDefinition.class, type.getProfile().get(0).getValue()); + if (sd == null) { + if (xver != null && xver.matchingUrl(type.getProfile().get(0).getValue()) && xver.status(type.getProfile().get(0).getValue()) == XVerExtensionStatus.Valid) { + sd = xver.makeDefinition(type.getProfile().get(0).getValue()); + } + } if (sd == null) System.out.println("Failed to find referenced profile: " + type.getProfile()); } diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ProfileUtilitiesTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ProfileUtilitiesTests.java index e5a62e947..c7e650f8e 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ProfileUtilitiesTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ProfileUtilitiesTests.java @@ -7,6 +7,7 @@ import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.r5.conformance.ProfileUtilities; import org.hl7.fhir.r5.model.Base; import org.hl7.fhir.r5.model.ElementDefinition; +import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent; import org.hl7.fhir.r5.model.IntegerType; import org.hl7.fhir.r5.model.StructureDefinition; import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule; @@ -51,6 +52,12 @@ public class ProfileUtilitiesTests { f.setBase(null); b.setRequirements(null); f.setRequirements(null); + for (ElementDefinitionConstraintComponent c : b.getConstraint()) { + c.setSource(null); + } + for (ElementDefinitionConstraintComponent c : f.getConstraint()) { + c.setSource(null); + } ok = Base.compareDeep(b, f, true); } } @@ -83,6 +90,12 @@ public class ProfileUtilitiesTests { if (ok) { ElementDefinition b = base.getSnapshot().getElement().get(i); ElementDefinition f = focus.getSnapshot().getElement().get(i); + for (ElementDefinitionConstraintComponent c : b.getConstraint()) { + c.setSource(null); + } + for (ElementDefinitionConstraintComponent c : f.getConstraint()) { + c.setSource(null); + } if (!f.hasBase() || !b.getPath().equals(f.getPath())) ok = false; else { @@ -128,6 +141,12 @@ public class ProfileUtilitiesTests { ElementDefinition f = focus.getSnapshot().getElement().get(i); b.setRequirements(null); f.setRequirements(null); + for (ElementDefinitionConstraintComponent c : b.getConstraint()) { + c.setSource(null); + } + for (ElementDefinitionConstraintComponent c : f.getConstraint()) { + c.setSource(null); + } if (!f.hasBase() || !b.getPath().equals(f.getPath())) { ok = false; } @@ -174,6 +193,12 @@ public class ProfileUtilitiesTests { ElementDefinition f = focus.getSnapshot().getElement().get(i); b.setRequirements(null); f.setRequirements(null); + for (ElementDefinitionConstraintComponent c : b.getConstraint()) { + c.setSource(null); + } + for (ElementDefinitionConstraintComponent c : f.getConstraint()) { + c.setSource(null); + } if (!f.hasBase() || !b.getPath().equals(f.getPath())) { ok = false; } @@ -221,6 +246,12 @@ public class ProfileUtilitiesTests { ElementDefinition f = focus.getSnapshot().getElement().get(i); b.setRequirements(null); f.setRequirements(null); + for (ElementDefinitionConstraintComponent c : b.getConstraint()) { + c.setSource(null); + } + for (ElementDefinitionConstraintComponent c : f.getConstraint()) { + c.setSource(null); + } if (!f.hasBase() || !b.getPath().equals(f.getPath())) { ok = false; } From 89b912dde29e63fed0c84b22360d7b9c66041650 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 9 Mar 2022 17:37:26 +1100 Subject: [PATCH 34/50] Fix cross version extension validation, and check that extensions are consistent wrt isModifier in profiles --- .../fhir/r5/utils/XVerExtensionManager.java | 4 +++- .../fhir/utilities/i18n/I18nConstants.java | 2 ++ .../fhir/utilities/npm/CommonPackages.java | 2 +- .../src/main/resources/Messages.properties | 2 ++ .../type/StructureDefinitionValidator.java | 23 +++++++++++++++++++ 5 files changed, 31 insertions(+), 2 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/XVerExtensionManager.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/XVerExtensionManager.java index 2b435782d..d78178566 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/XVerExtensionManager.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/XVerExtensionManager.java @@ -117,16 +117,18 @@ public class XVerExtensionManager { populateTypes(path, val, verSource, verTarget); } else if (path.has("elements")) { for (JsonElement i : path.getAsJsonArray("elements")) { + JsonObject elt = root.getAsJsonObject(e+"."+i.getAsString()); + if (elt != null) { String s = i.getAsString().replace("[x]", ""); sd.getDifferential().addElement().setPath("Extension.extension").setSliceName(s); sd.getDifferential().addElement().setPath("Extension.extension.extension").setMax("0"); sd.getDifferential().addElement().setPath("Extension.extension.url").setFixed(new UriType(s)); ElementDefinition val = sd.getDifferential().addElement().setPath("Extension.extension.value[x]").setMin(1); - JsonObject elt = root.getAsJsonObject(e+"."+i.getAsString()); if (!elt.has("types")) { throw new FHIRException("Internal error - nested elements not supported yet"); } populateTypes(elt, val, verSource, verTarget); + } } sd.getDifferential().addElement().setPath("Extension.url").setFixed(new UriType(url)); sd.getDifferential().addElement().setPath("Extension.value[x]").setMax("0"); diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/I18nConstants.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/I18nConstants.java index b8595a111..a3d1cf554 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/I18nConstants.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/I18nConstants.java @@ -366,6 +366,8 @@ public class I18nConstants { public static final String SD_ED_TYPE_PROFILE_UNKNOWN = "SD_ED_TYPE_PROFILE_UNKNOWN"; public static final String SD_ED_TYPE_PROFILE_NOTYPE = "SD_ED_TYPE_PROFILE_NOTYPE"; public static final String SD_ED_TYPE_PROFILE_WRONG = "SD_ED_TYPE_PROFILE_WRONG"; + public static final String SD_ED_TYPE_PROFILE_IS_MODIFIER = "SD_ED_TYPE_PROFILE_IS_MODIFIER"; + public static final String SD_ED_TYPE_PROFILE_NOT_MODIFIER = "SD_ED_TYPE_PROFILE_NOT_MODIFIER"; public static final String SD_ED_TYPE_PROFILE_WRONG_TARGET = "SD_ED_TYPE_PROFILE_WRONG_TARGET"; public static final String SD_ED_TYPE_NO_TARGET_PROFILE = "SD_ED_TYPE_NO_TARGET_PROFILE"; public static final String SD_ED_SHOULD_BIND = "SD_ED_SHOULD_BIND"; diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/CommonPackages.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/CommonPackages.java index 6394384b3..f62731099 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/CommonPackages.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/CommonPackages.java @@ -3,7 +3,7 @@ package org.hl7.fhir.utilities.npm; public class CommonPackages { public static final String ID_XVER = "hl7.fhir.xver-extensions"; - public static final String VER_XVER = "0.0.9"; + public static final String VER_XVER = "0.0.11"; public static final String ID_PUBPACK = "hl7.fhir.pubpack"; public static final String VER_PUBPACK = "0.0.9"; diff --git a/org.hl7.fhir.utilities/src/main/resources/Messages.properties b/org.hl7.fhir.utilities/src/main/resources/Messages.properties index 921678728..fa1748615 100644 --- a/org.hl7.fhir.utilities/src/main/resources/Messages.properties +++ b/org.hl7.fhir.utilities/src/main/resources/Messages.properties @@ -629,6 +629,8 @@ Unable_to_connect_to_terminology_server = Unable to connect to terminology serve SD_ED_TYPE_PROFILE_UNKNOWN = Unable to resolve profile {0} SD_ED_TYPE_PROFILE_NOTYPE = Found profile {0}, but unable to determine the type it applies to SD_ED_TYPE_PROFILE_WRONG = Profile {0} is for type {1}, but the {3} element has type {2} +SD_ED_TYPE_PROFILE_IS_MODIFIER = Profile {0} is for not for a modifier extension, but the {3} element is a modifier +SD_ED_TYPE_PROFILE_NOT_MODIFIER = Profile {0} is for a modifier extension, but the {3} element is not a modifier SD_ED_TYPE_PROFILE_WRONG_TARGET = Profile {0} is for type {1}, which is not a {4} (which is required because the {3} element has type {2}) SD_ED_TYPE_NO_TARGET_PROFILE = Type {0} does not allow for target Profiles TERMINOLOGY_TX_NOSVC_BOUND_REQ = Could not confirm that the codes provided are from the required value set {0} because there is no terminology service diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/StructureDefinitionValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/StructureDefinitionValidator.java index 7eb98cc1b..0bbd1792a 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/StructureDefinitionValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/StructureDefinitionValidator.java @@ -294,6 +294,15 @@ public class StructureDefinitionValidator extends BaseValidator { rule(errors, IssueType.EXCEPTION, stack.getLiteralPath(), false, I18nConstants.SD_ED_TYPE_PROFILE_NOTYPE, p); } else { rule(errors, IssueType.EXCEPTION, stack.getLiteralPath(), isInstanceOf(t, code), I18nConstants.SD_ED_TYPE_PROFILE_WRONG, p, t, code, path); + if (t.getType().equals("Extension")) { + boolean isModifierDefinition = checkIsModifierExtension(sd); + boolean isModifierContext = path.endsWith(".modifierExtension"); + if (isModifierDefinition) { + rule(errors, IssueType.EXCEPTION, stack.getLiteralPath(), isModifierContext, I18nConstants.SD_ED_TYPE_PROFILE_NOT_MODIFIER, p, t, code, path); + } else { + rule(errors, IssueType.EXCEPTION, stack.getLiteralPath(), !isModifierContext, I18nConstants.SD_ED_TYPE_PROFILE_IS_MODIFIER, p, t, code, path); + } + } } } } @@ -325,10 +334,24 @@ public class StructureDefinitionValidator extends BaseValidator { rule(errors, IssueType.EXCEPTION, stack.getLiteralPath(), false, I18nConstants.SD_ED_TYPE_PROFILE_NOTYPE, p); } else if (!isInstanceOf(t, code)) { rule(errors, IssueType.EXCEPTION, stack.getLiteralPath(), false, I18nConstants.SD_ED_TYPE_PROFILE_WRONG, p, t, code, path); + } else { + if (t.getType().equals("Extension")) { + boolean isModifierDefinition = checkIsModifierExtension(sd); + boolean isModifierContext = path.endsWith(".modifierExtension"); + if (isModifierDefinition) { + rule(errors, IssueType.EXCEPTION, stack.getLiteralPath(), isModifierContext, I18nConstants.SD_ED_TYPE_PROFILE_NOT_MODIFIER, p, t, code, path); + } else { + rule(errors, IssueType.EXCEPTION, stack.getLiteralPath(), !isModifierContext, I18nConstants.SD_ED_TYPE_PROFILE_IS_MODIFIER, p, t, code, path); + } + } } } } + private boolean checkIsModifierExtension(StructureDefinition t) { + return t.getSnapshot().getElementFirstRep().getIsModifier(); + } + private void validateTargetProfile(List errors, Element profile, String code, NodeStack stack, String path) { String p = profile.primitiveValue(); StructureDefinition sd = context.fetchResource(StructureDefinition.class, p); From f9c3ac3c0adc9245397c4c9c1026afa156bd49a3 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 9 Mar 2022 21:31:57 +1100 Subject: [PATCH 35/50] test case version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cfce9bbe8..dbb6f8c5a 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 5.4.0 - 1.1.90 + 1.1.92 5.7.1 1.7.1 3.0.0-M5 From 603bd0407d0bd8cbaa550dc1f17c596b05de1fbc Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Thu, 10 Mar 2022 06:52:26 +1100 Subject: [PATCH 36/50] fix r4b tests From 33f6c57d487d9103819cc63093d429689f82dfe0 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Thu, 10 Mar 2022 06:52:44 +1100 Subject: [PATCH 37/50] fix NPE --- .../java/org/hl7/fhir/r5/conformance/ProfileUtilities.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java index 55caa008f..8e9e0bf51 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java @@ -4329,12 +4329,12 @@ public class ProfileUtilities extends TranslatingUtilities { private boolean isBaseCondition(IdType c) { String key = c.asStringValue(); - return key.startsWith("ele-") || key.startsWith("res-") || key.startsWith("ext-") || key.startsWith("dom-") || key.startsWith("dr-"); + return key != null && key.startsWith("ele-") || key.startsWith("res-") || key.startsWith("ext-") || key.startsWith("dom-") || key.startsWith("dr-"); } private boolean isBaseConstraint(ElementDefinitionConstraintComponent con) { String key = con.getKey(); - return key.startsWith("ele-") || key.startsWith("res-") || key.startsWith("ext-") || key.startsWith("dom-") || key.startsWith("dr-"); + return key != null && key.startsWith("ele-") || key.startsWith("res-") || key.startsWith("ext-") || key.startsWith("dom-") || key.startsWith("dr-"); } private void makeChoiceRows(List subRows, ElementDefinition element, HierarchicalTableGenerator gen, String corePath, String profileBaseFileName, boolean mustSupportMode) { From a34c33c0c01f0ea209e1641769ea8330107ad53f Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Thu, 10 Mar 2022 07:43:01 +1100 Subject: [PATCH 38/50] =fix r4b tests --- .../convertors/misc/XVerPackegeFixer.java | 190 +++++++++++++----- .../fhir/r4b/comparison/ProfileComparer.java | 156 +++++++++----- .../r4b/conformance/ProfileUtilities.java | 123 +++++++++--- .../hl7/fhir/r4b/utils/ToolingExtensions.java | 5 +- .../fhir/r4b/utils/XVerExtensionManager.java | 18 +- .../fhir/r4b/test/ProfileUtilitiesTests.java | 31 +++ .../r4b/test/SnapShotGenerationTests.java | 60 +++--- 7 files changed, 420 insertions(+), 163 deletions(-) diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/XVerPackegeFixer.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/XVerPackegeFixer.java index 634e3107b..8335423de 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/XVerPackegeFixer.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/XVerPackegeFixer.java @@ -6,13 +6,19 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import javax.naming.ldap.StartTlsRequest; import javax.xml.parsers.ParserConfigurationException; +import org.hl7.fhir.convertors.misc.XVerPackegeFixer.References; +import org.hl7.fhir.dstu2.model.ElementDefinition; +import org.hl7.fhir.dstu2.model.StructureDefinition; +import org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionSnapshotComponent; import org.hl7.fhir.exceptions.FHIRFormatError; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.json.JsonTrackingParser; @@ -24,12 +30,35 @@ import com.google.gson.JsonObject; public class XVerPackegeFixer { - private static final String R5_FOLDER = "C:\\work\\org.hl7.fhir\\packages\\hl7.fhir.rX\\hl7.fhir.r5.core\\package"; - private static final String R4_FOLDER = "C:\\work\\org.hl7.fhir\\packages\\hl7.fhir.rX\\hl7.fhir.r4.core\\package"; - private static final String R3_FOLDER = "C:\\work\\org.hl7.fhir\\packages\\hl7.fhir.rX\\hl7.fhir.r3.core\\package"; - private static final String R2B_FOLDER = "C:\\work\\org.hl7.fhir\\packages\\hl7.fhir.rX\\hl7.fhir.r2b.core\\package"; - private static final String R2_FOLDER = "C:\\work\\org.hl7.fhir\\packages\\hl7.fhir.rX\\hl7.fhir.r2.core\\package"; - private static int mod; + public static class References { + private boolean modifier; + private boolean inherited; + + public boolean getModifier() { + return modifier; + } + + public void setModifier(boolean value) { + this.modifier = value; + } + + public boolean getInherited() { + return inherited; + } + + public void setInherited(boolean inherited) { + this.inherited = inherited; + } + + } + + + private static final String R5_FOLDER = "/Users/grahamegrieve/work/packages/hl7.fhir.rX/hl7.fhir.r5.core/package"; + private static final String R4_FOLDER = "/Users/grahamegrieve/work/packages/hl7.fhir.rX/hl7.fhir.r4.core/package"; + private static final String R3_FOLDER = "/Users/grahamegrieve/work/packages/hl7.fhir.rX/hl7.fhir.r3.core/package"; + private static final String R2B_FOLDER = "/Users/grahamegrieve/work/packages/hl7.fhir.rX/hl7.fhir.r2b.core/package"; + private static final String R2_FOLDER = "/Users/grahamegrieve/work/packages/hl7.fhir.rX/hl7.fhir.r2.core/package"; + private static int modCount; private static Map map5 = new HashMap<>(); private static Map map4 = new HashMap<>(); @@ -38,21 +67,23 @@ public class XVerPackegeFixer { private static Map map2b = new HashMap<>(); public static void main(String[] args) throws FileNotFoundException, ParserConfigurationException, SAXException, IOException { - mod = 0; + modCount = 0; for (File f : new File(args[0]).listFiles()) { - if (f.getName().startsWith("xver-")) { + if (f.getName().startsWith("xver-") && f.getName().contains("1.0")) { JsonObject j = JsonTrackingParser.parseJson(f); fixUp(j, f.getName()); JsonTrackingParser.write(j, f, true); } } - System.out.println("all done: "+mod+" modifiers"); + System.out.println("all done: "+modCount+" modifiers"); } private static void fixUp(JsonObject j, String name) throws FHIRFormatError, FileNotFoundException, IOException { name = name.replace(".json", ""); System.out.println("Process "+name); String version = name.substring(name.lastIndexOf("-")+1); + Set pr = new HashSet<>(); + int i = 0; for (Entry e : j.entrySet()) { if (i == 50) { @@ -62,18 +93,31 @@ public class XVerPackegeFixer { i++; String n = e.getKey(); JsonObject o = ((JsonObject) e.getValue()); - boolean ok = (o.has("types") && o.getAsJsonArray("types").size() > 0) || (o.has("elements") && o.getAsJsonArray("elements").size() > 0); - if (!ok) { + // boolean ok = (o.has("types") && o.getAsJsonArray("types").size() > 0) || (o.has("elements") && o.getAsJsonArray("elements").size() > 0); +// if (!ok) { + if (o.has("types")) { + o.remove("types"); + } + if (o.has("elements")) { + o.remove("elements"); + } + if (o.has("modifier")) { + o.remove("modifier"); + } List types = new ArrayList<>(); List elements = new ArrayList<>(); - getElementInfo(version, n, types, elements); + References mod = new References(); + getElementInfo(version, n, types, elements, mod); + if (mod.getInherited()) { + pr.add(n); + } if (elements.size() > 0) { JsonArray arr = o.getAsJsonArray("elements"); if (arr == null) { arr = new JsonArray(); o.add("elements", arr); } - for (String s : types) { + for (String s : elements) { arr.add(s); } } else if (types.size() > 0) { @@ -86,30 +130,37 @@ public class XVerPackegeFixer { arr.add(s); } } - } + if (mod.getModifier()) { + o.addProperty("modifier", true); + modCount++; + } +// } } + for (String s : pr) { + j.remove(s); + } System.out.println("done"); } - private static boolean getElementInfo(String version, String n, List types, List elements) throws FHIRFormatError, FileNotFoundException, IOException { - if ("contained".equals(n.substring(n.indexOf(".")+1))) { - return false; - } + private static boolean getElementInfo(String version, String n, List types, List elements, References mod) throws FHIRFormatError, FileNotFoundException, IOException { +// if ("contained".equals(n.substring(n.indexOf(".")+1))) { +// return false; +// } switch (version) { - case "4.6": return getElementInfoR5(n, types, elements); - case "4.0": return getElementInfoR4(n, types, elements); - case "3.0": return getElementInfoR3(n, types, elements); - case "1.4": return getElementInfoR2B(n, types, elements); - case "1.0": return getElementInfoR2(n, types, elements); + case "4.6": return getElementInfoR5(n, types, elements, mod); + case "4.0": return getElementInfoR4(n, types, elements, mod); + case "3.0": return getElementInfoR3(n, types, elements, mod); + case "1.4": return getElementInfoR2B(n, types, elements, mod); + case "1.0": return getElementInfoR2(n, types, elements, mod); } return false; } - private static Object tail(String value) { + private static String tail(String value) { return value.contains("/") ? value.substring(value.lastIndexOf("/")+1) : value; } - private static boolean getElementInfoR5(String n, List types, List elements) throws FHIRFormatError, FileNotFoundException, IOException { + private static boolean getElementInfoR5(String n, List types, List elements, References mod) throws FHIRFormatError, FileNotFoundException, IOException { String tn = n.substring(0, n.indexOf(".")); org.hl7.fhir.r5.model.StructureDefinition sd = null; if (map5.containsKey(tn)) { @@ -120,7 +171,8 @@ public class XVerPackegeFixer { } for (org.hl7.fhir.r5.model.ElementDefinition ed : sd.getSnapshot().getElement()) { if (ed.getPath().equals(n)) { - List children = listChildrenR5(sd.getSnapshot().getElement(), ed); + mod.setModifier(ed.getIsModifier()); + List children = listChildrenR5(sd.getSnapshot().getElement(), ed); if (children.size() > 0) { for (org.hl7.fhir.r5.model.ElementDefinition c : children) { String en = c.getPath().substring(ed.getPath().length()+1); @@ -164,7 +216,7 @@ public class XVerPackegeFixer { return res; } - private static boolean getElementInfoR4(String n, List types, List elements) throws FHIRFormatError, FileNotFoundException, IOException { + private static boolean getElementInfoR4(String n, List types, List elements, References mod) throws FHIRFormatError, FileNotFoundException, IOException { String tn = n.substring(0, n.indexOf(".")); org.hl7.fhir.r4.model.StructureDefinition sd = null; if (map4.containsKey(tn)) { @@ -175,6 +227,7 @@ public class XVerPackegeFixer { } for (org.hl7.fhir.r4.model.ElementDefinition ed : sd.getSnapshot().getElement()) { if (ed.getPath().equals(n)) { + mod.setModifier(ed.getIsModifier()); List children = listChildrenR4(sd.getSnapshot().getElement(), ed); if (children.size() > 0) { for (org.hl7.fhir.r4.model.ElementDefinition c : children) { @@ -220,7 +273,7 @@ public class XVerPackegeFixer { } - private static boolean getElementInfoR3(String n, List types, List elements) throws FHIRFormatError, FileNotFoundException, IOException { + private static boolean getElementInfoR3(String n, List types, List elements, References mod) throws FHIRFormatError, FileNotFoundException, IOException { String tn = n.substring(0, n.indexOf(".")); org.hl7.fhir.dstu3.model.StructureDefinition sd = null; if (map3.containsKey(tn)) { @@ -231,6 +284,7 @@ public class XVerPackegeFixer { } for (org.hl7.fhir.dstu3.model.ElementDefinition ed : sd.getSnapshot().getElement()) { if (ed.getPath().equals(n)) { + mod.setModifier(ed.getIsModifier()); List children = listChildrenR3(sd.getSnapshot().getElement(), ed); if (children.size() > 0) { for (org.hl7.fhir.dstu3.model.ElementDefinition c : children) { @@ -272,17 +326,14 @@ public class XVerPackegeFixer { } - private static boolean getElementInfoR2(String n, List types, List elements) throws FHIRFormatError, FileNotFoundException, IOException { + private static boolean getElementInfoR2(String n, List types, List elements, References mod) throws FHIRFormatError, FileNotFoundException, IOException { String tn = n.substring(0, n.indexOf(".")); org.hl7.fhir.dstu2.model.StructureDefinition sd = null; - if (map2.containsKey(tn)) { - sd = map2.get(tn); - } else { - sd = (org.hl7.fhir.dstu2.model.StructureDefinition) new org.hl7.fhir.dstu2.formats.JsonParser().parse(new FileInputStream(Utilities.path(R2_FOLDER, "StructureDefinition-"+tn+".json"))); - map2.put(tn, sd); - } + sd = loadType(tn); + mod.setInherited(isInherited(n, sd)); for (org.hl7.fhir.dstu2.model.ElementDefinition ed : sd.getSnapshot().getElement()) { if (ed.getPath().equals(n)) { + mod.setModifier(ed.getIsModifier()); List children = listChildrenR2(sd.getSnapshot().getElement(), ed); if (children.size() > 0) { for (org.hl7.fhir.dstu2.model.ElementDefinition c : children) { @@ -290,28 +341,76 @@ public class XVerPackegeFixer { elements.add(en); } } else { + boolean isReference = false; + StringBuilder r = new StringBuilder(); + r.append("Reference("); for (org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent t : ed.getType()) { if (t.hasProfile()) { - StringBuilder b = new StringBuilder(); - b.append(t.getCode()); - b.append("("); - boolean first = true; - for (org.hl7.fhir.dstu2.model.UriType u : t.getProfile()) { - if (first) first = false; else b.append("|"); - b.append(tail(u.getValue())); + if ("Reference".equals(t.getCode())) { + for (org.hl7.fhir.dstu2.model.UriType u : t.getProfile()) { + if (isReference) + r.append("|"); + r.append(tail(u.getValue())); + isReference = true; + } + } else { + StringBuilder b = new StringBuilder(); + b.append(t.getCode()); + b.append("("); + boolean first = true; + for (org.hl7.fhir.dstu2.model.UriType u : t.getProfile()) { + if (first) first = false; else b.append("|"); + b.append(tail(u.getValue())); + } + b.append(")"); + types.add(b.toString()); } - b.append(")"); - types.add(b.toString()); } else { types.add(t.getCode()); } } + if (isReference) { + r.append(")"); + types.add(r.toString()); + } } } } return false; } + private static org.hl7.fhir.dstu2.model.StructureDefinition loadType(String tn) + throws IOException, FileNotFoundException { + org.hl7.fhir.dstu2.model.StructureDefinition sd; + if (map2.containsKey(tn)) { + sd = map2.get(tn); + } else { + sd = (org.hl7.fhir.dstu2.model.StructureDefinition) new org.hl7.fhir.dstu2.formats.JsonParser().parse(new FileInputStream(Utilities.path(R2_FOLDER, "StructureDefinition-"+tn+".json"))); + map2.put(tn, sd); + } + return sd; + } + + + private static boolean isInherited(String n, StructureDefinition sd) throws FileNotFoundException, IOException { + String tail = n.substring(n.indexOf(".")+1); + while (sd != null) { + sd = sd.hasBase() ? loadType(tail(sd.getBase())) : null; + if (sd != null && hasPath(sd.getSnapshot(), sd.getName()+"."+tail)) { + return true; + } + } + return false; + } + + private static boolean hasPath(StructureDefinitionSnapshotComponent snapshot, String path) { + for (ElementDefinition ed : snapshot.getElement()) { + if (ed.getPath().equals(path)) { + return true; + } + } + return false; + } private static List listChildrenR2(List list, org.hl7.fhir.dstu2.model.ElementDefinition ed) { List res = new ArrayList<>(); @@ -328,7 +427,7 @@ public class XVerPackegeFixer { } - private static boolean getElementInfoR2B(String n, List types, List elements) throws FHIRFormatError, FileNotFoundException, IOException { + private static boolean getElementInfoR2B(String n, List types, List elements, References mod) throws FHIRFormatError, FileNotFoundException, IOException { String tn = n.substring(0, n.indexOf(".")); org.hl7.fhir.dstu2016may.model.StructureDefinition sd = null; if (map2b.containsKey(tn)) { @@ -339,6 +438,7 @@ public class XVerPackegeFixer { } for (org.hl7.fhir.dstu2016may.model.ElementDefinition ed : sd.getSnapshot().getElement()) { if (ed.getPath().equals(n)) { + mod.setModifier(ed.getIsModifier()); List children = listChildrenR2B(sd.getSnapshot().getElement(), ed); if (children.size() > 0) { for (org.hl7.fhir.dstu2016may.model.ElementDefinition c : children) { diff --git a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/comparison/ProfileComparer.java b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/comparison/ProfileComparer.java index 7d7d9bd33..c6ebdf81a 100644 --- a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/comparison/ProfileComparer.java +++ b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/comparison/ProfileComparer.java @@ -45,14 +45,14 @@ public class ProfileComparer extends CanonicalResourceComparer { public class ProfileComparison extends CanonicalResourceComparison { - private StructuralMatch combined; + private StructuralMatch combined; public ProfileComparison(StructureDefinition left, StructureDefinition right) { super(left, right); - combined = new StructuralMatch(); // base + combined = new StructuralMatch(); // base } - public StructuralMatch getCombined() { + public StructuralMatch getCombined() { return combined; } @@ -79,7 +79,21 @@ public class ProfileComparer extends CanonicalResourceComparer { } - + private class ElementDefinitionNode { + private ElementDefinition def; + private StructureDefinition src; + private ElementDefinitionNode(StructureDefinition src, ElementDefinition def) { + super(); + this.src = src; + this.def = def; + } + public ElementDefinition getDef() { + return def; + } + public StructureDefinition getSrc() { + return src; + } + } private ProfileUtilities utilsLeft; private ProfileUtilities utilsRight; @@ -127,7 +141,7 @@ public class ProfileComparer extends CanonicalResourceComparer { if (left.getType().equals(right.getType())) { DefinitionNavigator ln = new DefinitionNavigator(session.getContextLeft(), left); DefinitionNavigator rn = new DefinitionNavigator(session.getContextRight(), right); - StructuralMatch sm = new StructuralMatch(ln.current(), rn.current()); + StructuralMatch sm = new StructuralMatch(new ElementDefinitionNode(left, ln.current()), new ElementDefinitionNode(right, rn.current())); compareElements(res, sm, ln.path(), null, ln, rn); res.combined = sm; } @@ -147,7 +161,7 @@ public class ProfileComparer extends CanonicalResourceComparer { throw new DefinitionException("StructureDefinition snapshot is empty ("+name+": "+sd.getName()+")"); } - private void compareElements(ProfileComparison comp, StructuralMatch res, String path, String sliceName, DefinitionNavigator left, DefinitionNavigator right) throws DefinitionException, FHIRFormatError, IOException { + private void compareElements(ProfileComparison comp, StructuralMatch res, String path, String sliceName, DefinitionNavigator left, DefinitionNavigator right) throws DefinitionException, FHIRFormatError, IOException { assert(path != null); assert(left != null); assert(right != null); @@ -190,7 +204,7 @@ public class ProfileComparer extends CanonicalResourceComparer { subset.setExample(left.current().hasExample() ? left.current().getExample() : right.current().getExample()); if (left.current().getMustSupport() != right.current().getMustSupport()) { - vm(IssueSeverity.ERROR, "Elements differ in definition for mustSupport:\r\n \""+left.current().getMustSupport()+"\"\r\n \""+right.current().getMustSupport()+"\"", path, comp.getMessages(), res.getMessages()); + vm(IssueSeverity.WARNING, "Elements differ in definition for mustSupport: '"+left.current().getMustSupport()+"' vs '"+right.current().getMustSupport()+"'", path, comp.getMessages(), res.getMessages()); } subset.setMustSupport(left.current().getMustSupport() || right.current().getMustSupport()); @@ -198,15 +212,20 @@ public class ProfileComparer extends CanonicalResourceComparer { // compare and intersect - superset.setMin(unionMin(left.current().getMin(), right.current().getMin())); - superset.setMax(unionMax(left.current().getMax(), right.current().getMax())); - subset.setMin(intersectMin(left.current().getMin(), right.current().getMin())); - subset.setMax(intersectMax(left.current().getMax(), right.current().getMax())); - rule(comp, res, subset.getMax().equals("*") || Integer.parseInt(subset.getMax()) >= subset.getMin(), path, "Cardinality Mismatch: "+card(left)+"/"+card(right)); + int leftMin = left.current().getMin(); + int rightMin = right.current().getMin(); + int leftMax = "*".equals(left.current().getMax()) ? Integer.MAX_VALUE : Integer.parseInt(left.current().getMax()); + int rightMax = "*".equals(right.current().getMax()) ? Integer.MAX_VALUE : Integer.parseInt(right.current().getMax()); + + checkMinMax(comp, res, path, leftMin, rightMin, leftMax, rightMax); + superset.setMin(unionMin(leftMin, rightMin)); + superset.setMax(unionMax(leftMax, rightMax, left.current().getMax(), right.current().getMax())); + subset.setMin(intersectMin(leftMin, rightMin)); + subset.setMax(intersectMax(leftMax, rightMax, left.current().getMax(), right.current().getMax())); superset.getType().addAll(unionTypes(comp, res, path, left.current().getType(), right.current().getType())); subset.getType().addAll(intersectTypes(comp, res, subset, path, left.current().getType(), right.current().getType())); - rule(comp, res, !subset.getType().isEmpty() || (!left.current().hasType() && !right.current().hasType()), path, "Type Mismatch:\r\n "+typeCode(left)+"\r\n "+typeCode(right)); + rule(comp, res, !subset.getType().isEmpty() || (!left.current().hasType() && !right.current().hasType()), path, "Type Mismatch: "+typeCode(left)+" vs "+typeCode(right)); // // superset.setMaxLengthElement(unionMaxLength(left.current().getMaxLength(), right.current().getMaxLength())); @@ -283,7 +302,8 @@ public class ProfileComparer extends CanonicalResourceComparer { // return null; } - private void compareChildren(ProfileComparison comp, StructuralMatch res, String path, DefinitionNavigator left, DefinitionNavigator right) throws DefinitionException, IOException, FHIRFormatError { + + private void compareChildren(ProfileComparison comp, StructuralMatch res, String path, DefinitionNavigator left, DefinitionNavigator right) throws DefinitionException, IOException, FHIRFormatError { List lc = left.children(); List rc = right.children(); // it's possible that one of these profiles walks into a data type and the other doesn't @@ -299,10 +319,10 @@ public class ProfileComparer extends CanonicalResourceComparer { DefinitionNavigator r = findInList(rc, l); if (r == null) { comp.getUnion().getSnapshot().getElement().add(l.current().copy()); - res.getChildren().add(new StructuralMatch(l.current(), vmI(IssueSeverity.INFORMATION, "Removed this element", path))); + res.getChildren().add(new StructuralMatch(new ElementDefinitionNode(l.getStructure(), l.current()), vmI(IssueSeverity.INFORMATION, "Removed this element", path))); } else { matchR.add(r); - StructuralMatch sm = new StructuralMatch(l.current(), r.current()); + StructuralMatch sm = new StructuralMatch(new ElementDefinitionNode(l.getStructure(), l.current()), new ElementDefinitionNode(r.getStructure(), r.current())); res.getChildren().add(sm); compareElements(comp, sm, l.path(), null, l, r); } @@ -310,7 +330,7 @@ public class ProfileComparer extends CanonicalResourceComparer { for (DefinitionNavigator r : rc) { if (!matchR.contains(r)) { comp.getUnion().getSnapshot().getElement().add(r.current().copy()); - res.getChildren().add(new StructuralMatch(vmI(IssueSeverity.INFORMATION, "Added this element", path), r.current())); + res.getChildren().add(new StructuralMatch(vmI(IssueSeverity.INFORMATION, "Added this element", path), new ElementDefinitionNode(r.getStructure(), r.current()))); } } } @@ -324,7 +344,7 @@ public class ProfileComparer extends CanonicalResourceComparer { return null; } - private void ruleEqual(ProfileComparison comp, StructuralMatch res, DataType vLeft, DataType vRight, String name, String path) throws IOException { + private void ruleEqual(ProfileComparison comp, StructuralMatch res, DataType vLeft, DataType vRight, String name, String path) throws IOException { if (vLeft == null && vRight == null) { // nothing } else if (vLeft == null) { @@ -338,7 +358,7 @@ public class ProfileComparer extends CanonicalResourceComparer { private String toString(DataType val, boolean left) throws IOException { if (val instanceof PrimitiveType) - return "\"" + ((PrimitiveType) val).getValueAsString()+"\""; + return "'" + ((PrimitiveType) val).getValueAsString()+"'"; IParser jp = left ? session.getContextLeft().newJsonParser() : session.getContextRight().newJsonParser(); return jp.composeString(val, "value"); @@ -356,14 +376,14 @@ public class ProfileComparer extends CanonicalResourceComparer { return s; } - private boolean rule(ProfileComparison comp, StructuralMatch res, boolean test, String path, String message) { + private boolean rule(ProfileComparison comp, StructuralMatch res, boolean test, String path, String message) { if (!test) { vm(IssueSeverity.ERROR, message, path, comp.getMessages(), res.getMessages()); } return test; } - private String mergeText(ProfileComparison comp, StructuralMatch res, String path, String name, String left, String right, boolean isError) { + private String mergeText(ProfileComparison comp, StructuralMatch res, String path, String name, String left, String right, boolean isError) { if (left == null && right == null) return null; if (left == null) @@ -375,7 +395,7 @@ public class ProfileComparer extends CanonicalResourceComparer { if (left.equalsIgnoreCase(right)) return left; if (path != null) { - vm(isError ? IssueSeverity.ERROR : IssueSeverity.WARNING, "Elements differ in "+name+":\r\n \""+left+"\"\r\n \""+right+"\"", path, comp.getMessages(), res.getMessages()); + vm(isError ? IssueSeverity.ERROR : IssueSeverity.WARNING, "Elements differ in "+name+": '"+left+"' vs '"+right+"'", path, comp.getMessages(), res.getMessages()); } return "left: "+left+"; right: "+right; } @@ -429,6 +449,36 @@ public class ProfileComparer extends CanonicalResourceComparer { return right; } + private void checkMinMax(ProfileComparison comp, StructuralMatch res, String path, int leftMin, int rightMin, int leftMax, int rightMax) { + if (leftMin != rightMin) { + if (leftMin == 0) { + vm(IssueSeverity.INFORMATION, "Element minimum cardinalities differ: '"+leftMin+"' vs '"+rightMin+"'", path, comp.getMessages(), res.getMessages()); + } else if (rightMin == 0) { + vm(IssueSeverity.INFORMATION, "Element minimum cardinalities differ: '"+leftMin+"' vs '"+rightMin+"'", path, comp.getMessages(), res.getMessages()); + } else { + vm(IssueSeverity.INFORMATION, "Element minimum cardinalities differ: '"+leftMin+"' vs '"+rightMin+"'", path, comp.getMessages(), res.getMessages()); + } + } + if (leftMax != rightMax) { + if (leftMax == Integer.MAX_VALUE) { + vm(IssueSeverity.INFORMATION, "Element maximum cardinalities differ: '"+leftMax+"' vs '"+rightMax+"'", path, comp.getMessages(), res.getMessages()); + } else if (rightMax == Integer.MAX_VALUE) { + vm(IssueSeverity.INFORMATION, "Element maximum cardinalities differ: '"+leftMax+"' vs '"+rightMax+"'", path, comp.getMessages(), res.getMessages()); + } else { + vm(IssueSeverity.INFORMATION, "Element maximum cardinalities differ: '"+leftMax+"' vs '"+rightMax+"'", path, comp.getMessages(), res.getMessages()); + } + } +// rule(comp, res, subset.getMax().equals("*") || Integer.parseInt(subset.getMax()) >= subset.getMin(), path, "Cardinality Mismatch: "+card(left)+"/"+card(right)); + + // cross comparison - if max > min in either direction, there can be no instances that are valid against both + if (leftMax < rightMin) { + vm(IssueSeverity.ERROR, "Element minimum cardinalities conflict: '"+leftMin+".."+leftMax+"' vs '"+rightMin+".."+rightMax+"': No instances can be valid against both profiles", path, comp.getMessages(), res.getMessages()); + } + if (rightMax < leftMin) { + vm(IssueSeverity.ERROR, "Element minimum cardinalities conflict: '"+leftMin+".."+leftMax+"' vs '"+rightMin+".."+rightMax+"': No instances can be valid against both profiles", path, comp.getMessages(), res.getMessages()); + } + } + private int unionMin(int left, int right) { if (left > right) return right; @@ -436,18 +486,14 @@ public class ProfileComparer extends CanonicalResourceComparer { return left; } - private String intersectMax(String left, String right) { - int l = "*".equals(left) ? Integer.MAX_VALUE : Integer.parseInt(left); - int r = "*".equals(right) ? Integer.MAX_VALUE : Integer.parseInt(right); + private String intersectMax(int l, int r, String left, String right) { if (l < r) return left; else return right; } - private String unionMax(String left, String right) { - int l = "*".equals(left) ? Integer.MAX_VALUE : Integer.parseInt(left); - int r = "*".equals(right) ? Integer.MAX_VALUE : Integer.parseInt(right); + private String unionMax(int l, int r, String left, String right) { if (l < r) return right; else @@ -480,7 +526,7 @@ public class ProfileComparer extends CanonicalResourceComparer { return Integer.toString(defn.current().getMin())+".."+defn.current().getMax(); } - private Collection unionTypes(ProfileComparison comp, StructuralMatch res, String path, List left, List right) throws DefinitionException, IOException, FHIRFormatError { + private Collection unionTypes(ProfileComparison comp, StructuralMatch res, String path, List left, List right) throws DefinitionException, IOException, FHIRFormatError { List result = new ArrayList(); for (TypeRefComponent l : left) checkAddTypeUnion(comp, res, path, result, l, session.getContextLeft()); @@ -489,7 +535,7 @@ public class ProfileComparer extends CanonicalResourceComparer { return result; } - private void checkAddTypeUnion(ProfileComparison comp, StructuralMatch res, String path, List results, TypeRefComponent nw, IWorkerContext ctxt) throws DefinitionException, IOException, FHIRFormatError { + private void checkAddTypeUnion(ProfileComparison comp, StructuralMatch res, String path, List results, TypeRefComponent nw, IWorkerContext ctxt) throws DefinitionException, IOException, FHIRFormatError { boolean pfound = false; boolean tfound = false; nw = nw.copy(); @@ -586,7 +632,7 @@ public class ProfileComparer extends CanonicalResourceComparer { return false; } - private Collection intersectTypes(ProfileComparison comp, StructuralMatch res, ElementDefinition ed, String path, List left, List right) throws DefinitionException, IOException, FHIRFormatError { + private Collection intersectTypes(ProfileComparison comp, StructuralMatch res, ElementDefinition ed, String path, List left, List right) throws DefinitionException, IOException, FHIRFormatError { List result = new ArrayList(); for (TypeRefComponent l : left) { if (l.hasAggregation()) @@ -665,7 +711,7 @@ public class ProfileComparer extends CanonicalResourceComparer { return b.toString(); } - private boolean compareBindings(ProfileComparison comp, StructuralMatch res, ElementDefinition subset, ElementDefinition superset, String path, ElementDefinition lDef, ElementDefinition rDef) throws FHIRFormatError, DefinitionException, IOException { + private boolean compareBindings(ProfileComparison comp, StructuralMatch res, ElementDefinition subset, ElementDefinition superset, String path, ElementDefinition lDef, ElementDefinition rDef) throws FHIRFormatError, DefinitionException, IOException { assert(lDef.hasBinding() || rDef.hasBinding()); if (!lDef.hasBinding()) { subset.setBinding(rDef.getBinding()); @@ -801,7 +847,7 @@ public class ProfileComparer extends CanonicalResourceComparer { } // we can't really know about constraints. We create warnings, and collate them - private List unionConstraints(ProfileComparison comp, StructuralMatch res, String path, List left, List right) { + private List unionConstraints(ProfileComparison comp, StructuralMatch res, String path, List left, List right) { List result = new ArrayList(); for (ElementDefinitionConstraintComponent l : left) { boolean found = false; @@ -829,7 +875,7 @@ public class ProfileComparer extends CanonicalResourceComparer { return result; } - private StructureDefinition resolveProfile(ProfileComparison comp, StructuralMatch res, String path, String url, String name, IWorkerContext ctxt) { + private StructureDefinition resolveProfile(ProfileComparison comp, StructuralMatch res, String path, String url, String name, IWorkerContext ctxt) { StructureDefinition sd = ctxt.fetchResource(StructureDefinition.class, url); if (sd == null) { ValidationMessage vm = vmI(IssueSeverity.WARNING, "Unable to resolve profile "+url+" in profile "+name, path); @@ -841,7 +887,7 @@ public class ProfileComparer extends CanonicalResourceComparer { return binding.getStrength() == BindingStrength.EXAMPLE || binding.getStrength() == BindingStrength.PREFERRED; } - private ElementDefinitionBindingComponent unionBindings(ProfileComparison comp, StructuralMatch res, String path, ElementDefinitionBindingComponent left, ElementDefinitionBindingComponent right) throws FHIRFormatError, DefinitionException, IOException { + private ElementDefinitionBindingComponent unionBindings(ProfileComparison comp, StructuralMatch res, String path, ElementDefinitionBindingComponent left, ElementDefinitionBindingComponent right) throws FHIRFormatError, DefinitionException, IOException { ElementDefinitionBindingComponent union = new ElementDefinitionBindingComponent(); if (left.getStrength().compareTo(right.getStrength()) < 0) union.setStrength(left.getStrength()); @@ -881,17 +927,17 @@ public class ProfileComparer extends CanonicalResourceComparer { return gen.generate(model, prefix, 0, null); } - private void genElementComp(String defPath, HierarchicalTableGenerator gen, List rows, StructuralMatch combined, String corePath, String prefix, Row slicingRow, boolean root) throws IOException { + private void genElementComp(String defPath, HierarchicalTableGenerator gen, List rows, StructuralMatch combined, String corePath, String prefix, Row slicingRow, boolean root) throws IOException { Row originalRow = slicingRow; Row typesRow = null; - List> children = combined.getChildren(); + List> children = combined.getChildren(); Row row = gen.new Row(); rows.add(row); - String path = combined.either().getPath(); + String path = combined.either().getDef().getPath(); row.setAnchor(path); - row.setColor(utilsRight.getRowColor(combined.either(), false)); + row.setColor(utilsRight.getRowColor(combined.either().getDef(), false)); if (eitherHasSlicing(combined)) row.setLineColor(1); else if (eitherHasSliceName(combined)) @@ -917,7 +963,7 @@ public class ProfileComparer extends CanonicalResourceComparer { row.setIcon("icon_choice.gif", HierarchicalTableGenerator.TEXT_ICON_CHOICE); typesRow = row; } - } else if (combined.either().hasContentReference()) + } else if (combined.either().getDef().hasContentReference()) row.setIcon("icon_reuse.png", HierarchicalTableGenerator.TEXT_ICON_REUSE); else if (isPrimitive(combined)) row.setIcon("icon_primitive.png", HierarchicalTableGenerator.TEXT_ICON_PRIMITIVE); @@ -927,7 +973,7 @@ public class ProfileComparer extends CanonicalResourceComparer { row.setIcon("icon_datatype.gif", HierarchicalTableGenerator.TEXT_ICON_DATATYPE); else row.setIcon("icon_resource.png", HierarchicalTableGenerator.TEXT_ICON_RESOURCE); - String ref = defPath == null ? null : defPath + combined.either().getId(); + String ref = defPath == null ? null : defPath + combined.either().getDef().getId(); String sName = tail(path); String sn = getSliceName(combined); if (sn != null) @@ -937,23 +983,23 @@ public class ProfileComparer extends CanonicalResourceComparer { String leftColor = !combined.hasLeft() ? COLOR_NO_ROW_LEFT : combined.hasErrors() ? COLOR_DIFFERENT : null; String rightColor = !combined.hasRight() ? COLOR_NO_ROW_LEFT : combined.hasErrors() ? COLOR_DIFFERENT : null; if (combined.hasLeft()) { - nc = utilsRight.genElementNameCell(gen, combined.getLeft(), "??", true, corePath, prefix, root, false, false, null, typesRow, row, false, ext, used , ref, sName); + nc = utilsRight.genElementNameCell(gen, combined.getLeft().getDef(), "??", true, corePath, prefix, root, false, false, combined.getLeft().getSrc(), typesRow, row, false, ext, used , ref, sName); } else { - nc = utilsRight.genElementNameCell(gen, combined.getRight(), "??", true, corePath, prefix, root, false, false, null, typesRow, row, false, ext, used , ref, sName); + nc = utilsRight.genElementNameCell(gen, combined.getRight().getDef(), "??", true, corePath, prefix, root, false, false, combined.getRight().getSrc(), typesRow, row, false, ext, used , ref, sName); } if (combined.hasLeft()) { - frame(utilsRight.genElementCells(gen, combined.getLeft(), "??", true, corePath, prefix, root, false, false, null, typesRow, row, false, ext, used , ref, sName, nc, false), leftColor); + frame(utilsRight.genElementCells(gen, combined.getLeft().getDef(), "??", true, corePath, prefix, root, false, false, combined.getLeft().getSrc(), typesRow, row, true, ext, used , ref, sName, nc, false, false), leftColor); } else { frame(spacers(row, 4, gen), leftColor); } if (combined.hasRight()) { - frame(utilsRight.genElementCells(gen, combined.getRight(), "??", true, corePath, prefix, root, false, false, null, typesRow, row, false, ext, used, ref, sName, nc, false), rightColor); + frame(utilsRight.genElementCells(gen, combined.getRight().getDef(), "??", true, corePath, prefix, root, false, false, combined.getRight().getSrc(), typesRow, row, true, ext, used, ref, sName, nc, false, false), rightColor); } else { frame(spacers(row, 4, gen), rightColor); } row.getCells().add(cellForMessages(gen, combined.getMessages())); - for (StructuralMatch child : children) { + for (StructuralMatch child : children) { genElementComp(defPath, gen, row.getSubRows(), child, corePath, prefix, originalRow, false); } } @@ -978,47 +1024,47 @@ public class ProfileComparer extends CanonicalResourceComparer { return res; } - private String getSliceName(StructuralMatch combined) { + private String getSliceName(StructuralMatch combined) { // TODO Auto-generated method stub return null; } - private boolean isDataType(StructuralMatch combined) { + private boolean isDataType(StructuralMatch combined) { // TODO Auto-generated method stub return false; } - private boolean hasTarget(StructuralMatch combined) { + private boolean hasTarget(StructuralMatch combined) { // TODO Auto-generated method stub return false; } - private boolean isPrimitive(StructuralMatch combined) { + private boolean isPrimitive(StructuralMatch combined) { // TODO Auto-generated method stub return false; } - private boolean allAreReference(StructuralMatch combined) { + private boolean allAreReference(StructuralMatch combined) { // TODO Auto-generated method stub return false; } - private boolean hasChoice(StructuralMatch combined) { + private boolean hasChoice(StructuralMatch combined) { // TODO Auto-generated method stub return false; } - private boolean elementIsComplex(StructuralMatch combined) { + private boolean elementIsComplex(StructuralMatch combined) { // TODO Auto-generated method stub velement.hasType() && element.getType().get(0).hasProfile() && extensionIsComplex(element.getType().get(0).getProfile().get(0).getValue() return false; } - private boolean eitherHasSliceName(StructuralMatch combined) { + private boolean eitherHasSliceName(StructuralMatch combined) { // TODO Auto-generated method stub return false; } - private boolean eitherHasSlicing(StructuralMatch combined) { + private boolean eitherHasSlicing(StructuralMatch combined) { // TODO Auto-generated method stub return false; } diff --git a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/conformance/ProfileUtilities.java b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/conformance/ProfileUtilities.java index 0bcc84118..d8e13d43b 100644 --- a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/conformance/ProfileUtilities.java +++ b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/conformance/ProfileUtilities.java @@ -549,7 +549,17 @@ public class ProfileUtilities extends TranslatingUtilities { } public List getChildList(StructureDefinition structure, ElementDefinition element) { - return getChildList(structure, element.getPath(), element.getId(), false); + if (element.hasContentReference()) { + ElementDefinition target = element; + for (ElementDefinition t : structure.getSnapshot().getElement()) { + if (t.getId().equals(element.getContentReference().substring(1))) { + target = t; + } + } + return getChildList(structure, target.getPath(), target.getId(), false); + } else { + return getChildList(structure, element.getPath(), element.getId(), false); + } } public void updateMaps(StructureDefinition base, StructureDefinition derived) throws DefinitionException { @@ -1077,6 +1087,7 @@ public class ProfileUtilities extends TranslatingUtilities { ElementDefinition outcome = updateURLs(url, webUrl, currentBase.copy()); outcome.setPath(fixedPathDest(contextPathDst, outcome.getPath(), redirector, contextPathSrc)); updateFromBase(outcome, currentBase); + updateConstraintSources(outcome, srcSD.getUrl()); markDerived(outcome); if (resultPathBase == null) resultPathBase = outcome.getPath(); @@ -1913,6 +1924,15 @@ public class ProfileUtilities extends TranslatingUtilities { return res; } + private void updateConstraintSources(ElementDefinition ed, String url) { + for (ElementDefinitionConstraintComponent c : ed.getConstraint()) { + if (!c.hasSource()) { + c.setSource(url); + } + } + + } + private Set getListOfTypes(ElementDefinition e) { Set result = new HashSet<>(); for (TypeRefComponent t : e.getType()) { @@ -2087,6 +2107,8 @@ public class ProfileUtilities extends TranslatingUtilities { private void removeStatusExtensions(ElementDefinition outcome) { outcome.removeExtension(ToolingExtensions.EXT_FMM_LEVEL); + outcome.removeExtension(ToolingExtensions.EXT_FMM_SUPPORT); + outcome.removeExtension(ToolingExtensions.EXT_FMM_DERIVED); outcome.removeExtension(ToolingExtensions.EXT_STANDARDS_STATUS); outcome.removeExtension(ToolingExtensions.EXT_NORMATIVE_VERSION); outcome.removeExtension(ToolingExtensions.EXT_WORKGROUP); @@ -2406,6 +2428,11 @@ public class ProfileUtilities extends TranslatingUtilities { StructureDefinition sd = null; if (type.hasProfile()) { sd = context.fetchResource(StructureDefinition.class, type.getProfile().get(0).getValue()); + if (sd == null) { + if (xver != null && xver.matchingUrl(type.getProfile().get(0).getValue()) && xver.status(type.getProfile().get(0).getValue()) == XVerExtensionStatus.Valid) { + sd = xver.makeDefinition(type.getProfile().get(0).getValue()); + } + } if (sd == null) System.out.println("Failed to find referenced profile: " + type.getProfile()); } @@ -2475,19 +2502,19 @@ public class ProfileUtilities extends TranslatingUtilities { if (webUrl != null) { // also, must touch up the markdown if (element.hasDefinition()) - element.setDefinition(processRelativeUrls(element.getDefinition(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames)); + element.setDefinition(processRelativeUrls(element.getDefinition(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames, true)); if (element.hasComment()) - element.setComment(processRelativeUrls(element.getComment(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames)); + element.setComment(processRelativeUrls(element.getComment(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames, true)); if (element.hasRequirements()) - element.setRequirements(processRelativeUrls(element.getRequirements(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames)); + element.setRequirements(processRelativeUrls(element.getRequirements(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames, true)); if (element.hasMeaningWhenMissing()) - element.setMeaningWhenMissing(processRelativeUrls(element.getMeaningWhenMissing(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames)); + element.setMeaningWhenMissing(processRelativeUrls(element.getMeaningWhenMissing(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames, true)); } } return element; } - public static String processRelativeUrls(String markdown, String webUrl, String basePath, List resourceNames, Set filenames) { + public static String processRelativeUrls(String markdown, String webUrl, String basePath, List resourceNames, Set filenames, boolean processRelatives) { StringBuilder b = new StringBuilder(); int i = 0; while (i < markdown.length()) { @@ -2515,7 +2542,14 @@ public class ProfileUtilities extends TranslatingUtilities { } else { b.append("]("); // disabled 7-Dec 2021 GDG - we don't want to fool with relative URLs at all? - // b.append(webUrl); + // re-enabled 11-Feb 2022 GDG - we do want to do this. At least, $assemble in davinci-dtr, where the markdown comes from the SDC IG, and an SDC local reference must be changed to point to SDC. in this case, it's called when generating snapshots + // added processRelatives parameter to deal with this (well, to try) + if (processRelatives && webUrl != null) { +// System.out.println("Making "+url+" relative to '"+webUrl+"'"); + b.append(webUrl); + } else { +// System.out.println("Not making "+url+" relative to '"+webUrl+"'"); + } i = i + 1; } } else @@ -2773,7 +2807,9 @@ public class ProfileUtilities extends TranslatingUtilities { profile = source.getType().size() == 1 && source.getTypeFirstRep().hasProfile() ? context.fetchResource(StructureDefinition.class, source.getTypeFirstRep().getProfile().get(0).getValue()) : null; if (profile != null) { ElementDefinition e = profile.getSnapshot().getElement().get(0); - base.setDefinition(e.getDefinition()); + String webroot = profile.getUserString("webroot"); + + base.setDefinition(processRelativeUrls(e.getDefinition(), webroot, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames, true)); base.setShort(e.getShort()); if (e.hasCommentElement()) base.setCommentElement(e.getCommentElement()); @@ -3502,7 +3538,7 @@ public class ProfileUtilities extends TranslatingUtilities { List types = e.getType(); if (!e.hasType()) { if (root) { // we'll use base instead of types then - StructureDefinition bsd = context.fetchResource(StructureDefinition.class, profile.getBaseDefinition()); + StructureDefinition bsd = profile == null ? null : context.fetchResource(StructureDefinition.class, profile.getBaseDefinition()); if (bsd != null) { if (bsd.hasUserData("path")) { c.getPieces().add(gen.new Piece(Utilities.isAbsoluteUrl(bsd.getUserString("path")) ? bsd.getUserString("path") : imagePath +bsd.getUserString("path"), bsd.getName(), null)); @@ -3584,7 +3620,7 @@ public class ProfileUtilities extends TranslatingUtilities { c.addPiece(checkForNoChange(tl, gen.new Piece(null,", ", null))); } - ref = pkp.getLinkForProfile(profile, p.getValue()); + ref = pkp == null ? null : pkp.getLinkForProfile(profile, p.getValue()); if (ref != null) { String[] parts = ref.split("\\|"); if (parts[0].startsWith("http:") || parts[0].startsWith("https:")) { @@ -3665,7 +3701,7 @@ public class ProfileUtilities extends TranslatingUtilities { } - private String codeForAggregation(AggregationMode a) { + public static String codeForAggregation(AggregationMode a) { switch (a) { case BUNDLED : return "b"; case CONTAINED : return "c"; @@ -3674,7 +3710,7 @@ public class ProfileUtilities extends TranslatingUtilities { } } - private String hintForAggregation(AggregationMode a) { + public static String hintForAggregation(AggregationMode a) { if (a != null) return a.getDefinition(); else @@ -3683,7 +3719,7 @@ public class ProfileUtilities extends TranslatingUtilities { private String checkPrepend(String corePath, String path) { - if (pkp.prependLinks() && !(path.startsWith("http:") || path.startsWith("https:"))) + if (pkp != null && pkp.prependLinks() && !(path.startsWith("http:") || path.startsWith("https:"))) return corePath+path; else return path; @@ -4055,7 +4091,7 @@ public class ProfileUtilities extends TranslatingUtilities { if (logicalModel && element.hasRepresentation(PropertyRepresentation.XMLATTR)) sName = "@"+sName; Cell nc = genElementNameCell(gen, element, profileBaseFileName, snapshot, corePath, imagePath, root, logicalModel, allInvariants, profile, typesRow, row, hasDef, ext, used, ref, sName); - genElementCells(gen, element, profileBaseFileName, snapshot, corePath, imagePath, root, logicalModel, allInvariants, profile, typesRow, row, hasDef, ext, used, ref, sName, nc, mustSupport); + genElementCells(gen, element, profileBaseFileName, snapshot, corePath, imagePath, root, logicalModel, allInvariants, profile, typesRow, row, hasDef, ext, used, ref, sName, nc, mustSupport, true); if (element.hasSlicing()) { if (standardExtensionSlicing(element)) { used.used = true; // doesn't matter whether we have a type, we're used if we're setting up slicing ... element.hasType() && element.getType().get(0).hasProfile(); @@ -4183,7 +4219,7 @@ public class ProfileUtilities extends TranslatingUtilities { public List genElementCells(HierarchicalTableGenerator gen, ElementDefinition element, String profileBaseFileName, boolean snapshot, String corePath, String imagePath, boolean root, boolean logicalModel, boolean allInvariants, StructureDefinition profile, Row typesRow, Row row, boolean hasDef, - boolean ext, UnusedTracker used, String ref, String sName, Cell nameCell, boolean mustSupport) throws IOException { + boolean ext, UnusedTracker used, String ref, String sName, Cell nameCell, boolean mustSupport, boolean allowSubRows) throws IOException { List res = new ArrayList<>(); Cell gc = gen.new Cell(); row.getCells().add(gc); @@ -4209,7 +4245,7 @@ public class ProfileUtilities extends TranslatingUtilities { if (extDefn == null) { res.add(genCardinality(gen, element, row, hasDef, used, null)); res.add(addCell(row, gen.new Cell(null, null, "?gen-e1? "+element.getType().get(0).getProfile(), null, null))); - res.add(generateDescription(gen, row, element, (ElementDefinition) element.getUserData(DERIVATION_POINTER), used.used, profile == null ? "" : profile.getUrl(), eurl, profile, corePath, imagePath, root, logicalModel, allInvariants, snapshot, mustSupport)); + res.add(generateDescription(gen, row, element, (ElementDefinition) element.getUserData(DERIVATION_POINTER), used.used, profile == null ? "" : profile.getUrl(), eurl, profile, corePath, imagePath, root, logicalModel, allInvariants, snapshot, mustSupport, allowSubRows)); } else { String name = urltail(eurl); nameCell.getPieces().get(0).setText(name); @@ -4222,7 +4258,7 @@ public class ProfileUtilities extends TranslatingUtilities { else // if it's complex, we just call it nothing // genTypes(gen, row, extDefn.getSnapshot().getElement().get(0), profileBaseFileName, profile); res.add(addCell(row, gen.new Cell(null, null, "("+translate("sd.table", "Complex")+")", null, null))); - res.add(generateDescription(gen, row, element, extDefn.getElement(), used.used, null, extDefn.getUrl(), profile, corePath, imagePath, root, logicalModel, allInvariants, valueDefn, snapshot, mustSupport)); + res.add(generateDescription(gen, row, element, extDefn.getElement(), used.used, null, extDefn.getUrl(), profile, corePath, imagePath, root, logicalModel, allInvariants, valueDefn, snapshot, mustSupport, allowSubRows)); } } else { res.add(genCardinality(gen, element, row, hasDef, used, null)); @@ -4230,7 +4266,7 @@ public class ProfileUtilities extends TranslatingUtilities { res.add(addCell(row, gen.new Cell())); else res.add(genTypes(gen, row, element, profileBaseFileName, profile, corePath, imagePath, root, mustSupport)); - res.add(generateDescription(gen, row, element, (ElementDefinition) element.getUserData(DERIVATION_POINTER), used.used, null, null, profile, corePath, imagePath, root, logicalModel, allInvariants, snapshot, mustSupport)); + res.add(generateDescription(gen, row, element, (ElementDefinition) element.getUserData(DERIVATION_POINTER), used.used, null, null, profile, corePath, imagePath, root, logicalModel, allInvariants, snapshot, mustSupport, allowSubRows)); } } else { res.add(genCardinality(gen, element, row, hasDef, used, null)); @@ -4238,7 +4274,7 @@ public class ProfileUtilities extends TranslatingUtilities { res.add(genTypes(gen, row, element, profileBaseFileName, profile, corePath, imagePath, root, mustSupport)); else res.add(addCell(row, gen.new Cell())); - res.add(generateDescription(gen, row, element, (ElementDefinition) element.getUserData(DERIVATION_POINTER), used.used, null, null, profile, corePath, imagePath, root, logicalModel, allInvariants, snapshot, mustSupport)); + res.add(generateDescription(gen, row, element, (ElementDefinition) element.getUserData(DERIVATION_POINTER), used.used, null, null, profile, corePath, imagePath, root, logicalModel, allInvariants, snapshot, mustSupport, allowSubRows)); } return res; } @@ -4544,11 +4580,11 @@ public class ProfileUtilities extends TranslatingUtilities { && element.getSlicing().getRules() != SlicingRules.CLOSED && element.getSlicing().getDiscriminator().size() == 1 && element.getSlicing().getDiscriminator().get(0).getPath().equals("url") && element.getSlicing().getDiscriminator().get(0).getType().equals(DiscriminatorType.VALUE); } - private Cell generateDescription(HierarchicalTableGenerator gen, Row row, ElementDefinition definition, ElementDefinition fallback, boolean used, String baseURL, String url, StructureDefinition profile, String corePath, String imagePath, boolean root, boolean logicalModel, boolean allInvariants, boolean snapshot, boolean mustSupportOnly) throws IOException, FHIRException { - return generateDescription(gen, row, definition, fallback, used, baseURL, url, profile, corePath, imagePath, root, logicalModel, allInvariants, null, snapshot, mustSupportOnly); + private Cell generateDescription(HierarchicalTableGenerator gen, Row row, ElementDefinition definition, ElementDefinition fallback, boolean used, String baseURL, String url, StructureDefinition profile, String corePath, String imagePath, boolean root, boolean logicalModel, boolean allInvariants, boolean snapshot, boolean mustSupportOnly, boolean allowSubRows) throws IOException, FHIRException { + return generateDescription(gen, row, definition, fallback, used, baseURL, url, profile, corePath, imagePath, root, logicalModel, allInvariants, null, snapshot, mustSupportOnly, allowSubRows); } - private Cell generateDescription(HierarchicalTableGenerator gen, Row row, ElementDefinition definition, ElementDefinition fallback, boolean used, String baseURL, String url, StructureDefinition profile, String corePath, String imagePath, boolean root, boolean logicalModel, boolean allInvariants, ElementDefinition valueDefn, boolean snapshot, boolean mustSupportOnly) throws IOException, FHIRException { + private Cell generateDescription(HierarchicalTableGenerator gen, Row row, ElementDefinition definition, ElementDefinition fallback, boolean used, String baseURL, String url, StructureDefinition profile, String corePath, String imagePath, boolean root, boolean logicalModel, boolean allInvariants, ElementDefinition valueDefn, boolean snapshot, boolean mustSupportOnly, boolean allowSubRows) throws IOException, FHIRException { Cell c = gen.new Cell(); row.getCells().add(c); @@ -4564,7 +4600,7 @@ public class ProfileUtilities extends TranslatingUtilities { } } if (root) { - if (profile.getAbstract()) { + if (profile != null && profile.getAbstract()) { if (!c.getPieces().isEmpty()) { c.addPiece(gen.new Piece("br")); } c.addPiece(gen.new Piece(null, "This is an abstract profile", null)); } @@ -4659,7 +4695,7 @@ public class ProfileUtilities extends TranslatingUtilities { if (binding!=null && !binding.isEmpty()) { if (!c.getPieces().isEmpty()) c.addPiece(gen.new Piece("br")); - BindingResolution br = pkp.resolveBinding(profile, binding, definition.getPath()); + BindingResolution br = pkp == null ? makeNullBr(binding) : pkp.resolveBinding(profile, binding, definition.getPath()); c.getPieces().add(checkForNoChange(binding, gen.new Piece(null, translate("sd.table", "Binding")+": ", null).addStyle("font-weight:bold"))); c.getPieces().add(checkForNoChange(binding.getValueSetElement(), gen.new Piece(br.url == null ? null : Utilities.isAbsoluteUrl(br.url) || !pkp.prependLinks() ? br.url : corePath+br.url, br.display, null))); if (binding.hasStrength()) { @@ -4668,7 +4704,7 @@ public class ProfileUtilities extends TranslatingUtilities { c.getPieces().add(checkForNoChange(binding.getStrengthElement(), gen.new Piece(null, ")", null))); } if (binding.hasExtension(ToolingExtensions.EXT_MAX_VALUESET)) { - br = pkp.resolveBinding(profile, ToolingExtensions.readStringExtension(binding, ToolingExtensions.EXT_MAX_VALUESET), definition.getPath()); + br = pkp == null ? makeNullBr(binding) : pkp.resolveBinding(profile, ToolingExtensions.readStringExtension(binding, ToolingExtensions.EXT_MAX_VALUESET), definition.getPath()); c.addPiece(gen.new Piece("br")); c.getPieces().add(checkForNoChange(binding, gen.new Piece(corePath+"extension-elementdefinition-maxvalueset.html", translate("sd.table", "Max Binding")+": ", "Max Value Set Extension").addStyle("font-weight:bold"))); c.getPieces().add(checkForNoChange(binding, gen.new Piece(br.url == null ? null : Utilities.isAbsoluteUrl(br.url) || !pkp.prependLinks() ? br.url : corePath+br.url, br.display, null))); @@ -4683,6 +4719,13 @@ public class ProfileUtilities extends TranslatingUtilities { c.getPieces().add(gen.new Piece(null, ": ", null)); c.addMarkdownNoPara(PublicationHacker.fixBindingDescriptions(context, binding.getDescriptionElement()).asStringValue(), checkForNoChange(PublicationHacker.fixBindingDescriptions(context, binding.getDescriptionElement()))); } + if (binding.hasExtension(ToolingExtensions.EXT_BINDING_ADDITIONAL)) { + c.addPiece(gen.new Piece("br")); + c.getPieces().add(checkForNoChange(binding, gen.new Piece(null, translate("sd.table", "Additional Bindings")+": ", null).addStyle("font-weight:bold"))); + for (Extension ext : binding.getExtensionsByUrl(ToolingExtensions.EXT_BINDING_ADDITIONAL)) { + renderAdditionalBinding(gen, c, ext); + } + } } for (ElementDefinitionConstraintComponent inv : definition.getConstraint()) { if (!inv.hasSource() || profile == null || inv.getSource().equals(profile.getUrl()) || allInvariants) { @@ -4704,7 +4747,7 @@ public class ProfileUtilities extends TranslatingUtilities { if (definition.hasFixed()) { if (!c.getPieces().isEmpty()) { c.addPiece(gen.new Piece("br")); } c.getPieces().add(checkForNoChange(definition.getFixed(), gen.new Piece(null, translate("sd.table", "Fixed Value")+": ", null).addStyle("font-weight:bold"))); - if (!useTableForFixedValues || definition.getFixed().isPrimitive()) { + if (!useTableForFixedValues || !allowSubRows || definition.getFixed().isPrimitive()) { String s = buildJson(definition.getFixed()); String link = null; if (Utilities.isAbsoluteUrl(s)) @@ -4712,7 +4755,7 @@ public class ProfileUtilities extends TranslatingUtilities { c.getPieces().add(checkForNoChange(definition.getFixed(), gen.new Piece(link, s, null).addStyle("color: darkgreen"))); } else { c.getPieces().add(checkForNoChange(definition.getFixed(), gen.new Piece(null, "As shown", null).addStyle("color: darkgreen"))); - genFixedValue(gen, row, definition.getFixed(), snapshot, false, corePath, false); + genFixedValue(gen, row, definition.getFixed(), snapshot, false, corePath, false); } if (isCoded(definition.getFixed()) && !hasDescription(definition.getFixed())) { Piece p = describeCoded(gen, definition.getFixed()); @@ -4722,7 +4765,7 @@ public class ProfileUtilities extends TranslatingUtilities { } else if (definition.hasPattern()) { if (!c.getPieces().isEmpty()) { c.addPiece(gen.new Piece("br")); } c.getPieces().add(checkForNoChange(definition.getPattern(), gen.new Piece(null, translate("sd.table", "Required Pattern")+": ", null).addStyle("font-weight:bold"))); - if (!useTableForFixedValues || definition.getPattern().isPrimitive()) + if (!useTableForFixedValues || !allowSubRows || definition.getPattern().isPrimitive()) c.getPieces().add(checkForNoChange(definition.getPattern(), gen.new Piece(null, buildJson(definition.getPattern()), null).addStyle("color: darkgreen"))); else { c.getPieces().add(checkForNoChange(definition.getPattern(), gen.new Piece(null, "At least the following", null).addStyle("color: darkgreen"))); @@ -4762,6 +4805,30 @@ public class ProfileUtilities extends TranslatingUtilities { return c; } + private void renderAdditionalBinding(HierarchicalTableGenerator gen, Cell c, Extension ext) { + // 2 purpose value-set-link ([context]) {documentation} + String purpose = ext.getExtensionString("purpose"); + String valueSet = ext.getExtensionString("valueSet"); + String doco = ext.getExtensionString("documentation"); + //UsageContext usage = (ext.hasExtension("usage")) ? ext.getExtensionByUrl("usage").getValueUsageContext() : null; +// +// purpose: code - defines how the binding is used +// usage : UsageContext - defines the contexts in which this binding is used for it's purpose +// valueSet : canonical(ValueSet) +// documentation : markdown +// !! +// c.getPieces().add(checkForNoChange(inv, gen.new Piece(null, inv.getKey()+": ", null).addStyle("font-weight:bold"))); +// c.getPieces().add(checkForNoChange(inv, gen.new Piece(null, gt(inv.getHumanElement()), null))); + + } + + private BindingResolution makeNullBr(ElementDefinitionBindingComponent binding) { + BindingResolution br = new BindingResolution(); + br.url = "http://none.none/none"; + br.display = "todo"; + return br; + } + private ElementDefinitionBindingComponent makeUnifiedBinding(ElementDefinitionBindingComponent binding, ElementDefinition element) { if (!element.hasUserData(DERIVATION_POINTER)) { return binding; diff --git a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/utils/ToolingExtensions.java b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/utils/ToolingExtensions.java index 29d921926..6e00efbf4 100644 --- a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/utils/ToolingExtensions.java +++ b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/utils/ToolingExtensions.java @@ -198,6 +198,9 @@ public class ToolingExtensions { public static final String EXT_TARGET_ID = "http://hl7.org/fhir/StructureDefinition/targetElement"; public static final String EXT_TARGET_PATH = "http://hl7.org/fhir/StructureDefinition/targetPath"; public static final String EXT_VALUESET_SYSTEM = "http://hl7.org/fhir/StructureDefinition/valueset-system"; + public static final String EXT_EXPAND_RULES = "http://hl7.org/fhir/StructureDefinition/valueset-expand-rules"; + public static final String EXT_EXPAND_GROUP = "http://hl7.org/fhir/StructureDefinition/valueset-expand-group"; + public static final String EXT_BINDING_ADDITIONAL = "http://hl7.org/fhir/tools/StructureDefinition/additional-binding"; // specific extension helpers @@ -511,7 +514,7 @@ public class ToolingExtensions { * @return The extension, if on this element, else null */ public static Extension getExtension(DomainResource resource, String name) { - if (name == null) + if (resource == null || name == null) return null; if (!resource.hasExtension()) return null; diff --git a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/utils/XVerExtensionManager.java b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/utils/XVerExtensionManager.java index 011725dbe..17d12ab29 100644 --- a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/utils/XVerExtensionManager.java +++ b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/utils/XVerExtensionManager.java @@ -50,9 +50,6 @@ public class XVerExtensionManager { return XVerExtensionStatus.Invalid; } String v = url.substring(20, 23); - if ("5.0".equals(v)) { - v = "4.6"; // for now - } String e = url.substring(54); if (!lists.containsKey(v)) { if (context.getBinaries().containsKey("xver-paths-"+v+".json")) { @@ -67,6 +64,9 @@ public class XVerExtensionManager { } JsonObject root = lists.get(v); JsonObject path = root.getAsJsonObject(e); + if (path == null) { + path = root.getAsJsonObject(e+"[x]"); + } if (path == null) { return XVerExtensionStatus.Unknown; } @@ -83,13 +83,13 @@ public class XVerExtensionManager { public StructureDefinition makeDefinition(String url) { String verSource = url.substring(20, 23); - if ("5.0".equals(verSource)) { - verSource = "4.6"; // for now - } String verTarget = VersionUtilities.getMajMin(context.getVersion()); String e = url.substring(54); JsonObject root = lists.get(verSource); JsonObject path = root.getAsJsonObject(e); + if (path == null) { + path = root.getAsJsonObject(e+"[x]"); + } StructureDefinition sd = new StructureDefinition(); sd.setUserData(XVER_EXT_MARKER, "true"); @@ -117,16 +117,18 @@ public class XVerExtensionManager { populateTypes(path, val, verSource, verTarget); } else if (path.has("elements")) { for (JsonElement i : path.getAsJsonArray("elements")) { - String s = i.getAsString(); + JsonObject elt = root.getAsJsonObject(e+"."+i.getAsString()); + if (elt != null) { + String s = i.getAsString().replace("[x]", ""); sd.getDifferential().addElement().setPath("Extension.extension").setSliceName(s); sd.getDifferential().addElement().setPath("Extension.extension.extension").setMax("0"); sd.getDifferential().addElement().setPath("Extension.extension.url").setFixed(new UriType(s)); ElementDefinition val = sd.getDifferential().addElement().setPath("Extension.extension.value[x]").setMin(1); - JsonObject elt = root.getAsJsonObject(e+"."+s); if (!elt.has("types")) { throw new FHIRException("Internal error - nested elements not supported yet"); } populateTypes(elt, val, verSource, verTarget); + } } sd.getDifferential().addElement().setPath("Extension.url").setFixed(new UriType(url)); sd.getDifferential().addElement().setPath("Extension.value[x]").setMax("0"); diff --git a/org.hl7.fhir.r4b/src/test/java/org/hl7/fhir/r4b/test/ProfileUtilitiesTests.java b/org.hl7.fhir.r4b/src/test/java/org/hl7/fhir/r4b/test/ProfileUtilitiesTests.java index 930fcbb3b..d23e585e7 100644 --- a/org.hl7.fhir.r4b/src/test/java/org/hl7/fhir/r4b/test/ProfileUtilitiesTests.java +++ b/org.hl7.fhir.r4b/src/test/java/org/hl7/fhir/r4b/test/ProfileUtilitiesTests.java @@ -4,6 +4,7 @@ import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.r4b.conformance.ProfileUtilities; import org.hl7.fhir.r4b.model.Base; import org.hl7.fhir.r4b.model.ElementDefinition; +import org.hl7.fhir.r4b.model.ElementDefinition.ElementDefinitionConstraintComponent; import org.hl7.fhir.r4b.model.IntegerType; import org.hl7.fhir.r4b.model.StructureDefinition; import org.hl7.fhir.r4b.model.StructureDefinition.TypeDerivationRule; @@ -51,6 +52,12 @@ public class ProfileUtilitiesTests { f.setBase(null); b.setRequirements(null); f.setRequirements(null); + for (ElementDefinitionConstraintComponent c : b.getConstraint()) { + c.setSource(null); + } + for (ElementDefinitionConstraintComponent c : f.getConstraint()) { + c.setSource(null); + } ok = Base.compareDeep(b, f, true); } } @@ -83,6 +90,12 @@ public class ProfileUtilitiesTests { if (ok) { ElementDefinition b = base.getSnapshot().getElement().get(i); ElementDefinition f = focus.getSnapshot().getElement().get(i); + for (ElementDefinitionConstraintComponent c : b.getConstraint()) { + c.setSource(null); + } + for (ElementDefinitionConstraintComponent c : f.getConstraint()) { + c.setSource(null); + } if (!f.hasBase() || !b.getPath().equals(f.getPath())) ok = false; else { @@ -128,6 +141,12 @@ public class ProfileUtilitiesTests { ElementDefinition f = focus.getSnapshot().getElement().get(i); b.setRequirements(null); f.setRequirements(null); + for (ElementDefinitionConstraintComponent c : b.getConstraint()) { + c.setSource(null); + } + for (ElementDefinitionConstraintComponent c : f.getConstraint()) { + c.setSource(null); + } if (!f.hasBase() || !b.getPath().equals(f.getPath())) { ok = false; } @@ -174,6 +193,12 @@ public class ProfileUtilitiesTests { ElementDefinition f = focus.getSnapshot().getElement().get(i); b.setRequirements(null); f.setRequirements(null); + for (ElementDefinitionConstraintComponent c : b.getConstraint()) { + c.setSource(null); + } + for (ElementDefinitionConstraintComponent c : f.getConstraint()) { + c.setSource(null); + } if (!f.hasBase() || !b.getPath().equals(f.getPath())) { ok = false; } @@ -221,6 +246,12 @@ public class ProfileUtilitiesTests { ElementDefinition f = focus.getSnapshot().getElement().get(i); b.setRequirements(null); f.setRequirements(null); + for (ElementDefinitionConstraintComponent c : b.getConstraint()) { + c.setSource(null); + } + for (ElementDefinitionConstraintComponent c : f.getConstraint()) { + c.setSource(null); + } if (!f.hasBase() || !b.getPath().equals(f.getPath())) { ok = false; } diff --git a/org.hl7.fhir.r4b/src/test/java/org/hl7/fhir/r4b/test/SnapShotGenerationTests.java b/org.hl7.fhir.r4b/src/test/java/org/hl7/fhir/r4b/test/SnapShotGenerationTests.java index 5fc5ab7a9..0141e129a 100644 --- a/org.hl7.fhir.r4b/src/test/java/org/hl7/fhir/r4b/test/SnapShotGenerationTests.java +++ b/org.hl7.fhir.r4b/src/test/java/org/hl7/fhir/r4b/test/SnapShotGenerationTests.java @@ -10,6 +10,7 @@ import java.util.List; import java.util.stream.Stream; import javax.xml.parsers.ParserConfigurationException; +import javax.xml.soap.Text; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.NotImplementedException; @@ -49,6 +50,7 @@ import org.hl7.fhir.utilities.npm.ToolsVersion; import org.hl7.fhir.utilities.validation.ValidationMessage; import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity; import org.hl7.fhir.utilities.xml.XMLUtil; +import org.junit.Assert; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.params.ParameterizedTest; @@ -137,7 +139,8 @@ public class SnapShotGenerationTests { private boolean fail; private boolean newSliceProcessing; private boolean debug; - + private boolean noR4b; + private List rules = new ArrayList<>(); private StructureDefinition source; private List included = new ArrayList<>(); @@ -161,6 +164,7 @@ public class SnapShotGenerationTests { rules.add(new Rule(rule)); rule = XMLUtil.getNextSibling(rule); } + noR4b = test.hasAttribute("r4b") && "false".equals(test.getAttribute("r4b")); } public String getId() { @@ -466,33 +470,37 @@ public class SnapShotGenerationTests { fp.setHostServices(context); messages = new ArrayList(); - System.out.println("---- "+id+" -----------------------------------------"); - if (test.isFail()) { - boolean failed = true; - try { - if (test.isGen()) - testGen(true, test, context); - else - testSort(test, context); - failed = false; - } catch (Throwable e) { - System.out.println("Error running test: " + e.getMessage()); - if (!Utilities.noString(test.regex)) { - Assertions.assertTrue(e.getMessage().matches(test.regex), "correct error message"); - } else if ("Should have failed".equals(e.getMessage())) { - throw e; - } else { + if (test.noR4b) { + Assert.assertTrue(true); + } else { + System.out.println("---- "+id+" -----------------------------------------"); + if (test.isFail()) { + boolean failed = true; + try { + if (test.isGen()) + testGen(true, test, context); + else + testSort(test, context); + failed = false; + } catch (Throwable e) { + System.out.println("Error running test: " + e.getMessage()); + if (!Utilities.noString(test.regex)) { + Assertions.assertTrue(e.getMessage().matches(test.regex), "correct error message"); + } else if ("Should have failed".equals(e.getMessage())) { + throw e; + } else { + } } + Assertions.assertTrue(failed, "Should have failed"); + } else if (test.isGen()) + testGen(false, test, context); + else + testSort(test, context); + for (Rule r : test.getRules()) { + StructureDefinition sdn = new StructureDefinition(); + boolean ok = fp.evaluateToBoolean(sdn, sdn, sdn, r.expression); + Assertions.assertTrue(ok, r.description); } - Assertions.assertTrue(failed, "Should have failed"); - } else if (test.isGen()) - testGen(false, test, context); - else - testSort(test, context); - for (Rule r : test.getRules()) { - StructureDefinition sdn = new StructureDefinition(); - boolean ok = fp.evaluateToBoolean(sdn, sdn, sdn, r.expression); - Assertions.assertTrue(ok, r.description); } } From 791f16a05da1427beb38d0eaaf6c5943c47fe08a Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Thu, 10 Mar 2022 11:18:03 +1100 Subject: [PATCH 39/50] fix failing tests. --- .../fhir/convertors/misc/JsonProcessor.java | 189 +++++++++++ .../fhir/r5/conformance/ProfileUtilities.java | 311 +++++++++--------- .../hl7/fhir/utilities/tests/RegexTests.java | 25 ++ pom.xml | 2 +- 4 files changed, 373 insertions(+), 154 deletions(-) create mode 100644 org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/JsonProcessor.java create mode 100644 org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/tests/RegexTests.java diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/JsonProcessor.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/JsonProcessor.java new file mode 100644 index 000000000..a46bd5c5b --- /dev/null +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/JsonProcessor.java @@ -0,0 +1,189 @@ +package org.hl7.fhir.convertors.misc; + +import java.io.File; +import java.io.IOException; + +import org.hl7.fhir.utilities.json.JsonTrackingParser; + +import com.google.gson.JsonObject; + +public class JsonProcessor { + public static void main(String[] args) throws Exception { + new JsonProcessor().process(args[0]); + } + + private void process(String source) throws IOException { + JsonObject json = JsonTrackingParser.parseJsonFile(source); + process(json); + JsonTrackingParser.write(json, new File(source), true); + + } + + private void process(JsonObject json) { + process(json, "ActivityDefinition.status"); + process(json, "CapabilityStatement.status"); + process(json, "CodeSystem.status"); + process(json, "CompartmentDefinition.status"); + process(json, "ConceptMap.status"); + process(json, "DataElement.status"); + process(json, "ExpansionProfile.status"); + process(json, "GraphDefinition.status"); + process(json, "ImplementationGuide.status"); + process(json, "Library.status"); + process(json, "Measure.status"); + process(json, "MessageDefinition.status"); + process(json, "OperationDefinition.status"); + process(json, "PlanDefinition.status"); + process(json, "Questionnaire.status"); + process(json, "SearchParameter.status"); + process(json, "ServiceDefinition.status"); + process(json, "StructureDefinition.status"); + process(json, "StructureMap.status"); + process(json, "TestScript.status"); + process(json, "ValueSet.status"); + process(json, "ActivityDefinition.experimental"); + process(json, "CapabilityStatement.experimental"); + process(json, "CodeSystem.experimental"); + process(json, "CompartmentDefinition.experimental"); + process(json, "ConceptMap.experimental"); + process(json, "DataElement.experimental"); + process(json, "ExpansionProfile.experimental"); + process(json, "GraphDefinition.experimental"); + process(json, "ImplementationGuide.experimental"); + process(json, "Library.experimental"); + process(json, "Measure.experimental"); + process(json, "MessageDefinition.experimental"); + process(json, "OperationDefinition.experimental"); + process(json, "PlanDefinition.experimental"); + process(json, "Questionnaire.experimental"); + process(json, "SearchParameter.experimental"); + process(json, "ServiceDefinition.experimental"); + process(json, "StructureDefinition.experimental"); + process(json, "StructureMap.experimental"); + process(json, "TestScript.experimental"); + process(json, "ValueSet.experimental"); + process(json, "Identifier.use"); + process(json, "Quantity.comparator"); + process(json, "Address.use"); + process(json, "ContactPoint.use"); + process(json, "HumanName.use"); + process(json, "BackboneElement.modifierExtension"); + process(json, "DomainResource.modifierExtension"); + process(json, "Resource.implicitRules"); + process(json, "Account.status"); + process(json, "AllergyIntolerance.clinicalStatus"); + process(json, "AllergyIntolerance.verificationStatus"); + process(json, "Appointment.status"); + process(json, "AppointmentResponse.participantStatus"); + process(json, "Basic.code"); + process(json, "BodySite.active"); + process(json, "CarePlan.status"); + process(json, "CarePlan.intent"); + process(json, "CarePlan.activity.detail.status"); + process(json, "CarePlan.activity.detail.prohibited"); + process(json, "CareTeam.status"); + process(json, "ChargeItem.status"); + process(json, "Claim.status"); + process(json, "ClaimResponse.status"); + process(json, "ClinicalImpression.status"); + process(json, "Communication.status"); + process(json, "Communication.notDone"); + process(json, "CommunicationRequest.status"); + process(json, "Composition.status"); + process(json, "Composition.confidentiality"); + process(json, "Composition.section.mode"); + process(json, "ConceptMap.group.element.target.equivalence"); + process(json, "Condition.clinicalStatus"); + process(json, "Condition.verificationStatus"); + process(json, "Consent.status"); + process(json, "Contract.status"); + process(json, "Coverage.status"); + process(json, "DetectedIssue.status"); + process(json, "Device.status"); + process(json, "DeviceRequest.status"); + process(json, "DeviceRequest.intent"); + process(json, "DeviceUseStatement.status"); + process(json, "DiagnosticReport.status"); + process(json, "DocumentManifest.status"); + process(json, "DocumentReference.status"); + process(json, "DocumentReference.relatesTo"); + process(json, "EligibilityRequest.status"); + process(json, "EligibilityResponse.status"); + process(json, "Encounter.status"); + process(json, "Endpoint.status"); + process(json, "EnrollmentRequest.status"); + process(json, "EnrollmentResponse.status"); + process(json, "EpisodeOfCare.status"); + process(json, "ExplanationOfBenefit.status"); + process(json, "FamilyMemberHistory.status"); + process(json, "FamilyMemberHistory.notDone"); + process(json, "FamilyMemberHistory.estimatedAge"); + process(json, "Flag.status"); + process(json, "Goal.status"); + process(json, "Group.characteristic.exclude"); + process(json, "GuidanceResponse.status"); + process(json, "HealthcareService.active"); + process(json, "Immunization.status"); + process(json, "Immunization.notGiven"); + process(json, "List.status"); + process(json, "List.mode"); + process(json, "List.entry.deleted"); + process(json, "Location.status"); + process(json, "Location.mode"); + process(json, "MeasureReport.status"); + process(json, "MedicationAdministration.status"); + process(json, "MedicationAdministration.notGiven"); + process(json, "MedicationDispense.status"); + process(json, "MedicationRequest.status"); + process(json, "MedicationRequest.intent"); + process(json, "MedicationRequest.substitution.allowed"); + process(json, "MedicationStatement.status"); + process(json, "MedicationStatement.taken"); + process(json, "NamingSystem.status"); + process(json, "NutritionOrder.status"); + process(json, "Observation.status"); + process(json, "OperationOutcome.issue.severity"); + process(json, "Organization.active"); + process(json, "Patient.active"); + process(json, "Patient.deceased[x]"); + process(json, "Patient.animal"); + process(json, "Patient.link"); + process(json, "PaymentNotice.status"); + process(json, "PaymentReconciliation.status"); + process(json, "Person.active"); + process(json, "Procedure.status"); + process(json, "Procedure.notDone"); + process(json, "ProcedureRequest.status"); + process(json, "ProcedureRequest.intent"); + process(json, "ProcedureRequest.doNotPerform"); + process(json, "ProcessRequest.status"); + process(json, "ProcessResponse.status"); + process(json, "Questionnaire.item.enableWhen"); + process(json, "QuestionnaireResponse.status"); + process(json, "ReferralRequest.status"); + process(json, "ReferralRequest.intent"); + process(json, "RelatedPerson.active"); + process(json, "RequestGroup.status"); + process(json, "RequestGroup.intent"); + process(json, "ResearchStudy.status"); + process(json, "ResearchSubject.status"); + process(json, "Schedule.active"); + process(json, "Specimen.status"); + process(json, "Subscription.status"); + process(json, "SupplyDelivery.status"); + process(json, "SupplyRequest.status"); + process(json, "TestReport.status"); + process(json, "ValueSet.compose.include.filter"); + process(json, "VisionPrescription.status"); + } + + private void process(JsonObject json, String name) { + JsonObject j = json.getAsJsonObject(name); + if (j == null) { + System.out.println("Can't find "+name); + } else { + j.addProperty("modifier", true); + } + + } +} diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java index 8e9e0bf51..ec0032ca8 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java @@ -621,180 +621,184 @@ public class ProfileUtilities extends TranslatingUtilities { if (!base.getType().equals(derived.getType()) && derived.getDerivation() == TypeDerivationRule.CONSTRAINT) { throw new DefinitionException(context.formatMessage(I18nConstants.BASE__DERIVED_PROFILES_HAVE_DIFFERENT_TYPES____VS___, base.getUrl(), base.getType(), derived.getUrl(), derived.getType())); } - + if (snapshotStack.contains(derived.getUrl())) { throw new DefinitionException(context.formatMessage(I18nConstants.CIRCULAR_SNAPSHOT_REFERENCES_DETECTED_CANNOT_GENERATE_SNAPSHOT_STACK__, snapshotStack.toString())); } derived.setUserData("profileutils.snapshot.generating", true); snapshotStack.add(derived.getUrl()); - - if (!Utilities.noString(webUrl) && !webUrl.endsWith("/")) - webUrl = webUrl + '/'; - - if (defWebRoot == null) - defWebRoot = webUrl; - derived.setSnapshot(new StructureDefinitionSnapshotComponent()); - try { - checkDifferential(derived.getDifferential().getElement(), typeName(derived.getType()), derived.getUrl()); - checkDifferentialBaseType(derived); - - // so we have two lists - the base list, and the differential list - // the differential list is only allowed to include things that are in the base list, but - // is allowed to include them multiple times - thereby slicing them - // our approach is to walk through the base list, and see whether the differential - // says anything about them. - int baseCursor = 0; - int diffCursor = 0; // we need a diff cursor because we can only look ahead, in the bound scoped by longer paths + if (!Utilities.noString(webUrl) && !webUrl.endsWith("/")) + webUrl = webUrl + '/'; + + if (defWebRoot == null) + defWebRoot = webUrl; + derived.setSnapshot(new StructureDefinitionSnapshotComponent()); + + try { + checkDifferential(derived.getDifferential().getElement(), typeName(derived.getType()), derived.getUrl()); + checkDifferentialBaseType(derived); + + // so we have two lists - the base list, and the differential list + // the differential list is only allowed to include things that are in the base list, but + // is allowed to include them multiple times - thereby slicing them + + // our approach is to walk through the base list, and see whether the differential + // says anything about them. + int baseCursor = 0; + int diffCursor = 0; // we need a diff cursor because we can only look ahead, in the bound scoped by longer paths - for (ElementDefinition e : derived.getDifferential().getElement()) - e.clearUserData(GENERATED_IN_SNAPSHOT); + for (ElementDefinition e : derived.getDifferential().getElement()) + e.clearUserData(GENERATED_IN_SNAPSHOT); - // we actually delegate the work to a subroutine so we can re-enter it with a different cursors - StructureDefinitionDifferentialComponent diff = cloneDiff(derived.getDifferential()); // we make a copy here because we're sometimes going to hack the differential while processing it. Have to migrate user data back afterwards - StructureDefinitionSnapshotComponent baseSnapshot = base.getSnapshot(); - if (derived.getDerivation() == TypeDerivationRule.SPECIALIZATION) { - String derivedType = derived.getType(); - if (StructureDefinitionKind.LOGICAL.equals(derived.getKind()) && derived.getType().contains("/")) { - derivedType = derivedType.substring(derivedType.lastIndexOf("/")+1); + // we actually delegate the work to a subroutine so we can re-enter it with a different cursors + StructureDefinitionDifferentialComponent diff = cloneDiff(derived.getDifferential()); // we make a copy here because we're sometimes going to hack the differential while processing it. Have to migrate user data back afterwards + StructureDefinitionSnapshotComponent baseSnapshot = base.getSnapshot(); + if (derived.getDerivation() == TypeDerivationRule.SPECIALIZATION) { + String derivedType = derived.getType(); + if (StructureDefinitionKind.LOGICAL.equals(derived.getKind()) && derived.getType().contains("/")) { + derivedType = derivedType.substring(derivedType.lastIndexOf("/")+1); + } + baseSnapshot = cloneSnapshot(baseSnapshot, base.getType(), derivedType); } - baseSnapshot = cloneSnapshot(baseSnapshot, base.getType(), derivedType); - } -// if (derived.getId().equals("2.16.840.1.113883.10.20.22.2.1.1")) { -// debug = true; -// } - processPaths("", derived.getSnapshot(), baseSnapshot, diff, baseCursor, diffCursor, baseSnapshot.getElement().size()-1, - derived.getDifferential().hasElement() ? derived.getDifferential().getElement().size()-1 : -1, url, webUrl, derived.present(), null, null, false, base.getUrl(), null, false, null, null, new ArrayList(), base); - checkGroupConstraints(derived); - if (derived.getDerivation() == TypeDerivationRule.SPECIALIZATION) { - for (ElementDefinition e : diff.getElement()) { - if (!e.hasUserData(GENERATED_IN_SNAPSHOT)) { - ElementDefinition outcome = updateURLs(url, webUrl, e.copy()); - e.setUserData(GENERATED_IN_SNAPSHOT, outcome); - derived.getSnapshot().addElement(outcome); + // if (derived.getId().equals("2.16.840.1.113883.10.20.22.2.1.1")) { + // debug = true; + // } + processPaths("", derived.getSnapshot(), baseSnapshot, diff, baseCursor, diffCursor, baseSnapshot.getElement().size()-1, + derived.getDifferential().hasElement() ? derived.getDifferential().getElement().size()-1 : -1, url, webUrl, derived.present(), null, null, false, base.getUrl(), null, false, null, null, new ArrayList(), base); + checkGroupConstraints(derived); + if (derived.getDerivation() == TypeDerivationRule.SPECIALIZATION) { + for (ElementDefinition e : diff.getElement()) { + if (!e.hasUserData(GENERATED_IN_SNAPSHOT)) { + ElementDefinition outcome = updateURLs(url, webUrl, e.copy()); + e.setUserData(GENERATED_IN_SNAPSHOT, outcome); + derived.getSnapshot().addElement(outcome); + } } } - } - - if (derived.getKind() != StructureDefinitionKind.LOGICAL && !derived.getSnapshot().getElementFirstRep().getType().isEmpty()) - throw new Error(context.formatMessage(I18nConstants.TYPE_ON_FIRST_SNAPSHOT_ELEMENT_FOR__IN__FROM_, derived.getSnapshot().getElementFirstRep().getPath(), derived.getUrl(), base.getUrl())); - updateMaps(base, derived); - setIds(derived, false); - if (debug) { - System.out.println("Differential: "); - for (ElementDefinition ed : derived.getDifferential().getElement()) - System.out.println(" "+ed.getId()+" : "+typeSummaryWithProfile(ed)+"["+ed.getMin()+".."+ed.getMax()+"]"+sliceSummary(ed)+" "+constraintSummary(ed)); - System.out.println("Snapshot: "); - for (ElementDefinition ed : derived.getSnapshot().getElement()) - System.out.println(" "+ed.getId()+" : "+typeSummaryWithProfile(ed)+"["+ed.getMin()+".."+ed.getMax()+"]"+sliceSummary(ed)+" "+constraintSummary(ed)); - } - CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); - //Check that all differential elements have a corresponding snapshot element - int ce = 0; - for (ElementDefinition e : diff.getElement()) { - if (!e.hasUserData("diff-source")) - throw new Error(context.formatMessage(I18nConstants.UNXPECTED_INTERNAL_CONDITION__NO_SOURCE_ON_DIFF_ELEMENT)); - else { - if (e.hasUserData(DERIVATION_EQUALS)) - ((Base) e.getUserData("diff-source")).setUserData(DERIVATION_EQUALS, e.getUserData(DERIVATION_EQUALS)); - if (e.hasUserData(DERIVATION_POINTER)) - ((Base) e.getUserData("diff-source")).setUserData(DERIVATION_POINTER, e.getUserData(DERIVATION_POINTER)); - } - if (!e.hasUserData(GENERATED_IN_SNAPSHOT)) { - b.append(e.hasId() ? "id: "+e.getId() : "path: "+e.getPath()); - ce++; - if (e.hasId()) { - String msg = "No match found in the generated snapshot: check that the path and definitions are legal in the differential (including order)"; - messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url+"#"+e.getId(), msg, ValidationMessage.IssueSeverity.ERROR)); - } - } - } - if (!Utilities.noString(b.toString())) { - String msg = "The profile "+derived.getUrl()+" has "+ce+" "+Utilities.pluralize("element", ce)+" in the differential ("+b.toString()+") that don't have a matching element in the snapshot: check that the path and definitions are legal in the differential (including order)"; - System.out.println("Error in snapshot generation: "+msg); - if (!debug) { + if (derived.getKind() != StructureDefinitionKind.LOGICAL && !derived.getSnapshot().getElementFirstRep().getType().isEmpty()) + throw new Error(context.formatMessage(I18nConstants.TYPE_ON_FIRST_SNAPSHOT_ELEMENT_FOR__IN__FROM_, derived.getSnapshot().getElementFirstRep().getPath(), derived.getUrl(), base.getUrl())); + updateMaps(base, derived); + + setIds(derived, false); + if (debug) { System.out.println("Differential: "); for (ElementDefinition ed : derived.getDifferential().getElement()) - System.out.println(" "+ed.getId()+" = "+ed.getPath()+" : "+typeSummaryWithProfile(ed)+"["+ed.getMin()+".."+ed.getMax()+"]"+sliceSummary(ed)+" "+constraintSummary(ed)); + System.out.println(" "+ed.getId()+" : "+typeSummaryWithProfile(ed)+"["+ed.getMin()+".."+ed.getMax()+"]"+sliceSummary(ed)+" "+constraintSummary(ed)); System.out.println("Snapshot: "); for (ElementDefinition ed : derived.getSnapshot().getElement()) - System.out.println(" "+ed.getId()+" = "+ed.getPath()+" : "+typeSummaryWithProfile(ed)+"["+ed.getMin()+".."+ed.getMax()+"]"+sliceSummary(ed)+" "+constraintSummary(ed)); + System.out.println(" "+ed.getId()+" : "+typeSummaryWithProfile(ed)+"["+ed.getMin()+".."+ed.getMax()+"]"+sliceSummary(ed)+" "+constraintSummary(ed)); } - if (exception) - throw new DefinitionException(msg); - else - messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url, msg, ValidationMessage.IssueSeverity.ERROR)); - } - // hack around a problem in R4 definitions (somewhere?) - for (ElementDefinition ed : derived.getSnapshot().getElement()) { - for (ElementDefinitionMappingComponent mm : ed.getMapping()) { - if (mm.hasMap()) { - mm.setMap(mm.getMap().trim()); + CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); + //Check that all differential elements have a corresponding snapshot element + int ce = 0; + for (ElementDefinition e : diff.getElement()) { + if (!e.hasUserData("diff-source")) + throw new Error(context.formatMessage(I18nConstants.UNXPECTED_INTERNAL_CONDITION__NO_SOURCE_ON_DIFF_ELEMENT)); + else { + if (e.hasUserData(DERIVATION_EQUALS)) + ((Base) e.getUserData("diff-source")).setUserData(DERIVATION_EQUALS, e.getUserData(DERIVATION_EQUALS)); + if (e.hasUserData(DERIVATION_POINTER)) + ((Base) e.getUserData("diff-source")).setUserData(DERIVATION_POINTER, e.getUserData(DERIVATION_POINTER)); } - } - for (ElementDefinitionConstraintComponent s : ed.getConstraint()) { - if (s.hasSource()) { - String ref = s.getSource(); - if (!Utilities.isAbsoluteUrl(ref)) { - if (ref.contains(".")) { - s.setSource("http://hl7.org/fhir/StructureDefinition/"+ref.substring(0, ref.indexOf("."))+"#"+ref); - } else { - s.setSource("http://hl7.org/fhir/StructureDefinition/"+ref); - } - } - } - } - } - if (derived.getDerivation() == TypeDerivationRule.SPECIALIZATION) { - for (ElementDefinition ed : derived.getSnapshot().getElement()) { - if (!ed.hasBase()) { - ed.getBase().setPath(ed.getPath()).setMin(ed.getMin()).setMax(ed.getMax()); - } - } - } - // last, check for wrong profiles or target profiles - for (ElementDefinition ed : derived.getSnapshot().getElement()) { - for (TypeRefComponent t : ed.getType()) { - for (UriType u : t.getProfile()) { - StructureDefinition sd = context.fetchResource(StructureDefinition.class, u.getValue()); - if (sd == null) { - if (xver != null && xver.matchingUrl(u.getValue()) && xver.status(u.getValue()) == XVerExtensionStatus.Valid) { - sd = xver.makeDefinition(u.getValue()); - } + if (!e.hasUserData(GENERATED_IN_SNAPSHOT)) { + b.append(e.hasId() ? "id: "+e.getId() : "path: "+e.getPath()); + ce++; + if (e.hasId()) { + String msg = "No match found in the generated snapshot: check that the path and definitions are legal in the differential (including order)"; + messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url+"#"+e.getId(), msg, ValidationMessage.IssueSeverity.ERROR)); } - if (sd == null) { - if (messages != null) { - messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url+"#"+ed.getId(), "The type of profile "+u.getValue()+" cannot be checked as the profile is not known", IssueSeverity.WARNING)); + } + } + if (!Utilities.noString(b.toString())) { + String msg = "The profile "+derived.getUrl()+" has "+ce+" "+Utilities.pluralize("element", ce)+" in the differential ("+b.toString()+") that don't have a matching element in the snapshot: check that the path and definitions are legal in the differential (including order)"; + System.out.println("Error in snapshot generation: "+msg); + if (!debug) { + System.out.println("Differential: "); + for (ElementDefinition ed : derived.getDifferential().getElement()) + System.out.println(" "+ed.getId()+" = "+ed.getPath()+" : "+typeSummaryWithProfile(ed)+"["+ed.getMin()+".."+ed.getMax()+"]"+sliceSummary(ed)+" "+constraintSummary(ed)); + System.out.println("Snapshot: "); + for (ElementDefinition ed : derived.getSnapshot().getElement()) + System.out.println(" "+ed.getId()+" = "+ed.getPath()+" : "+typeSummaryWithProfile(ed)+"["+ed.getMin()+".."+ed.getMax()+"]"+sliceSummary(ed)+" "+constraintSummary(ed)); + } + if (exception) + throw new DefinitionException(msg); + else + messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url, msg, ValidationMessage.IssueSeverity.ERROR)); + } + // hack around a problem in R4 definitions (somewhere?) + for (ElementDefinition ed : derived.getSnapshot().getElement()) { + for (ElementDefinitionMappingComponent mm : ed.getMapping()) { + if (mm.hasMap()) { + mm.setMap(mm.getMap().trim()); + } + } + for (ElementDefinitionConstraintComponent s : ed.getConstraint()) { + if (s.hasSource()) { + String ref = s.getSource(); + if (!Utilities.isAbsoluteUrl(ref)) { + if (ref.contains(".")) { + s.setSource("http://hl7.org/fhir/StructureDefinition/"+ref.substring(0, ref.indexOf("."))+"#"+ref); + } else { + s.setSource("http://hl7.org/fhir/StructureDefinition/"+ref); + } + } + } + } + } + if (derived.getDerivation() == TypeDerivationRule.SPECIALIZATION) { + for (ElementDefinition ed : derived.getSnapshot().getElement()) { + if (!ed.hasBase()) { + ed.getBase().setPath(ed.getPath()).setMin(ed.getMin()).setMax(ed.getMax()); + } + } + } + // last, check for wrong profiles or target profiles + for (ElementDefinition ed : derived.getSnapshot().getElement()) { + for (TypeRefComponent t : ed.getType()) { + for (UriType u : t.getProfile()) { + StructureDefinition sd = context.fetchResource(StructureDefinition.class, u.getValue()); + if (sd == null) { + if (xver != null && xver.matchingUrl(u.getValue()) && xver.status(u.getValue()) == XVerExtensionStatus.Valid) { + sd = xver.makeDefinition(u.getValue()); + } } - } else { - String wt = t.getWorkingCode(); - if (ed.getPath().equals("Bundle.entry.response.outcome")) { - wt = "OperationOutcome"; - } - if (!sd.getType().equals(wt)) { - boolean ok = isCompatibleType(wt, sd); - if (!ok) { - String smsg = "The profile "+u.getValue()+" has type "+sd.getType()+" which is not consistent with the stated type "+wt; - if (exception) - throw new DefinitionException(smsg); - else - messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url+"#"+ed.getId(), smsg, IssueSeverity.ERROR)); + if (sd == null) { + if (messages != null) { + messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url+"#"+ed.getId(), "The type of profile "+u.getValue()+" cannot be checked as the profile is not known", IssueSeverity.WARNING)); + } + } else { + String wt = t.getWorkingCode(); + if (ed.getPath().equals("Bundle.entry.response.outcome")) { + wt = "OperationOutcome"; + } + if (!sd.getType().equals(wt)) { + boolean ok = isCompatibleType(wt, sd); + if (!ok) { + String smsg = "The profile "+u.getValue()+" has type "+sd.getType()+" which is not consistent with the stated type "+wt; + if (exception) + throw new DefinitionException(smsg); + else + messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url+"#"+ed.getId(), smsg, IssueSeverity.ERROR)); + } } } } } } + } catch (Exception e) { + // if we had an exception generating the snapshot, make sure we don't leave any half generated snapshot behind + derived.setSnapshot(null); + derived.clearUserData("profileutils.snapshot.generating"); + throw e; } - } catch (Exception e) { - // if we had an exception generating the snapshot, make sure we don't leave any half generated snapshot behind - derived.setSnapshot(null); + } finally { derived.clearUserData("profileutils.snapshot.generating"); - throw e; + snapshotStack.remove(derived.getUrl()); } - derived.clearUserData("profileutils.snapshot.generating"); } public void checkDifferentialBaseType(StructureDefinition derived) throws Error { @@ -1147,7 +1151,7 @@ public class ProfileUtilities extends TranslatingUtilities { processPaths(indent+" ", result, base, differential, nbc, start, nbl-1, diffCursor-1, url, webUrl, profileName, tgt.getElement().getPath(), outcome.getPath(), trimDifferential, contextName, resultPathBase, false, null, null, redirectorStack(redirector, outcome, cpath), srcSD); } } else { - StructureDefinition dt = outcome.getType().size() > 1 ? context.fetchTypeDefinition("Element") : getProfileForDataType(outcome.getType().get(0)); + StructureDefinition dt = outcome.getType().size() > 1 ? context.fetchTypeDefinition("Element") : getProfileForDataType(outcome.getType().get(0), webUrl); if (dt == null) { throw new DefinitionException(context.formatMessage(I18nConstants.UNKNOWN_TYPE__AT_, outcome.getType().get(0), cpath)); } @@ -1300,7 +1304,7 @@ public class ProfileUtilities extends TranslatingUtilities { processPaths(indent+" ", result, base, differential, nbc, start - 1, nbl-1, diffCursor - 1, url, webUrl, profileName, tgt.getElement().getPath(), diffMatches.get(0).getPath(), trimDifferential, contextName, resultPathBase, false, null, null, redirectorStack(redirector, outcome, cpath), srcSD); } } else { - StructureDefinition dt = outcome.getType().size() == 1 ? getProfileForDataType(outcome.getType().get(0)) : getProfileForDataType("Element"); + StructureDefinition dt = outcome.getType().size() == 1 ? getProfileForDataType(outcome.getType().get(0), webUrl) : getProfileForDataType("Element"); if (dt == null) throw new DefinitionException(context.formatMessage(I18nConstants._HAS_CHILDREN__FOR_TYPE__IN_PROFILE__BUT_CANT_FIND_TYPE, diffMatches.get(0).getPath(), differential.getElement().get(diffCursor).getPath(), typeCode(outcome.getType()), profileName)); contextName = dt.getUrl(); @@ -1511,7 +1515,7 @@ public class ProfileUtilities extends TranslatingUtilities { if (baseHasChildren(base, currentBase)) { // not a new type here throw new Error("This situation is not yet handled (constrain slicing to 1..1 and fix base slice for inline structure - please report issue to grahame@fhir.org along with a test case that reproduces this error (@ "+cpath+" | "+currentBase.getPath()+")"); } else { - StructureDefinition dt = getTypeForElement(differential, diffCursor, profileName, diffMatches, outcome); + StructureDefinition dt = getTypeForElement(differential, diffCursor, profileName, diffMatches, outcome, webUrl); contextName = dt.getUrl(); diffCursor++; start = diffCursor; @@ -1577,7 +1581,7 @@ public class ProfileUtilities extends TranslatingUtilities { processPaths(indent+" ", result, base, differential, baseCursor+1, diffCursor, baseLimit, diffLimit, url, webUrl, profileName, contextPathSrc, contextPathDst, trimDifferential, contextName, resultPathBase, false, null, null, redirector, srcSD); baseCursor = indexOfFirstNonChild(base, currentBase, baseCursor, baseLimit); } else { - StructureDefinition dt = getTypeForElement(differential, diffCursor, profileName, diffMatches, outcome); + StructureDefinition dt = getTypeForElement(differential, diffCursor, profileName, diffMatches, outcome, webUrl); contextName = dt.getUrl(); int start = diffCursor; while (differential.getElement().size() > diffCursor && pathStartsWith(differential.getElement().get(diffCursor).getPath(), cpath+".")) @@ -1778,7 +1782,7 @@ public class ProfileUtilities extends TranslatingUtilities { if (base.getElement().get(baseCursor).getType().size() != 1) { throw new Error(context.formatMessage(I18nConstants.DIFFERENTIAL_WALKS_INTO____BUT_THE_BASE_DOES_NOT_AND_THERE_IS_NOT_A_SINGLE_FIXED_TYPE_THE_TYPE_IS__THIS_IS_NOT_HANDLED_YET, cpath, diffMatches.get(0).toString(), base.getElement().get(baseCursor).typeSummary())); } - StructureDefinition dt = getProfileForDataType(base.getElement().get(baseCursor).getType().get(0)); + StructureDefinition dt = getProfileForDataType(base.getElement().get(baseCursor).getType().get(0), webUrl); if (dt == null) { throw new DefinitionException(context.formatMessage(I18nConstants.UNKNOWN_TYPE__AT_, outcome.getType().get(0), diffMatches.get(0).getPath())); } @@ -1894,7 +1898,7 @@ public class ProfileUtilities extends TranslatingUtilities { diffCursor - 1, url, webUrl, profileName+pathTail(diffMatches, 0), base.getElement().get(0).getPath(), base.getElement().get(0).getPath(), trimDifferential, contextName, resultPathBase, false, null, null, redirector, srcSD); } else { - StructureDefinition dt = getProfileForDataType(outcome.getType().get(0)); + StructureDefinition dt = getProfileForDataType(outcome.getType().get(0), webUrl); // if (t.getCode().equals("Extension") && t.hasProfile() && !t.getProfile().contains(":")) { // lloydfix dt = // } @@ -1946,7 +1950,7 @@ public class ProfileUtilities extends TranslatingUtilities { } public StructureDefinition getTypeForElement(StructureDefinitionDifferentialComponent differential, int diffCursor, String profileName, - List diffMatches, ElementDefinition outcome) { + List diffMatches, ElementDefinition outcome, String webUrl) { if (outcome.getType().size() == 0) { throw new DefinitionException(context.formatMessage(I18nConstants._HAS_NO_CHILDREN__AND_NO_TYPES_IN_PROFILE_, diffMatches.get(0).getPath(), differential.getElement().get(diffCursor).getPath(), profileName)); } @@ -1956,7 +1960,7 @@ public class ProfileUtilities extends TranslatingUtilities { throw new DefinitionException(context.formatMessage(I18nConstants._HAS_CHILDREN__AND_MULTIPLE_TYPES__IN_PROFILE_, diffMatches.get(0).getPath(), differential.getElement().get(diffCursor).getPath(), typeCode(outcome.getType()), profileName)); } } - StructureDefinition dt = getProfileForDataType(outcome.getType().get(0)); + StructureDefinition dt = getProfileForDataType(outcome.getType().get(0), webUrl); if (dt == null) throw new DefinitionException(context.formatMessage(I18nConstants.UNKNOWN_TYPE__AT_, outcome.getType().get(0), diffMatches.get(0).getPath())); return dt; @@ -2428,13 +2432,14 @@ public class ProfileUtilities extends TranslatingUtilities { return s; } - private StructureDefinition getProfileForDataType(TypeRefComponent type) { + private StructureDefinition getProfileForDataType(TypeRefComponent type, String webUrl) { StructureDefinition sd = null; if (type.hasProfile()) { sd = context.fetchResource(StructureDefinition.class, type.getProfile().get(0).getValue()); if (sd == null) { if (xver != null && xver.matchingUrl(type.getProfile().get(0).getValue()) && xver.status(type.getProfile().get(0).getValue()) == XVerExtensionStatus.Valid) { sd = xver.makeDefinition(type.getProfile().get(0).getValue()); + generateSnapshot(context.fetchTypeDefinition("Extension"), sd, sd.getUrl(), webUrl, sd.getName()); } } if (sd == null) diff --git a/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/tests/RegexTests.java b/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/tests/RegexTests.java new file mode 100644 index 000000000..f7f78d999 --- /dev/null +++ b/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/tests/RegexTests.java @@ -0,0 +1,25 @@ +package org.hl7.fhir.utilities.tests; + +import java.io.IOException; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class RegexTests { + + @Test + public void testPath1() throws IOException { + Assertions.assertFalse("http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1".matches("Library")); + } + + @Test + public void testPath2() throws IOException { + Assertions.assertTrue("http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1".matches(".*Library.*")); + } + + @Test + public void testPath3() throws IOException { + Assertions.assertTrue("http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1".matches("(?s).*Library.*")); + } + +} diff --git a/pom.xml b/pom.xml index dbb6f8c5a..2740cbe0e 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 5.4.0 - 1.1.92 + 1.1.93-SNAPSHOT 5.7.1 1.7.1 3.0.0-M5 From 7a7579628cc7fc08884e73449bba035fb0ae9836 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Thu, 10 Mar 2022 11:40:47 +1100 Subject: [PATCH 40/50] compile fix From 21af65d9d66604c56956015211ec3b2bf18e190e Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Fri, 11 Mar 2022 06:42:28 +1100 Subject: [PATCH 41/50] get tests passing for R5 changes From 3f9d651b9b607e9c61056f3c85871ed17cd735d2 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Fri, 11 Mar 2022 06:43:12 +1100 Subject: [PATCH 42/50] updates for r5 changes --- .../r4b/conformance/ProfileUtilities.java | 313 +++++++++--------- .../r4b/test/SnapShotGenerationTests.java | 1 - 2 files changed, 159 insertions(+), 155 deletions(-) diff --git a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/conformance/ProfileUtilities.java b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/conformance/ProfileUtilities.java index d8e13d43b..3baefc805 100644 --- a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/conformance/ProfileUtilities.java +++ b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/conformance/ProfileUtilities.java @@ -623,174 +623,178 @@ public class ProfileUtilities extends TranslatingUtilities { } derived.setUserData("profileutils.snapshot.generating", true); snapshotStack.add(derived.getUrl()); - - if (!Utilities.noString(webUrl) && !webUrl.endsWith("/")) - webUrl = webUrl + '/'; - - if (defWebRoot == null) - defWebRoot = webUrl; - derived.setSnapshot(new StructureDefinitionSnapshotComponent()); - try { - checkDifferential(derived.getDifferential().getElement(), typeName(derived.getType()), derived.getUrl()); - checkDifferentialBaseType(derived); - - // so we have two lists - the base list, and the differential list - // the differential list is only allowed to include things that are in the base list, but - // is allowed to include them multiple times - thereby slicing them - // our approach is to walk through the base list, and see whether the differential - // says anything about them. - int baseCursor = 0; - int diffCursor = 0; // we need a diff cursor because we can only look ahead, in the bound scoped by longer paths + if (!Utilities.noString(webUrl) && !webUrl.endsWith("/")) + webUrl = webUrl + '/'; + + if (defWebRoot == null) + defWebRoot = webUrl; + derived.setSnapshot(new StructureDefinitionSnapshotComponent()); + + try { + checkDifferential(derived.getDifferential().getElement(), typeName(derived.getType()), derived.getUrl()); + checkDifferentialBaseType(derived); + + // so we have two lists - the base list, and the differential list + // the differential list is only allowed to include things that are in the base list, but + // is allowed to include them multiple times - thereby slicing them + + // our approach is to walk through the base list, and see whether the differential + // says anything about them. + int baseCursor = 0; + int diffCursor = 0; // we need a diff cursor because we can only look ahead, in the bound scoped by longer paths - for (ElementDefinition e : derived.getDifferential().getElement()) - e.clearUserData(GENERATED_IN_SNAPSHOT); + for (ElementDefinition e : derived.getDifferential().getElement()) + e.clearUserData(GENERATED_IN_SNAPSHOT); - // we actually delegate the work to a subroutine so we can re-enter it with a different cursors - StructureDefinitionDifferentialComponent diff = cloneDiff(derived.getDifferential()); // we make a copy here because we're sometimes going to hack the differential while processing it. Have to migrate user data back afterwards - StructureDefinitionSnapshotComponent baseSnapshot = base.getSnapshot(); - if (derived.getDerivation() == TypeDerivationRule.SPECIALIZATION) { - String derivedType = derived.getType(); - if (StructureDefinitionKind.LOGICAL.equals(derived.getKind()) && derived.getType().contains("/")) { - derivedType = derivedType.substring(derivedType.lastIndexOf("/")+1); + // we actually delegate the work to a subroutine so we can re-enter it with a different cursors + StructureDefinitionDifferentialComponent diff = cloneDiff(derived.getDifferential()); // we make a copy here because we're sometimes going to hack the differential while processing it. Have to migrate user data back afterwards + StructureDefinitionSnapshotComponent baseSnapshot = base.getSnapshot(); + if (derived.getDerivation() == TypeDerivationRule.SPECIALIZATION) { + String derivedType = derived.getType(); + if (StructureDefinitionKind.LOGICAL.equals(derived.getKind()) && derived.getType().contains("/")) { + derivedType = derivedType.substring(derivedType.lastIndexOf("/")+1); + } + baseSnapshot = cloneSnapshot(baseSnapshot, base.getType(), derivedType); } - baseSnapshot = cloneSnapshot(baseSnapshot, base.getType(), derivedType); - } -// if (derived.getId().equals("2.16.840.1.113883.10.20.22.2.1.1")) { -// debug = true; -// } - processPaths("", derived.getSnapshot(), baseSnapshot, diff, baseCursor, diffCursor, baseSnapshot.getElement().size()-1, - derived.getDifferential().hasElement() ? derived.getDifferential().getElement().size()-1 : -1, url, webUrl, derived.present(), null, null, false, base.getUrl(), null, false, null, null, new ArrayList(), base); - checkGroupConstraints(derived); - if (derived.getDerivation() == TypeDerivationRule.SPECIALIZATION) { - for (ElementDefinition e : diff.getElement()) { - if (!e.hasUserData(GENERATED_IN_SNAPSHOT)) { - ElementDefinition outcome = updateURLs(url, webUrl, e.copy()); - e.setUserData(GENERATED_IN_SNAPSHOT, outcome); - derived.getSnapshot().addElement(outcome); + // if (derived.getId().equals("2.16.840.1.113883.10.20.22.2.1.1")) { + // debug = true; + // } + processPaths("", derived.getSnapshot(), baseSnapshot, diff, baseCursor, diffCursor, baseSnapshot.getElement().size()-1, + derived.getDifferential().hasElement() ? derived.getDifferential().getElement().size()-1 : -1, url, webUrl, derived.present(), null, null, false, base.getUrl(), null, false, null, null, new ArrayList(), base); + checkGroupConstraints(derived); + if (derived.getDerivation() == TypeDerivationRule.SPECIALIZATION) { + for (ElementDefinition e : diff.getElement()) { + if (!e.hasUserData(GENERATED_IN_SNAPSHOT)) { + ElementDefinition outcome = updateURLs(url, webUrl, e.copy()); + e.setUserData(GENERATED_IN_SNAPSHOT, outcome); + derived.getSnapshot().addElement(outcome); + } } } - } - - if (derived.getKind() != StructureDefinitionKind.LOGICAL && !derived.getSnapshot().getElementFirstRep().getType().isEmpty()) - throw new Error(context.formatMessage(I18nConstants.TYPE_ON_FIRST_SNAPSHOT_ELEMENT_FOR__IN__FROM_, derived.getSnapshot().getElementFirstRep().getPath(), derived.getUrl(), base.getUrl())); - updateMaps(base, derived); - setIds(derived, false); - if (debug) { - System.out.println("Differential: "); - for (ElementDefinition ed : derived.getDifferential().getElement()) - System.out.println(" "+ed.getId()+" : "+typeSummaryWithProfile(ed)+"["+ed.getMin()+".."+ed.getMax()+"]"+sliceSummary(ed)+" "+constraintSummary(ed)); - System.out.println("Snapshot: "); - for (ElementDefinition ed : derived.getSnapshot().getElement()) - System.out.println(" "+ed.getId()+" : "+typeSummaryWithProfile(ed)+"["+ed.getMin()+".."+ed.getMax()+"]"+sliceSummary(ed)+" "+constraintSummary(ed)); - } - CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); - //Check that all differential elements have a corresponding snapshot element - int ce = 0; - for (ElementDefinition e : diff.getElement()) { - if (!e.hasUserData("diff-source")) - throw new Error(context.formatMessage(I18nConstants.UNXPECTED_INTERNAL_CONDITION__NO_SOURCE_ON_DIFF_ELEMENT)); - else { - if (e.hasUserData(DERIVATION_EQUALS)) - ((Base) e.getUserData("diff-source")).setUserData(DERIVATION_EQUALS, e.getUserData(DERIVATION_EQUALS)); - if (e.hasUserData(DERIVATION_POINTER)) - ((Base) e.getUserData("diff-source")).setUserData(DERIVATION_POINTER, e.getUserData(DERIVATION_POINTER)); - } - if (!e.hasUserData(GENERATED_IN_SNAPSHOT)) { - b.append(e.hasId() ? "id: "+e.getId() : "path: "+e.getPath()); - ce++; - if (e.hasId()) { - String msg = "No match found in the generated snapshot: check that the path and definitions are legal in the differential (including order)"; - messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url+"#"+e.getId(), msg, ValidationMessage.IssueSeverity.ERROR)); - } - } - } - if (!Utilities.noString(b.toString())) { - String msg = "The profile "+derived.getUrl()+" has "+ce+" "+Utilities.pluralize("element", ce)+" in the differential ("+b.toString()+") that don't have a matching element in the snapshot: check that the path and definitions are legal in the differential (including order)"; - System.out.println("Error in snapshot generation: "+msg); - if (!debug) { + if (derived.getKind() != StructureDefinitionKind.LOGICAL && !derived.getSnapshot().getElementFirstRep().getType().isEmpty()) + throw new Error(context.formatMessage(I18nConstants.TYPE_ON_FIRST_SNAPSHOT_ELEMENT_FOR__IN__FROM_, derived.getSnapshot().getElementFirstRep().getPath(), derived.getUrl(), base.getUrl())); + updateMaps(base, derived); + + setIds(derived, false); + if (debug) { System.out.println("Differential: "); for (ElementDefinition ed : derived.getDifferential().getElement()) - System.out.println(" "+ed.getId()+" = "+ed.getPath()+" : "+typeSummaryWithProfile(ed)+"["+ed.getMin()+".."+ed.getMax()+"]"+sliceSummary(ed)+" "+constraintSummary(ed)); + System.out.println(" "+ed.getId()+" : "+typeSummaryWithProfile(ed)+"["+ed.getMin()+".."+ed.getMax()+"]"+sliceSummary(ed)+" "+constraintSummary(ed)); System.out.println("Snapshot: "); for (ElementDefinition ed : derived.getSnapshot().getElement()) - System.out.println(" "+ed.getId()+" = "+ed.getPath()+" : "+typeSummaryWithProfile(ed)+"["+ed.getMin()+".."+ed.getMax()+"]"+sliceSummary(ed)+" "+constraintSummary(ed)); + System.out.println(" "+ed.getId()+" : "+typeSummaryWithProfile(ed)+"["+ed.getMin()+".."+ed.getMax()+"]"+sliceSummary(ed)+" "+constraintSummary(ed)); } - if (exception) - throw new DefinitionException(msg); - else - messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url, msg, ValidationMessage.IssueSeverity.ERROR)); - } - // hack around a problem in R4 definitions (somewhere?) - for (ElementDefinition ed : derived.getSnapshot().getElement()) { - for (ElementDefinitionMappingComponent mm : ed.getMapping()) { - if (mm.hasMap()) { - mm.setMap(mm.getMap().trim()); + CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); + //Check that all differential elements have a corresponding snapshot element + int ce = 0; + for (ElementDefinition e : diff.getElement()) { + if (!e.hasUserData("diff-source")) + throw new Error(context.formatMessage(I18nConstants.UNXPECTED_INTERNAL_CONDITION__NO_SOURCE_ON_DIFF_ELEMENT)); + else { + if (e.hasUserData(DERIVATION_EQUALS)) + ((Base) e.getUserData("diff-source")).setUserData(DERIVATION_EQUALS, e.getUserData(DERIVATION_EQUALS)); + if (e.hasUserData(DERIVATION_POINTER)) + ((Base) e.getUserData("diff-source")).setUserData(DERIVATION_POINTER, e.getUserData(DERIVATION_POINTER)); } - } - for (ElementDefinitionConstraintComponent s : ed.getConstraint()) { - if (s.hasSource()) { - String ref = s.getSource(); - if (!Utilities.isAbsoluteUrl(ref)) { - if (ref.contains(".")) { - s.setSource("http://hl7.org/fhir/StructureDefinition/"+ref.substring(0, ref.indexOf("."))+"#"+ref); - } else { - s.setSource("http://hl7.org/fhir/StructureDefinition/"+ref); - } - } - } - } - } - if (derived.getDerivation() == TypeDerivationRule.SPECIALIZATION) { - for (ElementDefinition ed : derived.getSnapshot().getElement()) { - if (!ed.hasBase()) { - ed.getBase().setPath(ed.getPath()).setMin(ed.getMin()).setMax(ed.getMax()); - } - } - } - // last, check for wrong profiles or target profiles - for (ElementDefinition ed : derived.getSnapshot().getElement()) { - for (TypeRefComponent t : ed.getType()) { - for (UriType u : t.getProfile()) { - StructureDefinition sd = context.fetchResource(StructureDefinition.class, u.getValue()); - if (sd == null) { - if (xver != null && xver.matchingUrl(u.getValue()) && xver.status(u.getValue()) == XVerExtensionStatus.Valid) { - sd = xver.makeDefinition(u.getValue()); - } + if (!e.hasUserData(GENERATED_IN_SNAPSHOT)) { + b.append(e.hasId() ? "id: "+e.getId() : "path: "+e.getPath()); + ce++; + if (e.hasId()) { + String msg = "No match found in the generated snapshot: check that the path and definitions are legal in the differential (including order)"; + messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url+"#"+e.getId(), msg, ValidationMessage.IssueSeverity.ERROR)); } - if (sd == null) { - if (messages != null) { - messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url+"#"+ed.getId(), "The type of profile "+u.getValue()+" cannot be checked as the profile is not known", IssueSeverity.WARNING)); + } + } + if (!Utilities.noString(b.toString())) { + String msg = "The profile "+derived.getUrl()+" has "+ce+" "+Utilities.pluralize("element", ce)+" in the differential ("+b.toString()+") that don't have a matching element in the snapshot: check that the path and definitions are legal in the differential (including order)"; + System.out.println("Error in snapshot generation: "+msg); + if (!debug) { + System.out.println("Differential: "); + for (ElementDefinition ed : derived.getDifferential().getElement()) + System.out.println(" "+ed.getId()+" = "+ed.getPath()+" : "+typeSummaryWithProfile(ed)+"["+ed.getMin()+".."+ed.getMax()+"]"+sliceSummary(ed)+" "+constraintSummary(ed)); + System.out.println("Snapshot: "); + for (ElementDefinition ed : derived.getSnapshot().getElement()) + System.out.println(" "+ed.getId()+" = "+ed.getPath()+" : "+typeSummaryWithProfile(ed)+"["+ed.getMin()+".."+ed.getMax()+"]"+sliceSummary(ed)+" "+constraintSummary(ed)); + } + if (exception) + throw new DefinitionException(msg); + else + messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url, msg, ValidationMessage.IssueSeverity.ERROR)); + } + // hack around a problem in R4 definitions (somewhere?) + for (ElementDefinition ed : derived.getSnapshot().getElement()) { + for (ElementDefinitionMappingComponent mm : ed.getMapping()) { + if (mm.hasMap()) { + mm.setMap(mm.getMap().trim()); + } + } + for (ElementDefinitionConstraintComponent s : ed.getConstraint()) { + if (s.hasSource()) { + String ref = s.getSource(); + if (!Utilities.isAbsoluteUrl(ref)) { + if (ref.contains(".")) { + s.setSource("http://hl7.org/fhir/StructureDefinition/"+ref.substring(0, ref.indexOf("."))+"#"+ref); + } else { + s.setSource("http://hl7.org/fhir/StructureDefinition/"+ref); + } + } + } + } + } + if (derived.getDerivation() == TypeDerivationRule.SPECIALIZATION) { + for (ElementDefinition ed : derived.getSnapshot().getElement()) { + if (!ed.hasBase()) { + ed.getBase().setPath(ed.getPath()).setMin(ed.getMin()).setMax(ed.getMax()); + } + } + } + // last, check for wrong profiles or target profiles + for (ElementDefinition ed : derived.getSnapshot().getElement()) { + for (TypeRefComponent t : ed.getType()) { + for (UriType u : t.getProfile()) { + StructureDefinition sd = context.fetchResource(StructureDefinition.class, u.getValue()); + if (sd == null) { + if (xver != null && xver.matchingUrl(u.getValue()) && xver.status(u.getValue()) == XVerExtensionStatus.Valid) { + sd = xver.makeDefinition(u.getValue()); + } } - } else { - String wt = t.getWorkingCode(); - if (ed.getPath().equals("Bundle.entry.response.outcome")) { - wt = "OperationOutcome"; - } - if (!sd.getType().equals(wt)) { - boolean ok = isCompatibleType(wt, sd); - if (!ok) { - String smsg = "The profile "+u.getValue()+" has type "+sd.getType()+" which is not consistent with the stated type "+wt; - if (exception) - throw new DefinitionException(smsg); - else - messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url+"#"+ed.getId(), smsg, IssueSeverity.ERROR)); + if (sd == null) { + if (messages != null) { + messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url+"#"+ed.getId(), "The type of profile "+u.getValue()+" cannot be checked as the profile is not known", IssueSeverity.WARNING)); + } + } else { + String wt = t.getWorkingCode(); + if (ed.getPath().equals("Bundle.entry.response.outcome")) { + wt = "OperationOutcome"; + } + if (!sd.getType().equals(wt)) { + boolean ok = isCompatibleType(wt, sd); + if (!ok) { + String smsg = "The profile "+u.getValue()+" has type "+sd.getType()+" which is not consistent with the stated type "+wt; + if (exception) + throw new DefinitionException(smsg); + else + messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url+"#"+ed.getId(), smsg, IssueSeverity.ERROR)); + } } } } } } + } catch (Exception e) { + // if we had an exception generating the snapshot, make sure we don't leave any half generated snapshot behind + derived.setSnapshot(null); + derived.clearUserData("profileutils.snapshot.generating"); + throw e; } - } catch (Exception e) { - // if we had an exception generating the snapshot, make sure we don't leave any half generated snapshot behind - derived.setSnapshot(null); + } finally { derived.clearUserData("profileutils.snapshot.generating"); - throw e; + snapshotStack.remove(derived.getUrl()); } - derived.clearUserData("profileutils.snapshot.generating"); } public void checkDifferentialBaseType(StructureDefinition derived) throws Error { @@ -1143,7 +1147,7 @@ public class ProfileUtilities extends TranslatingUtilities { processPaths(indent+" ", result, base, differential, nbc, start, nbl-1, diffCursor-1, url, webUrl, profileName, tgt.getElement().getPath(), outcome.getPath(), trimDifferential, contextName, resultPathBase, false, null, null, redirectorStack(redirector, outcome, cpath), srcSD); } } else { - StructureDefinition dt = outcome.getType().size() > 1 ? context.fetchTypeDefinition("Element") : getProfileForDataType(outcome.getType().get(0)); + StructureDefinition dt = outcome.getType().size() > 1 ? context.fetchTypeDefinition("Element") : getProfileForDataType(outcome.getType().get(0), webUrl); if (dt == null) { throw new DefinitionException(context.formatMessage(I18nConstants.UNKNOWN_TYPE__AT_, outcome.getType().get(0), cpath)); } @@ -1296,7 +1300,7 @@ public class ProfileUtilities extends TranslatingUtilities { processPaths(indent+" ", result, base, differential, nbc, start - 1, nbl-1, diffCursor - 1, url, webUrl, profileName, tgt.getElement().getPath(), diffMatches.get(0).getPath(), trimDifferential, contextName, resultPathBase, false, null, null, redirectorStack(redirector, outcome, cpath), srcSD); } } else { - StructureDefinition dt = outcome.getType().size() == 1 ? getProfileForDataType(outcome.getType().get(0)) : getProfileForDataType("Element"); + StructureDefinition dt = outcome.getType().size() == 1 ? getProfileForDataType(outcome.getType().get(0), webUrl) : getProfileForDataType("Element"); if (dt == null) throw new DefinitionException(context.formatMessage(I18nConstants._HAS_CHILDREN__FOR_TYPE__IN_PROFILE__BUT_CANT_FIND_TYPE, diffMatches.get(0).getPath(), differential.getElement().get(diffCursor).getPath(), typeCode(outcome.getType()), profileName)); contextName = dt.getUrl(); @@ -1507,7 +1511,7 @@ public class ProfileUtilities extends TranslatingUtilities { if (baseHasChildren(base, currentBase)) { // not a new type here throw new Error("This situation is not yet handled (constrain slicing to 1..1 and fix base slice for inline structure - please report issue to grahame@fhir.org along with a test case that reproduces this error (@ "+cpath+" | "+currentBase.getPath()+")"); } else { - StructureDefinition dt = getTypeForElement(differential, diffCursor, profileName, diffMatches, outcome); + StructureDefinition dt = getTypeForElement(differential, diffCursor, profileName, diffMatches, outcome, webUrl); contextName = dt.getUrl(); diffCursor++; start = diffCursor; @@ -1573,7 +1577,7 @@ public class ProfileUtilities extends TranslatingUtilities { processPaths(indent+" ", result, base, differential, baseCursor+1, diffCursor, baseLimit, diffLimit, url, webUrl, profileName, contextPathSrc, contextPathDst, trimDifferential, contextName, resultPathBase, false, null, null, redirector, srcSD); baseCursor = indexOfFirstNonChild(base, currentBase, baseCursor, baseLimit); } else { - StructureDefinition dt = getTypeForElement(differential, diffCursor, profileName, diffMatches, outcome); + StructureDefinition dt = getTypeForElement(differential, diffCursor, profileName, diffMatches, outcome, webUrl); contextName = dt.getUrl(); int start = diffCursor; while (differential.getElement().size() > diffCursor && pathStartsWith(differential.getElement().get(diffCursor).getPath(), cpath+".")) @@ -1774,7 +1778,7 @@ public class ProfileUtilities extends TranslatingUtilities { if (base.getElement().get(baseCursor).getType().size() != 1) { throw new Error(context.formatMessage(I18nConstants.DIFFERENTIAL_WALKS_INTO____BUT_THE_BASE_DOES_NOT_AND_THERE_IS_NOT_A_SINGLE_FIXED_TYPE_THE_TYPE_IS__THIS_IS_NOT_HANDLED_YET, cpath, diffMatches.get(0).toString(), base.getElement().get(baseCursor).typeSummary())); } - StructureDefinition dt = getProfileForDataType(base.getElement().get(baseCursor).getType().get(0)); + StructureDefinition dt = getProfileForDataType(base.getElement().get(baseCursor).getType().get(0), webUrl); if (dt == null) { throw new DefinitionException(context.formatMessage(I18nConstants.UNKNOWN_TYPE__AT_, outcome.getType().get(0), diffMatches.get(0).getPath())); } @@ -1890,7 +1894,7 @@ public class ProfileUtilities extends TranslatingUtilities { diffCursor - 1, url, webUrl, profileName+pathTail(diffMatches, 0), base.getElement().get(0).getPath(), base.getElement().get(0).getPath(), trimDifferential, contextName, resultPathBase, false, null, null, redirector, srcSD); } else { - StructureDefinition dt = getProfileForDataType(outcome.getType().get(0)); + StructureDefinition dt = getProfileForDataType(outcome.getType().get(0), webUrl); // if (t.getCode().equals("Extension") && t.hasProfile() && !t.getProfile().contains(":")) { // lloydfix dt = // } @@ -1942,7 +1946,7 @@ public class ProfileUtilities extends TranslatingUtilities { } public StructureDefinition getTypeForElement(StructureDefinitionDifferentialComponent differential, int diffCursor, String profileName, - List diffMatches, ElementDefinition outcome) { + List diffMatches, ElementDefinition outcome, String webUrl) { if (outcome.getType().size() == 0) { throw new DefinitionException(context.formatMessage(I18nConstants._HAS_NO_CHILDREN__AND_NO_TYPES_IN_PROFILE_, diffMatches.get(0).getPath(), differential.getElement().get(diffCursor).getPath(), profileName)); } @@ -1952,7 +1956,7 @@ public class ProfileUtilities extends TranslatingUtilities { throw new DefinitionException(context.formatMessage(I18nConstants._HAS_CHILDREN__AND_MULTIPLE_TYPES__IN_PROFILE_, diffMatches.get(0).getPath(), differential.getElement().get(diffCursor).getPath(), typeCode(outcome.getType()), profileName)); } } - StructureDefinition dt = getProfileForDataType(outcome.getType().get(0)); + StructureDefinition dt = getProfileForDataType(outcome.getType().get(0), webUrl); if (dt == null) throw new DefinitionException(context.formatMessage(I18nConstants.UNKNOWN_TYPE__AT_, outcome.getType().get(0), diffMatches.get(0).getPath())); return dt; @@ -2424,13 +2428,14 @@ public class ProfileUtilities extends TranslatingUtilities { return s; } - private StructureDefinition getProfileForDataType(TypeRefComponent type) { + private StructureDefinition getProfileForDataType(TypeRefComponent type, String webUrl) { StructureDefinition sd = null; if (type.hasProfile()) { sd = context.fetchResource(StructureDefinition.class, type.getProfile().get(0).getValue()); if (sd == null) { if (xver != null && xver.matchingUrl(type.getProfile().get(0).getValue()) && xver.status(type.getProfile().get(0).getValue()) == XVerExtensionStatus.Valid) { sd = xver.makeDefinition(type.getProfile().get(0).getValue()); + generateSnapshot(context.fetchTypeDefinition("Extension"), sd, sd.getUrl(), webUrl, sd.getName()); } } if (sd == null) @@ -4325,12 +4330,12 @@ public class ProfileUtilities extends TranslatingUtilities { private boolean isBaseCondition(IdType c) { String key = c.asStringValue(); - return key.startsWith("ele-") || key.startsWith("res-") || key.startsWith("ext-") || key.startsWith("dom-") || key.startsWith("dr-"); + return key != null && key.startsWith("ele-") || key.startsWith("res-") || key.startsWith("ext-") || key.startsWith("dom-") || key.startsWith("dr-"); } private boolean isBaseConstraint(ElementDefinitionConstraintComponent con) { String key = con.getKey(); - return key.startsWith("ele-") || key.startsWith("res-") || key.startsWith("ext-") || key.startsWith("dom-") || key.startsWith("dr-"); + return key != null && key.startsWith("ele-") || key.startsWith("res-") || key.startsWith("ext-") || key.startsWith("dom-") || key.startsWith("dr-"); } private void makeChoiceRows(List subRows, ElementDefinition element, HierarchicalTableGenerator gen, String corePath, String profileBaseFileName, boolean mustSupportMode) { diff --git a/org.hl7.fhir.r4b/src/test/java/org/hl7/fhir/r4b/test/SnapShotGenerationTests.java b/org.hl7.fhir.r4b/src/test/java/org/hl7/fhir/r4b/test/SnapShotGenerationTests.java index 0141e129a..64efbc82d 100644 --- a/org.hl7.fhir.r4b/src/test/java/org/hl7/fhir/r4b/test/SnapShotGenerationTests.java +++ b/org.hl7.fhir.r4b/src/test/java/org/hl7/fhir/r4b/test/SnapShotGenerationTests.java @@ -10,7 +10,6 @@ import java.util.List; import java.util.stream.Stream; import javax.xml.parsers.ParserConfigurationException; -import javax.xml.soap.Text; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.NotImplementedException; From 56c52ab7dd86ca8c4dc5c7455aaa3817b7107d16 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Fri, 11 Mar 2022 10:34:18 +1100 Subject: [PATCH 43/50] make fhir version code case independent --- .../src/main/java/org/hl7/fhir/r5/model/Enumerations.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Enumerations.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Enumerations.java index 64de74462..38d4a4a8b 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Enumerations.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Enumerations.java @@ -7293,9 +7293,9 @@ public String toCode(int len) { return new Enumeration(this, FHIRVersion._4_1_0); if ("4.2.0".equals(codeString)) return new Enumeration(this, FHIRVersion._4_2_0); - if ("4.3.0-snapshot1".equals(codeString)) + if ("4.3.0-snapshot1".equalsIgnoreCase(codeString)) return new Enumeration(this, FHIRVersion._4_3_0SNAPSHOT1); - if ("4.3.0-cibuild".equals(codeString)) + if ("4.3.0-cibuild".equalsIgnoreCase(codeString)) return new Enumeration(this, FHIRVersion._4_3_0CIBUILD); if ("4.4.0".equals(codeString)) return new Enumeration(this, FHIRVersion._4_4_0); @@ -7303,9 +7303,9 @@ public String toCode(int len) { return new Enumeration(this, FHIRVersion._4_5_0); if ("4.6.0".equals(codeString)) return new Enumeration(this, FHIRVersion._4_6_0); - if ("5.0.0-snapshot1".equals(codeString)) + if ("5.0.0-snapshot1".equalsIgnoreCase(codeString)) return new Enumeration(this, FHIRVersion._5_0_0SNAPSHOT1); - if ("5.0.0-cibuild".equals(codeString)) + if ("5.0.0-cibuild".equalsIgnoreCase(codeString)) return new Enumeration(this, FHIRVersion._5_0_0CIBUILD); throw new FHIRException("Unknown FHIRVersion code '"+codeString+"'"); } From 6b3d7d4eaac93a1b327a531c2789767f4fa20897 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Fri, 11 Mar 2022 10:37:10 +1100 Subject: [PATCH 44/50] infer system when value set has includes --- .../terminologies/ValueSetCheckerSimple.java | 103 +++++++++++------- 1 file changed, 63 insertions(+), 40 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetCheckerSimple.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetCheckerSimple.java index cab2ff611..aeb491319 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetCheckerSimple.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetCheckerSimple.java @@ -33,8 +33,10 @@ package org.hl7.fhir.r5.terminologies; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.NoTerminologyServiceException; @@ -544,71 +546,92 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe private String systemForCodeInValueSet(String code) { - String sys = null; + Set sys = new HashSet<>(); + if (!scanForCodeInValueSet(code, sys)) { + return null; + } + if (sys.size() != 1) { + return null; + } else { + return sys.iterator().next(); + } + } + + private boolean scanForCodeInValueSet(String code, Set sys) { if (valueset.hasCompose()) { - if (valueset.getCompose().hasExclude()) { - return null; - } + // not sure what to do with the +// if (valueset.getCompose().hasExclude()) { +// return false; +// } for (ConceptSetComponent vsi : valueset.getCompose().getInclude()) { if (vsi.hasValueSet()) { - return null; - } - if (!vsi.hasSystem()) { - return null; - } - if (vsi.hasFilter()) { - return null; - } - CodeSystem cs = resolveCodeSystem(vsi.getSystem()); - if (cs == null) { - return null; - } - if (vsi.hasConcept()) { - for (ConceptReferenceComponent cc : vsi.getConcept()) { - boolean match = cs.getCaseSensitive() ? cc.getCode().equals(code) : cc.getCode().equalsIgnoreCase(code); - if (match) { - if (sys == null) { - sys = vsi.getSystem(); - } else if (!sys.equals(vsi.getSystem())) { - return null; - } + for (CanonicalType u : vsi.getValueSet()) { + if (!checkForCodeInValueSet(code, u.getValue(), sys)) { + return false; } } - } else { - ConceptDefinitionComponent cc = findCodeInConcept(cs.getConcept(), code); - if (cc != null) { - if (sys == null) { - sys = vsi.getSystem(); - } else if (!sys.equals(vsi.getSystem())) { - return null; + } else if (!vsi.hasSystem()) { + return false; + } + if (vsi.hasSystem()) { + if (vsi.hasFilter()) { + return false; + } + CodeSystem cs = resolveCodeSystem(vsi.getSystem()); + if (cs != null) { + + if (vsi.hasConcept()) { + for (ConceptReferenceComponent cc : vsi.getConcept()) { + boolean match = cs.getCaseSensitive() ? cc.getCode().equals(code) : cc.getCode().equalsIgnoreCase(code); + if (match) { + sys.add(vsi.getSystem()); + } + } + } else { + ConceptDefinitionComponent cc = findCodeInConcept(cs.getConcept(), code); + if (cc != null) { + sys.add(vsi.getSystem()); + } + } + } else { + if (vsi.hasConcept()) { + for (ConceptReferenceComponent cc : vsi.getConcept()) { + boolean match = cc.getCode().equals(code); + if (match) { + sys.add(vsi.getSystem()); + } + } } } } } } else if (valueset.hasExpansion()) { // Retrieve a list of all systems associated with this code in the expansion - List systems = new ArrayList(); - checkSystems(valueset.getExpansion().getContains(), code, systems); - if (systems.size()==1) - sys = systems.get(0); + if (!checkSystems(valueset.getExpansion().getContains(), code, sys)) { + return false; + } } + return true; + } - return sys; + private boolean checkForCodeInValueSet(String code, String uri, Set sys) { + ValueSetCheckerSimple vs = getVs(uri); + return vs.scanForCodeInValueSet(code, sys); } /* * Recursively go through all codes in the expansion and for any coding that matches the specified code, add the system for that coding * to the passed list. */ - private void checkSystems(List contains, String code, List systems) { + private boolean checkSystems(List contains, String code, Set systems) { for (ValueSetExpansionContainsComponent c: contains) { if (c.getCode().equals(code)) { - if (!systems.contains(c.getSystem())) - systems.add(c.getSystem()); + systems.add(c.getSystem()); } if (c.hasContains()) checkSystems(c.getContains(), code, systems); } + return true; } @Override From ef3aee75f10785e1ef3fac07e566fa2dbae9189c Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Fri, 11 Mar 2022 10:37:28 +1100 Subject: [PATCH 45/50] make fhir version code case independent --- .../java/org/hl7/fhir/r4b/model/Enumerations.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/model/Enumerations.java b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/model/Enumerations.java index 4f6d7369a..2910a183b 100644 --- a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/model/Enumerations.java +++ b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/model/Enumerations.java @@ -6169,9 +6169,9 @@ The primary difference between a medication statement and a medication administr return _4_1_0; if ("4.2.0".equals(codeString)) return _4_2_0; - if ("4.3.0-snapshot1".equals(codeString)) + if ("4.3.0-snapshot1".equalsIgnoreCase(codeString)) return _4_3_0SNAPSHOT1; - if ("4.3.0-cibuild".equals(codeString)) + if ("4.3.0-cibuild".equalsIgnoreCase(codeString)) return _4_3_0CIBUILD; throw new FHIRException("Unknown FHIRVersion code '"+codeString+"'"); } @@ -6434,9 +6434,9 @@ public String toCode(int len) { return FHIRVersion._4_1_0; if ("4.2.0".equals(codeString)) return FHIRVersion._4_2_0; - if ("4.3.0-snapshot1".equals(codeString)) + if ("4.3.0-snapshot1".equalsIgnoreCase(codeString)) return FHIRVersion._4_3_0SNAPSHOT1; - if ("4.3.0-cibuild".equals(codeString)) + if ("4.3.0-cibuild".equalsIgnoreCase(codeString)) return FHIRVersion._4_3_0CIBUILD; throw new IllegalArgumentException("Unknown FHIRVersion code '"+codeString+"'"); } @@ -6498,9 +6498,9 @@ public String toCode(int len) { return new Enumeration(this, FHIRVersion._4_1_0); if ("4.2.0".equals(codeString)) return new Enumeration(this, FHIRVersion._4_2_0); - if ("4.3.0-snapshot1".equals(codeString)) + if ("4.3.0-snapshot1".equalsIgnoreCase(codeString)) return new Enumeration(this, FHIRVersion._4_3_0SNAPSHOT1); - if ("4.3.0-cibuild".equals(codeString)) + if ("4.3.0-cibuild".equalsIgnoreCase(codeString)) return new Enumeration(this, FHIRVersion._4_3_0CIBUILD); throw new FHIRException("Unknown FHIRVersion code '"+codeString+"'"); } From 0b3ccbbe37b636314149f74d6c3f73caabcbde04 Mon Sep 17 00:00:00 2001 From: Lloyd McKenzie Date: Thu, 10 Mar 2022 16:48:41 -0700 Subject: [PATCH 46/50] Reverted lower-casing of version comparison --- .../src/main/java/org/hl7/fhir/r5/model/Enumerations.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Enumerations.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Enumerations.java index 8aedc92c1..95723dedb 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Enumerations.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Enumerations.java @@ -6874,7 +6874,6 @@ The primary difference between a medicationusage and a medicationadministration public static FHIRVersion fromCode(String codeString) throws FHIRException { if (codeString == null || "".equals(codeString)) return null; - codeString = codeString.toLowerCase(); if ("0.01".equals(codeString)) return _0_01; if ("0.05".equals(codeString)) @@ -7105,7 +7104,6 @@ public String toCode(int len) { public static boolean isValidCode(String codeString) { if (codeString == null || "".equals(codeString)) return false; - codeString = codeString.toLowerCase(); if ("0.01".equals(codeString)) return true; if ("0.05".equals(codeString)) @@ -7171,7 +7169,6 @@ public String toCode(int len) { if (codeString == null || "".equals(codeString)) if (codeString == null || "".equals(codeString)) return null; - codeString = codeString.toLowerCase(); if ("0.01".equals(codeString)) return FHIRVersion._0_01; if ("0.05".equals(codeString)) From bf7f0d07c5bbc66f49abecca381066302b2250d1 Mon Sep 17 00:00:00 2001 From: Mark Iantorno Date: Fri, 11 Mar 2022 01:57:16 +0000 Subject: [PATCH 47/50] Updating test case dependency to v1.1.93 ***NO_CI*** --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2740cbe0e..9680bb679 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 5.4.0 - 1.1.93-SNAPSHOT + 1.1.93 5.7.1 1.7.1 3.0.0-M5 From 6acfa16169c60135c5d3429e8b3236e69ea392c5 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Fri, 11 Mar 2022 13:10:25 +1100 Subject: [PATCH 48/50] set u release --- RELEASE_NOTES.md | 2 ++ pom.xml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 0d567b627..2bc5d2e2c 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,6 +1,7 @@ ## Validator Changes * fix handling of xver extensions with choice sub-extensions +* validate consistency of extension modifier flag with extension use in a profile ## Other code changes @@ -8,3 +9,4 @@ * Get package id from 'package' field when 'npm-package' unavailable * Ignore META-INF contents from other dependencies while building Validator jar * Fix to r5 TestingUtilities to allow NarrativeGenerationTests to pass. +* fix handling to xver extensions generating snapshots \ No newline at end of file diff --git a/pom.xml b/pom.xml index 2740cbe0e..9680bb679 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 5.4.0 - 1.1.93-SNAPSHOT + 1.1.93 5.7.1 1.7.1 3.0.0-M5 From e86c9afc7a737d6433d4370b66f3d212935dabfa Mon Sep 17 00:00:00 2001 From: markiantorno Date: Fri, 11 Mar 2022 03:04:43 +0000 Subject: [PATCH 49/50] Release: v5.6.37 ## Validator Changes * fix handling of xver extensions with choice sub-extensions * validate consistency of extension modifier flag with extension use in a profile ## Other code changes * more presenting extensions when rendering. * Get package id from 'package' field when 'npm-package' unavailable * Ignore META-INF contents from other dependencies while building Validator jar * Fix to r5 TestingUtilities to allow NarrativeGenerationTests to pass. * fix handling to xver extensions generating snapshots ***NO_CI*** --- 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.r4b/pom.xml | 2 +- org.hl7.fhir.r5/pom.xml | 2 +- org.hl7.fhir.report/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 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/org.hl7.fhir.convertors/pom.xml b/org.hl7.fhir.convertors/pom.xml index 4a8f14076..639d9a608 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 - 5.6.37-SNAPSHOT + 5.6.37 ../pom.xml diff --git a/org.hl7.fhir.dstu2/pom.xml b/org.hl7.fhir.dstu2/pom.xml index e31fd4a19..bc280316d 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 - 5.6.37-SNAPSHOT + 5.6.37 ../pom.xml diff --git a/org.hl7.fhir.dstu2016may/pom.xml b/org.hl7.fhir.dstu2016may/pom.xml index 7bb4e757d..dfdd83bc8 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 - 5.6.37-SNAPSHOT + 5.6.37 ../pom.xml diff --git a/org.hl7.fhir.dstu3/pom.xml b/org.hl7.fhir.dstu3/pom.xml index f2da5a89d..7653b20ac 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 - 5.6.37-SNAPSHOT + 5.6.37 ../pom.xml diff --git a/org.hl7.fhir.r4/pom.xml b/org.hl7.fhir.r4/pom.xml index b5a55706f..9a9d4be07 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 - 5.6.37-SNAPSHOT + 5.6.37 ../pom.xml diff --git a/org.hl7.fhir.r4b/pom.xml b/org.hl7.fhir.r4b/pom.xml index 5ed3f9ff0..2e6e2c737 100644 --- a/org.hl7.fhir.r4b/pom.xml +++ b/org.hl7.fhir.r4b/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.6.37-SNAPSHOT + 5.6.37 ../pom.xml diff --git a/org.hl7.fhir.r5/pom.xml b/org.hl7.fhir.r5/pom.xml index 34bd8e422..7161f7155 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 - 5.6.37-SNAPSHOT + 5.6.37 ../pom.xml diff --git a/org.hl7.fhir.report/pom.xml b/org.hl7.fhir.report/pom.xml index 0de887735..65d181998 100644 --- a/org.hl7.fhir.report/pom.xml +++ b/org.hl7.fhir.report/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.6.37-SNAPSHOT + 5.6.37 ../pom.xml diff --git a/org.hl7.fhir.utilities/pom.xml b/org.hl7.fhir.utilities/pom.xml index 11840b91e..b101300ff 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 - 5.6.37-SNAPSHOT + 5.6.37 ../pom.xml diff --git a/org.hl7.fhir.validation.cli/pom.xml b/org.hl7.fhir.validation.cli/pom.xml index 1899d4578..a48f26217 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 - 5.6.37-SNAPSHOT + 5.6.37 ../pom.xml diff --git a/org.hl7.fhir.validation/pom.xml b/org.hl7.fhir.validation/pom.xml index ba7b4fbde..a253b9110 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 - 5.6.37-SNAPSHOT + 5.6.37 ../pom.xml diff --git a/pom.xml b/pom.xml index 9680bb679..ee47b1620 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ HAPI FHIR --> org.hl7.fhir.core - 5.6.37-SNAPSHOT + 5.6.37 pom From e4ce145a0b9d1836281ec67f89400c0ffd7442bb Mon Sep 17 00:00:00 2001 From: markiantorno Date: Fri, 11 Mar 2022 03:21:07 +0000 Subject: [PATCH 50/50] Updating version to: 5.6.38-SNAPSHOT and incrementing test cases dependency. --- RELEASE_NOTES.md | 9 ++------- 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.r4b/pom.xml | 2 +- org.hl7.fhir.r5/pom.xml | 2 +- org.hl7.fhir.report/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 +- 13 files changed, 14 insertions(+), 19 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 2bc5d2e2c..7b06c6ab5 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,12 +1,7 @@ ## Validator Changes -* fix handling of xver extensions with choice sub-extensions -* validate consistency of extension modifier flag with extension use in a profile +* no changes ## Other code changes -* more presenting extensions when rendering. -* Get package id from 'package' field when 'npm-package' unavailable -* Ignore META-INF contents from other dependencies while building Validator jar -* Fix to r5 TestingUtilities to allow NarrativeGenerationTests to pass. -* fix handling to xver extensions generating snapshots \ No newline at end of file +* no changes \ No newline at end of file diff --git a/org.hl7.fhir.convertors/pom.xml b/org.hl7.fhir.convertors/pom.xml index 639d9a608..237b75e5c 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 - 5.6.37 + 5.6.38-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.dstu2/pom.xml b/org.hl7.fhir.dstu2/pom.xml index bc280316d..1effe69dd 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 - 5.6.37 + 5.6.38-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.dstu2016may/pom.xml b/org.hl7.fhir.dstu2016may/pom.xml index dfdd83bc8..7d94a2118 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 - 5.6.37 + 5.6.38-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.dstu3/pom.xml b/org.hl7.fhir.dstu3/pom.xml index 7653b20ac..042320848 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 - 5.6.37 + 5.6.38-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.r4/pom.xml b/org.hl7.fhir.r4/pom.xml index 9a9d4be07..94908fa80 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 - 5.6.37 + 5.6.38-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.r4b/pom.xml b/org.hl7.fhir.r4b/pom.xml index 2e6e2c737..381750fea 100644 --- a/org.hl7.fhir.r4b/pom.xml +++ b/org.hl7.fhir.r4b/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.6.37 + 5.6.38-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.r5/pom.xml b/org.hl7.fhir.r5/pom.xml index 7161f7155..598874c46 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 - 5.6.37 + 5.6.38-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.report/pom.xml b/org.hl7.fhir.report/pom.xml index 65d181998..57713cfae 100644 --- a/org.hl7.fhir.report/pom.xml +++ b/org.hl7.fhir.report/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.6.37 + 5.6.38-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.utilities/pom.xml b/org.hl7.fhir.utilities/pom.xml index b101300ff..1d4a14155 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 - 5.6.37 + 5.6.38-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.validation.cli/pom.xml b/org.hl7.fhir.validation.cli/pom.xml index a48f26217..27d7a0274 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 - 5.6.37 + 5.6.38-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.validation/pom.xml b/org.hl7.fhir.validation/pom.xml index a253b9110..ee3099531 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 - 5.6.37 + 5.6.38-SNAPSHOT ../pom.xml diff --git a/pom.xml b/pom.xml index ee47b1620..fa721fe1d 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ HAPI FHIR --> org.hl7.fhir.core - 5.6.37 + 5.6.38-SNAPSHOT pom