Auto update minimum slicing cardinality when slicer is assumed (extensions)
This commit is contained in:
parent
1c4ef1fa00
commit
fd346cc67b
|
@ -157,8 +157,7 @@ public class ProfilePathProcessor {
|
|||
* @throws DefinitionException, FHIRException
|
||||
* @throws Exception
|
||||
*/
|
||||
private ElementDefinition processPaths(
|
||||
final ProfilePathProcessorState cursors) throws FHIRException {
|
||||
private ElementDefinition processPaths(final ProfilePathProcessorState cursors) throws FHIRException {
|
||||
debugProcessPathsEntry(cursors);
|
||||
ElementDefinition res = null;
|
||||
List<TypeSlice> typeList = new ArrayList<>();
|
||||
|
@ -253,9 +252,8 @@ public class ProfilePathProcessor {
|
|||
.incrementDebugIndent()
|
||||
.withBaseLimit(newBaseLimit)
|
||||
.withDiffLimit(newDiffLimit)
|
||||
.withProfileName(getProfileName() + profileUtilities.pathTail(diffMatches, 0)).withSlicing(new PathSlicingParams(true, null, null)).
|
||||
processPaths(new ProfilePathProcessorState(cursors.base, cursors.baseCursor, newDiffCursor,
|
||||
cursors.contextName, cursors.resultPathBase));
|
||||
.withProfileName(getProfileName() + profileUtilities.pathTail(diffMatches, 0)).withSlicing(new PathSlicingParams(true, null, null))
|
||||
.processPaths(new ProfilePathProcessorState(cursors.base, cursors.baseCursor, newDiffCursor, cursors.contextName, cursors.resultPathBase));
|
||||
if (e == null)
|
||||
throw new FHIRException(profileUtilities.getContext().formatMessage(I18nConstants.DID_NOT_FIND_SINGLE_SLICE_, diffMatches.get(0).getPath()));
|
||||
e.setSlicing(diffMatches.get(0).getSlicing());
|
||||
|
@ -267,9 +265,10 @@ public class ProfilePathProcessor {
|
|||
outcome.setPath(profileUtilities.fixedPathDest(getContextPathTarget(), outcome.getPath(), getRedirector(), getContextPathSource()));
|
||||
profileUtilities.updateFromBase(outcome, currentBase, getSourceStructureDefinition().getUrl());
|
||||
|
||||
if (!diffMatches.get(0).hasSlicing())
|
||||
if (!diffMatches.get(0).hasSlicing()) {
|
||||
outcome.setSlicing(profileUtilities.makeExtensionSlicing());
|
||||
else {
|
||||
outcome.setUserData("auto-added-slicing", true);
|
||||
} else {
|
||||
outcome.setSlicing(diffMatches.get(0).getSlicing().copy());
|
||||
for (int i = 1; i < diffMatches.size(); i++) {
|
||||
if (diffMatches.get(i).hasSlicing()) {
|
||||
|
@ -348,7 +347,8 @@ public class ProfilePathProcessor {
|
|||
.withBaseLimit(newBaseLimit)
|
||||
.withDiffLimit(newDiffLimit)
|
||||
.withProfileName(getProfileName() + profileUtilities.pathTail(diffMatches, i))
|
||||
.withSlicing(new PathSlicingParams(true, slicerElement, null)).processPaths(new ProfilePathProcessorState(cursors.base, cursors.baseCursor, newDiffCursor, cursors.contextName, cursors.resultPathBase));
|
||||
.withSlicing(new PathSlicingParams(true, slicerElement, null))
|
||||
.processPaths(new ProfilePathProcessorState(cursors.base, cursors.baseCursor, newDiffCursor, cursors.contextName, cursors.resultPathBase));
|
||||
}
|
||||
// ok, done with that - next in the base list
|
||||
cursors.baseCursor = newBaseLimit + 1;
|
||||
|
|
|
@ -777,17 +777,21 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
int count = slice.checkMin();
|
||||
boolean repeats = !"1".equals(slice.getFocus().getBase().getMax()); // type slicing if repeats = 1
|
||||
if (count > -1 && repeats) {
|
||||
if (slice.getFocus().hasUserData("auto-added-slicing")) {
|
||||
slice.getFocus().setMin(count);
|
||||
} else {
|
||||
String msg = "The slice definition for "+slice.getFocus().getId()+" has a minimum of "+slice.getFocus().getMin()+" but the slices add up to a minimum of "+count;
|
||||
messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url+"#"+ed.getId(), msg, forPublication ? ValidationMessage.IssueSeverity.ERROR : ValidationMessage.IssueSeverity.INFORMATION));
|
||||
messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url+"#"+slice.getFocus().getId(), msg, forPublication ? ValidationMessage.IssueSeverity.ERROR : ValidationMessage.IssueSeverity.INFORMATION));
|
||||
}
|
||||
}
|
||||
count = slice.checkMax();
|
||||
if (count > -1 && repeats) {
|
||||
String msg = "The slice definition for "+slice.getFocus().getId()+" has a maximum of "+slice.getFocus().getMax()+" but the slices add up to a maximum of "+count+". Check that this is what is intended";
|
||||
messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url+"#"+ed.getId(), msg, ValidationMessage.IssueSeverity.INFORMATION));
|
||||
messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url+"#"+slice.getFocus().getId(), msg, ValidationMessage.IssueSeverity.INFORMATION));
|
||||
}
|
||||
if (!slice.checkMinMax()) {
|
||||
String msg = "The slice definition for "+slice.getFocus().getId()+" has a maximum of "+slice.getFocus().getMax()+" which is less than the minimum of "+slice.getFocus().getMin();
|
||||
messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url+"#"+ed.getId(), msg, ValidationMessage.IssueSeverity.WARNING));
|
||||
messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url+"#"+slice.getFocus().getId(), msg, ValidationMessage.IssueSeverity.WARNING));
|
||||
}
|
||||
slices.remove(s);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue