UNPKG

@medplum/core

Version:

Medplum TS/JS Library

1,257 lines (1,089 loc) 261 kB
import { AccessPolicy } from '@medplum/fhirtypes'; import { AccessPolicyResource } from '@medplum/fhirtypes'; import { Address } from '@medplum/fhirtypes'; import { Agent } from '@medplum/fhirtypes'; import { Attachment } from '@medplum/fhirtypes'; import { Binary } from '@medplum/fhirtypes'; import { Bot } from '@medplum/fhirtypes'; import { BulkDataExport } from '@medplum/fhirtypes'; import { Bundle } from '@medplum/fhirtypes'; import { CodeableConcept } from '@medplum/fhirtypes'; import { Coding } from '@medplum/fhirtypes'; import { Communication } from '@medplum/fhirtypes'; import { ConceptMap } from '@medplum/fhirtypes'; import type { CustomTableLayout } from 'pdfmake/interfaces'; import { Device } from '@medplum/fhirtypes'; import { DiagnosticReport } from '@medplum/fhirtypes'; import { DocumentReference } from '@medplum/fhirtypes'; import { ElementDefinition } from '@medplum/fhirtypes'; import { ElementDefinitionBinding } from '@medplum/fhirtypes'; import { Encounter } from '@medplum/fhirtypes'; import { Extension } from '@medplum/fhirtypes'; import { ExtensionValue } from '@medplum/fhirtypes'; import { ExtractResource } from '@medplum/fhirtypes'; import { HumanName } from '@medplum/fhirtypes'; import { Identifier } from '@medplum/fhirtypes'; import { ImagingStudy } from '@medplum/fhirtypes'; import { Media } from '@medplum/fhirtypes'; import { Money } from '@medplum/fhirtypes'; import { Observation } from '@medplum/fhirtypes'; import { ObservationComponent } from '@medplum/fhirtypes'; import { ObservationDefinition } from '@medplum/fhirtypes'; import { ObservationDefinitionQualifiedInterval } from '@medplum/fhirtypes'; import { OperationOutcome } from '@medplum/fhirtypes'; import { OperationOutcomeIssue } from '@medplum/fhirtypes'; import { Patient } from '@medplum/fhirtypes'; import { Period } from '@medplum/fhirtypes'; import { Practitioner } from '@medplum/fhirtypes'; import { Project } from '@medplum/fhirtypes'; import { ProjectMembership } from '@medplum/fhirtypes'; import { ProjectMembershipAccess } from '@medplum/fhirtypes'; import { ProjectSetting } from '@medplum/fhirtypes'; import { Quantity } from '@medplum/fhirtypes'; import { QuestionnaireResponse } from '@medplum/fhirtypes'; import { QuestionnaireResponseItemAnswer } from '@medplum/fhirtypes'; import { Range as Range_2 } from '@medplum/fhirtypes'; import { Readable } from 'stream'; import { Reference } from '@medplum/fhirtypes'; import { RelatedPerson } from '@medplum/fhirtypes'; import { Resource } from '@medplum/fhirtypes'; import { ResourceType } from '@medplum/fhirtypes'; import { SampledData } from '@medplum/fhirtypes'; import { SearchParameter } from '@medplum/fhirtypes'; import { StructureDefinition } from '@medplum/fhirtypes'; import { StructureMap } from '@medplum/fhirtypes'; import { Subscription } from '@medplum/fhirtypes'; import type { TDocumentDefinitions } from 'pdfmake/interfaces'; import type { TFontDictionary } from 'pdfmake/interfaces'; import { Timing } from '@medplum/fhirtypes'; import { UserConfiguration } from '@medplum/fhirtypes'; import { ValueSet } from '@medplum/fhirtypes'; import { ViewDefinition } from '@medplum/fhirtypes'; import { ViewDefinitionSelect } from '@medplum/fhirtypes'; export declare function accepted(location: string): OperationOutcome; /** * Interactions with a resource that can be controlled via an access policy. * * Codes taken from http://hl7.org/fhir/codesystem-restful-interaction.html */ export declare const AccessPolicyInteraction: { readonly READ: "read"; readonly VREAD: "vread"; readonly UPDATE: "update"; readonly DELETE: "delete"; readonly HISTORY: "history"; readonly CREATE: "create"; readonly SEARCH: "search"; }; export declare type AccessPolicyInteraction = (typeof AccessPolicyInteraction)[keyof typeof AccessPolicyInteraction]; /** * Shallow check that an interaction is permitted by the AccessPolicy on a given resource type, * at least for some resources. A more in-depth check for the specific resource(s) being accessed * is required in addition to this one. * @param accessPolicy - The AccessPolicy to check against. * @param interaction - The FHIR interaction being performed. * @param resourceType - The type of resource being interacted with. * @returns True when the interaction is provisionally permitted by the AccessPolicy. */ export declare function accessPolicySupportsInteraction(accessPolicy: AccessPolicy, interaction: AccessPolicyInteraction, resourceType: ResourceType): boolean; export declare const AckCode: { /** AA - Application Accept */ readonly AA: "AA"; /** AE - Application Error */ readonly AE: "AE"; /** AR - Application Reject */ readonly AR: "AR"; /** CA - Commit Accept */ readonly CA: "CA"; /** CE - Commit Error */ readonly CE: "CE"; /** CR - Commit Reject */ readonly CR: "CR"; }; export declare type AckCode = keyof typeof AckCode; /** * Adds the supplied profileUrl to the resource.meta.profile if it is not already * specified * @param resource - A FHIR resource * @param profileUrl - The profile URL to add * @returns The resource */ export declare function addProfileToResource<T extends Resource = Resource>(resource: T, profileUrl: string): T; export declare interface AddressFormatOptions { all?: boolean; use?: boolean; lineSeparator?: string; } export declare interface AgentConnectRequest extends BaseAgentRequestMessage { type: 'agent:connect:request'; agentId: string; } export declare interface AgentConnectResponse extends BaseAgentMessage { type: 'agent:connect:response'; } export declare interface AgentError extends BaseAgentMessage { type: 'agent:error'; body: string; } export declare interface AgentHeartbeatRequest extends BaseAgentRequestMessage { type: 'agent:heartbeat:request'; } export declare interface AgentHeartbeatResponse extends BaseAgentMessage { type: 'agent:heartbeat:response'; version: string; } export declare type AgentMessage = AgentRequestMessage | AgentResponseMessage; export declare interface AgentReloadConfigRequest extends BaseAgentRequestMessage { type: 'agent:reloadconfig:request'; } export declare interface AgentReloadConfigResponse extends BaseAgentMessage { type: 'agent:reloadconfig:response'; statusCode: number; } export declare type AgentRequestMessage = AgentConnectRequest | AgentHeartbeatRequest | AgentTransmitRequest | AgentReloadConfigRequest | AgentUpgradeRequest; export declare type AgentResponseMessage = AgentConnectResponse | AgentHeartbeatResponse | AgentTransmitResponse | AgentReloadConfigResponse | AgentUpgradeResponse | AgentError; export declare interface AgentTransmitRequest extends BaseAgentRequestMessage { type: 'agent:transmit:request'; channel?: string; remote: string; contentType: string; body: string; } export declare interface AgentTransmitResponse extends BaseAgentMessage { type: 'agent:transmit:response'; channel?: string; remote: string; contentType: string; statusCode?: number; body: string; } export declare interface AgentUpgradeRequest extends BaseAgentRequestMessage { type: 'agent:upgrade:request'; version?: string; force?: boolean; } export declare interface AgentUpgradeResponse extends BaseAgentMessage { type: 'agent:upgrade:response'; statusCode: number; } export declare const allOk: OperationOutcome; export declare type AnchorResourceOpenEvent<T extends FhircastAnchorResourceType> = T extends FhircastAnchorResourceType ? `${T}-open` : never; /** * 6.5.1. and * Returns true if both operands evaluate to true, * false if either operand evaluates to false, * and the empty collection otherwise. */ export declare class AndAtom extends BooleanInfixOperatorAtom { constructor(left: Atom, right: Atom); eval(context: AtomContext, input: TypedValue[]): TypedValue[]; } export declare function append<T>(array: T[] | undefined, value: T): T[]; /** * 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. * @param existingValue - The * @param elements - The elements to which default values should be added. * @param key - (optional) The key of the element(s) for which default values should be added. Elements with nested * keys are also included. If undefined, default values for all elements are added. * @returns `existingValue` with default values added */ export declare function applyDefaultValuesToElement(existingValue: object, elements: Record<string, InternalSchemaElement>, key?: string): object; /** * 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. * * @param resource - The resource to which default values should be added. * @param schema - The schema to use for adding default values. * @returns A clone of `resource` with default values added. */ export declare function applyDefaultValuesToResource(resource: Resource, schema: InternalTypeSchema): Resource; export declare function applyFixedOrPatternValue(inputValue: any, key: string, element: InternalSchemaElement, elements: Record<string, InternalSchemaElement>): any; export declare class ArithemticOperatorAtom extends BooleanInfixOperatorAtom { readonly impl: (x: number, y: number) => number | boolean; constructor(operator: string, left: Atom, right: Atom, impl: (x: number, y: number) => number | boolean); eval(context: AtomContext, input: TypedValue[]): TypedValue[]; } /** * Converts an ArrayBuffer to a base-64 encoded string. * @param arrayBuffer - The input array buffer. * @returns The base-64 encoded string. */ export declare function arrayBufferToBase64(arrayBuffer: ArrayBufferLike | ArrayBufferView): string; /** * Converts an ArrayBuffer to hex string. * See: https://stackoverflow.com/a/55200387 * @param arrayBuffer - The input array buffer. * @returns The resulting hex string. */ export declare function arrayBufferToHex(arrayBuffer: ArrayBufferLike | ArrayBufferView): string; export declare function arrayify<T>(value: T | T[] | undefined): T[] | undefined; export declare class AsAtom extends InfixOperatorAtom { constructor(left: Atom, right: Atom); eval(context: AtomContext, input: TypedValue[]): TypedValue[]; } export declare function assert(condition: unknown, msg?: string): asserts condition; export declare function assertContextVersionOptional(event: string): asserts event is FhircastEventVersionOptional; /** * Asserts that the operation completed successfully and that the resource is defined. * @param outcome - The operation outcome. * @param resource - The resource that may or may not have been returned. */ export declare function assertOk<T>(outcome: OperationOutcome, resource: T | undefined): asserts resource is T; /** * Asserts that a given candidate is a `ReleaseManifest`. * @param candidate - An object assumed to be a `ReleaseManifest`. */ export declare function assertReleaseManifest(candidate: unknown): asserts candidate is ReleaseManifest; export declare interface AsyncCrawlerVisitor { onEnterObject?: (path: string, value: TypedValueWithPath, schema: InternalTypeSchema) => Promise<void>; onExitObject?: (path: string, value: TypedValueWithPath, schema: InternalTypeSchema) => Promise<void>; onEnterResource?: (path: string, value: TypedValueWithPath, schema: InternalTypeSchema) => Promise<void>; onExitResource?: (path: string, value: TypedValueWithPath, schema: InternalTypeSchema) => Promise<void>; visitPropertyAsync: (parent: TypedValueWithPath, key: string, path: string, value: TypedValueWithPath | TypedValueWithPath[], schema: InternalTypeSchema) => Promise<void>; } export declare interface Atom { eval(context: AtomContext, input: TypedValue[]): TypedValue[]; toString(): string; } export declare interface AtomContext { parent?: AtomContext; variables: Record<string, TypedValue>; } export declare interface BackgroundJobContext { project?: WithId<Project>; interaction: BackgroundJobInteraction; } export declare type BackgroundJobInteraction = 'create' | 'update' | 'delete'; export declare function badRequest(details: string, expression?: string): OperationOutcome; export declare interface BaseAgentMessage { type: string; callback?: string; } export declare interface BaseAgentRequestMessage extends BaseAgentMessage { accessToken?: string; } export declare interface BaseLoginRequest { readonly projectId?: string; readonly clientId?: string; readonly resourceType?: string; readonly scope?: string; readonly nonce?: string; readonly codeChallenge?: string; readonly codeChallengeMethod?: CodeChallengeMethod; readonly googleClientId?: string; readonly launch?: string; readonly redirectUri?: string; } export declare type BaseSchema = Record<string, { elements: Record<string, Partial<InternalSchemaElement>>; }>; /** * Source for a FHIR Binary. */ export declare type BinarySource = string | File | Blob | Uint8Array; export declare abstract class BooleanInfixOperatorAtom extends InfixOperatorAtom { abstract eval(context: AtomContext, input: TypedValue[]): TypedValue[]; } /** * Returns a single element array with a typed boolean value. * @param value - The primitive boolean value. * @returns Single element array with a typed boolean value. */ export declare function booleanToTypedValue(value: boolean): [TypedValue]; export declare interface BotEvent<T = unknown> { readonly bot: Reference<Bot>; readonly contentType: string; readonly input: T; readonly secrets: Record<string, ProjectSetting>; readonly traceId?: string; /** Headers from the original request, when invoked by HTTP request */ readonly headers?: Record<string, string | string[] | undefined>; } export declare function buildElementsContext({ parentContext, path, elements, profileUrl, debugMode, accessPolicyResource, }: { /** The most recent `ElementsContextType` in which this context is being built. */ parentContext: ElementsContextType | undefined; /** The FHIR path from the root resource to which the keys of `elements` are relative. */ path: string; /** * The mapping of keys to `InternalSchemaElement` at the current `path` relative to the * root resource. This should be either `InternalTypeSchema.elements` or `SliceDefinition.elements`. */ elements: Record<string, InternalSchemaElement>; /** The URL, if any, of the resource profile or extension from which the `elements` collection originated. */ profileUrl?: string; /** Whether debug logging is enabled */ debugMode?: boolean; accessPolicyResource?: AccessPolicyResource; }): ElementsContextType | undefined; export declare function buildTypeName(components: string[]): string; export declare function businessRule(key: string, message: string): OperationOutcome; /** * Calculates the age in years from the birth date. * @param birthDateStr - The birth date or start date in ISO-8601 format YYYY-MM-DD. * @param endDateStr - Optional end date in ISO-8601 format YYYY-MM-DD. Default value is today. * @returns The age in years, months, and days. */ export declare function calculateAge(birthDateStr: string, endDateStr?: string): { years: number; months: number; days: number; }; /** * 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. * @param birthDateStr - The birth date or start date in ISO-8601 format YYYY-MM-DD. * @param endDateStr - Optional end date in ISO-8601 format YYYY-MM-DD. Default value is today. * @returns The age string. */ export declare function calculateAgeString(birthDateStr: string, endDateStr?: string): string | undefined; export declare type CanBePopulated = { length: number; } | object; /** * Determines if the current user can read the specified resource type. * @param accessPolicy - The access policy. * @param resourceType - The resource type. * @returns True if the current user can read the specified resource type. * @deprecated Use accessPolicySupportsInteraction() instead. */ export declare function canReadResourceType(accessPolicy: AccessPolicy, resourceType: ResourceType): boolean; /** * 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. * @param accessPolicy - The access policy. * @param resource - The resource. * @returns True if the current user can write the specified resource type. * @deprecated Use satisfiedAccessPolicy() instead. */ export declare function canWriteResource(accessPolicy: AccessPolicy, resource: Resource): boolean; /** * 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. * @param accessPolicy - The access policy. * @param resourceType - The resource type. * @returns True if the current user can write the specified resource type. * @deprecated Use accessPolicySupportsInteraction() instead. */ export declare function canWriteResourceType(accessPolicy: AccessPolicy, resourceType: ResourceType): boolean; export declare function capitalize(word: string): string; /** * Recursively checks for null values in an object. * * Note that "null" is a special value in JSON that is not allowed in FHIR. * @param value - Input value of any type. * @param path - Path string to the value for OperationOutcome. * @param issues - Output list of issues. */ export declare function checkForNull(value: unknown, path: string, issues: OperationOutcomeIssue[]): void; /** * Tests that a given version string is a valid existing Medplum release version. * @param appName - The name of the app to check the version for. * @param version - A version to be checked against the existing Medplum repo releases. * @returns `true` if `version` is a valid semver version that corresponds to an existing release, otherwise `false`. */ export declare function checkIfValidMedplumVersion(appName: string, version: string): Promise<boolean>; /** * Clears the locally-cached `ReleaseManifest`s for all versions. */ export declare function clearReleaseCache(): void; /** * 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`. */ export declare class ClientStorage implements IClientStorage { private readonly storage; constructor(storage?: Storage); clear(): void; getString(key: string): string | undefined; setString(key: string, value: string | undefined): void; getObject<T>(key: string): T | undefined; setObject<T>(key: string, value: T): void; } declare interface CloseEvent_2 extends globalThis.Event { code: number; reason: string; wasClean: boolean; } export { CloseEvent_2 as CloseEvent } export declare interface Code { code?: CodeableConcept; } /** * Allowed values for `code_challenge_method` in a PKCE exchange. */ export declare type CodeChallengeMethod = 'plain' | 'S256'; export declare function compressElement(element: InternalSchemaElement): Partial<InternalSchemaElement>; export declare class ConcatAtom extends InfixOperatorAtom { constructor(left: Atom, right: Atom); eval(context: AtomContext, input: TypedValue[]): TypedValue[]; } /** * Concatenates the given base URL and URL. * * If the URL is absolute, it is returned as-is. * * @param baseUrl - The base URL. * @param path - The URL to concat. Can be relative or absolute. * @returns The concatenated URL. */ export declare function concatUrls(baseUrl: string | URL, path: string): string; export declare function conceptMapTranslate(map: ConceptMap, params: ConceptMapTranslateParameters): ConceptMapTranslateOutput; export declare interface ConceptMapTranslateMatch { equivalence?: string; concept?: Coding; } export declare interface ConceptMapTranslateOutput { result: boolean; message?: string; match?: ConceptMapTranslateMatch[]; } export declare interface ConceptMapTranslateParameters { url?: string; source?: string; code?: string; system?: string; coding?: Coding; codeableConcept?: CodeableConcept; targetsystem?: string; } export declare function conflict(details: string, code?: string): OperationOutcome; export declare interface Constraint { key: string; severity: 'error' | 'warning'; expression: string; description: string; } export declare class ContainsAtom extends BooleanInfixOperatorAtom { constructor(left: Atom, right: Atom); eval(context: AtomContext, input: TypedValue[]): TypedValue[]; } /** * Content type constants. */ export declare const ContentType: { readonly CSS: "text/css"; readonly DICOM: "application/dicom"; readonly FAVICON: "image/vnd.microsoft.icon"; readonly FHIR_JSON: "application/fhir+json"; readonly FORM_URL_ENCODED: "application/x-www-form-urlencoded"; readonly HL7_V2: "x-application/hl7-v2+er7"; readonly HTML: "text/html"; readonly JAVASCRIPT: "text/javascript"; readonly JSON: "application/json"; readonly JSON_PATCH: "application/json-patch+json"; readonly JWT: "application/jwt"; readonly MULTIPART_FORM_DATA: "multipart/form-data"; readonly PNG: "image/png"; readonly SCIM_JSON: "application/scim+json"; readonly SVG: "image/svg+xml"; readonly TEXT: "text/plain"; readonly TYPESCRIPT: "text/typescript"; readonly PING: "x-application/ping"; readonly XML: "text/xml"; readonly CDA_XML: "application/cda+xml"; }; /** * 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. * @param resource - The input resource which may or may not include contained resources. * @returns A bundle with the input resource and all contained resources. */ export declare function convertContainedResourcesToBundle(resource: Resource & { contained?: Resource[]; }): Bundle; export declare function convertToSearchableDates(typedValues: TypedValue[]): Period[]; export declare function convertToSearchableNumbers(typedValues: TypedValue[]): [number | undefined, number | undefined][]; export declare function convertToSearchableQuantities(typedValues: TypedValue[]): Quantity[]; export declare function convertToSearchableReferences(typedValues: TypedValue[]): string[]; export declare function convertToSearchableStrings(typedValues: TypedValue[]): string[]; export declare function convertToSearchableTokens(typedValues: TypedValue[], context?: TokensContext): SearchableToken[]; export declare function convertToSearchableUris(typedValues: TypedValue[]): string[]; /** * More on Bundles can be found here * http://hl7.org/fhir/R4/bundle.html */ /** * Takes a bundle and creates a Transaction Type bundle * @param bundle - The Bundle object that we'll receive from the search query * @returns transaction type bundle */ export declare function convertToTransactionBundle(bundle: Bundle): Bundle; export declare const CPT = "http://www.ama-assn.org/go/cpt"; export declare interface CrawlerOptions { skipMissingProperties?: boolean; schema?: InternalTypeSchema; initialPath?: string; } export declare interface CrawlerVisitor { onEnterObject?: (path: string, value: TypedValueWithPath, schema: InternalTypeSchema) => void; onExitObject?: (path: string, value: TypedValueWithPath, schema: InternalTypeSchema) => void; onEnterResource?: (path: string, value: TypedValueWithPath, schema: InternalTypeSchema) => void; onExitResource?: (path: string, value: TypedValueWithPath, schema: InternalTypeSchema) => void; visitProperty: (parent: TypedValueWithPath, key: string, path: string, propertyValues: (TypedValueWithPath | TypedValueWithPath[])[], schema: InternalTypeSchema) => void; } /** * Crawls the typed value synchronously. * @param typedValue - The typed value to crawl. * @param visitor - The visitor functions to apply while crawling. * @param options - Options for how to crawl the typed value. */ export declare function crawlTypedValue(typedValue: TypedValue, visitor: CrawlerVisitor, options?: CrawlerOptions): void; /** * Crawls the typed value asynchronously. * @param typedValue - The typed value to crawl. * @param visitor - The visitor functions to apply while crawling. * @param options - Options for how to crawl the typed value. * @returns Promise to crawl the typed value. */ export declare function crawlTypedValueAsync(typedValue: TypedValue, visitor: AsyncCrawlerVisitor, options?: CrawlerOptions): Promise<void>; /** * Binary upload options. */ export declare interface CreateBinaryOptions { /** * The binary data to upload. */ readonly data: BinarySource; /** * Content type for the binary. */ readonly contentType: string; /** * Optional filename for the binary. */ readonly filename?: string; /** * Optional security context for the binary. */ readonly securityContext?: Reference; /** * Optional fetch options. **NOTE:** only `requestOptions.signal` is respected when `onProgress` is also provided. */ readonly onProgress?: (e: ProgressEvent) => void; } export declare function createConstraintIssue(expression: string, constraint: Constraint): OperationOutcomeIssue; export declare const created: OperationOutcome; export declare interface CreateDocumentReferenceOptions extends CreateBinaryOptions { /** * Optional additional fields for the DocumentReference resource. */ readonly additionalFields?: Omit<Partial<DocumentReference>, 'content'>; } /** * Creates a serializable JSON payload for the `FHIRcast` protocol * * @param topic - The topic that this message will be published on. Usually a UUID. * @param event - The event name, ie. "Patient-open" or "Patient-close". * @param context - The updated context, containing new versions of resources related to this event. * @param versionId - The current `versionId` of the anchor context. For example, in `DiagnosticReport-update`, it's the `versionId` of the `DiagnosticReport`. * @returns A serializable `FhircastMessagePayload`. */ export declare function createFhircastMessagePayload<EventName extends FhircastEventVersionOptional>(topic: string, event: EventName, context: FhircastEventContext<EventName> | FhircastEventContext<EventName>[], versionId?: never): FhircastMessagePayload<EventName>; export declare function createFhircastMessagePayload<EventName extends FhircastEventVersionRequired>(topic: string, event: EventName, context: FhircastEventContext<EventName> | FhircastEventContext<EventName>[], versionId: string): FhircastMessagePayload<EventName>; export declare interface CreateMediaOptions extends CreateBinaryOptions { /** * Optional additional fields for the Media resource. */ readonly additionalFields?: Partial<Media>; } export declare function createOperationOutcomeIssue(severity: IssueSeverity, code: IssueType, message: string, path: string, data?: Record<string, any>): OperationOutcomeIssue; export declare interface CreatePdfFunction { (docDefinition: TDocumentDefinitions, tableLayouts?: Record<string, CustomTableLayout>, fonts?: TFontDictionary): Promise<any>; } /** * PDF upload options. */ export declare interface CreatePdfOptions extends Omit<CreateBinaryOptions, 'data' | 'contentType'> { /** * The PDF document definition. See {@link https://pdfmake.github.io/docs/0.1/document-definition-object/} */ readonly docDefinition: TDocumentDefinitions; /** * Optional pdfmake custom table layout. */ readonly tableLayouts?: Record<string, CustomTableLayout>; /** * Optional pdfmake custom font dictionary. */ readonly fonts?: TFontDictionary; } export declare function createProcessingIssue(expression: string, message: string, err: Error, data?: Record<string, any>): OperationOutcomeIssue; /** * Creates a reference resource. * @param resource - The FHIR resource. * @returns A reference resource. */ export declare function createReference<T extends Resource>(resource: T): Reference<T> & { reference: string; }; export declare function createStructureIssue(expression: string, details: string): OperationOutcomeIssue; export declare type CurrentContext<T extends FhircastAnchorResourceType | '' = FhircastAnchorResourceType | ''> = T extends '' ? { 'context.type': ''; context: never[]; } : T extends 'DiagnosticReport' ? { 'context.type': 'DiagnosticReport'; 'context.versionId': string; context: (FhircastEventContext<'DiagnosticReport-open'> | FhircastHubContentContext)[]; } : T extends 'Patient' | 'Encounter' | 'ImagingStudy' ? { 'context.type': T; 'context.versionId': string; context: FhircastEventContext<AnchorResourceOpenEvent<T>>[]; } : never; export declare interface DataSampleOptions { /** Code for the data points. */ code?: CodeableConcept; /** Unit for the data points. */ unit?: QuantityUnit; /** Sampling information for high-frequency Observations. */ sampling?: Omit<SampledData, 'data'>; } export declare class DataSampler { private code?; private unit?; private readonly sampling?; private readonly dataPoints; /** * @param opts - Optional parameters. */ constructor(opts?: DataSampleOptions); addObservation(obs: Observation): void; addData(...data: number[]): void; private checkUnit; summarize(code: CodeableConcept, fn: StatsFn): Observation; } export declare type DataTypesMap = { [type: string]: InternalTypeSchema; }; /** * Decodes a base64 string. * Handles both browser and Node environments. * Supports Unicode characters. * @param data - The base-64 encoded input string. * @returns The decoded string. */ export declare function decodeBase64(data: string): string; /** * Decodes a string from Base64URL format. * @param data - The Base64URL encoded input string. * @returns The decoded string. */ export declare function decodeBase64Url(data: string): string; /** * 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 * @param input - The input to clone. * @returns A deep clone of the input. */ export declare function deepClone<T>(input: T): T; /** * Resource equality. * Ignores meta.versionId and meta.lastUpdated. * @param object1 - The first object. * @param object2 - The second object. * @param path - Optional path string. * @returns True if the objects are equal. */ export declare function deepEquals(object1: unknown, object2: unknown, path?: string): boolean; /** * Checks if value includes all fields and values of pattern. * It doesn't matter if value has extra fields, values, etc. * @param value - The object being tested against pattern. * @param pattern - The object pattern/shape checked to exist within value. * @returns True if value includes all fields and values of pattern. */ export declare function deepIncludes(value: any, pattern: any): boolean; export declare const DEFAULT_ACCEPT: string; export declare const DEFAULT_MAX_SEARCH_COUNT = 1000; export declare const DEFAULT_SEARCH_COUNT = 20; export declare class DotAtom extends InfixOperatorAtom { constructor(left: Atom, right: Atom); eval(context: AtomContext, input: TypedValue[]): TypedValue[]; toString(): string; } /** * 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. */ export declare type ElementsContextType = { /** The FHIR path from the root resource to which the keys of `elements` are relative. */ path: string; /** * The mapping of keys to `ExtendedInternalSchemaElement` at the current `path` relative to the * root resource. `elements` originate from either `InternalTypeSchema.elements` or * `SliceDefinition.elements` when the elements context is created within a slice. */ elements: Record<string, ExtendedInternalSchemaElement>; /** * Similar mapping as `elements`, but with keys being the full path from the root resource rather * than relative to `path`, in other words, the keys of the Record are `${path}.${key}`. */ elementsByPath: Record<string, ExtendedInternalSchemaElement>; /** The URL, if any, of the resource profile or extension from which the `elements` collection originated. */ profileUrl: string | undefined; /** Whether debug logging is enabled */ debugMode: boolean; /** The `AccessPolicyResource` provided, if any, used to determine hidden and readonly elements. */ accessPolicyResource?: AccessPolicyResource; /** * Used to get an `ExtendedElementProperties` object for an element at a given path. This * is primarily useful when working with elements not included in `InternalTypeSchema.elements` * as is the case for nested elements that have not been modified by a profile or extension, * e.g. Patient.name.family. * * This function does not attempt to determine if the input `path` is actually an element in the * resource. When a syntactically correct path to a nonexistent element, e.g. Patient.foobar, is provided, * a `ExtendedElementProperties` object with default values is returned. * * @param path - The full path to an element in the resource, e.g. Patient.name.family * @returns An `ExtendedElementProperties` object with `readonly` and `hidden` properties for the * element at `path`, or `undefined` if the input path is malformed. */ getExtendedProps(path: string): ExtendedElementProperties | undefined; /** `true` if this is a default/placeholder `ElementsContextType` */ isDefaultContext?: boolean; }; export declare interface ElementType { code: string; targetProfile?: string[]; profile?: string[]; } export declare interface EmailPasswordLoginRequest extends BaseLoginRequest { readonly email: string; readonly password: string; /** @deprecated Use scope of "offline" or "offline_access" instead. */ readonly remember?: boolean; } export declare class EmptySetAtom implements Atom { eval(): []; toString(): string; } /** * Encodes a base64 string. * Handles both browser and Node environments. * Supports Unicode characters. * @param data - The unencoded input string. * @returns The base-64 encoded string. */ export declare function encodeBase64(data: string): string; /** * Encodes a string into Base64URL format. * This is the encoding required for JWT parts. * @param data - The unencoded input string. * @returns The Base64URL encoded string. */ export declare function encodeBase64Url(data: string): string; /** * Encrypts a string with SHA256 encryption. * @param str - The unencrypted input string. * @returns The encrypted value in an ArrayBuffer. */ export declare function encryptSHA256(str: string): Promise<ArrayBuffer>; /** * Ensures the given URL has no leading slash. * @param url - The URL to ensure has no leading slash. * @returns The URL string with no slash. */ export declare function ensureNoLeadingSlash(url: string): string; /** * Ensures the given URL has a trailing slash. * @param url - The URL to ensure has a trailing slash. * @returns The URL with a trailing slash. */ export declare function ensureTrailingSlash(url: string): string; export declare class EqualsAtom extends BooleanInfixOperatorAtom { constructor(left: Atom, right: Atom); eval(context: AtomContext, input: TypedValue[]): TypedValue[]; } export declare class EquivalentAtom extends BooleanInfixOperatorAtom { constructor(left: Atom, right: Atom); eval(context: AtomContext, input: TypedValue[]): TypedValue[]; } declare interface ErrorEvent_2 extends globalThis.Event { message: string; error: Error; } export { ErrorEvent_2 as ErrorEvent } /** * Returns the escaped HTML string of the input string. * @param unsafe - The unsafe HTML string to escape. * @returns The escaped HTML string. */ export declare function escapeHtml(unsafe: string): string; /** * Evaluates a FHIRPath expression against a resource or other object. * @param expression - The FHIRPath expression to evaluate. * @param input - The resource or object to evaluate the expression against. * @returns The result of the FHIRPath expression against the resource or object. */ export declare function evalFhirPath(expression: string | FhirPathAtom, input: unknown): unknown[]; /** * Evaluates a FHIRPath expression against a resource or other object. * @param expression - The FHIRPath expression to evaluate. * @param input - The resource or object to evaluate the expression against. * @param variables - A map of variables for eval input. * @param cache - Cache for parsed ASTs. * @returns The result of the FHIRPath expression against the resource or object. */ export declare function evalFhirPathTyped(expression: string | FhirPathAtom, input: TypedValue[], variables?: Record<string, TypedValue>, cache?: LRUCache<FhirPathAtom> | undefined): TypedValue[]; /** * Evaluates a SQL-on-FHIR view on a set of FHIR resources. * @param view - The view definition. * @param resources - The array of FHIR resources. * @returns The output rows. */ export declare function evalSqlOnFhir(view: ViewDefinition, resources: Resource[]): OutputRow[]; declare interface Event_2 { readonly type: string; readonly defaultPrevented?: boolean; } export { Event_2 as Event } declare type EventListener_2 = (e: Event_2) => void; export { EventListener_2 as EventListener } declare class EventTarget_2 { private readonly listeners; constructor(); addEventListener(type: string, callback: EventListener_2): void; removeEventListener(type: string, callback: EventListener_2): void; dispatchEvent(event: Event_2): boolean; removeAllListeners(): void; } export { EventTarget_2 as EventTarget } export declare function expandSampledData(sample: SampledData): number[]; export declare function expandSampledObservation(obs: Observation): Observation[]; export declare type ExtendedElementProperties = { readonly: boolean; hidden: boolean; }; export declare interface ExtendedInternalSchemaElement extends InternalSchemaElement { readonly?: boolean; } export declare type ExternalSecret<T extends ExternalSecretPrimitive = ExternalSecretPrimitive> = { system: ExternalSecretSystem; key: string; type: TypeName<T>; }; export declare type ExternalSecretPrimitive = string | boolean | number; export declare type ExternalSecretPrimitiveType = 'string' | 'boolean' | 'number'; export declare type ExternalSecretSystem = keyof typeof ExternalSecretSystems; export declare const ExternalSecretSystems: { readonly aws_ssm_parameter_store: "aws_ssm_parameter_store"; }; /** * Fetches the latest Medplum release version string. * @param appName - The name of the app to fetch the latest version for. * @returns A version string corresponding to the latest Medplum release version. */ export declare function fetchLatestVersionString(appName: string): Promise<string>; export declare type FetchLike = (url: string, options?: any) => Promise<any>; /** * Fetches the manifest for a given Medplum release version. * @param appName - The name of the app to fetch the manifest for. * @param version - The version to fetch. If no `version` is provided, defaults to the `latest` version. * @param params - An optional list of key-value pairs to be appended to the URL query string. * @returns - The manifest for the specified or latest version. */ export declare function fetchVersionManifest(appName: string, version?: string, params?: Record<string, string>): Promise<ReleaseManifest>; export declare const FHIRCAST_EVENT_NAMES: { readonly 'Patient-open': "Patient-open"; readonly 'Patient-close': "Patient-close"; readonly 'ImagingStudy-open': "ImagingStudy-open"; readonly 'ImagingStudy-close': "ImagingStudy-close"; readonly 'Encounter-open': "Encounter-open"; readonly 'Encounter-close': "Encounter-close"; readonly 'DiagnosticReport-open': "DiagnosticReport-open"; readonly 'DiagnosticReport-close': "DiagnosticReport-close"; readonly 'DiagnosticReport-select': "DiagnosticReport-select"; readonly 'DiagnosticReport-update': "DiagnosticReport-update"; readonly syncerror: "syncerror"; }; export declare const FHIRCAST_EVENT_RESOURCES: { readonly 'Patient-open': { readonly patient: { readonly resourceType: "Patient"; }; readonly encounter: { readonly resourceType: "Encounter"; readonly optional: true; }; }; readonly 'Patient-close': { readonly patient: { readonly resourceType: "Patient"; }; readonly encounter: { readonly resourceType: "Encounter"; readonly optional: true; }; }; readonly 'ImagingStudy-open': { readonly study: { readonly resourceType: "ImagingStudy"; }; readonly encounter: { readonly resourceType: "Encounter"; readonly optional: true; }; readonly patient: { readonly resourceType: "Patient"; readonly optional: true; }; }; readonly 'ImagingStudy-close': { readonly study: { readonly resourceType: "ImagingStudy"; }; readonly encounter: { readonly resourceType: "Encounter"; readonly optional: true; }; readonly patient: { readonly resourceType: "Patient"; readonly optional: true; }; }; readonly 'Encounter-open': { readonly encounter: { readonly resourceType: "Encounter"; }; readonly patient: { readonly resourceType: "Patient"; }; }; readonly 'Encounter-close': { readonly encounter: { readonly resourceType: "Encounter"; }; readonly patient: { readonly resourceType: "Patient"; }; }; readonly 'DiagnosticReport-open': { readonly report: { readonly resourceType: "DiagnosticReport"; }; readonly encounter: { readonly resourceType: "Encounter"; readonly optional: true; }; readonly study: { readonly resourceType: "ImagingStudy"; readonly optional: true; readonly manyAllowed: true; }; readonly patient: { readonly resourceType: "Patient"; }; }; readonly 'DiagnosticReport-close': { readonly report: { readonly resourceType: "DiagnosticReport"; }; readonly encounter: { readonly resourceType: "Encounter"; readonly optional: true; }; readonly study: { readonly resourceType: "ImagingStudy"; readonly optional: true; readonly manyAllowed: true; }; readonly patient: { readonly resourceType: "Patient"; }; }; readonly 'DiagnosticReport-select': { readonly report: { readonly resourceType: "DiagnosticReport"; readonly reference: true; }; readonly patient: { readonly resourceType: "Patient"; readonly optional: true; readonly reference: true; }; readonly select: { readonly resourceType: "*"; readonly reference: true; readonly manyAllowed: true; }; }; readonly 'DiagnosticReport-update': { readonly report: { readonly resourceType: "DiagnosticReport"; readonly reference: true; }; readonly patient: { readonly resourceType: "Patient"; readonly optional: true; readonly reference: true; }; readonly updates: { readonly resourceType: "Bundle"; }; }; readonly syncerror: { readonly operationoutcome: { readonly resourceType: "OperationOutcome"; }; }; }; export declare const FHIRCAST_EVENT_VERSION_REQUIRED: readonly ["DiagnosticReport-update"]; export declare const FHIRCAST_RESOURCE_TYPES: readonly ["Patient", "Encounter", "ImagingStudy", "DiagnosticReport", "OperationOutcome", "Bundle"]; export declare type FhircastAnchorResourceType = 'Patient' | 'ImagingStudy' | 'Encounter' | 'DiagnosticReport'; export declare type FhircastConnectEvent = { type: 'connect'; }; /** * 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. */ export declare class FhircastConnection extends TypedEventTarget<FhircastSubscriptionEventMap> { readonly subRequest: SubscriptionRequest; private readonly websocket; /** * Creates a new `FhircastConnection`. * @param subRequest - The subscription request to initialize the connection from. */ constructor(subRequest: SubscriptionRequest); disconnect(): void; } export declare type FhircastContextResourceType<EventName extends FhircastEventName, K extends FhircastEventKeys<EventName>> = (typeof FHIRCAST_EVENT_RESOURCES)[EventName][K] extends { resourceType: infer R; } ? R : never; export declare type FhircastDiagnosticReportCloseContext = FhircastDiagnosticReportOpenContext; export declare type FhircastDiagnosticReportOpenContext = FhircastReportContext | FhircastEncounterContext | FhircastStudyContext | FhircastPatientContext; export declare type FhircastDiagnosticReportSelectContext = FhircastReportReferenceContext | FhircastPatientReferenceContext | FhircastSelectContext; export declare type FhircastDiagnosticReportUpdateContext = FhircastReportReferenceContext | FhircastPatientReferenceContext | FhircastUpdatesContext; export declare type FhircastDisconnectEvent = { type: 'disconnect'; }; export declare type FhircastEncounterCloseContext = FhircastEncounterOpenContext; export declare type FhircastEncounterContext = { key: 'encounter'; resource: Encounter; }; export declare type FhircastEncounterOpenContext = FhircastEncounterContext | FhircastPatientContext; export declare type FhircastEventContext<EventName extends FhircastEventName = FhircastResourceEventName> = EventName extends 'Patient-open' ? FhircastPatientOpenContext : EventName extends 'Patient-close' ? FhircastPatientCloseContext : EventName extends 'ImagingStudy-open' ? FhircastImagingStudyOpenContext : EventName e