Skip to content

Commit

Permalink
Improve handling of bindings without a valueSet
Browse files Browse the repository at this point in the history
  • Loading branch information
cmoesel committed Jul 25, 2023
1 parent e07cc4a commit 53bfe45
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/fhirdefs/impliedExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ function applyToValueXElement(
// Handle different representation in DSTU2 and STU3
fromED.binding.valueSet ??
fromED.binding.valueSetUri ??
fromED.binding.valueSetReference.reference,
fromED.binding.valueSetReference?.reference,
fromED.binding.strength
);
if (fromED.binding.description) {
Expand Down
24 changes: 15 additions & 9 deletions src/fhirtypes/ElementDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1677,16 +1677,22 @@ export class ElementDefinition {
) {
throw new BindingStrengthError(listElement?.binding?.strength, strength);
}
// Canonical URLs may include | to specify version: https://www.hl7.org/fhir/references.html#canonical
if (!isUri(vsURI.split('|')[0])) {
throw new InvalidUriError(vsURI);
}

// We're good. Bind it.
this.binding = {
strength,
valueSet: vsURI
};
if (vsURI == null) {
// Just bind the strength since valueSet is allowed to be 0..1
this.binding = { strength };
} else {
// Canonical URLs may include | to specify version: https://www.hl7.org/fhir/references.html#canonical
if (!isUri(vsURI.split('|')[0])) {
throw new InvalidUriError(vsURI);
}

// We're good. Bind it.
this.binding = {
strength,
valueSet: vsURI
};
}
}

/**
Expand Down

0 comments on commit 53bfe45

Please sign in to comment.