Skip to main content

core

Home > @medplum/core

core package

Classes

Class

Description

AndAtom

6.5.1. and Returns true if both operands evaluate to true, false if either operand evaluates to false, and the empty collection otherwise.

ArithemticOperatorAtom

AsAtom

ClientStorage

The ClientStorage class is a utility class for storing strings and objects.

When using MedplumClient in the browser, it will be backed by browser localStorage.

When Using MedplumClient in the server, it will be backed by the MemoryStorage class. For example, the Medplum CLI uses FileSystemStorage.

ConcatAtom

ContainsAtom

DotAtom

EmptySetAtom

EqualsAtom

EquivalentAtom

EventTarget_2

FhircastConnection

A class representing a FHIRcast connection.

FhircastConnection extends EventTarget and emits 3 lifecycle events: 1. connect - An event to signal when a WebSocket connection has been opened. Fired as soon as a WebSocket emits open. 2. message - Contains a payload field containing a FHIRcast message payload exactly as it comes in over WebSockets. 3. disconnect - An event to signal when a WebSocket connection has been closed. Fired as soon as a WebSocket emits close.

To close the connection, call connection.disconnect() and listen to the disconnect event to know when the connection has been disconnected.

FhirFilterComparison

The FhirFilterComparison class represents a comparison expression.

FhirFilterConnective

The FhirFilterConnective class represents a connective expression. It contains a list of child expressions.

FhirFilterNegation

The FhirFilterNegation class represents a negation expression. It contains a single child expression.

FhirPathAtom

FileBuilder

FunctionAtom

Hl7Context

The Hl7Context class represents the parsing context for an HL7 message.

Hl7Field

The Hl7Field class represents one HL7 field. A field is a collection of components.

Hl7Message

The Hl7Message class represents one HL7 message. A message is a collection of segments.

Hl7Segment

The Hl7Segment class represents one HL7 segment. A segment is a collection of fields. The name field is the first field.

ImpliesAtom

6.5.5. implies Returns true if left is true and right is true, true left is false and right true, false or empty true left is empty

InAtom

IndexerAtom

IsAtom

LiteralAtom

Logger

LRUCache

LRU cache (least recently used) Source: https://stackoverflow.com/a/46432113

MedplumClient

The MedplumClient class provides a client for the Medplum FHIR server.

The client can be used in the browser, in a Node.js application, or in a Medplum Bot.

The client provides helpful methods for common operations such as: 1. Authenticating 2. Creating resources 3. Reading resources 4. Updating resources 5. Deleting resources 6. Searching 7. Making GraphQL queries

