|
|
|
@ -20,10 +20,6 @@ package org.hl7.fhir.r5.conformance;
|
|
|
|
|
* #L%
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static org.hl7.fhir.utilities.I18nConstants.formatMessage;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
@ -42,7 +38,6 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.hl7.fhir.exceptions.DefinitionException;
|
|
|
|
|
import org.hl7.fhir.exceptions.FHIRException;
|
|
|
|
|
import org.hl7.fhir.exceptions.FHIRFormatError;
|
|
|
|
|
import org.hl7.fhir.r5.conformance.ProfileUtilities.BaseTypeSlice;
|
|
|
|
|
import org.hl7.fhir.r5.conformance.ProfileUtilities.ProfileKnowledgeProvider.BindingResolution;
|
|
|
|
|
import org.hl7.fhir.r5.context.IWorkerContext;
|
|
|
|
|
import org.hl7.fhir.r5.context.IWorkerContext.ValidationResult;
|
|
|
|
@ -101,7 +96,6 @@ import org.hl7.fhir.r5.utils.formats.CSVWriter;
|
|
|
|
|
import org.hl7.fhir.r5.utils.formats.XLSXWriter;
|
|
|
|
|
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
|
|
|
|
import org.hl7.fhir.utilities.I18nConstants;
|
|
|
|
|
import org.hl7.fhir.utilities.TerminologyServiceOptions;
|
|
|
|
|
import org.hl7.fhir.utilities.Utilities;
|
|
|
|
|
import org.hl7.fhir.utilities.VersionUtilities;
|
|
|
|
|
import org.hl7.fhir.utilities.validation.ValidationOptions;
|
|
|
|
@ -280,12 +274,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
this.messages = messages;
|
|
|
|
|
this.pkp = pkp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ProfileUtilities(IWorkerContext theContext, List<ValidationMessage> messages, ProfileKnowledgeProvider pkp, ResourceBundle i18Nmessages) {
|
|
|
|
|
this(theContext, messages, pkp);
|
|
|
|
|
this.i18nMessages = i18Nmessages;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private class UnusedTracker {
|
|
|
|
|
private boolean used;
|
|
|
|
|
}
|
|
|
|
@ -334,7 +323,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
if (element.getContentReference().equals("#"+e.getId()))
|
|
|
|
|
return getChildMap(profile, e);
|
|
|
|
|
}
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.UNABLE_TO_RESOLVE_NAME_REFERENCE__AT_PATH_, element.getContentReference(), element.getPath()));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.UNABLE_TO_RESOLVE_NAME_REFERENCE__AT_PATH_, element.getContentReference(), element.getPath()));
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
List<ElementDefinition> res = new ArrayList<ElementDefinition>();
|
|
|
|
@ -356,7 +345,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
|
|
|
|
|
public List<ElementDefinition> getSliceList(StructureDefinition profile, ElementDefinition element) throws DefinitionException {
|
|
|
|
|
if (!element.hasSlicing())
|
|
|
|
|
throw new Error(formatMessage(i18nMessages, I18nConstants.GETSLICELIST_SHOULD_ONLY_BE_CALLED_WHEN_THE_ELEMENT_HAS_SLICING));
|
|
|
|
|
throw new Error(context.formatMessage(I18nConstants.GETSLICELIST_SHOULD_ONLY_BE_CALLED_WHEN_THE_ELEMENT_HAS_SLICING));
|
|
|
|
|
|
|
|
|
|
List<ElementDefinition> res = new ArrayList<ElementDefinition>();
|
|
|
|
|
List<ElementDefinition> elements = profile.getSnapshot().getElement();
|
|
|
|
@ -395,9 +384,9 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
List<ElementDefinition> list = diff ? profile.getDifferential().getElement() : profile.getSnapshot().getElement();
|
|
|
|
|
for (ElementDefinition e : list) {
|
|
|
|
|
if (e == null)
|
|
|
|
|
throw new Error(formatMessage(i18nMessages, I18nConstants.ELEMENT__NULL_, profile.getUrl()));
|
|
|
|
|
throw new Error(context.formatMessage(I18nConstants.ELEMENT__NULL_, profile.getUrl()));
|
|
|
|
|
if (e.getId() == null)
|
|
|
|
|
throw new Error(formatMessage(i18nMessages, I18nConstants.ELEMENT_ID__NULL__ON_, e.toString(), profile.getUrl()));
|
|
|
|
|
throw new Error(context.formatMessage(I18nConstants.ELEMENT_ID__NULL__ON_, e.toString(), profile.getUrl()));
|
|
|
|
|
|
|
|
|
|
if (!capturing && id!=null && e.getId().equals(id)) {
|
|
|
|
|
capturing = true;
|
|
|
|
@ -438,9 +427,9 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
|
|
|
|
|
public void updateMaps(StructureDefinition base, StructureDefinition derived) throws DefinitionException {
|
|
|
|
|
if (base == null)
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.NO_BASE_PROFILE_PROVIDED));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.NO_BASE_PROFILE_PROVIDED));
|
|
|
|
|
if (derived == null)
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.NO_DERIVED_STRUCTURE_PROVIDED));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.NO_DERIVED_STRUCTURE_PROVIDED));
|
|
|
|
|
|
|
|
|
|
for (StructureDefinitionMappingComponent baseMap : base.getMapping()) {
|
|
|
|
|
boolean found = false;
|
|
|
|
@ -471,30 +460,30 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
*/
|
|
|
|
|
public void generateSnapshot(StructureDefinition base, StructureDefinition derived, String url, String webUrl, String profileName) throws DefinitionException, FHIRException {
|
|
|
|
|
if (base == null) {
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.NO_BASE_PROFILE_PROVIDED));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.NO_BASE_PROFILE_PROVIDED));
|
|
|
|
|
}
|
|
|
|
|
if (derived == null) {
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.NO_DERIVED_STRUCTURE_PROVIDED));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.NO_DERIVED_STRUCTURE_PROVIDED));
|
|
|
|
|
}
|
|
|
|
|
checkNotGenerating(base, "Base for generating a snapshot for the profile "+derived.getUrl());
|
|
|
|
|
checkNotGenerating(derived, "Focus for generating a snapshot");
|
|
|
|
|
derived.setUserData("profileutils.snapshot.generating", true);
|
|
|
|
|
|
|
|
|
|
if (!base.hasType()) {
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.BASE_PROFILE__HAS_NO_TYPE, base.getUrl()));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.BASE_PROFILE__HAS_NO_TYPE, base.getUrl()));
|
|
|
|
|
}
|
|
|
|
|
if (!derived.hasType()) {
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.DERIVED_PROFILE__HAS_NO_TYPE, derived.getUrl()));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.DERIVED_PROFILE__HAS_NO_TYPE, derived.getUrl()));
|
|
|
|
|
}
|
|
|
|
|
if (!derived.hasDerivation()) {
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.DERIVED_PROFILE__HAS_NO_DERIVATION_VALUE_AND_SO_CANT_BE_PROCESSED, derived.getUrl()));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.DERIVED_PROFILE__HAS_NO_DERIVATION_VALUE_AND_SO_CANT_BE_PROCESSED, derived.getUrl()));
|
|
|
|
|
}
|
|
|
|
|
if (!base.getType().equals(derived.getType()) && derived.getDerivation() == TypeDerivationRule.CONSTRAINT) {
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.BASE__DERIVED_PROFILES_HAVE_DIFFERENT_TYPES____VS___, base.getUrl(), base.getType(), derived.getUrl(), derived.getType()));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.BASE__DERIVED_PROFILES_HAVE_DIFFERENT_TYPES____VS___, base.getUrl(), base.getType(), derived.getUrl(), derived.getType()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (snapshotStack.contains(derived.getUrl())) {
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.CIRCULAR_SNAPSHOT_REFERENCES_DETECTED_CANNOT_GENERATE_SNAPSHOT_STACK__, snapshotStack.toString()));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.CIRCULAR_SNAPSHOT_REFERENCES_DETECTED_CANNOT_GENERATE_SNAPSHOT_STACK__, snapshotStack.toString()));
|
|
|
|
|
}
|
|
|
|
|
snapshotStack.add(derived.getUrl());
|
|
|
|
|
|
|
|
|
@ -518,7 +507,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
int diffCursor = 0; // we need a diff cursor because we can only look ahead, in the bound scoped by longer paths
|
|
|
|
|
|
|
|
|
|
if (derived.hasDifferential() && !derived.getDifferential().getElementFirstRep().getPath().contains(".") && !derived.getDifferential().getElementFirstRep().getType().isEmpty())
|
|
|
|
|
throw new Error(formatMessage(i18nMessages, I18nConstants.TYPE_ON_FIRST_DIFFERENTIAL_ELEMENT));
|
|
|
|
|
throw new Error(context.formatMessage(I18nConstants.TYPE_ON_FIRST_DIFFERENTIAL_ELEMENT));
|
|
|
|
|
|
|
|
|
|
for (ElementDefinition e : derived.getDifferential().getElement())
|
|
|
|
|
e.clearUserData(GENERATED_IN_SNAPSHOT);
|
|
|
|
@ -549,7 +538,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!derived.getSnapshot().getElementFirstRep().getType().isEmpty())
|
|
|
|
|
throw new Error(formatMessage(i18nMessages, I18nConstants.TYPE_ON_FIRST_SNAPSHOT_ELEMENT_FOR__IN__FROM_, derived.getSnapshot().getElementFirstRep().getPath(), derived.getUrl(), base.getUrl()));
|
|
|
|
|
throw new Error(context.formatMessage(I18nConstants.TYPE_ON_FIRST_SNAPSHOT_ELEMENT_FOR__IN__FROM_, derived.getSnapshot().getElementFirstRep().getPath(), derived.getUrl(), base.getUrl()));
|
|
|
|
|
updateMaps(base, derived);
|
|
|
|
|
|
|
|
|
|
if (debug) {
|
|
|
|
@ -566,7 +555,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
int ce = 0;
|
|
|
|
|
for (ElementDefinition e : diff.getElement()) {
|
|
|
|
|
if (!e.hasUserData("diff-source"))
|
|
|
|
|
throw new Error(formatMessage(i18nMessages, I18nConstants.UNXPECTED_INTERNAL_CONDITION__NO_SOURCE_ON_DIFF_ELEMENT));
|
|
|
|
|
throw new Error(context.formatMessage(I18nConstants.UNXPECTED_INTERNAL_CONDITION__NO_SOURCE_ON_DIFF_ELEMENT));
|
|
|
|
|
else {
|
|
|
|
|
if (e.hasUserData(DERIVATION_EQUALS))
|
|
|
|
|
((Base) e.getUserData("diff-source")).setUserData(DERIVATION_EQUALS, e.getUserData(DERIVATION_EQUALS));
|
|
|
|
@ -645,14 +634,14 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
boolean first = true;
|
|
|
|
|
for (ElementDefinition ed : elements) {
|
|
|
|
|
if (!ed.hasPath()) {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.NO_PATH_ON_ELEMENT_IN_DIFFERENTIAL_IN_, url));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.NO_PATH_ON_ELEMENT_IN_DIFFERENTIAL_IN_, url));
|
|
|
|
|
}
|
|
|
|
|
String p = ed.getPath();
|
|
|
|
|
if (p == null) {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.NO_PATH_VALUE_ON_ELEMENT_IN_DIFFERENTIAL_IN_, url));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.NO_PATH_VALUE_ON_ELEMENT_IN_DIFFERENTIAL_IN_, url));
|
|
|
|
|
}
|
|
|
|
|
if (!((first && type.equals(p)) || p.startsWith(type+"."))) {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.ILLEGAL_PATH__IN_DIFFERENTIAL_IN__MUST_START_WITH_, p, url, type, (first ? " (o be '"+type+"')" : "")));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.ILLEGAL_PATH__IN_DIFFERENTIAL_IN__MUST_START_WITH_, p, url, type, (first ? " (o be '"+type+"')" : "")));
|
|
|
|
|
}
|
|
|
|
|
if (p.contains(".")) {
|
|
|
|
|
// Element names (the parts of a path delineated by the '.' character) SHALL NOT contain whitespace (i.e. Unicode characters marked as whitespace)
|
|
|
|
@ -662,25 +651,25 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
String[] pl = p.split("\\.");
|
|
|
|
|
for (String pp : pl) {
|
|
|
|
|
if (pp.length() < 1) {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.ILLEGAL_PATH__IN_DIFFERENTIAL_IN__NAME_PORTION_MISING_, p, url));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.ILLEGAL_PATH__IN_DIFFERENTIAL_IN__NAME_PORTION_MISING_, p, url));
|
|
|
|
|
}
|
|
|
|
|
if (pp.length() > 64) {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.ILLEGAL_PATH__IN_DIFFERENTIAL_IN__NAME_PORTION_EXCEEDS_64_CHARS_IN_LENGTH, p, url));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.ILLEGAL_PATH__IN_DIFFERENTIAL_IN__NAME_PORTION_EXCEEDS_64_CHARS_IN_LENGTH, p, url));
|
|
|
|
|
}
|
|
|
|
|
for (char ch : pp.toCharArray()) {
|
|
|
|
|
if (Character.isWhitespace(ch)) {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.ILLEGAL_PATH__IN_DIFFERENTIAL_IN__NO_UNICODE_WHITESPACE, p, url));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.ILLEGAL_PATH__IN_DIFFERENTIAL_IN__NO_UNICODE_WHITESPACE, p, url));
|
|
|
|
|
}
|
|
|
|
|
if (Utilities.existsInList(ch, ',', ':', ';', '\'', '"', '/', '|', '?', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '{', '}')) {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.ILLEGAL_PATH__IN_DIFFERENTIAL_IN__ILLEGAL_CHARACTER_, p, url, ch));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.ILLEGAL_PATH__IN_DIFFERENTIAL_IN__ILLEGAL_CHARACTER_, p, url, ch));
|
|
|
|
|
}
|
|
|
|
|
if (ch < ' ' || ch > 'z') {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.ILLEGAL_PATH__IN_DIFFERENTIAL_IN__ILLEGAL_CHARACTER_, p, url, ch));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.ILLEGAL_PATH__IN_DIFFERENTIAL_IN__ILLEGAL_CHARACTER_, p, url, ch));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (pp.contains("[") || pp.contains("]")) {
|
|
|
|
|
if (!pp.endsWith("[x]") || (pp.substring(0, pp.length()-3).contains("[") || (pp.substring(0, pp.length()-3).contains("]")))) {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.ILLEGAL_PATH__IN_DIFFERENTIAL_IN__ILLEGAL_CHARACTERS_, p, url));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.ILLEGAL_PATH__IN_DIFFERENTIAL_IN__ILLEGAL_CHARACTERS_, p, url));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -834,7 +823,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
if (resultPathBase == null)
|
|
|
|
|
resultPathBase = outcome.getPath();
|
|
|
|
|
else if (!outcome.getPath().startsWith(resultPathBase))
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.ADDING_WRONG_PATH__OUTCOMEGETPATH___RESULTPATHBASE__, outcome.getPath(), resultPathBase));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.ADDING_WRONG_PATH__OUTCOMEGETPATH___RESULTPATHBASE__, outcome.getPath(), resultPathBase));
|
|
|
|
|
result.getElement().add(outcome);
|
|
|
|
|
if (hasInnerDiffMatches(differential, cpath, diffCursor, diffLimit, base.getElement(), true)) {
|
|
|
|
|
// well, the profile walks into this, so we need to as well
|
|
|
|
@ -844,17 +833,17 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
baseCursor = indexOfFirstNonChild(base, currentBase, baseCursor+1, baseLimit);
|
|
|
|
|
} else {
|
|
|
|
|
if (outcome.getType().size() == 0) {
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants._HAS_NO_CHILDREN__AND_NO_TYPES_IN_PROFILE_, diffMatches.get(0).getPath(), differential.getElement().get(diffCursor).getPath(), profileName));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants._HAS_NO_CHILDREN__AND_NO_TYPES_IN_PROFILE_, diffMatches.get(0).getPath(), differential.getElement().get(diffCursor).getPath(), profileName));
|
|
|
|
|
}
|
|
|
|
|
if (outcome.getType().size() > 1) {
|
|
|
|
|
for (TypeRefComponent t : outcome.getType()) {
|
|
|
|
|
if (!t.getWorkingCode().equals("Reference"))
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants._HAS_CHILDREN__AND_MULTIPLE_TYPES__IN_PROFILE_, diffMatches.get(0).getPath(), differential.getElement().get(diffCursor).getPath(), typeCode(outcome.getType()), profileName));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants._HAS_CHILDREN__AND_MULTIPLE_TYPES__IN_PROFILE_, diffMatches.get(0).getPath(), differential.getElement().get(diffCursor).getPath(), typeCode(outcome.getType()), profileName));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
StructureDefinition dt = getProfileForDataType(outcome.getType().get(0));
|
|
|
|
|
if (dt == null)
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.UNKNOWN_TYPE__AT_, outcome.getType().get(0), diffMatches.get(0).getPath()));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.UNKNOWN_TYPE__AT_, outcome.getType().get(0), diffMatches.get(0).getPath()));
|
|
|
|
|
contextName = dt.getUrl();
|
|
|
|
|
int start = diffCursor;
|
|
|
|
|
while (differential.getElement().size() > diffCursor && pathStartsWith(differential.getElement().get(diffCursor).getPath(), cpath+"."))
|
|
|
|
@ -874,7 +863,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
if (!sd.hasSnapshot()) {
|
|
|
|
|
StructureDefinition sdb = context.fetchResource(StructureDefinition.class, sd.getBaseDefinition());
|
|
|
|
|
if (sdb == null)
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.UNABLE_TO_FIND_BASE__FOR_, sd.getBaseDefinition(), sd.getUrl()));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.UNABLE_TO_FIND_BASE__FOR_, sd.getBaseDefinition(), sd.getUrl()));
|
|
|
|
|
checkNotGenerating(sdb, "an extension base");
|
|
|
|
|
generateSnapshot(sdb, sd, sd.getUrl(), (sdb.hasUserData("path")) ? Utilities.extractBaseUrl(sdb.getUserString("path")) : webUrl, sd.getName());
|
|
|
|
|
}
|
|
|
|
@ -887,7 +876,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
src = t;
|
|
|
|
|
}
|
|
|
|
|
if (src == null)
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.UNABLE_TO_FIND_ELEMENT__IN_, eid, p.getValue()));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.UNABLE_TO_FIND_ELEMENT__IN_, eid, p.getValue()));
|
|
|
|
|
} else
|
|
|
|
|
src = sd.getSnapshot().getElement().get(0);
|
|
|
|
|
template = src.copy().setPath(currentBase.getPath());
|
|
|
|
@ -920,7 +909,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
if (resultPathBase == null)
|
|
|
|
|
resultPathBase = outcome.getPath();
|
|
|
|
|
else if (!outcome.getPath().startsWith(resultPathBase))
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.ADDING_WRONG_PATH));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.ADDING_WRONG_PATH));
|
|
|
|
|
result.getElement().add(outcome);
|
|
|
|
|
baseCursor++;
|
|
|
|
|
diffCursor = differential.getElement().indexOf(diffMatches.get(0))+1;
|
|
|
|
@ -947,7 +936,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
if (ed != diffMatches.get(0) && !ed.getPath().endsWith(".extension"))
|
|
|
|
|
nonExtension = true;
|
|
|
|
|
if (nonExtension)
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants._HAS_CHILDREN__AND_MULTIPLE_TYPES__IN_PROFILE_, diffMatches.get(0).getPath(), differential.getElement().get(diffCursor).getPath(), typeCode(outcome.getType()), profileName));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants._HAS_CHILDREN__AND_MULTIPLE_TYPES__IN_PROFILE_, diffMatches.get(0).getPath(), differential.getElement().get(diffCursor).getPath(), typeCode(outcome.getType()), profileName));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -957,7 +946,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
if (outcome.hasContentReference()) {
|
|
|
|
|
ElementDefinition tgt = getElementById(base.getElement(), outcome.getContentReference());
|
|
|
|
|
if (tgt == null)
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.UNABLE_TO_RESOLVE_REFERENCE_TO_, outcome.getContentReference()));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.UNABLE_TO_RESOLVE_REFERENCE_TO_, outcome.getContentReference()));
|
|
|
|
|
replaceFromContentReference(outcome, tgt);
|
|
|
|
|
int nbc = base.getElement().indexOf(tgt)+1;
|
|
|
|
|
int nbl = nbc;
|
|
|
|
@ -967,7 +956,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
} else {
|
|
|
|
|
StructureDefinition dt = outcome.getType().size() == 1 ? getProfileForDataType(outcome.getType().get(0)) : getProfileForDataType("Element");
|
|
|
|
|
if (dt == null)
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants._HAS_CHILDREN__FOR_TYPE__IN_PROFILE__BUT_CANT_FIND_TYPE, diffMatches.get(0).getPath(), differential.getElement().get(diffCursor).getPath(), typeCode(outcome.getType()), profileName));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants._HAS_CHILDREN__FOR_TYPE__IN_PROFILE__BUT_CANT_FIND_TYPE, diffMatches.get(0).getPath(), differential.getElement().get(diffCursor).getPath(), typeCode(outcome.getType()), profileName));
|
|
|
|
|
contextName = dt.getUrl();
|
|
|
|
|
processPaths(indent+" ", result, dt.getSnapshot(), differential, 1 /* starting again on the data type, but skip the root */, start, dt.getSnapshot().getElement().size()-1,
|
|
|
|
|
diffCursor - 1, url, getWebUrl(dt, webUrl, indent), profileName+pathTail(diffMatches, 0), diffMatches.get(0).getPath(), outcome.getPath(), trimDifferential, contextName, resultPathBase, false, null, new ArrayList<ElementRedirection>(), srcSD);
|
|
|
|
@ -1017,18 +1006,18 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
|
|
|
|
|
if (diffMatches.get(0).getSlicing().hasOrdered()) {
|
|
|
|
|
if (diffMatches.get(0).getSlicing().getOrdered()) {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.ERROR_AT_PATH__IN__TYPE_SLICING_WITH_SLICINGORDERED__TRUE, cpath, url));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.ERROR_AT_PATH__IN__TYPE_SLICING_WITH_SLICINGORDERED__TRUE, cpath, url));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (diffMatches.get(0).getSlicing().hasDiscriminator()) {
|
|
|
|
|
if (diffMatches.get(0).getSlicing().getDiscriminator().size() != 1) {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.ERROR_AT_PATH__IN__TYPE_SLICING_WITH_SLICINGDISCRIMINATORCOUNT__1, cpath, url));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.ERROR_AT_PATH__IN__TYPE_SLICING_WITH_SLICINGDISCRIMINATORCOUNT__1, cpath, url));
|
|
|
|
|
}
|
|
|
|
|
if (diffMatches.get(0).getSlicing().getDiscriminatorFirstRep().getType() != DiscriminatorType.TYPE) {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.ERROR_AT_PATH__IN__TYPE_SLICING_WITH_SLICINGDISCRIMINATORTYPE__TYPE, cpath, url));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.ERROR_AT_PATH__IN__TYPE_SLICING_WITH_SLICINGDISCRIMINATORTYPE__TYPE, cpath, url));
|
|
|
|
|
}
|
|
|
|
|
if (!"$this".equals(diffMatches.get(0).getSlicing().getDiscriminatorFirstRep().getPath())) {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.ERROR_AT_PATH__IN__TYPE_SLICING_WITH_SLICINGDISCRIMINATORPATH__THIS, cpath, url));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.ERROR_AT_PATH__IN__TYPE_SLICING_WITH_SLICINGDISCRIMINATORPATH__THIS, cpath, url));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// check the slice names too while we're at it...
|
|
|
|
@ -1041,14 +1030,14 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
if (autoFixSliceNames) {
|
|
|
|
|
ts.defn.setSliceName(tn);
|
|
|
|
|
} else {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.ERROR_AT_PATH__SLICE_NAME_MUST_BE__BUT_IS_, (!Utilities.noString(contextPathSrc) ? contextPathSrc : cpath), tn, ts.defn.getSliceName()));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.ERROR_AT_PATH__SLICE_NAME_MUST_BE__BUT_IS_, (!Utilities.noString(contextPathSrc) ? contextPathSrc : cpath), tn, ts.defn.getSliceName()));
|
|
|
|
|
}
|
|
|
|
|
} if (!ts.defn.hasType()) {
|
|
|
|
|
ts.defn.addType().setCode(ts.type);
|
|
|
|
|
} else if (ts.defn.getType().size() > 1) {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.ERROR_AT_PATH__SLICE_FOR_TYPE__HAS_MORE_THAN_ONE_TYPE_, (!Utilities.noString(contextPathSrc) ? contextPathSrc : cpath), tn, ts.defn.typeSummary()));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.ERROR_AT_PATH__SLICE_FOR_TYPE__HAS_MORE_THAN_ONE_TYPE_, (!Utilities.noString(contextPathSrc) ? contextPathSrc : cpath), tn, ts.defn.typeSummary()));
|
|
|
|
|
} else if (!ts.defn.getType().get(0).getCode().equals(ts.type)) {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.ERROR_AT_PATH__SLICE_FOR_TYPE__HAS_WRONG_TYPE_, (!Utilities.noString(contextPathSrc) ? contextPathSrc : cpath), tn, ts.defn.typeSummary()));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.ERROR_AT_PATH__SLICE_FOR_TYPE__HAS_WRONG_TYPE_, (!Utilities.noString(contextPathSrc) ? contextPathSrc : cpath), tn, ts.defn.typeSummary()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1058,7 +1047,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
ElementDefinition e = processPaths(indent+" ", result, base, differential, baseCursor, ndc, nbl, ndl, url, webUrl, profileName+pathTail(diffMatches, 0), contextPathSrc, contextPathDst,
|
|
|
|
|
trimDifferential, contextName, resultPathBase, true, null, redirector, srcSD);
|
|
|
|
|
if (e==null)
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.DID_NOT_FIND_TYPE_ROOT_, diffMatches.get(0).getPath()));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.DID_NOT_FIND_TYPE_ROOT_, diffMatches.get(0).getPath()));
|
|
|
|
|
// now set up slicing on the e (cause it was wiped by what we called.
|
|
|
|
|
e.setSlicing(new ElementDefinitionSlicingComponent());
|
|
|
|
|
e.getSlicing().addDiscriminator().setType(DiscriminatorType.TYPE).setPath("$this");
|
|
|
|
@ -1073,7 +1062,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
// our processing scope for the differential is the item in the list, and all the items before the next one in the list
|
|
|
|
|
if (diffMatches.get(i).getMin() > 0) {
|
|
|
|
|
if (diffMatches.size() > i+1) {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.INVALID_SLICING__THERE_IS_MORE_THAN_ONE_TYPE_SLICE_AT__BUT_ONE_OF_THEM__HAS_MIN__1_SO_THE_OTHER_SLICES_CANNOT_EXIST, diffMatches.get(i).getPath(), diffMatches.get(i).getSliceName()));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.INVALID_SLICING__THERE_IS_MORE_THAN_ONE_TYPE_SLICE_AT__BUT_ONE_OF_THEM__HAS_MIN__1_SO_THE_OTHER_SLICES_CANNOT_EXIST, diffMatches.get(i).getPath(), diffMatches.get(i).getSliceName()));
|
|
|
|
|
} else {
|
|
|
|
|
e.setMin(1);
|
|
|
|
|
}
|
|
|
|
@ -1105,9 +1094,9 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
if (!unbounded(currentBase) && !isSlicedToOneOnly(diffMatches.get(0)))
|
|
|
|
|
// you can only slice an element that doesn't repeat if the sum total of your slices is limited to 1
|
|
|
|
|
// (but you might do that in order to split up constraints by type)
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.ATTEMPT_TO_A_SLICE_AN_ELEMENT_THAT_DOES_NOT_REPEAT__FROM__IN_, currentBase.getPath(), currentBase.getPath(), contextName, url));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.ATTEMPT_TO_A_SLICE_AN_ELEMENT_THAT_DOES_NOT_REPEAT__FROM__IN_, currentBase.getPath(), currentBase.getPath(), contextName, url));
|
|
|
|
|
if (!diffMatches.get(0).hasSlicing() && !isExtension(currentBase)) // well, the diff has set up a slice, but hasn't defined it. this is an error
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.DIFFERENTIAL_DOES_NOT_HAVE_A_SLICE__B_OF_____IN_PROFILE_, currentBase.getPath(), baseCursor, baseLimit, diffCursor, diffLimit, url));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.DIFFERENTIAL_DOES_NOT_HAVE_A_SLICE__B_OF_____IN_PROFILE_, currentBase.getPath(), baseCursor, baseLimit, diffCursor, diffLimit, url));
|
|
|
|
|
|
|
|
|
|
// well, if it passed those preconditions then we slice the dest.
|
|
|
|
|
int start = 0;
|
|
|
|
@ -1119,7 +1108,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
ElementDefinition e = processPaths(indent+" ", result, base, differential, baseCursor, ndc, nbl, ndl, url, webUrl, profileName+pathTail(diffMatches, 0), contextPathSrc, contextPathDst,
|
|
|
|
|
trimDifferential, contextName, resultPathBase, true, null, redirector, srcSD);
|
|
|
|
|
if (e==null)
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.DID_NOT_FIND_SINGLE_SLICE_, diffMatches.get(0).getPath()));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.DID_NOT_FIND_SINGLE_SLICE_, diffMatches.get(0).getPath()));
|
|
|
|
|
e.setSlicing(diffMatches.get(0).getSlicing());
|
|
|
|
|
start++;
|
|
|
|
|
} else {
|
|
|
|
@ -1133,7 +1122,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
else
|
|
|
|
|
outcome.setSlicing(diffMatches.get(0).getSlicing().copy());
|
|
|
|
|
if (!outcome.getPath().startsWith(resultPathBase))
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.ADDING_WRONG_PATH));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.ADDING_WRONG_PATH));
|
|
|
|
|
result.getElement().add(outcome);
|
|
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
@ -1141,7 +1130,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
updateFromDefinition(outcome, diffMatches.get(0), profileName, trimDifferential, url, srcSD);
|
|
|
|
|
removeStatusExtensions(outcome);
|
|
|
|
|
if (!outcome.hasContentReference() && !outcome.hasType()) {
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.NOT_DONE_YET));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.NOT_DONE_YET));
|
|
|
|
|
}
|
|
|
|
|
start++;
|
|
|
|
|
// result.getElement().remove(result.getElement().size()-1);
|
|
|
|
@ -1190,7 +1179,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
if (resultPathBase == null)
|
|
|
|
|
resultPathBase = outcome.getPath();
|
|
|
|
|
else if (!outcome.getPath().startsWith(resultPathBase))
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.ADDING_WRONG_PATH));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.ADDING_WRONG_PATH));
|
|
|
|
|
result.getElement().add(outcome);
|
|
|
|
|
// the profile walks into this, so we need to as well
|
|
|
|
|
// did we implicitly step into a new type?
|
|
|
|
@ -1199,17 +1188,17 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
baseCursor = indexOfFirstNonChild(base, currentBase, baseCursor, baseLimit);
|
|
|
|
|
} else {
|
|
|
|
|
if (outcome.getType().size() == 0) {
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants._HAS_NO_CHILDREN__AND_NO_TYPES_IN_PROFILE_, diffMatches.get(0).getPath(), differential.getElement().get(diffCursor).getPath(), profileName));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants._HAS_NO_CHILDREN__AND_NO_TYPES_IN_PROFILE_, diffMatches.get(0).getPath(), differential.getElement().get(diffCursor).getPath(), profileName));
|
|
|
|
|
}
|
|
|
|
|
if (outcome.getType().size() > 1) {
|
|
|
|
|
for (TypeRefComponent t : outcome.getType()) {
|
|
|
|
|
if (!t.getWorkingCode().equals("Reference"))
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants._HAS_CHILDREN__AND_MULTIPLE_TYPES__IN_PROFILE_, diffMatches.get(0).getPath(), differential.getElement().get(diffCursor).getPath(), typeCode(outcome.getType()), profileName));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants._HAS_CHILDREN__AND_MULTIPLE_TYPES__IN_PROFILE_, diffMatches.get(0).getPath(), differential.getElement().get(diffCursor).getPath(), typeCode(outcome.getType()), profileName));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
StructureDefinition dt = getProfileForDataType(outcome.getType().get(0));
|
|
|
|
|
if (dt == null)
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.UNKNOWN_TYPE__AT_, outcome.getType().get(0), diffMatches.get(0).getPath()));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.UNKNOWN_TYPE__AT_, outcome.getType().get(0), diffMatches.get(0).getPath()));
|
|
|
|
|
contextName = dt.getUrl();
|
|
|
|
|
int start = diffCursor;
|
|
|
|
|
while (differential.getElement().size() > diffCursor && pathStartsWith(differential.getElement().get(diffCursor).getPath(), cpath+"."))
|
|
|
|
@ -1225,7 +1214,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
ElementDefinition outcome = updateURLs(url, webUrl, base.getElement().get(baseCursor).copy());
|
|
|
|
|
outcome.setPath(fixedPathDest(contextPathDst, outcome.getPath(), redirector, contextPathSrc));
|
|
|
|
|
if (!outcome.getPath().startsWith(resultPathBase))
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.ADDING_WRONG_PATH_IN_PROFILE___VS_, profileName, outcome.getPath(), resultPathBase));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.ADDING_WRONG_PATH_IN_PROFILE___VS_, profileName, outcome.getPath(), resultPathBase));
|
|
|
|
|
result.getElement().add(outcome); // so we just copy it in
|
|
|
|
|
baseCursor++;
|
|
|
|
|
}
|
|
|
|
@ -1273,18 +1262,18 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
|
|
|
|
|
if (diffMatches.get(0).getSlicing().hasOrdered()) {
|
|
|
|
|
if (diffMatches.get(0).getSlicing().getOrdered()) {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.ERROR_AT_PATH__IN__TYPE_SLICING_WITH_SLICINGORDERED__TRUE, cpath, url));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.ERROR_AT_PATH__IN__TYPE_SLICING_WITH_SLICINGORDERED__TRUE, cpath, url));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (diffMatches.get(0).getSlicing().hasDiscriminator()) {
|
|
|
|
|
if (diffMatches.get(0).getSlicing().getDiscriminator().size() != 1) {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.ERROR_AT_PATH__IN__TYPE_SLICING_WITH_SLICINGDISCRIMINATORCOUNT__1, cpath, url));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.ERROR_AT_PATH__IN__TYPE_SLICING_WITH_SLICINGDISCRIMINATORCOUNT__1, cpath, url));
|
|
|
|
|
}
|
|
|
|
|
if (diffMatches.get(0).getSlicing().getDiscriminatorFirstRep().getType() != DiscriminatorType.TYPE) {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.ERROR_AT_PATH__IN__TYPE_SLICING_WITH_SLICINGDISCRIMINATORTYPE__TYPE, cpath, url));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.ERROR_AT_PATH__IN__TYPE_SLICING_WITH_SLICINGDISCRIMINATORTYPE__TYPE, cpath, url));
|
|
|
|
|
}
|
|
|
|
|
if (!"$this".equals(diffMatches.get(0).getSlicing().getDiscriminatorFirstRep().getPath())) {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.ERROR_AT_PATH__IN__TYPE_SLICING_WITH_SLICINGDISCRIMINATORPATH__THIS, cpath, url));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.ERROR_AT_PATH__IN__TYPE_SLICING_WITH_SLICINGDISCRIMINATORPATH__THIS, cpath, url));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// check the slice names too while we're at it...
|
|
|
|
@ -1294,13 +1283,13 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
if (!ts.defn.hasSliceName()) {
|
|
|
|
|
ts.defn.setSliceName(tn);
|
|
|
|
|
} else if (!ts.defn.getSliceName().equals(tn)) {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.ERROR_AT_PATH__SLICE_NAME_MUST_BE__BUT_IS_, (!Utilities.noString(contextPathSrc) ? contextPathSrc : cpath), tn, ts.defn.getSliceName()));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.ERROR_AT_PATH__SLICE_NAME_MUST_BE__BUT_IS_, (!Utilities.noString(contextPathSrc) ? contextPathSrc : cpath), tn, ts.defn.getSliceName()));
|
|
|
|
|
} if (!ts.defn.hasType()) {
|
|
|
|
|
ts.defn.addType().setCode(ts.type);
|
|
|
|
|
} else if (ts.defn.getType().size() > 1) {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.ERROR_AT_PATH__SLICE_FOR_TYPE__HAS_MORE_THAN_ONE_TYPE_, (!Utilities.noString(contextPathSrc) ? contextPathSrc : cpath), tn, ts.defn.typeSummary()));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.ERROR_AT_PATH__SLICE_FOR_TYPE__HAS_MORE_THAN_ONE_TYPE_, (!Utilities.noString(contextPathSrc) ? contextPathSrc : cpath), tn, ts.defn.typeSummary()));
|
|
|
|
|
} else if (!ts.defn.getType().get(0).getCode().equals(ts.type)) {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.ERROR_AT_PATH__SLICE_FOR_TYPE__HAS_WRONG_TYPE_, (!Utilities.noString(contextPathSrc) ? contextPathSrc : cpath), tn, ts.defn.typeSummary()));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.ERROR_AT_PATH__SLICE_FOR_TYPE__HAS_WRONG_TYPE_, (!Utilities.noString(contextPathSrc) ? contextPathSrc : cpath), tn, ts.defn.typeSummary()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1310,7 +1299,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
ElementDefinition e = processPaths(indent+" ", result, base, differential, baseCursor, ndc, nbl, ndl, url, webUrl, profileName+pathTail(diffMatches, 0), contextPathSrc, contextPathDst,
|
|
|
|
|
trimDifferential, contextName, resultPathBase, true, cpath, redirector, srcSD);
|
|
|
|
|
if (e==null)
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.DID_NOT_FIND_TYPE_ROOT_, diffMatches.get(0).getPath()));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.DID_NOT_FIND_TYPE_ROOT_, diffMatches.get(0).getPath()));
|
|
|
|
|
// now set up slicing on the e (cause it was wiped by what we called.
|
|
|
|
|
e.setSlicing(new ElementDefinitionSlicingComponent());
|
|
|
|
|
e.getSlicing().addDiscriminator().setType(DiscriminatorType.TYPE).setPath("$this");
|
|
|
|
@ -1327,7 +1316,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
// our processing scope for the differential is the item in the list, and all the items before the next one in the list
|
|
|
|
|
if (diffMatches.get(i).getMin() > 0) {
|
|
|
|
|
if (diffMatches.size() > i+1) {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.INVALID_SLICING__THERE_IS_MORE_THAN_ONE_TYPE_SLICE_AT__BUT_ONE_OF_THEM__HAS_MIN__1_SO_THE_OTHER_SLICES_CANNOT_EXIST, diffMatches.get(i).getPath(), diffMatches.get(i).getSliceName()));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.INVALID_SLICING__THERE_IS_MORE_THAN_ONE_TYPE_SLICE_AT__BUT_ONE_OF_THEM__HAS_MIN__1_SO_THE_OTHER_SLICES_CANNOT_EXIST, diffMatches.get(i).getPath(), diffMatches.get(i).getSliceName()));
|
|
|
|
|
}
|
|
|
|
|
fixedType = type;
|
|
|
|
|
}
|
|
|
|
@ -1379,11 +1368,11 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
ElementDefinitionSlicingComponent dSlice = diffMatches.get(0).getSlicing();
|
|
|
|
|
ElementDefinitionSlicingComponent bSlice = currentBase.getSlicing();
|
|
|
|
|
if (dSlice.hasOrderedElement() && bSlice.hasOrderedElement() && !orderMatches(dSlice.getOrderedElement(), bSlice.getOrderedElement()))
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.SLICING_RULES_ON_DIFFERENTIAL__DO_NOT_MATCH_THOSE_ON_BASE___ORDER___, summarizeSlicing(dSlice), summarizeSlicing(bSlice), path, contextName));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.SLICING_RULES_ON_DIFFERENTIAL__DO_NOT_MATCH_THOSE_ON_BASE___ORDER___, summarizeSlicing(dSlice), summarizeSlicing(bSlice), path, contextName));
|
|
|
|
|
if (!discriminatorMatches(dSlice.getDiscriminator(), bSlice.getDiscriminator()))
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.SLICING_RULES_ON_DIFFERENTIAL__DO_NOT_MATCH_THOSE_ON_BASE___DISCIMINATOR___, summarizeSlicing(dSlice), summarizeSlicing(bSlice), path, contextName));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.SLICING_RULES_ON_DIFFERENTIAL__DO_NOT_MATCH_THOSE_ON_BASE___DISCIMINATOR___, summarizeSlicing(dSlice), summarizeSlicing(bSlice), path, contextName));
|
|
|
|
|
if (!currentBase.isChoice() && !ruleMatches(dSlice.getRules(), bSlice.getRules()))
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.SLICING_RULES_ON_DIFFERENTIAL__DO_NOT_MATCH_THOSE_ON_BASE___RULE___, summarizeSlicing(dSlice), summarizeSlicing(bSlice), path, contextName));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(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());
|
|
|
|
|
outcome.setPath(fixedPathDest(contextPathDst, outcome.getPath(), redirector, contextPathSrc));
|
|
|
|
@ -1407,11 +1396,11 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
int ndl = findEndOfElement(differential, ndx);
|
|
|
|
|
if (nbl == baseCursor) {
|
|
|
|
|
if (base.getElement().get(baseCursor).getType().size() != 1) {
|
|
|
|
|
throw new Error(formatMessage(i18nMessages, I18nConstants.DIFFERENTIAL_WALKS_INTO____BUT_THE_BASE_DOES_NOT_AND_THERE_IS_NOT_A_SINGLE_FIXED_TYPE_THE_TYPE_IS__THIS_IS_NOT_HANDLED_YET, cpath, diffMatches.get(0).toString(), base.getElement().get(baseCursor).typeSummary()));
|
|
|
|
|
throw new Error(context.formatMessage(I18nConstants.DIFFERENTIAL_WALKS_INTO____BUT_THE_BASE_DOES_NOT_AND_THERE_IS_NOT_A_SINGLE_FIXED_TYPE_THE_TYPE_IS__THIS_IS_NOT_HANDLED_YET, cpath, diffMatches.get(0).toString(), base.getElement().get(baseCursor).typeSummary()));
|
|
|
|
|
}
|
|
|
|
|
StructureDefinition dt = getProfileForDataType(base.getElement().get(baseCursor).getType().get(0));
|
|
|
|
|
if (dt == null) {
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.UNKNOWN_TYPE__AT_, outcome.getType().get(0), diffMatches.get(0).getPath()));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.UNKNOWN_TYPE__AT_, outcome.getType().get(0), diffMatches.get(0).getPath()));
|
|
|
|
|
}
|
|
|
|
|
contextName = dt.getUrl();
|
|
|
|
|
while (differential.getElement().size() > diffCursor && pathStartsWith(differential.getElement().get(diffCursor).getPath(), cpath+"."))
|
|
|
|
@ -1442,7 +1431,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
outcome.setPath(fixedPathDest(contextPathDst, outcome.getPath(), redirector, contextPathSrc));
|
|
|
|
|
outcome.setSlicing(null);
|
|
|
|
|
if (!outcome.getPath().startsWith(resultPathBase))
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.ADDING_WRONG_PATH));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.ADDING_WRONG_PATH));
|
|
|
|
|
if (diffpos < diffMatches.size() && diffMatches.get(diffpos).hasSliceName() && diffMatches.get(diffpos).getSliceName().equals(outcome.getSliceName())) {
|
|
|
|
|
// if there's a diff, we update the outcome with diff
|
|
|
|
|
// no? updateFromDefinition(outcome, diffMatches.get(diffpos), profileName, closed, url);
|
|
|
|
@ -1464,7 +1453,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
outcome = updateURLs(url, webUrl, base.getElement().get(baseCursor).copy());
|
|
|
|
|
outcome.setPath(fixedPathDest(contextPathDst, outcome.getPath(), redirector, contextPathSrc));
|
|
|
|
|
if (!outcome.getPath().startsWith(resultPathBase))
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.ADDING_WRONG_PATH));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.ADDING_WRONG_PATH));
|
|
|
|
|
result.getElement().add(outcome);
|
|
|
|
|
baseCursor++;
|
|
|
|
|
}
|
|
|
|
@ -1479,7 +1468,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
if (currentBase.getPath().endsWith("[x]")) {
|
|
|
|
|
checkImplicitTypes = true;
|
|
|
|
|
} else {
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.THE_BASE_SNAPSHOT_MARKS_A_SLICING_AS_CLOSED_BUT_THE_DIFFERENTIAL_TRIES_TO_EXTEND_IT_IN__AT__, profileName, path, cpath));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.THE_BASE_SNAPSHOT_MARKS_A_SLICING_AS_CLOSED_BUT_THE_DIFFERENTIAL_TRIES_TO_EXTEND_IT_IN__AT__, profileName, path, cpath));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (diffpos == diffMatches.size()) {
|
|
|
|
@ -1490,14 +1479,14 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
ElementDefinition diffItem = diffMatches.get(diffpos);
|
|
|
|
|
for (ElementDefinition baseItem : baseMatches)
|
|
|
|
|
if (baseItem.getSliceName().equals(diffItem.getSliceName()))
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.NAMED_ITEMS_ARE_OUT_OF_ORDER_IN_THE_SLICE));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.NAMED_ITEMS_ARE_OUT_OF_ORDER_IN_THE_SLICE));
|
|
|
|
|
outcome = updateURLs(url, webUrl, currentBase.copy());
|
|
|
|
|
// outcome = updateURLs(url, diffItem.copy());
|
|
|
|
|
outcome.setPath(fixedPathDest(contextPathDst, outcome.getPath(), redirector, contextPathSrc));
|
|
|
|
|
updateFromBase(outcome, currentBase);
|
|
|
|
|
outcome.setSlicing(null);
|
|
|
|
|
if (!outcome.getPath().startsWith(resultPathBase))
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.ADDING_WRONG_PATH));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.ADDING_WRONG_PATH));
|
|
|
|
|
result.getElement().add(outcome);
|
|
|
|
|
updateFromDefinition(outcome, diffItem, profileName, trimDifferential, url, srcSD);
|
|
|
|
|
removeStatusExtensions(outcome);
|
|
|
|
@ -1509,7 +1498,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
if (outcome.getType().size() > 1)
|
|
|
|
|
for (TypeRefComponent t : outcome.getType()) {
|
|
|
|
|
if (!t.getCode().equals("Reference"))
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants._HAS_CHILDREN__AND_MULTIPLE_TYPES__IN_PROFILE_, diffMatches.get(0).getPath(), differential.getElement().get(diffCursor).getPath(), typeCode(outcome.getType()), profileName));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants._HAS_CHILDREN__AND_MULTIPLE_TYPES__IN_PROFILE_, diffMatches.get(0).getPath(), differential.getElement().get(diffCursor).getPath(), typeCode(outcome.getType()), profileName));
|
|
|
|
|
}
|
|
|
|
|
TypeRefComponent t = outcome.getType().get(0);
|
|
|
|
|
if (t.getCode().equals("BackboneElement")) {
|
|
|
|
@ -1529,7 +1518,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
// lloydfix dt =
|
|
|
|
|
// }
|
|
|
|
|
if (dt == null)
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants._HAS_CHILDREN__FOR_TYPE__IN_PROFILE__BUT_CANT_FIND_TYPE, diffMatches.get(0).getPath(), differential.getElement().get(diffCursor).getPath(), typeCode(outcome.getType()), profileName));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants._HAS_CHILDREN__FOR_TYPE__IN_PROFILE__BUT_CANT_FIND_TYPE, diffMatches.get(0).getPath(), differential.getElement().get(diffCursor).getPath(), typeCode(outcome.getType()), profileName));
|
|
|
|
|
contextName = dt.getUrl();
|
|
|
|
|
int start = diffCursor;
|
|
|
|
|
while (differential.getElement().size() > diffCursor && pathStartsWith(differential.getElement().get(diffCursor).getPath(), diffMatches.get(0).getPath()+"."))
|
|
|
|
@ -1553,7 +1542,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
for (ElementDefinition e : result.getElement()) {
|
|
|
|
|
i++;
|
|
|
|
|
if (e.hasMinElement() && e.getMinElement().getValue()==null)
|
|
|
|
|
throw new Error(formatMessage(i18nMessages, I18nConstants.NULL_MIN));
|
|
|
|
|
throw new Error(context.formatMessage(I18nConstants.NULL_MIN));
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
@ -1561,7 +1550,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
|
|
|
|
|
private void checkNotGenerating(StructureDefinition sd, String role) {
|
|
|
|
|
if (sd.hasUserData("profileutils.snapshot.generating")) {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.ATTEMPT_TO_USE_A_SNAPSHOT_ON_PROFILE__AS__BEFORE_IT_IS_GENERATED, sd.getUrl(), role));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.ATTEMPT_TO_USE_A_SNAPSHOT_ON_PROFILE__AS__BEFORE_IT_IS_GENERATED, sd.getUrl(), role));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1586,12 +1575,12 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
} else if (isPrimitive(Utilities.uncapitalize(t))) {
|
|
|
|
|
fixedType = Utilities.uncapitalize(t);
|
|
|
|
|
} else {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.UNEXPECTED_CONDITION_IN_DIFFERENTIAL_TYPESLICETYPELISTSIZE__10_AND_IMPLICIT_SLICE_NAME_DOES_NOT_CONTAIN_A_VALID_TYPE__AT_, t, diffMatches.get(i).getPath(), diffMatches.get(i).getSliceName()));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.UNEXPECTED_CONDITION_IN_DIFFERENTIAL_TYPESLICETYPELISTSIZE__10_AND_IMPLICIT_SLICE_NAME_DOES_NOT_CONTAIN_A_VALID_TYPE__AT_, t, diffMatches.get(i).getPath(), diffMatches.get(i).getSliceName()));
|
|
|
|
|
}
|
|
|
|
|
} else if (diffMatches.get(i).getType().size() == 1) {
|
|
|
|
|
fixedType = diffMatches.get(i).getType().get(0).getCode();
|
|
|
|
|
} else {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.UNEXPECTED_CONDITION_IN_DIFFERENTIAL_TYPESLICETYPELISTSIZE__1_AT_, diffMatches.get(i).getPath(), diffMatches.get(i).getSliceName()));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.UNEXPECTED_CONDITION_IN_DIFFERENTIAL_TYPESLICETYPELISTSIZE__1_AT_, diffMatches.get(i).getPath(), diffMatches.get(i).getSliceName()));
|
|
|
|
|
}
|
|
|
|
|
return fixedType;
|
|
|
|
|
}
|
|
|
|
@ -2466,7 +2455,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
if (derived.hasIsSummaryElement()) {
|
|
|
|
|
if (!Base.compareDeep(derived.getIsSummaryElement(), base.getIsSummaryElement(), false)) {
|
|
|
|
|
if (base.hasIsSummary())
|
|
|
|
|
throw new Error(formatMessage(i18nMessages, I18nConstants.ERROR_IN_PROFILE__AT__BASE_ISSUMMARY___DERIVED_ISSUMMARY__, pn, derived.getPath(), base.getIsSummaryElement().asStringValue(), derived.getIsSummaryElement().asStringValue()));
|
|
|
|
|
throw new Error(context.formatMessage(I18nConstants.ERROR_IN_PROFILE__AT__BASE_ISSUMMARY___DERIVED_ISSUMMARY__, pn, derived.getPath(), base.getIsSummaryElement().asStringValue(), derived.getIsSummaryElement().asStringValue()));
|
|
|
|
|
base.setIsSummaryElement(derived.getIsSummaryElement().copy());
|
|
|
|
|
} else if (trimDifferential)
|
|
|
|
|
derived.setIsSummaryElement(null);
|
|
|
|
@ -2605,7 +2594,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
}
|
|
|
|
|
if (!tgtOk) {
|
|
|
|
|
if (messages == null) {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.ERROR_AT__THE_TARGET_PROFILE__IS_NOT__VALID_CONSTRAINT_ON_THE_BASE_, purl, derived.getPath(), url, td.getTargetProfile()));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.ERROR_AT__THE_TARGET_PROFILE__IS_NOT__VALID_CONSTRAINT_ON_THE_BASE_, purl, derived.getPath(), url, td.getTargetProfile()));
|
|
|
|
|
} else {
|
|
|
|
|
messages.add(new ValidationMessage(Source.InstanceValidator, IssueType.BUSINESSRULE, derived.getPath(), "The target profile "+u.getValue()+" is not a valid constraint on the base ("+td.getTargetProfile()+") at "+derived.getPath(), IssueSeverity.ERROR));
|
|
|
|
|
}
|
|
|
|
@ -2614,7 +2603,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!ok) {
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.STRUCTUREDEFINITION__AT__ILLEGAL_CONSTRAINED_TYPE__FROM__IN_, purl, derived.getPath(), t, b.toString(), srcSD.getUrl()));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.STRUCTUREDEFINITION__AT__ILLEGAL_CONSTRAINED_TYPE__FROM__IN_, purl, derived.getPath(), t, b.toString(), srcSD.getUrl()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -3181,7 +3170,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
try {
|
|
|
|
|
return gen.generate(model, imagePath, 0, outputTracker);
|
|
|
|
|
} catch (org.hl7.fhir.exceptions.FHIRException e) {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.ERROR_GENERATING_TABLE_FOR_PROFILE__, profile.getUrl(), e.getMessage()), e);
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.ERROR_GENERATING_TABLE_FOR_PROFILE__, profile.getUrl(), e.getMessage()), e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -4006,7 +3995,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
if (ed.getPath().equals(path))
|
|
|
|
|
return ed;
|
|
|
|
|
}
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.UNABLE_TO_FIND_ELEMENT_, path));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.UNABLE_TO_FIND_ELEMENT_, path));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -4275,7 +4264,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
return sd.getType();
|
|
|
|
|
if (Utilities.existsInList(value, "SimpleQuantity", "MoneyQuantity"))
|
|
|
|
|
return "Quantity";
|
|
|
|
|
throw new Error(formatMessage(i18nMessages, I18nConstants.INTERNAL_ERROR___TYPE_NOT_KNOWN_, value));
|
|
|
|
|
throw new Error(context.formatMessage(I18nConstants.INTERNAL_ERROR___TYPE_NOT_KNOWN_, value));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -4575,7 +4564,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
if (ed.getType().isEmpty() || isAbstract(ed.getType().get(0).getWorkingCode()) || ed.getType().get(0).getWorkingCode().equals(ed.getPath())) {
|
|
|
|
|
if (ed.hasType() && "Resource".equals(ed.getType().get(0).getWorkingCode()) && child.getSelf().getType().get(0).hasProfile()) {
|
|
|
|
|
if (child.getSelf().getType().get(0).getProfile().size() > 1) {
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.UNHANDLED_SITUATION_RESOURCE_IS_PROFILED_TO_MORE_THAN_ONE_OPTION__CANNOT_SORT_PROFILE));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.UNHANDLED_SITUATION_RESOURCE_IS_PROFILED_TO_MORE_THAN_ONE_OPTION__CANNOT_SORT_PROFILE));
|
|
|
|
|
}
|
|
|
|
|
StructureDefinition profile = context.fetchResource(StructureDefinition.class, child.getSelf().getType().get(0).getProfile().get(0).getValue());
|
|
|
|
|
while (profile != null && profile.getDerivation() == TypeDerivationRule.CONSTRAINT) {
|
|
|
|
@ -4598,12 +4587,12 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
} else if (ed.getType().size() == 1 && !ed.getType().get(0).getWorkingCode().equals("*")) {
|
|
|
|
|
StructureDefinition profile = context.fetchResource(StructureDefinition.class, sdNs(ed.getType().get(0).getWorkingCode()));
|
|
|
|
|
if (profile==null)
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.UNABLE_TO_RESOLVE_PROFILE__IN_ELEMENT_, sdNs(ed.getType().get(0).getWorkingCode()), ed.getPath()));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.UNABLE_TO_RESOLVE_PROFILE__IN_ELEMENT_, sdNs(ed.getType().get(0).getWorkingCode()), ed.getPath()));
|
|
|
|
|
ccmp = new ElementDefinitionComparer(false, profile.getSnapshot().getElement(), ed.getType().get(0).getWorkingCode(), child.getSelf().getPath().length(), cmp.name);
|
|
|
|
|
} else if (child.getSelf().getType().size() == 1) {
|
|
|
|
|
StructureDefinition profile = context.fetchResource(StructureDefinition.class, sdNs(child.getSelf().getType().get(0).getWorkingCode()));
|
|
|
|
|
if (profile==null)
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.UNABLE_TO_RESOLVE_PROFILE__IN_ELEMENT_, sdNs(ed.getType().get(0).getWorkingCode()), ed.getPath()));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.UNABLE_TO_RESOLVE_PROFILE__IN_ELEMENT_, sdNs(ed.getType().get(0).getWorkingCode()), ed.getPath()));
|
|
|
|
|
ccmp = new ElementDefinitionComparer(false, profile.getSnapshot().getElement(), child.getSelf().getType().get(0).getWorkingCode(), child.getSelf().getPath().length(), cmp.name);
|
|
|
|
|
} else if (ed.getPath().endsWith("[x]") && !child.getSelf().getPath().endsWith("[x]")) {
|
|
|
|
|
String edLastNode = ed.getPath().replaceAll("(.*\\.)*(.*)", "$2");
|
|
|
|
@ -4613,12 +4602,12 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
p = Utilities.uncapitalize(p);
|
|
|
|
|
StructureDefinition sd = context.fetchResource(StructureDefinition.class, sdNs(p));
|
|
|
|
|
if (sd == null)
|
|
|
|
|
throw new Error(formatMessage(i18nMessages, I18nConstants.UNABLE_TO_FIND_PROFILE__AT_, p, ed.getId()));
|
|
|
|
|
throw new Error(context.formatMessage(I18nConstants.UNABLE_TO_FIND_PROFILE__AT_, p, ed.getId()));
|
|
|
|
|
ccmp = new ElementDefinitionComparer(false, sd.getSnapshot().getElement(), p, child.getSelf().getPath().length(), cmp.name);
|
|
|
|
|
} else if (child.getSelf().hasType() && child.getSelf().getType().get(0).getWorkingCode().equals("Reference")) {
|
|
|
|
|
for (TypeRefComponent t: child.getSelf().getType()) {
|
|
|
|
|
if (!t.getWorkingCode().equals("Reference")) {
|
|
|
|
|
throw new Error(formatMessage(i18nMessages, I18nConstants.CANT_HAVE_CHILDREN_ON_AN_ELEMENT_WITH_A_POLYMORPHIC_TYPE__YOU_MUST_SLICE_AND_CONSTRAIN_THE_TYPES_FIRST_SORTELEMENTS_, ed.getPath(), typeCode(ed.getType())));
|
|
|
|
|
throw new Error(context.formatMessage(I18nConstants.CANT_HAVE_CHILDREN_ON_AN_ELEMENT_WITH_A_POLYMORPHIC_TYPE__YOU_MUST_SLICE_AND_CONSTRAIN_THE_TYPES_FIRST_SORTELEMENTS_, ed.getPath(), typeCode(ed.getType())));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
StructureDefinition profile = context.fetchResource(StructureDefinition.class, sdNs(ed.getType().get(0).getWorkingCode()));
|
|
|
|
@ -4626,7 +4615,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
} else if (!child.getSelf().hasType() && ed.getType().get(0).getWorkingCode().equals("Reference")) {
|
|
|
|
|
for (TypeRefComponent t: ed.getType()) {
|
|
|
|
|
if (!t.getWorkingCode().equals("Reference")) {
|
|
|
|
|
throw new Error(formatMessage(i18nMessages, I18nConstants.NOT_HANDLED_YET_SORTELEMENTS_, ed.getPath(), typeCode(ed.getType())));
|
|
|
|
|
throw new Error(context.formatMessage(I18nConstants.NOT_HANDLED_YET_SORTELEMENTS_, ed.getPath(), typeCode(ed.getType())));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
StructureDefinition profile = context.fetchResource(StructureDefinition.class, sdNs(ed.getType().get(0).getWorkingCode()));
|
|
|
|
@ -4635,7 +4624,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
// this is allowed if we only profile the extensions
|
|
|
|
|
StructureDefinition profile = context.fetchResource(StructureDefinition.class, sdNs("Element"));
|
|
|
|
|
if (profile==null)
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.UNABLE_TO_RESOLVE_PROFILE__IN_ELEMENT_, sdNs(ed.getType().get(0).getWorkingCode()), ed.getPath()));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.UNABLE_TO_RESOLVE_PROFILE__IN_ELEMENT_, sdNs(ed.getType().get(0).getWorkingCode()), ed.getPath()));
|
|
|
|
|
ccmp = new ElementDefinitionComparer(false, profile.getSnapshot().getElement(), "Element", child.getSelf().getPath().length(), cmp.name);
|
|
|
|
|
// throw new Error("Not handled yet (sortElements: "+ed.getPath()+":"+typeCode(ed.getType())+")");
|
|
|
|
|
}
|
|
|
|
@ -4704,9 +4693,9 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
// generate schematrons for the rules in a structure definition
|
|
|
|
|
public void generateSchematrons(OutputStream dest, StructureDefinition structure) throws IOException, DefinitionException {
|
|
|
|
|
if (structure.getDerivation() != TypeDerivationRule.CONSTRAINT)
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.NOT_THE_RIGHT_KIND_OF_STRUCTURE_TO_GENERATE_SCHEMATRONS_FOR));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.NOT_THE_RIGHT_KIND_OF_STRUCTURE_TO_GENERATE_SCHEMATRONS_FOR));
|
|
|
|
|
if (!structure.hasSnapshot())
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.NEEDS_A_SNAPSHOT));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.NEEDS_A_SNAPSHOT));
|
|
|
|
|
|
|
|
|
|
StructureDefinition base = context.fetchResource(StructureDefinition.class, structure.getBaseDefinition());
|
|
|
|
|
|
|
|
|
@ -4722,7 +4711,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
// generate a CSV representation of the structure definition
|
|
|
|
|
public void generateCsvs(OutputStream dest, StructureDefinition structure, boolean asXml) throws IOException, DefinitionException, Exception {
|
|
|
|
|
if (!structure.hasSnapshot())
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.NEEDS_A_SNAPSHOT));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.NEEDS_A_SNAPSHOT));
|
|
|
|
|
|
|
|
|
|
CSVWriter csv = new CSVWriter(dest, structure, asXml);
|
|
|
|
|
|
|
|
|
@ -4738,7 +4727,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
System.out.println("no structure!");
|
|
|
|
|
}
|
|
|
|
|
if (!structure.hasSnapshot()) {
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.NEEDS_A_SNAPSHOT));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.NEEDS_A_SNAPSHOT));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XLSXWriter xlsx = new XLSXWriter(dest, structure, asXml, hideMustSupportFalse);
|
|
|
|
@ -4898,7 +4887,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
for (ElementDefinition ed : list) {
|
|
|
|
|
List<String> paths = new ArrayList<String>();
|
|
|
|
|
if (!ed.hasPath())
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.NO_PATH_ON_ELEMENT_DEFINITION__IN_, Integer.toString(list.indexOf(ed)), name));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.NO_PATH_ON_ELEMENT_DEFINITION__IN_, Integer.toString(list.indexOf(ed)), name));
|
|
|
|
|
sliceInfo.seeElement(ed);
|
|
|
|
|
String[] pl = ed.getPath().split("\\.");
|
|
|
|
|
for (int i = paths.size(); i < pl.length; i++) // -1 because the last path is in focus
|
|
|
|
@ -4922,7 +4911,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
ed.setId(bs);
|
|
|
|
|
if (idList.containsKey(bs)) {
|
|
|
|
|
if (exception || messages == null) {
|
|
|
|
|
throw new DefinitionException(formatMessage(i18nMessages, I18nConstants.SAME_ID_ON_MULTIPLE_ELEMENTS__IN_, bs, idList.get(bs), ed.getPath(), name));
|
|
|
|
|
throw new DefinitionException(context.formatMessage(I18nConstants.SAME_ID_ON_MULTIPLE_ELEMENTS__IN_, bs, idList.get(bs), ed.getPath(), name));
|
|
|
|
|
} else
|
|
|
|
|
messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.BUSINESSRULE, name+"."+bs, "Duplicate Element id "+bs, ValidationMessage.IssueSeverity.ERROR));
|
|
|
|
|
}
|
|
|
|
@ -5116,7 +5105,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|
|
|
|
if (sd.hasBaseDefinition()) {
|
|
|
|
|
StructureDefinition base = context.fetchResource(StructureDefinition.class, sd.getBaseDefinition());
|
|
|
|
|
if (base == null)
|
|
|
|
|
throw new FHIRException(formatMessage(i18nMessages, I18nConstants.UNABLE_TO_FIND_BASE_DEFINITION_FOR_LOGICAL_MODEL__FROM_, sd.getBaseDefinition(), sd.getUrl()));
|
|
|
|
|
throw new FHIRException(context.formatMessage(I18nConstants.UNABLE_TO_FIND_BASE_DEFINITION_FOR_LOGICAL_MODEL__FROM_, sd.getBaseDefinition(), sd.getUrl()));
|
|
|
|
|
copyElements(sd, base.getSnapshot().getElement());
|
|
|
|
|
}
|
|
|
|
|
copyElements(sd, sd.getDifferential().getElement());
|
|
|
|
|