Fix for where profile_element extension was being ignored when checking types after snapshot generation

This commit is contained in:
Grahame Grieve 2023-03-21 06:12:02 +11:00
parent b5419efcab
commit 71a19710a0
1 changed files with 21 additions and 11 deletions

View File

@ -661,10 +661,7 @@ public class ProfileUtilities extends TranslatingUtilities {
System.out.println(" "+ed.getId()+" = "+ed.getPath()+" : "+typeSummaryWithProfile(ed)+"["+ed.getMin()+".."+ed.getMax()+"]"+sliceSummary(ed)+" "+constraintSummary(ed)); System.out.println(" "+ed.getId()+" = "+ed.getPath()+" : "+typeSummaryWithProfile(ed)+"["+ed.getMin()+".."+ed.getMax()+"]"+sliceSummary(ed)+" "+constraintSummary(ed));
} }
} }
if (exception) handleError(url, msg);
throw new DefinitionException(msg);
else
messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url, msg, ValidationMessage.IssueSeverity.ERROR));
} }
// hack around a problem in R4 definitions (somewhere?) // hack around a problem in R4 definitions (somewhere?)
for (ElementDefinition ed : derived.getSnapshot().getElement()) { for (ElementDefinition ed : derived.getSnapshot().getElement()) {
@ -712,14 +709,20 @@ public class ProfileUtilities extends TranslatingUtilities {
if (ed.getPath().equals("Bundle.entry.response.outcome")) { if (ed.getPath().equals("Bundle.entry.response.outcome")) {
wt = "OperationOutcome"; wt = "OperationOutcome";
} }
if (!sd.getType().equals(wt)) { String tt = sd.getType();
boolean ok = isCompatibleType(wt, sd); boolean elementProfile = u.hasExtension(ToolingExtensions.EXT_PROFILE_ELEMENT);
if (elementProfile) {
ElementDefinition edt = sd.getSnapshot().getElementById(u.getExtensionString(ToolingExtensions.EXT_PROFILE_ELEMENT));
if (edt == null) {
handleError(url, "The profile "+u.getValue()+" has type "+sd.getType()+" which is not consistent with the stated type "+wt);
} else {
tt = edt.typeSummary();
}
}
if (!tt.equals(wt)) {
boolean ok = !elementProfile && isCompatibleType(wt, sd);
if (!ok) { if (!ok) {
String smsg = "The profile "+u.getValue()+" has type "+sd.getType()+" which is not consistent with the stated type "+wt; handleError(url, "The profile "+u.getValue()+" has type "+sd.getType()+" which is not consistent with the stated type "+wt);
if (exception)
throw new DefinitionException(smsg);
else
messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url+"#"+ed.getId(), smsg, IssueSeverity.ERROR));
} }
} }
} }
@ -738,6 +741,13 @@ public class ProfileUtilities extends TranslatingUtilities {
} }
} }
private void handleError(String url, String msg) {
if (exception)
throw new DefinitionException(msg);
else
messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url, msg, ValidationMessage.IssueSeverity.ERROR));
}