The client can also be used to integrate with other FHIR servers. For an example, see the Epic Connection Demo Bot [here](https://github.com/medplum/medplum/tree/main/examples/medplum-demo-bots/src/epic).

MedplumKeyValueClient

MemoryStorage

The MemoryStorage class is a minimal in-memory implementation of the Storage interface.

MockAsyncClientStorage

The MockAsyncClientStorage class is a mock implementation of the ClientStorage class. This can be used for testing async initialization of the MedplumClient.

NotEqualsAtom

NotEquivalentAtom

OperationOutcomeError

OrAtom

6.5.2. or Returns false if both operands evaluate to false, true if either operand evaluates to true, and empty ({ }) otherwise:

Parser

ParserBuilder

ReadablePromise

The ReadablePromise class wraps a request promise suitable for React Suspense. See: https://blog.logrocket.com/react-suspense-data-fetching/\#wrappromise-js See: https://github.com/ovieokeh/suspense-data-fetching/blob/master/lib/api/wrapPromise.js

ReconnectingWebSocket

SubscriptionEmitter

An EventTarget that emits events when new subscription notifications come in over WebSockets.

-----

### Events emitted:

  • connect - A new subscription is connected to the SubscriptionManager and message events for this subscription can be expected. - disconnect - The specified subscription is no longer being monitored by the SubscriptionManager. - error - An error has occurred. - message - A message containing a notification Bundle has been received. - open - The WebSocket has been opened. - close - The WebSocket has been closed. - heartbeat - A heartbeat message has been received.

SubscriptionManager

SymbolAtom

Tokenizer

TransformMapCollection

The TransformMapCollection class is a collection of StructureMap and ConceptMap resources. It is used to store and retrieve imported StructureMaps and ConceptMaps by URL.

TypedEventTarget

UnaryOperatorAtom

UnionAtom

XorAtom

6.5.4. xor Returns true if exactly one of the operands evaluates to true, false if either both operands evaluate to true or both operands evaluate to false, and the empty collection otherwise.

Abstract Classes

Abstract Class

Description

BooleanInfixOperatorAtom

InfixOperatorAtom

PrefixOperatorAtom

Enumerations

Enumeration

Description

AccessPolicyInteraction

Interactions with a resource that can be controlled via an access policy.

Codes taken from http://hl7.org/fhir/codesystem-restful-interaction.html

LogLevel

Logging level, with greater values representing more detailed logs emitted.

The zero value means no server logs will be emitted.

OAuthClientAssertionType

OAuth 2.0 Client Authentication Methods See: https://datatracker.ietf.org/doc/html/rfc7523\#section-2.2

OAuthGrantType

OAuth 2.0 Grant Type Identifiers Standard identifiers: https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-07\#name-grant-types JWT bearer extension: https://datatracker.ietf.org/doc/html/rfc7523 Token exchange extension: https://datatracker.ietf.org/doc/html/rfc8693

OAuthTokenAuthMethod

OAuth 2.0 Client Authentication Methods See: https://openid.net/specs/openid-connect-core-1\_0.html\#ClientAuthentication

OAuthTokenType

OAuth 2.0 Token Type Identifiers See: https://datatracker.ietf.org/doc/html/rfc8693\#name-token-type-identifiers

Operator

Search operators. These operators represent "modifiers" and "prefixes" in FHIR search. See: https://www.hl7.org/fhir/search.html

SearchParameterType

Functions

Function

Description

accepted(location)

addProfileToResource(resource, profileUrl)

Adds the supplied profileUrl to the resource.meta.profile if it is not already specified

append(array, value)

applyDefaultValuesToElement(existingValue, elements, key)

Adds default values to existingValue for the given key and its children. If key is undefined, default values are added to all elements in elements. Default values consist of all fixed and pattern values defined in the relevant elements.

applyDefaultValuesToElementWithVisitor(existingValue, path, element, elements, schema)

applyDefaultValuesToResource(resource, schema)

Adds default values to resource based on the supplied schema. Default values includes all required fixed and pattern values specified on elements in the schema. If an element has a fixed/pattern value but is optional, i.e. element.min === 0, the default value is not added.

applyFixedOrPatternValue(inputValue, key, element, elements)

arrayBufferToBase64(arrayBuffer)

Converts an ArrayBuffer to a base-64 encoded string.

arrayBufferToHex(arrayBuffer)

Converts an ArrayBuffer to hex string. See: https://stackoverflow.com/a/55200387

arrayify(value)

assert(condition, msg)

assertContextVersionOptional(event)

assertOk(outcome, resource)

Asserts that the operation completed successfully and that the resource is defined.

assertReleaseManifest(candidate)

Asserts that a given candidate is a ReleaseManifest.

badRequest(details, expression)

booleanToTypedValue(value)

Returns a single element array with a typed boolean value.

buildElementsContext({ parentContext, path, elements, profileUrl, debugMode, accessPolicyResource, })

buildTypeName(components)

calculateAge(birthDateStr, endDateStr)

Calculates the age in years from the birth date.

calculateAgeString(birthDateStr, endDateStr)

Calculates the age string for display using the age appropriate units. If the age is greater than or equal to 2 years, then the age is displayed in years. If the age is greater than or equal to 1 month, then the age is displayed in months. Otherwise, the age is displayed in days.

canReadResourceType(accessPolicy, resourceType)

Determines if the current user can read the specified resource type.

canWriteResource(accessPolicy, resource)

Determines if the current user can write the specified resource. This is a more in-depth check after building the candidate result of a write operation.

canWriteResourceType(accessPolicy, resourceType)

Determines if the current user can write the specified resource type. This is a preliminary check before evaluating a write operation in depth. If a user cannot write a resource type at all, then don't bother looking up previous versions.

capitalize(word)

checkForNull(value, path, issues)

Recursively checks for null values in an object.

Note that "null" is a special value in JSON that is not allowed in FHIR.

checkIfValidMedplumVersion(version)

Tests that a given version string is a valid existing Medplum release version.

clearReleaseCache()

Clears the locally-cached ReleaseManifests for all versions.

compressElement(element)

concatUrls(baseUrl, path)

Concatenates the given base URL and URL.

If the URL is absolute, it is returned as-is.

conceptMapTranslate(map, params)

conflict(details, code)

convertContainedResourcesToBundle(resource)

Converts a resource with contained resources to a transaction bundle. This function is useful when creating a resource that contains other resources. Handles local references and topological sorting.

convertToTransactionBundle(bundle)

Takes a bundle and creates a Transaction Type bundle

crawlResource(resource, visitor, schema, initialPath)

Crawls the resource synchronously.

crawlResource(resource, visitor, options)

Crawls the resource asynchronously.

crawlResource(resource, visitor, options)

Crawls the resource synchronously.

crawlResourceAsync(resource, visitor, options)

Crawls the resource asynchronously.

crawlTypedValue(typedValue, visitor, options)

Crawls the typed value synchronously.

crawlTypedValueAsync(typedValue, visitor, options)

Crawls the typed value asynchronously.

createConstraintIssue(expression, constraint)

createFhircastMessagePayload(topic, event, context, versionId)

Creates a serializable JSON payload for the FHIRcast protocol

createFhircastMessagePayload(topic, event, context, versionId)

createOperationOutcomeIssue(severity, code, message, path, data)

createProcessingIssue(expression, message, err, data)

createReference(resource)

Creates a reference resource.

createStructureIssue(expression, details)

decodeBase64(data)

Decodes a base64 string. Handles both browser and Node environments. Supports Unicode characters.

deepClone(input)

Creates a deep clone of the input value.

Limitations: - Only supports JSON primitives and arrays. - Does not support Functions, lambdas, etc. - Does not support circular references.

See: https://web.dev/structured-clone/ See: https://stackoverflow.com/questions/40488190/how-is-structured-clone-algorithm-different-from-deep-copy

deepEquals(object1, object2, path)

Resource equality. Ignores meta.versionId and meta.lastUpdated.

deepIncludes(value, pattern)

Checks if value includes all fields and values of pattern. It doesn't matter if value has extra fields, values, etc.

encodeBase64(data)

Encodes a base64 string. Handles both browser and Node environments. Supports Unicode characters.

encryptSHA256(str)

Encrypts a string with SHA256 encryption.

ensureNoLeadingSlash(url)

Ensures the given URL has no leading slash.

ensureTrailingSlash(url)

Ensures the given URL has a trailing slash.

evalFhirPath(expression, input)

Evaluates a FHIRPath expression against a resource or other object.

evalFhirPathTyped(expression, input, variables)

Evaluates a FHIRPath expression against a resource or other object.

evalSqlOnFhir(view, resources)

Evaluates a SQL-on-FHIR view on a set of FHIR resources.

fetchLatestVersionString()

fetchVersionManifest(version)

fhirPathArrayEquals(x, y)

Determines if two arrays are equal according to FHIRPath equality rules.

fhirPathArrayEquivalent(x, y)

Determines if two arrays are equivalent according to FHIRPath equality rules.

fhirPathArrayNotEquals(x, y)

Determines if two arrays are not equal according to FHIRPath equality rules.

fhirPathEquals(x, y)

Determines if two values are equal according to FHIRPath equality rules.

fhirPathEquivalent(x, y)

Determines if two values are equivalent according to FHIRPath equality rules.

fhirPathIs(typedValue, desiredType)

Determines if the typed value is the desired type.

fhirPathNot(input)

Returns a negated FHIRPath boolean expression.

findObservationInterval(definition, patient, value, category)

Tries to find an observation interval for the given patient and value.

findObservationReferenceRange(definition, patient, names)

Tries to find an observation reference range for the given patient and condition names.

findResourceByCode(resources, code, system)

Finds the first resource in the input array that matches the specified code and system.

flatMapFilter(arr, fn)

formatAddress(address, options)

Formats a FHIR Address as a string.

formatCodeableConcept(codeableConcept)

Formats a CodeableConcept element as a string.

formatCoding(coding, includeCode)

Formats a Coding element as a string.

formatDate(date, locales, options)

Formats a FHIR date string as a human readable string. Handles missing values and invalid dates.

formatDateTime(dateTime, locales, options)

Formats a FHIR dateTime string as a human readable string. Handles missing values and invalid dates.

formatFamilyName(name)

Formats the family name portion of a FHIR HumanName element.

formatGivenName(name)

Formats the given name portion of a FHIR HumanName element.

formatHl7DateTime(isoDate)

Formats an ISO date/time string into an HL7 date/time string.

formatHumanName(name, options)

Formats a FHIR HumanName as a string.

formatMoney(money)

formatObservationValue(obs)

Formats a FHIR Observation resource value as a string.

formatPeriod(period, locales, options)

Formats a FHIR Period as a human readable string.

formatQuantity(quantity, precision)

Returns a human-readable string for a FHIR Quantity datatype, taking into account units and comparators

formatRange(range, precision, exclusive)

Returns a human-readable string for a FHIR Range datatype, taking into account one-sided ranges

formatReferenceString(value)

Formats a FHIR Reference as a string.

formatSearchQuery(definition)

Formats a search definition object into a query string. Note: The return value does not include the resource type.

formatTime(time, locales, options)

Formats a FHIR time string as a human readable string. Handles missing values and invalid dates.

formatTiming(timing)

Formats a FHIR Timing as a human readable string.

generateId()

Cross platform random UUID generator Note that this is not intended for production use, but rather for testing This should be replaced when crypto.randomUUID is fully supported See: https://stackoverflow.com/revisions/2117523/28

getAllDataTypes()

getAllQuestionnaireAnswers(response)

Returns an array of questionnaire answers as a map by link ID.

getCodeBySystem(concept, system)

Tries to find a code string for a given system within a given codeable concept.

getDataType(type, profileUrl)

getDateProperty(date)

Returns a Date property as a Date. When working with JSON objects, Dates are often serialized as ISO-8601 strings. When that happens, we need to safely convert to a proper Date object.

getDefaultValuesForNewSliceEntry(key, slice, slicing, schema)

getDisplayString(resource)

Returns a display string for the resource.

getElementDefinition(typeName, propertyName, profileUrl)

Returns an element definition by type and property name.

getElementDefinitionFromElements(elements, propertyName)

Returns an element definition from mapping of elements by property name.

getElementDefinitionTypeName(elementDefinition)

Returns the type name for an ElementDefinition.

getExpressionForResourceType(resourceType, expression)

getExpressionsForResourceType(resourceType, expression)

getExtension(resource, urls)

Returns an extension by extension URLs.

getExtensionValue(resource, urls)

Returns an extension value by extension URLs.

getIdentifier(resource, system)

Returns the resource identifier for the given system.

If multiple identifiers exist with the same system, the first one is returned.

If the system is not found, then returns undefined.

getImageSrc(resource)

Returns an image URL for the resource, if one is available.

getNestedProperty(value, key, options)

getNestedProperty(value, key, options)

getPathDifference(parentPath, path)

Returns the difference between two paths which is often suitable to use as a key in a Record<string, InternalSchemaElement>

getPathDisplayName(path)

Returns a human friendly display name for a FHIR element definition path.

getPropertyDisplayName(propertyName)

Returns a human friendly display name for a FHIR element property or slice name

getQueryString(query)

Converts the given query to a string.

getQuestionnaireAnswers(response)

Returns all questionnaire answers as a map by link ID.

getRandomString()

Returns a cryptographically secure random string.

getReferenceString(input)

Returns a reference string for a resource.

getResourceTypes()

Returns an array of all resource types. Note that this is based on globalSchema, and will only return resource types that are currently in memory.

getSearchParameter(resourceType, code)

Returns a search parameter for a resource type by search code.

getSearchParameterDetails(resourceType, searchParam)

Returns the type details of a SearchParameter.

The SearchParameter resource has a "type" parameter, but that is missing some critical information.

For example: 1) The "date" type includes "date", "datetime", and "period". 2) The "token" type includes enums and booleans. 3) Arrays/multiple values are not reflected at all.

