Merge pull request #1818 from hapifhir/ShowDeprecationInSnapshotAndKey
Show deprecation in snapshot and key
This commit is contained in:
commit
20131f8b6a
|
@ -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";
|
||||
}
|
||||
|
|
|
@ -35,16 +35,7 @@ import java.io.FileReader;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.exceptions.DefinitionException;
|
||||
|
@ -331,6 +322,10 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
private static final boolean DONT_DO_THIS = false;
|
||||
private final boolean ADD_REFERENCE_TO_TABLE = true;
|
||||
|
||||
private final List<String> NONPROPAGATING_EXTENSIONS = new ArrayList<>(Arrays.asList(new String[] {
|
||||
"http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status",
|
||||
"http://hl7.org/fhir/StructureDefinition/structuredefinition-normative-version"}));
|
||||
|
||||
private boolean useTableForFixedValues = true;
|
||||
private boolean debug;
|
||||
|
||||
|
@ -1224,7 +1219,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
if (!currentBase.hasSlicing() || cpath.equals(typeSlicingPath)) {
|
||||
if (diffMatches.isEmpty()) { // the differential doesn't say anything about this item
|
||||
// so we just copy it in
|
||||
ElementDefinition outcome = updateURLs(url, webUrl, currentBase.copy());
|
||||
ElementDefinition outcome = updateURLs(url, webUrl, stripNonPropagatingExtensions(currentBase.copy()));
|
||||
outcome.setPath(fixedPathDest(contextPathDst, outcome.getPath(), redirector, contextPathSrc));
|
||||
updateFromBase(outcome, currentBase);
|
||||
updateConstraintSources(outcome, srcSD.getUrl());
|
||||
|
@ -1421,7 +1416,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
}
|
||||
}
|
||||
if (template == null)
|
||||
template = currentBase.copy();
|
||||
template = stripNonPropagatingExtensions(currentBase.copy());
|
||||
else
|
||||
// some of what's in currentBase overrides template
|
||||
template = fillOutFromBase(template, currentBase);
|
||||
|
@ -1443,7 +1438,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);
|
||||
|
@ -1764,7 +1758,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
start++;
|
||||
} else {
|
||||
// we're just going to accept the differential slicing at face value
|
||||
ElementDefinition outcome = updateURLs(url, webUrl, currentBase.copy());
|
||||
ElementDefinition outcome = updateURLs(url, webUrl, stripNonPropagatingExtensions(currentBase.copy()));
|
||||
outcome.setPath(fixedPathDest(contextPathDst, outcome.getPath(), redirector, contextPathSrc));
|
||||
updateFromBase(outcome, currentBase);
|
||||
|
||||
|
@ -1781,7 +1775,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));
|
||||
}
|
||||
|
@ -1851,7 +1844,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
if (diffMatches.isEmpty()) {
|
||||
if (hasInnerDiffMatches(differential, path, diffCursor, diffLimit, base.getElement(), true)) {
|
||||
// so we just copy it in
|
||||
ElementDefinition outcome = updateURLs(url, webUrl, currentBase.copy());
|
||||
ElementDefinition outcome = updateURLs(url, webUrl, stripNonPropagatingExtensions(currentBase.copy()));
|
||||
outcome.setPath(fixedPathDest(contextPathDst, outcome.getPath(), redirector, contextPathSrc));
|
||||
updateFromBase(outcome, currentBase);
|
||||
markDerived(outcome);
|
||||
|
@ -2098,7 +2091,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
I18nConstants.SLICING_RULES_ON_DIFFERENTIAL__DO_NOT_MATCH_THOSE_ON_BASE___RULE___,
|
||||
summarizeSlicing(dSlice), summarizeSlicing(bSlice), path, contextName));
|
||||
}
|
||||
ElementDefinition outcome = updateURLs(url, webUrl, currentBase.copy());
|
||||
ElementDefinition outcome = updateURLs(url, webUrl, stripNonPropagatingExtensions(currentBase.copy()));
|
||||
outcome.setPath(fixedPathDest(contextPathDst, outcome.getPath(), redirector, contextPathSrc));
|
||||
updateFromBase(outcome, currentBase);
|
||||
if (diffMatches.get(0).hasSlicing() || !diffMatches.get(0).hasSliceName()) {
|
||||
|
@ -2107,7 +2100,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
|
||||
|
@ -2231,7 +2223,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
if (baseItem.getSliceName().equals(diffItem.getSliceName()))
|
||||
throw new DefinitionException(
|
||||
context.formatMessage(I18nConstants.NAMED_ITEMS_ARE_OUT_OF_ORDER_IN_THE_SLICE));
|
||||
outcome = updateURLs(url, webUrl, currentBase.copy());
|
||||
outcome = updateURLs(url, webUrl, stripNonPropagatingExtensions(currentBase.copy()));
|
||||
// outcome = updateURLs(url, diffItem.copy());
|
||||
outcome.setPath(fixedPathDest(contextPathDst, outcome.getPath(), redirector, contextPathSrc));
|
||||
updateFromBase(outcome, currentBase);
|
||||
|
@ -2241,7 +2233,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()
|
||||
|
@ -2321,6 +2312,25 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
* Some extensions we don't want to propagate. For example, the fact a resource is normative doesn't mean a profile on the resource is normative.
|
||||
* Specific rules:
|
||||
* - standards status of 'normative' never propagates
|
||||
* - normative-since never propagates
|
||||
* - standards status doesn't propagate at the root, but *does* propagate on individual elements
|
||||
* - An element that's 'draft' in a resource still has to be draft in a profile
|
||||
* - There's a slight funkiness here if you have a draft profile that's inheriting from a normative resource with certain STU elements, but the intention remains clear
|
||||
*/
|
||||
private ElementDefinition stripNonPropagatingExtensions(ElementDefinition e) {
|
||||
if (e.hasExtension()) {
|
||||
if (e.hasExtension(ToolingExtensions.EXT_NORMATIVE_VERSION))
|
||||
e.removeExtension(ToolingExtensions.EXT_NORMATIVE_VERSION);
|
||||
if (!e.getPath().contains(".") && e.hasExtension(ToolingExtensions.EXT_STANDARDS_STATUS))
|
||||
e.removeExtension(ToolingExtensions.EXT_STANDARDS_STATUS);
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
private ElementDefinition getById(List<ElementDefinition> list, String baseId) {
|
||||
for (ElementDefinition t : list) {
|
||||
if (baseId.equals(t.getId())) {
|
||||
|
@ -2521,17 +2531,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";
|
||||
}
|
||||
|
|
|
@ -325,7 +325,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));
|
||||
}
|
||||
|
@ -687,7 +686,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);
|
||||
|
@ -1040,7 +1038,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(UserDataNames.SNAPSHOT_GENERATED_IN_SNAPSHOT, outcome); // because of updateFromDefinition isn't called
|
||||
} else {
|
||||
|
@ -1178,7 +1175,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
|
||||
|
|
|
@ -1585,16 +1585,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";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue