Dropped the removeStatusExtensions subroutine. Most of the extensions it was trying to remove weren't allowed to exist in the provided context, and those that were were not appropriate to remove. (For example, it doesn't make sense to show that an element is deprecated in the differential, but not the snapshot.)

Needed for HL7/fhir-ig-publisher#567
This commit is contained in:
Lloyd McKenzie 2024-11-19 10:51:03 -07:00
parent bbb7b0c88a
commit 02bd9a5305
4 changed files with 1 additions and 41 deletions

View File

@ -797,7 +797,6 @@ public class ProfileUtilities extends TranslatingUtilities {
if (diffMatches.get(0).hasSliceName())
outcome.setSliceName(diffMatches.get(0).getSliceName());
updateFromDefinition(outcome, diffMatches.get(0), profileName, trimDifferential, url, srcSD);
removeStatusExtensions(outcome);
// if (outcome.getPath().endsWith("[x]") && outcome.getType().size() == 1 && !outcome.getType().get(0).getCode().equals("*") && !diffMatches.get(0).hasSlicing()) // if the base profile allows multiple types, but the profile only allows one, rename it
// outcome.setPath(outcome.getPath().substring(0, outcome.getPath().length()-3)+Utilities.capitalize(outcome.getType().get(0).getCode()));
outcome.setSlicing(null);
@ -1049,7 +1048,6 @@ public class ProfileUtilities extends TranslatingUtilities {
// Else we'll treat it as the base definition of the slice.
if (!diffMatches.get(0).hasSliceName()) {
updateFromDefinition(outcome, diffMatches.get(0), profileName, trimDifferential, url, srcSD);
removeStatusExtensions(outcome);
if (!outcome.hasContentReference() && !outcome.hasType()) {
throw new DefinitionException("not done yet");
}
@ -1139,7 +1137,6 @@ public class ProfileUtilities extends TranslatingUtilities {
// we don't want to
// update the unsliced
// description
removeStatusExtensions(outcome);
} else if (!diffMatches.get(0).hasSliceName())
diffMatches.get(0).setUserData(GENERATED_IN_SNAPSHOT, outcome); // because of updateFromDefinition isn't
// called
@ -1239,7 +1236,6 @@ public class ProfileUtilities extends TranslatingUtilities {
throw new DefinitionException("Adding wrong path");
result.getElement().add(outcome);
updateFromDefinition(outcome, diffItem, profileName, trimDifferential, url, srcSD);
removeStatusExtensions(outcome);
// --- LM Added this
diffCursor = differential.getElement().indexOf(diffItem) + 1;
if (!outcome.getType().isEmpty()
@ -1332,13 +1328,6 @@ public class ProfileUtilities extends TranslatingUtilities {
return res;
}
private void removeStatusExtensions(ElementDefinition outcome) {
outcome.removeExtension(ToolingExtensions.EXT_FMM_LEVEL);
outcome.removeExtension(ToolingExtensions.EXT_STANDARDS_STATUS);
outcome.removeExtension(ToolingExtensions.EXT_NORMATIVE_VERSION);
outcome.removeExtension(ToolingExtensions.EXT_WORKGROUP);
}
private String descED(List<ElementDefinition> list, int index) {
return index >= 0 && index < list.size() ? list.get(index).present() : "X";
}

View File

@ -1443,7 +1443,6 @@ public class ProfileUtilities extends TranslatingUtilities {
}
}
updateFromDefinition(outcome, diffMatches.get(0), profileName, trimDifferential, url, srcSD);
removeStatusExtensions(outcome);
// if (outcome.getPath().endsWith("[x]") && outcome.getType().size() == 1 && !outcome.getType().get(0).getCode().equals("*") && !diffMatches.get(0).hasSlicing()) // if the base profile allows multiple types, but the profile only allows one, rename it
// outcome.setPath(outcome.getPath().substring(0, outcome.getPath().length()-3)+Utilities.capitalize(outcome.getType().get(0).getCode()));
outcome.setSlicing(null);
@ -1781,7 +1780,6 @@ public class ProfileUtilities extends TranslatingUtilities {
// Else we'll treat it as the base definition of the slice.
if (!diffMatches.get(0).hasSliceName()) {
updateFromDefinition(outcome, diffMatches.get(0), profileName, trimDifferential, url, srcSD);
removeStatusExtensions(outcome);
if (!outcome.hasContentReference() && !outcome.hasType()) {
throw new DefinitionException(context.formatMessage(I18nConstants.NOT_DONE_YET));
}
@ -2107,7 +2105,6 @@ public class ProfileUtilities extends TranslatingUtilities {
// we don't want to
// update the unsliced
// description
removeStatusExtensions(outcome);
} else if (!diffMatches.get(0).hasSliceName()) {
diffMatches.get(0).setUserData(GENERATED_IN_SNAPSHOT, outcome); // because of updateFromDefinition isn't
// called
@ -2241,7 +2238,6 @@ public class ProfileUtilities extends TranslatingUtilities {
throw new DefinitionException(context.formatMessage(I18nConstants.ADDING_WRONG_PATH));
result.getElement().add(outcome);
updateFromDefinition(outcome, diffItem, profileName, trimDifferential, url, srcSD);
removeStatusExtensions(outcome);
// --- LM Added this
diffCursor = differential.getElement().indexOf(diffItem) + 1;
if (!outcome.getType().isEmpty()
@ -2521,17 +2517,6 @@ 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);
outcome.removeExtension(ToolingExtensions.EXT_FMM_SUPPORT);
outcome.removeExtension(ToolingExtensions.EXT_FMM_DERIVED);
}
private String descED(List<ElementDefinition> list, int index) {
return index >= 0 && index < list.size() ? list.get(index).present() : "X";
}

View File

@ -324,7 +324,6 @@ public class ProfilePathProcessor {
// differential - if the first one in the list has a name, we'll process it. Else we'll treat it as the base definition of the slice.
if (!diffMatches.get(0).hasSliceName()) {
profileUtilities.updateFromDefinition(outcome, diffMatches.get(0), getProfileName(), isTrimDifferential(), getUrl(),getSourceStructureDefinition(), getDerived(), diffPath(diffMatches.get(0)), mapHelper);
profileUtilities.removeStatusExtensions(outcome);
if (!outcome.hasContentReference() && !outcome.hasType() && outcome.getPath().contains(".")) {
throw new DefinitionException(profileUtilities.getContext().formatMessage(I18nConstants.NOT_DONE_YET));
}
@ -686,7 +685,6 @@ public class ProfilePathProcessor {
}
}
profileUtilities.updateFromDefinition(outcome, diffMatches.get(0), getProfileName(), isTrimDifferential(), getUrl(), getSourceStructureDefinition(), getDerived(), diffPath(diffMatches.get(0)), mapHelper);
profileUtilities.removeStatusExtensions(outcome);
// if (outcome.getPath().endsWith("[x]") && outcome.getType().size() == 1 && !outcome.getType().get(0).getCode().equals("*") && !diffMatches.get(0).hasSlicing()) // if the base profile allows multiple types, but the profile only allows one, rename it
// outcome.setPath(outcome.getPath().substring(0, outcome.getPath().length()-3)+Utilities.capitalize(outcome.getType().get(0).getCode()));
outcome.setSlicing(null);
@ -1039,7 +1037,6 @@ public class ProfilePathProcessor {
if (diffMatches.get(0).hasSlicing() || !diffMatches.get(0).hasSliceName()) {
profileUtilities.updateFromSlicing(outcome.getSlicing(), diffMatches.get(0).getSlicing());
profileUtilities.updateFromDefinition(outcome, diffMatches.get(0), getProfileName(), closed, getUrl(), getSourceStructureDefinition(), getDerived(), diffPath(diffMatches.get(0)), mapHelper); // if there's no slice, we don't want to update the unsliced description
profileUtilities.removeStatusExtensions(outcome);
} else if (!diffMatches.get(0).hasSliceName()) {
diffMatches.get(0).setUserData(profileUtilities.UD_GENERATED_IN_SNAPSHOT, outcome); // because of updateFromDefinition isn't called
} else {
@ -1177,7 +1174,6 @@ public class ProfilePathProcessor {
debugCheck(outcome);
getResult().getElement().add(outcome);
profileUtilities.updateFromDefinition(outcome, diffItem, getProfileName(), isTrimDifferential(), getUrl(), getSourceStructureDefinition(), getDerived(), diffPath(diffItem), mapHelper);
profileUtilities.removeStatusExtensions(outcome);
// --- LM Added this
cursors.diffCursor = getDifferential().getElement().indexOf(diffItem) + 1;
if (!outcome.getType().isEmpty() && (/*outcome.getType().get(0).getCode().equals("Extension") || */getDifferential().getElement().size() > cursors.diffCursor) && outcome.getPath().contains(".")/* && isDataType(outcome.getType())*/) { // don't want to do this for the root, since that's base, and we're already processing it

View File

@ -1590,16 +1590,6 @@ public class ProfileUtilities {
}
}
protected void removeStatusExtensions(ElementDefinition outcome) {
outcome.removeExtension(ToolingExtensions.EXT_FMM_LEVEL);
outcome.removeExtension(ToolingExtensions.EXT_FMM_SUPPORT);
outcome.removeExtension(ToolingExtensions.EXT_STANDARDS_STATUS);
outcome.removeExtension(ToolingExtensions.EXT_NORMATIVE_VERSION);
outcome.removeExtension(ToolingExtensions.EXT_WORKGROUP);
outcome.removeExtension(ToolingExtensions.EXT_FMM_SUPPORT);
outcome.removeExtension(ToolingExtensions.EXT_FMM_DERIVED);
}
protected String descED(List<ElementDefinition> list, int index) {
return index >=0 && index < list.size() ? list.get(index).present() : "X";
}
@ -2499,7 +2489,7 @@ public class ProfileUtilities {
if (derived.hasSliceName()) {
base.setSliceName(derived.getSliceName());
}
if (derived.hasShortElement()) {
if (!Base.compareDeep(derived.getShortElement(), base.getShortElement(), false))
base.setShortElement(derived.getShortElement().copy());