getSearchParameters(resourceType)

Returns the search parameters for the resource type indexed by search code.

getStatus(outcome)

getTypedPropertyValue(input, path, options)

Returns the value of the property and the property type. Some property definitions support multiple types. For example, "Observation.value[x]" can be "valueString", "valueInteger", "valueQuantity", etc. According to the spec, there can only be one property for a given element definition. This function returns the value and the type.

getTypedPropertyValueWithoutSchema(typedValue, path)

Returns the value of the property and the property type using a type schema. Note that because the type schema is not available, this function may be inaccurate. In some cases, that is the desired behavior.

getTypedPropertyValueWithPath(input, path, options)

getTypedPropertyValueWithSchema(typedValue, path, element)

Returns the value of the property and the property type using a type schema.

getValueSliceName(value, slices, discriminators, profileUrl)

getWebSocketUrl(baseUrl, path)

Concatenates a given base URL and path, ensuring the URL has the appropriate ws:// or wss:// protocol instead of http:// or https://.

indexDefaultSearchParameters(bundle)

indexSearchParameter(searchParam)

Indexes a SearchParameter resource for fast lookup. Indexes by SearchParameter.code, which is the query string parameter name.

indexSearchParameterBundle(bundle)

Indexes a bundle of SearchParameter resources for faster lookup.

