core
core package
Classes
Class | Description |
---|---|
6.5.1. and Returns true if both operands evaluate to true, false if either operand evaluates to false, and the empty collection otherwise. | |
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 | |
A class representing a
To close the connection, call | |
The FhirFilterComparison class represents a comparison expression. | |
The FhirFilterConnective class represents a connective expression. It contains a list of child expressions. | |
The FhirFilterNegation class represents a negation expression. It contains a single child expression. | |
The Hl7Context class represents the parsing context for an HL7 message. | |
The Hl7Field class represents one HL7 field. A field is a collection of components. | |
The Hl7Message class represents one HL7 message. A message is a collection of segments. | |
The Hl7Segment class represents one HL7 segment. A segment is a collection of fields. The name field is the first field. | |
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 | |
LRU cache (least recently used) Source: https://stackoverflow.com/a/46432113 | |
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). | |
The MemoryStorage class is a minimal in-memory implementation of the Storage interface. | |
The MockAsyncClientStorage class is a mock implementation of the ClientStorage class. This can be used for testing async initialization of the MedplumClient. | |
6.5.2. or Returns false if both operands evaluate to false, true if either operand evaluates to true, and empty ( | |
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 | |
An ----- ### Events emitted:
| |
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 |
---|---|
Enumerations
Enumeration | Description |
---|---|
Interactions with a resource that can be controlled via an access policy. Codes taken from http://hl7.org/fhir/codesystem-restful-interaction.html | |
Logging level, with greater values representing more detailed logs emitted. The zero value means no server logs will be emitted. | |
OAuth 2.0 Client Authentication Methods See: https://datatracker.ietf.org/doc/html/rfc7523\#section-2.2 | |
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 | |
OAuth 2.0 Client Authentication Methods See: https://openid.net/specs/openid-connect-core-1\_0.html\#ClientAuthentication | |
OAuth 2.0 Token Type Identifiers See: https://datatracker.ietf.org/doc/html/rfc8693\#name-token-type-identifiers | |
Search operators. These operators represent "modifiers" and "prefixes" in FHIR search. See: https://www.hl7.org/fhir/search.html | |
Functions
Function | Description |
---|---|
Adds default values to | |
applyDefaultValuesToElementWithVisitor(existingValue, path, element, elements, schema) | |
Adds default values to | |
applyFixedOrPatternValue(inputValue, key, element, elements) | |
Converts an ArrayBuffer to a base-64 encoded string. | |
Converts an ArrayBuffer to hex string. See: https://stackoverflow.com/a/55200387 | |
Asserts that the operation completed successfully and that the resource is defined. | |
Returns a single element array with a typed boolean value. | |
buildElementsContext({ parentContext, path, elements, profileUrl, debugMode, }) | |
Calculates the age in years from the birth date. | |
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. | |
Determines if the current user can read the specified resource type. | |
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. | |
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. | |
Recursively checks for null values in an object. Note that "null" is a special value in JSON that is not allowed in FHIR. | |
Concatenates the given base URL and URL. If the URL is absolute, it is returned as-is. | |
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. | |
Takes a bundle and creates a Transaction Type bundle | |
createFhircastMessagePayload(topic, event, context, versionId) | Creates a serializable JSON payload for the |
createFhircastMessagePayload(topic, event, context, versionId) | |
createOperationOutcomeIssue(severity, code, message, path, data) | |
Creates a reference resource. | |
Decodes a base64 string. Handles both browser and Node environments. | |
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 | |
Resource equality. Ignores meta.versionId and meta.lastUpdated. | |
Checks if value includes all fields and values of pattern. It doesn't matter if value has extra fields, values, etc. | |
Encodes a base64 string. Handles both browser and Node environments. | |
Encrypts a string with SHA256 encryption. | |
Ensures the given URL has no leading slash. | |
Ensures the given URL has a trailing slash. | |
Evaluates a FHIRPath expression against a resource or other object. | |
Evaluates a FHIRPath expression against a resource or other object. | |
Determines if two arrays are equal according to FHIRPath equality rules. | |
Determines if two arrays are equivalent according to FHIRPath equality rules. | |
Determines if two values are equal according to FHIRPath equality rules. | |
Determines if two values are equivalent according to FHIRPath equality rules. | |
Determines if the typed value is the desired type. | |
Returns a negated FHIRPath boolean expression. | |
findObservationInterval(definition, patient, value, category) | Tries to find an observation interval for the given patient and value. |
Tries to find an observation reference range for the given patient and condition names. | |
Finds the first resource in the input array that matches the specified code and system. | |
Formats a FHIR Address as a string. | |
Formats a CodeableConcept element as a string. | |
Formats a Coding element as a string. | |
Formats a FHIR date string as a human readable string. Handles missing values and invalid dates. | |
Formats a FHIR dateTime string as a human readable string. Handles missing values and invalid dates. | |
Formats the family name portion of a FHIR HumanName element. | |
Formats the given name portion of a FHIR HumanName element. | |
Formats an ISO date/time string into an HL7 date/time string. | |
Formats a FHIR HumanName as a string. | |
Formats a FHIR Observation resource value as a string. | |
Formats a FHIR Period as a human readable string. | |
Returns a human-readable string for a FHIR Quantity datatype, taking into account units and comparators | |
Returns a human-readable string for a FHIR Range datatype, taking into account one-sided ranges | |
Formats a search definition object into a query string. Note: The return value does not include the resource type. | |
Formats a FHIR time string as a human readable string. Handles missing values and invalid dates. | |
Formats a FHIR Timing as a human readable string. | |
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 | |
Returns an array of questionnaire answers as a map by link ID. | |
Tries to find a code string for a given system within a given codeable concept. | |
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) | |
Returns a display string for the resource. | |
Returns an element definition by type and property name. | |
Returns an element definition from mapping of elements by property name. | |
Returns the type name for an ElementDefinition. | |
Returns an extension by extension URLs. | |
Returns an extension value by extension URLs. | |
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. | |
Returns an image URL for the resource, if one is available. | |
Returns the difference between two paths which is often suitable to use as a key in a | |
Returns a human friendly display name for a FHIR element definition path. | |
Returns a human friendly display name for a FHIR element property or slice name | |
Converts the given | |
Returns all questionnaire answers as a map by link ID. | |
Returns a cryptographically secure random string. | |
Returns a reference string for a resource. | |
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. | |
Returns a search parameter for a resource type by search code. | |
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. | |
Returns the search parameters for the resource type indexed by search code. | |
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. | |
Returns the value of the property and the property type using a type schema. | |
getValueSliceName(value, slices, discriminators, profileUrl) | |
Concatenates a given base URL and path, ensuring the URL has the appropriate | |
Indexes a SearchParameter resource for fast lookup. Indexes by SearchParameter.code, which is the query string parameter name. | |
Indexes a bundle of SearchParameter resources for faster lookup. | |
Parses and indexes structure definitions | |
Returns true if the input value is a CodeableConcept object. This is a heuristic check based on the presence of the "coding" property. | |
Returns true if the input value is a Coding object. This is a heuristic check based on the presence of the "code" property. | |
Returns true if the input value is a YYYY-MM-DD date string. | |
Returns true if the input value is a YYYY-MM-DDThh:mm:ss.sssZ date/time string. | |
Returns true if the value is empty (null, undefined, empty string, or empty object). | |
Checks if a | |
Returns true if the token is a JWT. | |
Returns true if the access token was issued by a Medplum server. | |
Returns true if the input is an object. | |
Determines if the input is a Period object. This is heuristic based, as we do not have strong typing at runtime. | |
Returns true if the value is a non-empty string, an object with a length property greater than zero, or a non-empty object | |
Returns true if the resource is a "ProfileResource". | |
Determines if the input is a Quantity object. This is heuristic based, as we do not have strong typing at runtime. | |
Typeguard to validate that an object is a FHIR resource | |
Typeguard to validate that an object is a FHIR resource | |
Returns true if the given string is a valid FHIR resource type. | |
Returns true if the type schema is a non-abstract FHIR resource. | |
Returns true if the input value is a string. | |
Returns true if the input array is an array of strings. | |
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. | |
Returns true if the input string is a UUID. | |
Returns true if the given date object is a valid date. Dates can be invalid if created by parsing an invalid string. | |
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.__ | |
Memoizes the result of a parameterless function | |
Returns true if the resource satisfies the current access policy. | |
Returns true if the value is in the range accounting for precision. | |
Determines if the resource matches the search request. | |
Normalizes an error object into a displayable error string. | |
Normalizes an error object into an OperationOutcome. | |
Returns a string represenation of the operation outcome issue. | |
Returns a string represenation of the operation outcome. | |
Parses a FHIR criteria string into a SearchRequest. FHIR criteria strings are found on resources such as Subscription. | |
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. | |
Parses a FHIR _filter parameter expression into an AST. | |
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]. | |
Parses the JWT payload. | |
Parses a FHIR Mapping Language document into an AST. | |
Parses a reference and returns a tuple of [ResourceType, ID]. | |
Parses a URL string into a SearchRequest. | |
Parses a search URL into a search request. | |
Parses a search URL into a search request. | |
Parses a StructureDefinition resource into an internal schema better suited for programmatic validation and usage in internal systems | |
Parses an extended FHIR search criteria string (i.e. application/x-fhir-query). | |
Returns true if the two numbers are equal to the given precision. | |
Returns true if the first number is greater than the second number to the given precision. | |
Returns true if the first number is greater than or equal to the second number to the given precision. | |
Returns true if the first number is less than the second number to the given precision. | |
Returns true if the first number is less than or equal to the second number to the given precision. | |
Returns the input number rounded to the specified number of digits. | |
Removes duplicates in array using FHIRPath equality rules. | |
Topologically sorts a 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 | |
Returns the ID portion of a reference. | |
Checks that there is an access policy permitting the given resource interaction, returning the matching policy object. | |
Creates a serialized url-encoded payload for a | |
Sets a code for a given system within a given codeable concept. | |
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. | |
Sleeps for the specified number of milliseconds. | |
Sorts an array of strings in place using the localeCompare method. This method will mutate the input array. | |
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. | |
Reads data from a Readable stream and returns a Promise that resolves with a Buffer containing all the data. | |
FHIR JSON stringify. Removes properties with empty string values. Removes objects with zero properties. See: https://www.hl7.org/fhir/json.html | |
Output the string representation of a value, suitable for use as part of a search query. | |
Transforms input values using a FHIR StructureMap. | |
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. | |
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. | |
Tries to convert an unknown input value to a Period object. | |
Returns a "best guess" TypedValue for a given value. | |
Returns the JWT expiration time in number of milliseconds elapsed since the epoch. | |
Validates that a | |
Validates that the given string is a valid FHIR resource type. On success, silently returns void. On failure, throws an OperationOutcomeError. | |
Interfaces
Interface | Description |
---|---|
Binary upload options. | |
PDF upload options. | |
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 | |
Internal representation of a non-primitive FHIR type, suitable for use in resource validation | |
Email address definition. Compatible with nodemailer Mail.Address. | |
Email attachment definition. Compatible with nodemailer Mail.Options. | |
Email message definition. Compatible with nodemailer Mail.Options. | |
The MedplumClientOptions interface defines configuration options for MedplumClient. All configuration settings are optional. | |
JSONPatch patch operation. Compatible with fast-json-patch and rfc6902 Operation. | |
An indexed TypeSchema. Example: The IndexedStructureDefinition for "Patient" would include the following TypeSchemas: 1) Patient 2) Patient_Contact 3) Patient_Communication 4) Patient_Link | |
ValueSet $expand operation parameters. See: https://hl7.org/fhir/r4/valueset-operation-expand.html |
Variables
Variable | Description |
---|---|
Content type constants. | |
Global schema singleton. | |
Operator precedence See: https://hl7.org/fhirpath/\#operator-precedence | |
Project admin resource types are special resources that are only accessible to project administrators. | |
List of property types. http://www.hl7.org/fhir/valueset-defined-types.html The list here includes additions found from StructureDefinition resources. | |
Protected resource types are in the "medplum" project. Reading and writing is limited to the system account. | |
Type Aliases
Type Alias | Description |
---|---|
Source for a FHIR Binary. | |
Allowed values for | |
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. | |
The FhirFilterExpression type is the base type of all filter expressions. | |
Email destination definition. | |
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 | |
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. | |
A Can be passed to | |