Skip to main content
Version: v0.0.4

Function: loadValueSet()

loadValueSet(json): ValueSet

Load an untrusted FHIR R4 ValueSet JSON value into an immutable ValueSet.

Accepts the standard resource shape: resourceType: "ValueSet" with an optional intensional compose (include/exclude of system/concept/filter/valueSet) and/or a pre-computed expansion (contains, with total and the valueset-toocostly extension read into a derived truncated flag). The result is deep-frozen. Anything structurally unusable throws a TerminologyError carrying FATAL_CODES.TERM_VALUESET_MALFORMED.

Parameters

json

unknown

The untrusted resource (typically JSON.parse output - hence unknown).

Returns

ValueSet

The immutable, validated ValueSet.

Throws

TERM_VALUESET_MALFORMED when the resource is not a usable ValueSet.

Example

import { loadValueSet } from "@cosyte/terminology";

const vs = loadValueSet({
resourceType: "ValueSet",
url: "http://example.org/vs/colors",
compose: {
include: [{ system: "http://example.org/cs", concept: [{ code: "red" }, { code: "green" }] }],
},
});
vs.compose?.include.length; // => 1