Skip to content

Commit

Permalink
Edge case fix for matching codeSetMap entries
Browse files Browse the repository at this point in the history
Fixes an edge case where if a valueset expansion has values from
two different versions of the same codesystem and the code being looked
up specifies no version and exists in the second one. Previously, we
just returned the result of the 'contains' check on the first set of
codes.

Signed-off-by: Lee Surprenant <[email protected]>
  • Loading branch information
lmsurpre committed May 24, 2022
1 parent 1e055cf commit 4c3fb07
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,14 @@ private CodeSystem getCodeSystem(ValueSet valueSet, Uri system, com.ibm.fhir.mod
for (Include include : compose.getInclude()) {
if (include.getSystem().equals(system) &&
(include.getVersion() == null || version == null || include.getVersion().equals(version))) {
String url = (version != null && version.getValue() != null) ? system.getValue() + "|" + version.getValue() : system.getValue();

String url = system.getValue();
if (version != null && version.hasValue()) {
url += "|" + version.getValue();
} else if (include.getVersion() != null && include.getVersion().hasValue()) {
url += "|" + include.getVersion().getValue();
}

return CodeSystemSupport.getCodeSystem(url);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,18 +307,6 @@ public void doVisit(FHIRPathResourceNode node) {
private void validate(FHIRPathElementNode elementNode) {
Class<?> elementType = elementNode.element().getClass();
List<Constraint> constraints = new ArrayList<>(ModelSupport.getConstraints(elementType));
// if (Extension.class.equals(elementType)) {
// String url = elementNode.element().as(Extension.class).getUrl();
// if (isAbsolute(url)) {
// Collection<FHIRRegistryResource> registryResources = FHIRRegistry.getInstance().getRegistryResources(StructureDefinition.class);
// if (FHIRRegistry.getInstance().hasResource(url, StructureDefinition.class)) {
// constraints.add(Constraint.Factory.createConstraint("generated-ext-1", Constraint.LEVEL_RULE, Constraint.LOCATION_BASE,
// "Extension must conform to definition '" + url + "'", "conformsTo('" + url + "')", SOURCE_VALIDATOR, false, true));
// } else {
// issues.add(issue(IssueSeverity.WARNING, IssueType.NOT_SUPPORTED, "Extension definition '" + url + "' is not supported", elementNode));
// }
// }
// }
validate(elementNode, constraints);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,10 +460,11 @@ private static boolean validateCode(Map<java.lang.String, Set<java.lang.String>>
}
}
} else {
// coding didn't specify a version, so try them all
java.lang.String prefix = system + "|";
for (java.lang.String key : codeSetMap.keySet()) {
if (key.startsWith(prefix)) {
return codeSetMap.get(key).contains(code);
if (key.startsWith(prefix) && codeSetMap.get(key).contains(code)) {
return true;
}
}
}
Expand Down

0 comments on commit 4c3fb07

Please sign in to comment.