Skip to content

Commit

Permalink
TX: empty VS expansion is an error
Browse files Browse the repository at this point in the history
Part of #217
  • Loading branch information
qligier committed Mar 28, 2024
1 parent a0eade5 commit f92ff7b
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,25 @@ public IAnyResource validateCode(@ResourceParam final IBaseParameters baseParame
if (result == null || result.getValueSet() == null) {
// We have failed expanding the value set, this means it may be a complex one
log.debug("OK - expansion failed");
final var membership = this.evaluateCodeInComposition(coding, valueSet.getCompose());
if (membership == CodeMembership.EXCLUDED) {
log.debug("OK - code is excluded from value set composition");
return mapCodeErrorToParameters(
"The code '%s' is excluded from the value set '%s' composition".formatted(
coding.getCode(),
url
),
coding
);
} else if (membership == CodeMembership.INCLUDED) {
log.debug("OK - code is included in value set composition");
} else {
log.debug("OK - code is not included/excluded from value set composition, inferring inclusion");
}
return mapCodingToSuccessfulParameters(coding);
}

// Value set is expanded
final var baseValueSet = (IDomainResource) result.getValueSet();
if (baseValueSet instanceof final ValueSet valueSetR5) {
valueSet = valueSetR5;
Expand All @@ -146,6 +163,12 @@ public IAnyResource validateCode(@ResourceParam final IBaseParameters baseParame
this.fhirContext.getVersion().getVersion());
}

if (valueSet.getExpansion().getContains().isEmpty()) {
// The value set is empty
log.debug("OK - expansion failed without reporting errors (empty value set)");
return mapCodingToSuccessfulParameters(coding);
}

if (cacheId != null) {
this.cacheExpandedValueSet(cacheId, url, valueSet);
}
Expand Down

0 comments on commit f92ff7b

Please sign in to comment.