Skip to content

Commit

Permalink
Fix to use derived element cardinality not element base cardinality w…
Browse files Browse the repository at this point in the history
…hen elementdefinition-json-name is present
  • Loading branch information
Grahame Grieve committed Nov 5, 2024
1 parent 6b0175e commit 31764fc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ private void parseChildComplex(List<ValidationMessage> errors, String path, Json
}
}
} else {
if (property.isList()) {
if (property.isJsonList()) {
logError(errors, ValidationMessage.NO_RULE_DATE, line(e), col(e), npath, IssueType.INVALID, context.formatMessage(I18nConstants.THIS_PROPERTY_MUST_BE_AN_ARRAY_NOT_, describe(e), name, path), IssueSeverity.ERROR);
}
parseChildComplexInstance(errors, npath, fpath, element, property, name, e, null, null, null);
Expand Down Expand Up @@ -611,7 +611,7 @@ private void parseChildPrimitive(List<ValidationMessage> errors, JsonProperty ma
logError(errors, "2022-11-26", line(main.getValue()), col(main.getValue()), path, IssueType.INVALID, context.formatMessage(I18nConstants.JSON_PROPERTY_VALUE_NO_QUOTES, main.getName(), main.getValue().asString()), IssueSeverity.ERROR);
}
if (main != null || fork != null) {
if (property.isList()) {
if (property.isJsonList()) {
boolean ok = true;
if (!(main == null || main.getValue() instanceof JsonArray)) {
logError(errors, ValidationMessage.NO_RULE_DATE, line(main.getValue()), col(main.getValue()), npath, IssueType.INVALID, context.formatMessage(I18nConstants.THIS_PROPERTY_MUST_BE_AN_ARRAY_NOT_, describe(main.getValue()), name, path), IssueSeverity.ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,19 @@ public boolean isList() {
return !"1".equals(definition.getBase().hasMax() ? definition.getBase().getMax() : definition.getMax());
}

/**
* This handles a very special case: An extension used with json extensions in CDS hooks,
* where the extension definition, not the base, decides whether it's an array or not
* @return
*/
public boolean isJsonList() {
if (definition.hasExtension("http://hl7.org/fhir/tools/StructureDefinition/elementdefinition-json-name")) {
return !"1".equals(definition.getMax());
} else {
return !"1".equals(definition.getBase().hasMax() ? definition.getBase().getMax() : definition.getMax());
}
}

public boolean isBaseList() {
return !"1".equals(definition.getBase().getMax());
}
Expand Down

0 comments on commit 31764fc

Please sign in to comment.