indexStructureDefinitionBundle(bundle)

Parses and indexes structure definitions

inflateBaseSchema(base)

inflateElement(path, partial)

initFhirPathParserBuilder()

isAccepted(outcome)

isCodeableConcept(value)

Returns true if the input value is a CodeableConcept object. This is a heuristic check based on the presence of the "coding" property.

isCoding(value)

Returns true if the input value is a Coding object. This is a heuristic check based on the presence of the "code" property.

isCompletedSubscriptionRequest(subscriptionRequest)

isComplexTypeCode(code)

isConflict(outcome)

isContextVersionRequired(event)

isCreated(outcome)

isDataTypeLoaded(type)

isDateString(input)

Returns true if the input value is a YYYY-MM-DD date string.

isDateTimeString(input)

Returns true if the input value is a YYYY-MM-DDThh:mm:ss.sssZ date/time string.

isEmpty(v)

Returns true if the value is empty (null, undefined, empty string, or empty object).

isFhircastResourceType(resourceType)

Checks if a ResourceType can be used in a FHIRcast context.

isFhirCriteriaMet(subscription, currentResource, getPreviousResource)

isGone(outcome)

isJwt(token)

Returns true if the token is a JWT.

isLowerCase(c)

isMedplumAccessToken(accessToken)

Returns true if the access token was issued by a Medplum server.

