We had been stripping standards status always. In practice, we only want to strip it when inheriting, and then only in certain circumstances.

This commit is contained in:
Lloyd McKenzie 2024-11-22 08:37:50 -07:00
parent 02bd9a5305
commit f0867ce8d0
1 changed files with 30 additions and 16 deletions

View File

@ -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);
@ -1763,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);
@ -1849,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);
@ -2096,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()) {
@ -2228,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);
@ -2317,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())) {