From 8c0539136cf2e252e32528c43db7815075d03cce Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Tue, 18 Jul 2023 11:08:09 +1000 Subject: [PATCH] suppress spurious error message --- .../conformance/profile/ProfileUtilities.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/profile/ProfileUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/profile/ProfileUtilities.java index 1674d9eed..86baecc68 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/profile/ProfileUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/profile/ProfileUtilities.java @@ -2292,13 +2292,17 @@ public class ProfileUtilities extends TranslatingUtilities { } // Before applying changes, apply them to what's in the profile StructureDefinition profile = null; + boolean msg = true; if (base.hasSliceName()) { profile = base.getType().size() == 1 && base.getTypeFirstRep().hasProfile() ? context.fetchResource(StructureDefinition.class, base.getTypeFirstRep().getProfile().get(0).getValue(), srcSD) : null; } if (profile==null) { profile = source.getType().size() == 1 && source.getTypeFirstRep().hasProfile() ? context.fetchResource(StructureDefinition.class, source.getTypeFirstRep().getProfile().get(0).getValue(), derivedSrc) : null; if (profile != null && !"Extension".equals(profile.getType()) && profile.getKind() != StructureDefinitionKind.RESOURCE && profile.getKind() != StructureDefinitionKind.LOGICAL) { + // this is a problem - we're kind of hacking things here. The problem is that we sometimes want the details from the profile to override the + // inherited attributes, and sometimes not profile = null; + msg = false; } } if (profile != null) { @@ -2320,15 +2324,17 @@ public class ProfileUtilities extends TranslatingUtilities { } else if (source.getType().size() == 1 && source.getTypeFirstRep().hasProfile() && !source.getTypeFirstRep().getProfile().get(0).hasExtension(ToolingExtensions.EXT_PROFILE_ELEMENT)) { // todo: should we change down the profile_element if there's one? String type = source.getTypeFirstRep().getWorkingCode(); - if ("Extension".equals(type)) { - System.out.println("Can't find Extension definition for "+source.getTypeFirstRep().getProfile().get(0).asStringValue()+" but trying to go on"); - if (allowUnknownProfile != AllowUnknownProfile.ALL_TYPES) { - throw new DefinitionException("Unable to find Extension definition for "+source.getTypeFirstRep().getProfile().get(0).asStringValue()); - } - } else { - System.out.println("Can't find "+type+" profile "+source.getTypeFirstRep().getProfile().get(0).asStringValue()+" but trying to go on"); - if (allowUnknownProfile == AllowUnknownProfile.NONE) { - throw new DefinitionException("Unable to find "+type+" profile "+source.getTypeFirstRep().getProfile().get(0).asStringValue()); + if (msg) { + if ("Extension".equals(type)) { + System.out.println("Can't find Extension definition for "+source.getTypeFirstRep().getProfile().get(0).asStringValue()+" but trying to go on"); + if (allowUnknownProfile != AllowUnknownProfile.ALL_TYPES) { + throw new DefinitionException("Unable to find Extension definition for "+source.getTypeFirstRep().getProfile().get(0).asStringValue()); + } + } else { + System.out.println("Can't find "+type+" profile "+source.getTypeFirstRep().getProfile().get(0).asStringValue()+" but trying to go on"); + if (allowUnknownProfile == AllowUnknownProfile.NONE) { + throw new DefinitionException("Unable to find "+type+" profile "+source.getTypeFirstRep().getProfile().get(0).asStringValue()); + } } } }