isNotFound(outcome)

isObject(obj)

Returns true if the input is an object.

isOk(outcome)

isOperationOutcome(value)

isPeriod(input)

Determines if the input is a Period object. This is heuristic based, as we do not have strong typing at runtime.

isPopulated(arg)

Returns true if the value is a non-empty string, an object with a length property greater than zero, or a non-empty object

isPrimitiveType(code)

Returns true if the type code is a primitive type.

isProfileLoaded(profileUrl)

isProfileResource(resource)

Returns true if the resource is a "ProfileResource".

isQuantity(input)

Determines if the input is a Quantity object. This is heuristic based, as we do not have strong typing at runtime.

isQuantityEquivalent(x, y)

isReference(value)

Typeguard to validate that an object is a FHIR resource

isResource(value)

Typeguard to validate that an object is a FHIR resource

isResourceType(resourceType)

Returns true if the given string is a valid FHIR resource type.

isResourceTypeSchema(typeSchema)

Returns true if the type schema is a non-abstract FHIR resource.

isSliceDefinitionWithTypes(slice)

isString(value)

Returns true if the input value is a string.

isStringArray(arr)

Returns true if the input array is an array of strings.

isTextObject(value)

Returns true if the input value is an object with a string text property. This is a heuristic check based on the presence of the "text" property.

isUnauthenticated(outcome)

isUUID(input)

Returns true if the input string is a UUID.

isValidDate(date)

Returns true if the given date object is a valid date. Dates can be invalid if created by parsing an invalid string.

isValidHostname(input)

Tests whether a given input is a valid hostname.

__NOTE: Does not validate that the input is a valid domain name, only a valid hostname.__

isValidMedplumSemver(version)

Tests that a given version string follows the basic semver pattern of <int>.<int>.<int>, which is used for Medplum versions.

lazy(fn)

Memoizes the result of a parameterless function

loadDataType(sd)

mapByIdentifier(resourceBundle, identifierSystem)

Returns a Map of resources from a bundle, using the specified identifier system as the key.

matchDiscriminant(value, discriminator, slice, elements)

matchesAccessPolicy(accessPolicy, resource, readonlyMode)

Returns true if the resource satisfies the current access policy.

matchesRange(value, range, precision)

Returns true if the value is in the range accounting for precision.

matchesSearchRequest(resource, searchRequest)

Determines if the resource matches the search request.

normalizeArrayBufferView(typedArrayOrBuffer)

Normalizes an ArrayBufferLike (eg. an ArrayBuffer) to a raw ArrayBufferLike (without a view). If the passed buffer is a view, it gives the raw ArrayBufferLike.

This is useful in cases where you need to operate on the raw bytes of an ArrayBuffer where a TypedArray (eg. Uint32Array) might be passed in. This ensures that you will always operate on the raw bytes rather than accidentally truncating the input by operating on the elements of the view.

normalizeCreateBinaryOptions(arg1, arg2, arg3, arg4)

normalizeCreatePdfOptions(arg1, arg2, arg3, arg4)

normalizeErrorString(error)

Normalizes an error object into a displayable error string.

normalizeOperationOutcome(error)

Normalizes an error object into an OperationOutcome.

operationOutcomeIssueToString(issue)

Returns a string represenation of the operation outcome issue.

operationOutcomeToString(outcome)

Returns a string represenation of the operation outcome.

parseCriteriaAsSearchRequest(criteria)

Parses a FHIR criteria string into a SearchRequest. FHIR criteria strings are found on resources such as Subscription.

parseFhirPath(input)

Parses a FHIRPath expression into an AST. The result can be used to evaluate the expression against a resource or other object. This method is useful if you know that you will evaluate the same expression many times against different resources.

parseFilterParameter(input)

Parses a FHIR _filter parameter expression into an AST.

parseHl7DateTime(hl7DateTime, options)

Returns a formatted string representing the date in ISO-8601 format.

HL7-Definition V2 Specifies a point in time using a 24-hour clock notation.

Format: YYYY[MM[DD[HH[MM[SS[. S[S[S[S]]]]]]]]][+/-ZZZZ].

parseJWTPayload(token)

Parses the JWT payload.

parseLogLevel(level)

parseMappingLanguage(input)

