From b799e9b4195c7a81461b8a3b27fcb15720afad9c Mon Sep 17 00:00:00 2001 From: patrick-werner Date: Fri, 2 Aug 2019 22:39:19 +0200 Subject: [PATCH 1/8] added surefire plugin --- pom.xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d3e355b8b..d9cec0aae 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ 4.0.0-SNAPSHOT - true + false org.hl7.fhir.core @@ -254,6 +254,13 @@ + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M3 + + + From dc4807e65029f79121b07c93e906f3353ca8443f Mon Sep 17 00:00:00 2001 From: patrick-werner Date: Fri, 2 Aug 2019 22:49:54 +0200 Subject: [PATCH 2/8] fixed double entry of surefire plugin inserted maven-jar-plugin version to fix warning --- org.hl7.fhir.validation.cli/pom.xml | 1 + pom.xml | 13 +++++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/org.hl7.fhir.validation.cli/pom.xml b/org.hl7.fhir.validation.cli/pom.xml index 5eb1b0cd8..39a88e7b0 100644 --- a/org.hl7.fhir.validation.cli/pom.xml +++ b/org.hl7.fhir.validation.cli/pom.xml @@ -83,6 +83,7 @@ org.apache.maven.plugins maven-jar-plugin + 3.1.2 diff --git a/pom.xml b/pom.xml index d9cec0aae..af0fd8fe8 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,6 @@ 4.0.0-SNAPSHOT - false org.hl7.fhir.core @@ -151,6 +150,11 @@ maven-surefire-plugin true + + + + * + @@ -254,13 +258,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - 3.0.0-M3 - - - From 94dda8524098cb94701f40509a56430f916133d0 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Mon, 5 Aug 2019 11:31:42 +1000 Subject: [PATCH 3/8] fix broken snapshot generation tests --- .../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 9e06398cd..34c76d4c7 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 @@ -2533,13 +2533,13 @@ public class ProfileUtilities extends TranslatingUtilities { row.setLineColor(0); boolean hasDef = element != null; boolean ext = false; - if (s.equals("extension")) { + if (tail(element.getPath()).equals("extension")) { if (element.hasType() && element.getType().get(0).hasProfile() && extensionIsComplex(element.getType().get(0).getProfile().get(0).getValue())) row.setIcon("icon_extension_complex.png", HierarchicalTableGenerator.TEXT_ICON_EXTENSION_COMPLEX); else row.setIcon("icon_extension_simple.png", HierarchicalTableGenerator.TEXT_ICON_EXTENSION_SIMPLE); ext = true; - } else if (s.equals("modifierExtension")) { + } else if (tail(element.getPath()).equals("modifierExtension")) { if (element.hasType() && element.getType().get(0).hasProfile() && extensionIsComplex(element.getType().get(0).getProfile().get(0).getValue())) row.setIcon("icon_modifier_extension_complex.png", HierarchicalTableGenerator.TEXT_ICON_EXTENSION_COMPLEX); else From 8122ce591e2d06fb279304541031064bea41bd26 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Mon, 5 Aug 2019 11:32:23 +1000 Subject: [PATCH 4/8] add Element.hasChildren --- .../main/java/org/hl7/fhir/r5/elementmodel/Element.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Element.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Element.java index 9535a805d..1f9672f64 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Element.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Element.java @@ -604,6 +604,14 @@ public class Element extends Base { return getNamedChild(name) != null; } + public boolean hasChildren(String name) { + if (children != null) + for (Element child : children) + if (child.getName().equals(name)) + return true; + return false; + } + @Override public String toString() { return name+"="+fhirType() + "["+(children == null || hasValue() ? value : Integer.toString(children.size())+" children")+"]"; From 8ebfe45ad53ed207c5de15c1367bed58278206a1 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Mon, 5 Aug 2019 11:32:48 +1000 Subject: [PATCH 5/8] add sugar StructureDefinition.describeType --- .../org/hl7/fhir/r5/model/StructureDefinition.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/StructureDefinition.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/StructureDefinition.java index 956297c82..541be965f 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/StructureDefinition.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/StructureDefinition.java @@ -3885,5 +3885,18 @@ public class StructureDefinition extends MetadataResource { */ public static final ca.uhn.fhir.model.api.Include INCLUDE_BASE = new ca.uhn.fhir.model.api.Include("StructureDefinition:base").toLocked(); +public String describeType() { + if ("Extension".equals(getType())) + return "Extension" ; + switch (getKind()) { + case COMPLEXTYPE: return getDerivation() == TypeDerivationRule.CONSTRAINT ? "DataType Constraint" : "DataType" ; + case LOGICAL: return getDerivation() == TypeDerivationRule.CONSTRAINT ? "Logical Model" : "Logical Model Profile"; + case PRIMITIVETYPE: return getDerivation() == TypeDerivationRule.CONSTRAINT ? "Type Constraint" : "Type"; + case RESOURCE: return getDerivation() == TypeDerivationRule.CONSTRAINT ? "Resource Profile" : "Resource"; + default: + return "Definition"; + } +} + } From 0a05788e5728e186ddd2bb937d77c36695198eba Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Mon, 5 Aug 2019 11:33:06 +1000 Subject: [PATCH 6/8] improve error message --- .../java/org/hl7/fhir/r5/validation/InstanceValidator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/InstanceValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/InstanceValidator.java index bccf9c666..51920240f 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/InstanceValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/InstanceValidator.java @@ -2738,9 +2738,9 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat } if (!anyFound) { if (slicer.getSlicing().getDiscriminator().size() > 1) - throw new DefinitionException("Could not match any discriminators (" + discriminators + ") for slice " + ed.getId() + " in profile " + profile.getUrl() + " - does not have fixed value, binding or existence assertions for any of the discriminators"); + throw new DefinitionException("Could not match any discriminators (" + discriminators + ") for slice " + ed.getId() + " in profile " + profile.getUrl() + " - None of the discriminator " + discriminators + " have fixed value, binding or existence assertions"); else - throw new DefinitionException("Could not match discriminator (" + discriminators + ") for slice " + ed.getId() + " in profile " + profile.getUrl() + " - does not have fixed value, binding or existence assertions"); + throw new DefinitionException("Could not match discriminator (" + discriminators + ") for slice " + ed.getId() + " in profile " + profile.getUrl() + " - the discriminator " + discriminators + " does not have fixed value, binding or existence assertions"); } try { From 75c24db33b555d054f5b887b6d4bc696aefd8667 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Mon, 5 Aug 2019 11:33:45 +1000 Subject: [PATCH 7/8] fix snapshot generation tests --- .../snapshot-generation/au2-actual.xml | 6 ++--- .../snapshot-generation/au3-actual.xml | 27 ++++++++++--------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/org.hl7.fhir.r5/src/test/resources/snapshot-generation/au2-actual.xml b/org.hl7.fhir.r5/src/test/resources/snapshot-generation/au2-actual.xml index c3a315a35..bb791b73a 100644 --- a/org.hl7.fhir.r5/src/test/resources/snapshot-generation/au2-actual.xml +++ b/org.hl7.fhir.r5/src/test/resources/snapshot-generation/au2-actual.xml @@ -62,7 +62,7 @@ . . . - extension + namespace-id @@ -112,7 +112,7 @@ . . . - extension + universal-id @@ -162,7 +162,7 @@ . . . - extension + universal-id-type diff --git a/org.hl7.fhir.r5/src/test/resources/snapshot-generation/au3-actual.xml b/org.hl7.fhir.r5/src/test/resources/snapshot-generation/au3-actual.xml index 903a1dbbc..3a6b9757f 100644 --- a/org.hl7.fhir.r5/src/test/resources/snapshot-generation/au3-actual.xml +++ b/org.hl7.fhir.r5/src/test/resources/snapshot-generation/au3-actual.xml @@ -119,7 +119,7 @@ - + . . . @@ -129,10 +129,7 @@ - Reference - ( - http://hl7.org.au/fhir/StructureDefinition/au-practitioner - ) + (Slice Definition) Slice: @@ -141,11 +138,12 @@ - + . - . + . + . . - performer + Examiner @@ -157,9 +155,10 @@ - + . . + . . . display @@ -175,11 +174,12 @@ - + . - . + . + . . - performer + Organisation @@ -191,9 +191,10 @@ - + . . + . . . display From c4cff0c7908514fb31a414b0a0e064fffa6a05aa Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Mon, 5 Aug 2019 11:55:19 +1000 Subject: [PATCH 8/8] fix problem where differential rendering is missing inherited information --- .../fhir/r5/conformance/ProfileUtilities.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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 34c76d4c7..8424b0b6a 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 @@ -448,7 +448,7 @@ public class ProfileUtilities extends TranslatingUtilities { 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 = derived.getDifferential().copy(); // we make a copy here because we're sometimes going to hack the differential while processing it. + 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 processPaths("", derived.getSnapshot(), base.getSnapshot(), diff, baseCursor, diffCursor, base.getSnapshot().getElement().size()-1, derived.getDifferential().hasElement() ? derived.getDifferential().getElement().size()-1 : -1, url, webUrl, derived.present(), null, null, false, base.getUrl(), null, false, new ArrayList(), base); @@ -467,6 +467,14 @@ public class ProfileUtilities extends TranslatingUtilities { setIds(derived, false); //Check that all differential elements have a corresponding snapshot element for (ElementDefinition e : diff.getElement()) { + if (!e.hasUserData("diff-source")) + throw new Error("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)) { System.out.println("Error in snapshot generation: Differential for "+derived.getUrl()+" with " + (e.hasId() ? "id: "+e.getId() : "path: "+e.getPath())+" has an element that is not marked with a snapshot match"); if (exception) @@ -489,6 +497,17 @@ public class ProfileUtilities extends TranslatingUtilities { } } + private StructureDefinitionDifferentialComponent cloneDiff(StructureDefinitionDifferentialComponent source) { + StructureDefinitionDifferentialComponent diff = new StructureDefinitionDifferentialComponent(); + for (ElementDefinition sed : source.getElement()) { + ElementDefinition ted = sed.copy(); + diff.getElement().add(ted); + ted.setUserData("diff-source", sed); + } + return diff; + } + + private String constraintSummary(ElementDefinition ed) { CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); if (ed.hasPattern())