Ensure "I" flag in profile table representation is not used for underlying infrastructural constraints that exist everywhere

This commit is contained in:
Grahame Grieve 2020-09-22 22:00:15 +10:00
parent 5e3b51e286
commit 58b6969544
1 changed files with 36 additions and 4 deletions

View File

@ -3812,7 +3812,7 @@ public class ProfileUtilities extends TranslatingUtilities {
if (element != null && element.getIsSummary()) { if (element != null && element.getIsSummary()) {
checkForNoChange(element.getIsSummaryElement(), gc.addStyledText(translate("sd.table", "This element is included in summaries"), "\u03A3", null, null, null, false)); checkForNoChange(element.getIsSummaryElement(), gc.addStyledText(translate("sd.table", "This element is included in summaries"), "\u03A3", null, null, null, false));
} }
if (element != null && (!element.getConstraint().isEmpty() || !element.getCondition().isEmpty())) { if (element != null && (hasNonBaseConstraints(element.getConstraint()) || hasNonBaseConditions(element.getCondition()))) {
gc.addStyledText(translate("sd.table", "This element has or is affected by some invariants ("+listConstraintsAndConditions(element)+")"), "I", null, null, null, false); gc.addStyledText(translate("sd.table", "This element has or is affected by some invariants ("+listConstraintsAndConditions(element)+")"), "I", null, null, null, false);
} }
@ -3860,6 +3860,7 @@ public class ProfileUtilities extends TranslatingUtilities {
return res; return res;
} }
private Cell addCell(Row row, Cell cell) { private Cell addCell(Row row, Cell cell) {
row.getCells().add(cell); row.getCells().add(cell);
return (cell); return (cell);
@ -3869,18 +3870,49 @@ public class ProfileUtilities extends TranslatingUtilities {
return app == null ? src : src + app; return app == null ? src : src + app;
} }
private boolean hasNonBaseConditions(List<IdType> conditions) {
for (IdType c : conditions) {
if (!isBaseCondition(c)) {
return true;
}
}
return false;
}
private boolean hasNonBaseConstraints(List<ElementDefinitionConstraintComponent> constraints) {
for (ElementDefinitionConstraintComponent c : constraints) {
if (!isBaseConstraint(c)) {
return true;
}
}
return false;
}
private String listConstraintsAndConditions(ElementDefinition element) { private String listConstraintsAndConditions(ElementDefinition element) {
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
for (ElementDefinitionConstraintComponent con : element.getConstraint()) { for (ElementDefinitionConstraintComponent con : element.getConstraint()) {
if (!isBaseConstraint(con)) {
b.append(con.getKey()); b.append(con.getKey());
} }
}
for (IdType id : element.getCondition()) { for (IdType id : element.getCondition()) {
if (!isBaseCondition(id)) {
b.append(id.asStringValue()); b.append(id.asStringValue());
} }
}
return b.toString(); return b.toString();
} }
private boolean isBaseCondition(IdType c) {
String key = c.asStringValue();
return key.startsWith("ele-") || key.startsWith("res-") || key.startsWith("ext-") || key.startsWith("dom-") || key.startsWith("dr-");
}
private boolean isBaseConstraint(ElementDefinitionConstraintComponent con) {
String key = con.getKey();
return key.startsWith("ele-") || key.startsWith("res-") || key.startsWith("ext-") || key.startsWith("dom-") || key.startsWith("dr-");
}
private void makeChoiceRows(List<Row> subRows, ElementDefinition element, HierarchicalTableGenerator gen, String corePath, String profileBaseFileName) { private void makeChoiceRows(List<Row> subRows, ElementDefinition element, HierarchicalTableGenerator gen, String corePath, String profileBaseFileName) {
// create a child for each choice // create a child for each choice