Parses a FHIR Mapping Language document into an AST.

parseParameter(searchParam, modifier, value)

parseReference(reference)

Parses a reference and returns a tuple of [ResourceType, ID].

parseSearchDefinition(url)

Parses a URL string into a SearchRequest.

parseSearchRequest(url, query)

Parses a search URL into a search request.

parseSearchUrl(url)

Parses a search URL into a search request.

parseStructureDefinition(sd)

Parses a StructureDefinition resource into an internal schema better suited for programmatic validation and usage in internal systems

parseXFhirQuery(query, variables)

Parses an extended FHIR search criteria string (i.e. application/x-fhir-query).

preciseEquals(a, b, precision)

Returns true if the two numbers are equal to the given precision.

preciseGreaterThan(a, b, precision)

Returns true if the first number is greater than the second number to the given precision.

preciseGreaterThanOrEquals(a, b, precision)

Returns true if the first number is greater than or equal to the second number to the given precision.

preciseLessThan(a, b, precision)

Returns true if the first number is less than the second number to the given precision.

preciseLessThanOrEquals(a, b, precision)

Returns true if the first number is less than or equal to the second number to the given precision.

preciseRound(a, precision)

Returns the input number rounded to the specified number of digits.

removeDuplicates(arr)

Removes duplicates in array using FHIRPath equality rules.

removeProfileFromResource(resource, profileUrl)

Removes the supplied profileUrl from the resource.meta.profile if it is present

reorderBundle(bundle)

Topologically sorts a batch or transaction bundle to improve reference resolution. The bundle is sorted such that a resource is created _before_ references to that resource appear in the bundle.

In the event of cycles, this function will first create a POST request for each resource in the cycle, and then will append a PUT request to the bundle. This ensures that each resources in the cycle is visited twice, and all references can be resolved

resolveId(input)

Returns the ID portion of a reference.

resourceMatchesSubscriptionCriteria({ resource, subscription, context, getPreviousResource, logger, })

satisfiedAccessPolicy(resource, interaction, accessPolicy)

Checks that there is an access policy permitting the given resource interaction, returning the matching policy object.

serializeFhircastSubscriptionRequest(subscriptionRequest)

Creates a serialized url-encoded payload for a FHIRcast subscription from a SubscriptionRequest object that can be directly used in an HTTP request to the Hub.

serverError(err)

serverTimeout(msg)

setCodeBySystem(concept, system, code)

Sets a code for a given system within a given codeable concept.

setIdentifier(resource, system, value)

Sets a resource identifier for the given system.

Note that this method is only available on resources that have an "identifier" property, and that property must be an array of Identifier objects, which is not true for all FHIR resources.

If the identifier already exists, then the value is updated.

Otherwise a new identifier is added.

singleton(collection, type)

singularize(value)

sleep(ms)

Sleeps for the specified number of milliseconds.

sortStringArray(array)

Sorts an array of strings in place using the localeCompare method.

This method will mutate the input array.

splitN(str, delim, n)

Splits a string into an array of strings using the specified delimiter. Unlike the built-in split function, this function will split the string into a maximum of exactly n parts. Trailing empty strings are included in the result.

splitSearchOnComma(input)

Splits a FHIR search value on commas. Respects backslash escape.

See: https://hl7.org/fhir/r4/search.html\#escaping

streamToBuffer(stream)

Reads data from a Readable stream and returns a Promise that resolves with a Buffer containing all the data.

stringify(value, pretty)

FHIR JSON stringify. Removes properties with empty string values. Removes objects with zero properties. See: https://www.hl7.org/fhir/json.html

stringifyTypedValue(v)

Output the string representation of a value, suitable for use as part of a search query.

structureMapTransform(structureMap, input, transformMaps)

Transforms input values using a FHIR StructureMap.

See: https://www.hl7.org/fhir/mapping-language.html

subsetResource(resource, properties)

Construct the subset of a resource containing a minimum set of fields. The returned resource is not guaranteed to contain only the provided properties, and may contain others (e.g. resourceType and id)

toJsBoolean(obj)

Converts unknown object into a JavaScript boolean. Note that this is different than the FHIRPath "toBoolean", which has particular semantics around arrays, empty arrays, and type conversions.

toPeriod(input)

Tries to convert an unknown input value to a Period object.

toTypedValue(value)

Returns a "best guess" TypedValue for a given value.

tryGetDataType(type, profileUrl)

tryGetJwtExpiration(token)

Returns the JWT expiration time in number of milliseconds elapsed since the epoch.

tryGetProfile(profileUrl)

typedValueToString(typedValue)

Converts a typed value to a string.

validateFhircastSubscriptionRequest(subscriptionRequest)

Validates that a SubscriptionRequest.

validateResource(resource, options)

validateResourceType(resourceType)

Validates that the given string is a valid FHIR resource type.

On success, silently returns void. On failure, throws an OperationOutcomeError.

validateTypedValue(typedValue, options)

validationError(details)

wordWrap(text, maxLength)

Returns a word-wrapped string. Based on: https://stackoverflow.com/a/38709683

Interfaces

Interface

Description

AddressFormatOptions

AgentConnectRequest

AgentConnectResponse

AgentError

AgentHeartbeatRequest

AgentHeartbeatResponse

AgentReloadConfigRequest

AgentReloadConfigResponse

AgentTransmitRequest

AgentTransmitResponse

AgentUpgradeRequest

AgentUpgradeResponse

AsyncCrawlerVisitor

Atom

AtomContext

BackgroundJobContext

BaseAgentMessage

BaseAgentRequestMessage

BaseLoginRequest

BotEvent

CloseEvent_2

Code

ConceptMapTranslateMatch

ConceptMapTranslateOutput

ConceptMapTranslateParameters

Constraint

CrawlerOptions

CrawlerVisitor

CreateBinaryOptions

Binary upload options.

CreateMediaOptions

CreatePdfFunction

CreatePdfOptions

PDF upload options.

ElementType

EmailPasswordLoginRequest

ErrorEvent_2

Event_2

ExtendedInternalSchemaElement

Filter

GetTypedPropertyValueOptions

GoogleCredentialResponse

GoogleLoginRequest

Hl7DateParseOptions

HumanNameFormatOptions

IClientStorage

IncludeTarget

IndexedStructureDefinition

An IndexedStructureDefinition is a lookup-optimized version of a StructureDefinition.

StructureDefinition resources contain schema information for other resource types. These schemas can be used to automatically generate user interface elements for resources.

However, a StructureDefinition resource is not optimized for realtime lookups. All resource types, sub types, and property definitions are stored in a flat array of ElementDefinition objects. Therefore, to lookup the schema for a property (i.e., "Patient.name") requires a linear scan of all ElementDefinition objects

A StructureDefinition resource contains information about one or more types. For example, the "Patient" StructureDefinition includes "Patient", "Patient_Contact", "Patient_Communication", and "Patient_Link". This is inefficient.

Instead, we create an indexed version of the StructureDefinition, called IndexedStructureDefinition. In an IndexedStructureDefinition, retrieving a property definition is a hashtable lookup.

The hierarchy is: IndexedStructureDefinition - top level for one resource type TypeSchema - one per resource type and all contained BackboneElements PropertySchema - one per property/field

InfixParselet

InternalSchemaElement

InternalTypeSchema

Internal representation of a non-primitive FHIR type, suitable for use in resource validation

InviteRequest

IReconnectingWebSocket

IReconnectingWebSocketCtor

IWebSocket

Generic interface that an implementation of WebSocket must satisfy to be used with ReconnectingWebSocket. This is a slightly modified fork of the WebSocket global type used in Node.

The main key difference is making all the onclose, onerror, etc. functions have any[] args, making data in send() of type any, and making binaryType of type string, though the particular implementation should narrow each of these implementation-specific types.

LoggerConfig

LoggerOptions

LoginAuthenticationResponse

LoginProfileResponse

LoginScopeResponse

LoginState

MailAddress

Email address definition. Compatible with nodemailer Mail.Address.

MailAttachment

Email attachment definition. Compatible with nodemailer Mail.Options.

MailOptions

Email message definition. Compatible with nodemailer Mail.Options.

Marker

MedplumClientOptions

The MedplumClientOptions interface defines configuration options for MedplumClient.

All configuration settings are optional.

MedplumInfraConfig

MedplumRequestOptions

MedplumSourceInfraConfig

NewPatientRequest

NewProjectRequest

NewUserRequest

PatchOperation

JSONPatch patch operation. Compatible with fast-json-patch and rfc6902 Operation.

PrefixParselet

RequestProfileSchemaOptions

SearchParameterDetails

SearchRequest

SelectionStructure

Represents a "selection structure" in the SQL-on-FHIR specification.

In practice, this can be a ViewDefinition or ViewDefinitionSelect.

TypeScript does not like checks for properties that are not part of the type, so we use this interface instead.

SliceDefinition

SliceDiscriminator

SlicingRules

SortRule

SubManagerOptions

Token

TokenizerOptions

TokenResponse

TypedValue

TypeInfo

An indexed TypeSchema.

Example: The IndexedStructureDefinition for "Patient" would include the following TypeSchemas: 1) Patient 2) Patient_Contact 3) Patient_Communication 4) Patient_Link

ValidatorOptions

ValueSetExpandParams

ValueSet $expand operation parameters. See: https://hl7.org/fhir/r4/valueset-operation-expand.html

Variables

Variable

Description

allOk

ContentType

Content type constants.

CPT

created

DEFAULT_ACCEPT

DEFAULT_MAX_SEARCH_COUNT

DEFAULT_SEARCH_COUNT

ExternalSecretSystems

FHIRCAST_EVENT_NAMES

FHIRCAST_EVENT_RESOURCES

FHIRCAST_EVENT_VERSION_REQUIRED

FHIRCAST_RESOURCE_TYPES

fhirTypeToJsType

forbidden

GITHUB_RELEASES_URL

globalSchema

Global schema singleton.

gone

HTTP_HL7_ORG

HTTP_TERMINOLOGY_HL7_ORG

ICD10

LOINC

MEDPLUM_CLI_CLIENT_ID

MEDPLUM_VERSION

multipleMatches

NDC

notFound

notModified

OperatorPrecedence

Operator precedence See: https://hl7.org/fhirpath/\#operator-precedence

preconditionFailed

projectAdminResourceTypes

Project admin resource types are special resources that are only accessible to project administrators.

PropertyType

List of property types. http://www.hl7.org/fhir/valueset-defined-types.html The list here includes additions found from StructureDefinition resources.

protectedResourceTypes

Protected resource types are in the "medplum" project. Reading and writing is limited to the system account.

RXNORM

SNOMED

tooManyRequests

UCUM

unauthorized

unauthorizedTokenAudience

unauthorizedTokenExpired

VALID_HOSTNAME_REGEX

validationRegexes

Type Aliases

Type Alias

Description

AgentMessage

AgentRequestMessage

AgentResponseMessage

AsyncResourceVisitor

BackgroundJobInteraction

BaseSchema

BinarySource

Source for a FHIR Binary.

CanBePopulated

CodeChallengeMethod

Allowed values for code_challenge_method in a PKCE exchange.

ConvertToUnion

CurrentContext

DataTypesMap

ElementsContextType

Information for the set of elements at a given path within in a resource. This mostly exists to normalize access to elements regardless of whether they are from a profile, extension, or slice.

EventListener_2

ExtendedElementProperties

ExternalSecret

ExternalSecretPrimitive

ExternalSecretPrimitiveType

ExternalSecretSystem

FetchLike

FhircastConnectEvent

FhircastDisconnectEvent

FhircastEventContext

FhircastEventContextDetails

FhircastEventContextKey

FhircastEventContextMap

FhircastEventName

FhircastEventPayload

FhircastEventResource

FhircastEventResourceType

FhircastEventVersionOptional

FhircastEventVersionRequired

FhircastMessageEvent

FhircastMessagePayload

FhircastMultiResourceContext

FhircastResourceEventName

FhircastResourceType

FhircastSingleResourceContext

FhircastSubscriptionEventMap

FhircastValidContextForEvent

FhirFilterExpression

The FhirFilterExpression type is the base type of all filter expressions.

IssueSeverity

IssueType

IWebSocketEventMap

This map exists separately from WebSocketEventMap, which is the actual event map used for the ReconnectingWebSocket class itself, due to slight difference in the type between the events as we use them, and the events as they exist as global interfaces. We need the global interfaces to be generic enough to satisfy conformant implementations that don't exactly match the events we export and use in ReconnectingWebSocket itself.

LoggerConfigOverride

MailDestination

Email destination definition.

MedplumClientEventMap

This map enumerates all the lifecycle events that MedplumClient emits and what the shape of the Event is.

Message

Options

OutputRow

SQL on FHIR output row.

PendingSubscriptionRequest

ProfileResource

ProtocolsProvider

QueryTypes

QueryTypes defines the different ways to specify FHIR search parameters.

Can be any valid input to the URLSearchParams() constructor.

TypeScript definitions for URLSearchParams do not match runtime behavior. The official spec only accepts string values. Web browsers and Node.js automatically coerce values to strings. See: https://github.com/microsoft/TypeScript/issues/32951

ReleaseManifest

ResourceArray

ResourceArray is an array of resources with a bundle property. The bundle property is a FHIR Bundle containing the search results. This is useful for retrieving bundle metadata such as total, offset, and next link.

ResourceCrawlerOptions

ResourceMatchesSubscriptionCriteria

ResourceVisitor

ResourceWithCode

SliceDefinitionWithTypes

StringMap

SubscriptionEventMap

SubscriptionRequest

A FHIRcast subscription request.

Can be passed to MedplumClient.fhircastConnect or MedplumClient.fhircastUnsubscribe to either open a FHIRcast connection, or unsubscribe from the subscription.

TypedValueWithPath

TypeName

ValueOrExternalSecret

WebSocketEventMap_2