Skip to main content

@medplum/core

Enumerations

Classes

Interfaces

Type Aliases

QueryTypes

Ƭ QueryTypes: URLSearchParams | string[][] | Record<string, any> | string | undefined

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

Defined in

packages/core/src/client.ts:257


ResourceArray

Ƭ ResourceArray<T>: T[] & { bundle: Bundle<T> }

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.

Type parameters

NameType
Textends Resource = Resource

Defined in

packages/core/src/client.ts:264


BinarySource

Ƭ BinarySource: string | File | Blob | Uint8Array

Source for a FHIR Binary.

Defined in

packages/core/src/client.ts:397


MailDestination

Ƭ MailDestination: string | MailAddress | string[] | MailAddress[]

Email destination definition.

Defined in

packages/core/src/client.ts:411


EventListener

Ƭ EventListener: (e: Event) => void

Type declaration

▸ (e): void

Parameters
NameType
eEvent
Returns

void

Defined in

packages/core/src/eventtarget.ts:10


FhirFilterExpression

Ƭ FhirFilterExpression: FhirFilterComparison | FhirFilterNegation | FhirFilterConnective

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

Defined in

packages/core/src/filter/types.ts:8


ProfileResource

Ƭ ProfileResource: Patient | Practitioner | RelatedPerson

Defined in

packages/core/src/utils.ts:24


ResourceWithCode

Ƭ ResourceWithCode: Resource & Code

Defined in

packages/core/src/utils.ts:32

Variables

publicResourceTypes

Const publicResourceTypes: string[]

Public resource types are in the "public" project. They are available to all users.

Defined in

packages/core/src/access.ts:9


protectedResourceTypes

Const protectedResourceTypes: string[]

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

Defined in

packages/core/src/access.ts:26


projectAdminResourceTypes

Const projectAdminResourceTypes: string[]

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

Defined in

packages/core/src/access.ts:32


MEDPLUM_VERSION

Const MEDPLUM_VERSION: string

Defined in

packages/core/src/client.ts:55


ContentType

Const ContentType: Object

Content type constants.

Type declaration

NameType
CSSstring
FAVICONstring
FHIR_JSONstring
FORM_URL_ENCODEDstring
HL7_V2string
HTMLstring
JAVASCRIPTstring
JSONstring
JSON_PATCHstring
PNGstring
SVGstring
TEXTstring
TYPESCRIPTstring

Defined in

packages/core/src/contenttype.ts:4


allOk

Const allOk: OperationOutcome

Defined in

packages/core/src/outcomes.ts:14


created

Const created: OperationOutcome

Defined in

packages/core/src/outcomes.ts:28


notModified

Const notModified: OperationOutcome

Defined in

packages/core/src/outcomes.ts:42


notFound

Const notFound: OperationOutcome

Defined in

packages/core/src/outcomes.ts:56


unauthorized

Const unauthorized: OperationOutcome

Defined in

packages/core/src/outcomes.ts:70


forbidden

Const forbidden: OperationOutcome

Defined in

packages/core/src/outcomes.ts:84


gone

Const gone: OperationOutcome

Defined in

packages/core/src/outcomes.ts:98


tooManyRequests

Const tooManyRequests: OperationOutcome

Defined in

packages/core/src/outcomes.ts:112


DEFAULT_SEARCH_COUNT

Const DEFAULT_SEARCH_COUNT: 20

Defined in

packages/core/src/search/search.ts:5


globalSchema

Const globalSchema: IndexedStructureDefinition

Global schema singleton.

Defined in

packages/core/src/types.ts:463

Functions

canReadResourceType

canReadResourceType(accessPolicy, resourceType): boolean

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

Parameters

NameTypeDescription
accessPolicyAccessPolicyThe access policy.
resourceType"Observation" | "Patient" | "Practitioner" | "RelatedPerson" | "AccessPolicy" | "Account" | "ActivityDefinition" | "AdverseEvent" | "Agent" | "AllergyIntolerance" | "Appointment" | "AppointmentResponse" | "AsyncJob" | "AuditEvent" | "Basic" | "Binary" | "BiologicallyDerivedProduct" | "BodyStructure" | "Bot" | "BulkDataExport" | "Bundle" | "CapabilityStatement" | "CarePlan" | "CareTeam" | "CatalogEntry" | "ChargeItem" | "ChargeItemDefinition" | "Claim" | "ClaimResponse" | "ClientApplication" | "ClinicalImpression" | "CodeSystem" | "Communication" | "CommunicationRequest" | "CompartmentDefinition" | "Composition" | "ConceptMap" | "Condition" | "Consent" | "Contract" | "Coverage" | "CoverageEligibilityRequest" | "CoverageEligibilityResponse" | "DetectedIssue" | "Device" | "DeviceDefinition" | "DeviceMetric" | "DeviceRequest" | "DeviceUseStatement" | "DiagnosticReport" | "DocumentManifest" | "DocumentReference" | "DomainConfiguration" | "EffectEvidenceSynthesis" | "Encounter" | "Endpoint" | "EnrollmentRequest" | "EnrollmentResponse" | "EpisodeOfCare" | "EventDefinition" | "Evidence" | "EvidenceVariable" | "ExampleScenario" | "ExplanationOfBenefit" | "FamilyMemberHistory" | "Flag" | "Goal" | "GraphDefinition" | "Group" | "GuidanceResponse" | "HealthcareService" | "ImagingStudy" | "Immunization" | "ImmunizationEvaluation" | "ImmunizationRecommendation" | "ImplementationGuide" | "InsurancePlan" | "Invoice" | "JsonWebKey" | "Library" | "Linkage" | "List" | "Location" | "Login" | "Measure" | "MeasureReport" | "Media" | "Medication" | "MedicationAdministration" | "MedicationDispense" | "MedicationKnowledge" | "MedicationRequest" | "MedicationStatement" | "MedicinalProduct" | "MedicinalProductAuthorization" | "MedicinalProductContraindication" | "MedicinalProductIndication" | "MedicinalProductIngredient" | "MedicinalProductInteraction" | "MedicinalProductManufactured" | "MedicinalProductPackaged" | "MedicinalProductPharmaceutical" | "MedicinalProductUndesirableEffect" | "MessageDefinition" | "MessageHeader" | "MolecularSequence" | "NamingSystem" | "NutritionOrder" | "ObservationDefinition" | "OperationDefinition" | "OperationOutcome" | "Organization" | "OrganizationAffiliation" | "Parameters" | "PasswordChangeRequest" | "PaymentNotice" | "PaymentReconciliation" | "Person" | "PlanDefinition" | "PractitionerRole" | "Procedure" | "Project" | "ProjectMembership" | "Provenance" | "Questionnaire" | "QuestionnaireResponse" | "RequestGroup" | "ResearchDefinition" | "ResearchElementDefinition" | "ResearchStudy" | "ResearchSubject" | "RiskAssessment" | "RiskEvidenceSynthesis" | "Schedule" | "SearchParameter" | "ServiceRequest" | "Slot" | "SmartAppLaunch" | "Specimen" | "SpecimenDefinition" | "StructureDefinition" | "StructureMap" | "Subscription" | "Substance" | "SubstanceNucleicAcid" | "SubstancePolymer" | "SubstanceProtein" | "SubstanceReferenceInformation" | "SubstanceSourceMaterial" | "SubstanceSpecification" | "SupplyDelivery" | "SupplyRequest" | "Task" | "TerminologyCapabilities" | "TestReport" | "TestScript" | "User" | "UserConfiguration" | "ValueSet" | "VerificationResult" | "VisionPrescription"The resource type.

Returns

boolean

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

Defined in

packages/core/src/access.ts:72


canWriteResourceType

canWriteResourceType(accessPolicy, resourceType): 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.

Parameters

NameTypeDescription
accessPolicyAccessPolicyThe access policy.
resourceType"Observation" | "Patient" | "Practitioner" | "RelatedPerson" | "AccessPolicy" | "Account" | "ActivityDefinition" | "AdverseEvent" | "Agent" | "AllergyIntolerance" | "Appointment" | "AppointmentResponse" | "AsyncJob" | "AuditEvent" | "Basic" | "Binary" | "BiologicallyDerivedProduct" | "BodyStructure" | "Bot" | "BulkDataExport" | "Bundle" | "CapabilityStatement" | "CarePlan" | "CareTeam" | "CatalogEntry" | "ChargeItem" | "ChargeItemDefinition" | "Claim" | "ClaimResponse" | "ClientApplication" | "ClinicalImpression" | "CodeSystem" | "Communication" | "CommunicationRequest" | "CompartmentDefinition" | "Composition" | "ConceptMap" | "Condition" | "Consent" | "Contract" | "Coverage" | "CoverageEligibilityRequest" | "CoverageEligibilityResponse" | "DetectedIssue" | "Device" | "DeviceDefinition" | "DeviceMetric" | "DeviceRequest" | "DeviceUseStatement" | "DiagnosticReport" | "DocumentManifest" | "DocumentReference" | "DomainConfiguration" | "EffectEvidenceSynthesis" | "Encounter" | "Endpoint" | "EnrollmentRequest" | "EnrollmentResponse" | "EpisodeOfCare" | "EventDefinition" | "Evidence" | "EvidenceVariable" | "ExampleScenario" | "ExplanationOfBenefit" | "FamilyMemberHistory" | "Flag" | "Goal" | "GraphDefinition" | "Group" | "GuidanceResponse" | "HealthcareService" | "ImagingStudy" | "Immunization" | "ImmunizationEvaluation" | "ImmunizationRecommendation" | "ImplementationGuide" | "InsurancePlan" | "Invoice" | "JsonWebKey" | "Library" | "Linkage" | "List" | "Location" | "Login" | "Measure" | "MeasureReport" | "Media" | "Medication" | "MedicationAdministration" | "MedicationDispense" | "MedicationKnowledge" | "MedicationRequest" | "MedicationStatement" | "MedicinalProduct" | "MedicinalProductAuthorization" | "MedicinalProductContraindication" | "MedicinalProductIndication" | "MedicinalProductIngredient" | "MedicinalProductInteraction" | "MedicinalProductManufactured" | "MedicinalProductPackaged" | "MedicinalProductPharmaceutical" | "MedicinalProductUndesirableEffect" | "MessageDefinition" | "MessageHeader" | "MolecularSequence" | "NamingSystem" | "NutritionOrder" | "ObservationDefinition" | "OperationDefinition" | "OperationOutcome" | "Organization" | "OrganizationAffiliation" | "Parameters" | "PasswordChangeRequest" | "PaymentNotice" | "PaymentReconciliation" | "Person" | "PlanDefinition" | "PractitionerRole" | "Procedure" | "Project" | "ProjectMembership" | "Provenance" | "Questionnaire" | "QuestionnaireResponse" | "RequestGroup" | "ResearchDefinition" | "ResearchElementDefinition" | "ResearchStudy" | "ResearchSubject" | "RiskAssessment" | "RiskEvidenceSynthesis" | "Schedule" | "SearchParameter" | "ServiceRequest" | "Slot" | "SmartAppLaunch" | "Specimen" | "SpecimenDefinition" | "StructureDefinition" | "StructureMap" | "Subscription" | "Substance" | "SubstanceNucleicAcid" | "SubstancePolymer" | "SubstanceProtein" | "SubstanceReferenceInformation" | "SubstanceSourceMaterial" | "SubstanceSpecification" | "SupplyDelivery" | "SupplyRequest" | "Task" | "TerminologyCapabilities" | "TestReport" | "TestScript" | "User" | "UserConfiguration" | "ValueSet" | "VerificationResult" | "VisionPrescription"The resource type.

Returns

boolean

True if the current user can write the specified resource type.

Defined in

packages/core/src/access.ts:91


canWriteResource

canWriteResource(accessPolicy, resource): 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.

Parameters

NameTypeDescription
accessPolicyAccessPolicyThe access policy.
resourceResourceThe resource.

Returns

boolean

True if the current user can write the specified resource type.

Defined in

packages/core/src/access.ts:115


matchesAccessPolicy

matchesAccessPolicy(accessPolicy, resource, readonlyMode): boolean

Returns true if the resource satisfies the current access policy.

Parameters

NameTypeDescription
accessPolicyAccessPolicyThe access policy.
resourceResourceThe resource.
readonlyModebooleanTrue if the resource is being read.

Returns

boolean

True if the resource matches the access policy.

Deprecated

Use satisfiedAccessPolicy() instead.

Defined in

packages/core/src/access.ts:131


satisfiedAccessPolicy

satisfiedAccessPolicy(resource, interaction, accessPolicy): AccessPolicyResource | undefined

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

Parameters

NameTypeDescription
resourceResourceThe resource being acted upon.
interactionAccessPolicyInteractionThe interaction being performed on the resource.
accessPolicyundefined | AccessPolicyThe relevant access policy for the current user.

Returns

AccessPolicyResource | undefined

The satisfied access policy, or undefined if the access policy does not permit the given interaction.

Defined in

packages/core/src/access.ts:155


decodeBase64

decodeBase64(data): string

Decodes a base64 string. Handles both browser and Node environments.

Parameters

NameTypeDescription
datastringThe base-64 encoded input string.

Returns

string

The decoded string.

Defined in

packages/core/src/base64.ts:7


encodeBase64

encodeBase64(data): string

Encodes a base64 string. Handles both browser and Node environments.

Parameters

NameTypeDescription
datastringThe unencoded input string.

Returns

string

The base-64 encoded string.

Defined in

packages/core/src/base64.ts:23


convertToTransactionBundle

convertToTransactionBundle(bundle): Bundle

Takes a bundle and creates a Transaction Type bundle

Parameters

NameTypeDescription
bundleBundle<Resource>The Bundle object that we'll receive from the search query

Returns

Bundle

transaction type bundle

Defined in

packages/core/src/bundle.ts:16


reorderBundle

reorderBundle(bundle): 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

Parameters

NameTypeDescription
bundleBundle<Resource>Input bundle with type batch or transaction

Returns

Bundle

Bundle of the same type, with Bundle.entry reordered

Defined in

packages/core/src/bundle.ts:71


getRandomString

getRandomString(): string

Returns a cryptographically secure random string.

Returns

string

A cryptographically secure random string.

Defined in

packages/core/src/crypto.ts:7


encryptSHA256

encryptSHA256(str): Promise<ArrayBuffer>

Encrypts a string with SHA256 encryption.

Parameters

NameTypeDescription
strstringThe unencrypted input string.

Returns

Promise<ArrayBuffer>

The encrypted value in an ArrayBuffer.

Defined in

packages/core/src/crypto.ts:18


generateId

generateId(): 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

string

A random UUID.

Defined in

packages/core/src/crypto.ts:29


parseMappingLanguage

parseMappingLanguage(input): StructureMap

Parses a FHIR Mapping Language document into an AST.

Parameters

NameTypeDescription
inputstringThe FHIR Mapping Language document to parse.

Returns

StructureMap

The AST representing the document.

Defined in

packages/core/src/fhirmapper/parse.ts:369


parseFilterParameter

parseFilterParameter(input): FhirFilterExpression

Parses a FHIR _filter parameter expression into an AST.

Parameters

NameTypeDescription
inputstringThe FHIR _filter parameter expression.

Returns

FhirFilterExpression

The AST representing the filters.

Defined in

packages/core/src/filter/parse.ts:101


formatAddress

formatAddress(address, options?): string

Formats a FHIR Address as a string.

Parameters

NameTypeDescription
addressAddressThe address to format.
options?AddressFormatOptionsOptional address format options.

Returns

string

The formatted address string.

Defined in

packages/core/src/format.ts:36


formatHumanName

formatHumanName(name, options?): string

Formats a FHIR HumanName as a string.

Parameters

NameTypeDescription
nameHumanNameThe name to format.
options?HumanNameFormatOptionsOptional name format options.

Returns

string

The formatted name string.

Defined in

packages/core/src/format.ts:70


formatGivenName

formatGivenName(name): string

Formats the given name portion of a FHIR HumanName element.

Parameters

NameTypeDescription
nameHumanNameThe name to format.

Returns

string

The formatted given name string.

Defined in

packages/core/src/format.ts:101


formatFamilyName

formatFamilyName(name): string

Formats the family name portion of a FHIR HumanName element.

Parameters

NameTypeDescription
nameHumanNameThe name to format.

Returns

string

The formatted family name string.

Defined in

packages/core/src/format.ts:114


isValidDate

isValidDate(date): boolean

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

Parameters

NameTypeDescription
dateDateA date object.

Returns

boolean

Returns true if the date is a valid date.

Defined in

packages/core/src/format.ts:124


formatDate

formatDate(date, locales?, options?): string

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

Parameters

NameTypeDescription
dateundefined | stringThe date to format.
locales?LocalesArgumentOptional locales.
options?DateTimeFormatOptionsOptional date format options.

Returns

string

The formatted date string.

Defined in

packages/core/src/format.ts:136


formatTime

formatTime(time, locales?, options?): string

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

Parameters

NameTypeDescription
timeundefined | stringThe date to format.
locales?LocalesArgumentOptional locales.
options?DateTimeFormatOptionsOptional time format options.

Returns

string

The formatted time string.

Defined in

packages/core/src/format.ts:160


formatDateTime

formatDateTime(dateTime, locales?, options?): string

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

Parameters

NameTypeDescription
dateTimeundefined | stringThe dateTime to format.
locales?LocalesArgumentOptional locales.
options?DateTimeFormatOptionsOptional dateTime format options.

Returns

string

The formatted dateTime string.

Defined in

packages/core/src/format.ts:183


formatPeriod

formatPeriod(period, locales?, options?): string

Formats a FHIR Period as a human readable string.

Parameters

NameTypeDescription
periodundefined | PeriodThe period to format.
locales?LocalesArgumentOptional locales.
options?DateTimeFormatOptionsOptional period format options.

Returns

string

The formatted period string.

Defined in

packages/core/src/format.ts:205


formatTiming

formatTiming(timing): string

Formats a FHIR Timing as a human readable string.

Parameters

NameTypeDescription
timingundefined | TimingThe timing to format.

Returns

string

The formatted timing string.

Defined in

packages/core/src/format.ts:251


formatRange

formatRange(range, precision?, exclusive?): string

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

Parameters

NameTypeDefault valueDescription
rangeundefined | RangeundefinedA FHIR Range element
precision?numberundefinedNumber of decimal places to display in the rendered quantity values
exclusivebooleanfalseIf true, one-sided ranges will be rendered with the '>' or '<' bounds rather than '>=' or '<='

Returns

string

A human-readable string representation of the Range

Defined in

packages/core/src/format.ts:313


formatQuantity

formatQuantity(quantity, precision?): string

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

Parameters

NameTypeDescription
quantityundefined | QuantityA FHIR Quantity element
precision?numberNumber of decimal places to display in the rendered quantity values

Returns

string

A human-readable string representation of the Quantity

Defined in

packages/core/src/format.ts:355


formatMoney

formatMoney(money): string

Parameters

NameType
moneyundefined | Money

Returns

string

Defined in

packages/core/src/format.ts:385


formatCodeableConcept

formatCodeableConcept(codeableConcept): string

Formats a CodeableConcept element as a string.

Parameters

NameTypeDescription
codeableConceptundefined | CodeableConceptA FHIR CodeableConcept element

Returns

string

The codeable concept as a string.

Defined in

packages/core/src/format.ts:402


formatCoding

formatCoding(coding): string

Formats a Coding element as a string.

Parameters

NameTypeDescription
codingundefined | CodingA FHIR Coding element

Returns

string

The coding as a string.

Defined in

packages/core/src/format.ts:420


formatObservationValue

formatObservationValue(obs): string

Formats a FHIR Observation resource value as a string.

Parameters

NameTypeDescription
obsundefined | Observation | ObservationComponentA FHIR Observation resource.

Returns

string

A human-readable string representation of the Observation.

Defined in

packages/core/src/format.ts:429


parseHl7DateTime

parseHl7DateTime(hl7DateTime, options?): string | undefined

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].

Parameters

NameTypeDescription
hl7DateTimeundefined | stringDate/time string.
options?Hl7DateParseOptionsOptional parsing options.

Returns

string | undefined

The date in ISO-8601 format.

Defined in

packages/core/src/hl7.ts:410


formatHl7DateTime

formatHl7DateTime(isoDate): string

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

Parameters

NameTypeDescription
isoDatestring | DateThe ISO date/time string.

Returns

string

The HL7 date/time string.

Defined in

packages/core/src/hl7.ts:486


parseJWTPayload

parseJWTPayload(token): Record<string, number | string>

Parses the JWT payload.

Parameters

NameTypeDescription
tokenstringJWT token.

Returns

Record<string, number | string>

Collection of key value claims in the JWT payload.

Defined in

packages/core/src/jwt.ts:25


isMedplumAccessToken

isMedplumAccessToken(accessToken): boolean

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

Parameters

NameTypeDescription
accessTokenstringAn access token of unknown origin.

Returns

boolean

True if the access token was issued by a Medplum server.

Defined in

packages/core/src/jwt.ts:35


accepted

accepted(location): OperationOutcome

Parameters

NameType
locationstring

Returns

OperationOutcome

Defined in

packages/core/src/outcomes.ts:126


badRequest

badRequest(details, expression?): OperationOutcome

Parameters

NameType
detailsstring
expression?string

Returns

OperationOutcome

Defined in

packages/core/src/outcomes.ts:143


validationError

validationError(details): OperationOutcome

Parameters

NameType
detailsstring

Returns

OperationOutcome

Defined in

packages/core/src/outcomes.ts:159


serverError

serverError(err): OperationOutcome

Parameters

NameType
errError

Returns

OperationOutcome

Defined in

packages/core/src/outcomes.ts:174


isOperationOutcome

isOperationOutcome(value): value is OperationOutcome

Parameters

NameType
valueunknown

Returns

value is OperationOutcome

Defined in

packages/core/src/outcomes.ts:190


isOk

isOk(outcome): boolean

Parameters

NameType
outcomeOperationOutcome

Returns

boolean

Defined in

packages/core/src/outcomes.ts:194


isAccepted

isAccepted(outcome): boolean

Parameters

NameType
outcomeOperationOutcome

Returns

boolean

Defined in

packages/core/src/outcomes.ts:200


isNotFound

isNotFound(outcome): boolean

Parameters

NameType
outcomeOperationOutcome

Returns

boolean

Defined in

packages/core/src/outcomes.ts:204


isGone

isGone(outcome): boolean

Parameters

NameType
outcomeOperationOutcome

Returns

boolean

Defined in

packages/core/src/outcomes.ts:208


getStatus

getStatus(outcome): number

Parameters

NameType
outcomeOperationOutcome

Returns

number

Defined in

packages/core/src/outcomes.ts:212


assertOk

assertOk<T>(outcome, resource): asserts resource is T

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

Type parameters

Name
T

Parameters

NameTypeDescription
outcomeOperationOutcomeThe operation outcome.
resourceundefined | TThe resource that may or may not have been returned.

Returns

asserts resource is T

Defined in

packages/core/src/outcomes.ts:241


normalizeOperationOutcome

normalizeOperationOutcome(error): OperationOutcome

Normalizes an error object into an OperationOutcome.

Parameters

NameTypeDescription
errorunknownThe error value which could be a string, Error, OperationOutcome, or other unknown type.

Returns

OperationOutcome

The normalized OperationOutcome.

Defined in

packages/core/src/outcomes.ts:262


normalizeErrorString

normalizeErrorString(error): string

Normalizes an error object into a displayable error string.

Parameters

NameTypeDescription
errorunknownThe error value which could be a string, Error, OperationOutcome, or other unknown type.

Returns

string

A display string for the error.

Defined in

packages/core/src/outcomes.ts:277


operationOutcomeToString

operationOutcomeToString(outcome): string

Returns a string represenation of the operation outcome.

Parameters

NameTypeDescription
outcomeOperationOutcomeThe operation outcome.

Returns

string

The string representation of the operation outcome.

Defined in

packages/core/src/outcomes.ts:301


operationOutcomeIssueToString

operationOutcomeIssueToString(issue): string

Returns a string represenation of the operation outcome issue.

Parameters

NameTypeDescription
issueOperationOutcomeIssueThe operation outcome issue.

Returns

string

The string representation of the operation outcome issue.

Defined in

packages/core/src/outcomes.ts:311


createStructureIssue

createStructureIssue(expression, details): OperationOutcomeIssue

Parameters

NameType
expressionstring
detailsstring

Returns

OperationOutcomeIssue

Defined in

packages/core/src/outcomes.ts:336


createConstraintIssue

createConstraintIssue(expression, constraint): OperationOutcomeIssue

Parameters

NameType
expressionstring
constraintConstraint

Returns

OperationOutcomeIssue

Defined in

packages/core/src/outcomes.ts:340


createProcessingIssue

createProcessingIssue(expression, message, err, data?): OperationOutcomeIssue

Parameters

NameType
expressionstring
messagestring
errError
data?Record<string, any>

Returns

OperationOutcomeIssue

Defined in

packages/core/src/outcomes.ts:346


isResourceType

isResourceType(resourceType): boolean

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

isResourceType('Patient'); // true
isResourceType('XYZ'); // false

Note that this depends on globalSchema, which is populated by the StructureDefinition loader.

In a server context, you can load all schema definitions:

import { indexStructureDefinitionBundle } from '@medplum/core';
import { readJson } from '@medplum/definitions';
import { Bundle } from '@medplum/fhirtypes';

indexStructureDefinitionBundle(readJson('fhir/r4/profiles-resources.json') as Bundle);

In a client context, you can load the schema definitions using MedplumClient:

import { MedplumClient } from '@medplum/core';

const medplum = new MedplumClient();
await medplum.requestSchema('Patient');

Parameters

NameTypeDescription
resourceTypestringThe candidate resource type string.

Returns

boolean

True if the resource type is a valid FHIR resource type.

Defined in

packages/core/src/schema.ts:83


validateResourceType

validateResourceType(resourceType): void

Validates that the given string is a valid FHIR resource type. On success, silently returns void. On failure, throws an OperationOutcomeError.

validateResourceType('Patient'); // nothing
validateResourceType('XYZ'); // throws OperationOutcomeError

Note that this depends on globalSchema, which is populated by the StructureDefinition loader.

In a server context, you can load all schema definitions:

import { indexStructureDefinitionBundle } from '@medplum/core';
import { readJson } from '@medplum/definitions';
import { Bundle } from '@medplum/fhirtypes';

indexStructureDefinitionBundle(readJson('fhir/r4/profiles-resources.json') as Bundle);

In a client context, you can load the schema definitions using MedplumClient:

import { MedplumClient } from '@medplum/core';

const medplum = new MedplumClient();
await medplum.requestSchema('Patient');

Parameters

NameTypeDescription
resourceTypestringThe candidate resource type string.

Returns

void

Defined in

packages/core/src/schema.ts:124


validateResource

validateResource<T>(resource): void

Validates a candidate FHIR resource object. On success, silently returns void. On failure, throws an OperationOutcomeError with issues for each violation.

validateResource({ resourceType: 'Patient' }); // nothing
validateResource({ resourceType: 'XYZ' }); // throws OperationOutcomeError

Note that this depends on globalSchema, which is populated by the StructureDefinition loader.

In a server context, you can load all schema definitions:

import { indexStructureDefinitionBundle } from '@medplum/core';
import { readJson } from '@medplum/definitions';
import { Bundle } from '@medplum/fhirtypes';

indexStructureDefinitionBundle(readJson('fhir/r4/profiles-resources.json') as Bundle);

In a client context, you can load the schema definitions using MedplumClient:

import { MedplumClient } from '@medplum/core';

const medplum = new MedplumClient();
await medplum.requestSchema('Patient');

Type parameters

NameType
Textends Resource

Parameters

NameTypeDescription
resourceTThe candidate resource.

Returns

void

Deprecated

use validate() instead

Defined in

packages/core/src/schema.ts:166


checkForNull

checkForNull(value, path, issues): void

Recursively checks for null values in an object.

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

Parameters

NameTypeDescription
valueunknownInput value of any type.
pathstringPath string to the value for OperationOutcome.
issuesOperationOutcomeIssue[]Output list of issues.

Returns

void

Defined in

packages/core/src/schema.ts:441


getSearchParameterDetails

getSearchParameterDetails(resourceType, searchParam): SearchParameterDetails

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.

Parameters

NameTypeDescription
resourceTypestringThe root resource type.
searchParamSearchParameterThe search parameter.

Returns

SearchParameterDetails

The search parameter type details.

Defined in

packages/core/src/search/details.ts:55


getExpressionsForResourceType

getExpressionsForResourceType(resourceType, expression): Atom[]

Parameters

NameType
resourceTypestring
expressionstring

Returns

Atom[]

Defined in

packages/core/src/search/details.ts:223


getExpressionForResourceType

getExpressionForResourceType(resourceType, expression): string | undefined

Parameters

NameType
resourceTypestring
expressionstring

Returns

string | undefined

Defined in

packages/core/src/search/details.ts:230


matchesSearchRequest

matchesSearchRequest(resource, searchRequest): boolean

Determines if the resource matches the search request.

Parameters

NameTypeDescription
resourceResourceThe resource that was created or updated.
searchRequestSearchRequest<Resource>The subscription criteria as a search request.

Returns

boolean

True if the resource satisfies the search request.

Defined in

packages/core/src/search/match.ts:13


parseSearchRequest

parseSearchRequest<T>(resourceType, query): SearchRequest<T>

Parses a search URL into a search request.

Type parameters

NameType
Textends Resource = Resource

Parameters

NameTypeDescription
resourceTypeT["resourceType"]The FHIR resource type.
queryRecord<string, undefined | string | string[]>The collection of query string parameters.

Returns

SearchRequest<T>

A parsed SearchRequest.

Defined in

packages/core/src/search/search.ts:126


parseSearchUrl

parseSearchUrl<T>(url): SearchRequest<T>

Parses a search URL into a search request.

Type parameters

NameType
Textends Resource = Resource

Parameters

NameTypeDescription
urlURLThe search URL.

Returns

SearchRequest<T>

A parsed SearchRequest.

Defined in

packages/core/src/search/search.ts:148


parseSearchDefinition

parseSearchDefinition<T>(url): SearchRequest<T>

Parses a URL string into a SearchRequest.

Type parameters

NameType
Textends Resource = Resource

Parameters

NameTypeDescription
urlstringThe URL to parse.

Returns

SearchRequest<T>

Parsed search definition.

Defined in

packages/core/src/search/search.ts:158


parseCriteriaAsSearchRequest

parseCriteriaAsSearchRequest(criteria): SearchRequest

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

Parameters

NameTypeDescription
criteriastringThe FHIR criteria string.

Returns

SearchRequest

Parsed search definition.

Defined in

packages/core/src/search/search.ts:168


formatSearchQuery

formatSearchQuery(definition): string

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

Parameters

NameTypeDescription
definitionSearchRequest<Resource>The search definition.

Returns

string

Formatted URL.

Defined in

packages/core/src/search/search.ts:416


streamToBuffer

streamToBuffer(stream): Promise<Buffer>

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

Parameters

NameTypeDescription
streamReadableThe Readable stream to read from.

Returns

Promise<Buffer>

A Promise that resolves with a Buffer containing all the data from the Readable stream.

Defined in

packages/core/src/sftp.ts:8


indexStructureDefinitionBundle

indexStructureDefinitionBundle(bundle): void

Indexes a bundle of StructureDefinitions for faster lookup.

Parameters

NameTypeDescription
bundleBundle<Resource>A FHIR bundle StructureDefinition resources.

Returns

void

See

IndexedStructureDefinition for more details on indexed StructureDefinitions.

Defined in

packages/core/src/types.ts:140


indexStructureDefinition

indexStructureDefinition(structureDefinition): void

Indexes a StructureDefinition for fast lookup.

Parameters

NameTypeDescription
structureDefinitionStructureDefinitionThe original StructureDefinition.

Returns

void

See

IndexedStructureDefinition for more details on indexed StructureDefinitions.

Defined in

packages/core/src/types.ts:154


indexSearchParameterBundle

indexSearchParameterBundle(bundle): void

Indexes a bundle of SearchParameter resources for faster lookup.

Parameters

NameTypeDescription
bundleBundle<SearchParameter>A FHIR bundle SearchParameter resources.

Returns

void

See

IndexedStructureDefinition for more details on indexed StructureDefinitions.

Defined in

packages/core/src/types.ts:237


indexSearchParameter

indexSearchParameter(searchParam): void

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

Parameters

NameTypeDescription
searchParamSearchParameterThe SearchParameter resource.

Returns

void

See

IndexedStructureDefinition for more details on indexed StructureDefinitions.

Defined in

packages/core/src/types.ts:252


getElementDefinitionTypeName

getElementDefinitionTypeName(elementDefinition): string

Returns the type name for an ElementDefinition.

Parameters

NameTypeDescription
elementDefinitionElementDefinitionThe element definition.

Returns

string

The Medplum type name.

Defined in

packages/core/src/types.ts:315


buildTypeName

buildTypeName(components): string

Parameters

NameType
componentsstring[]

Returns

string

Defined in

packages/core/src/types.ts:322


isResourceTypeSchema

isResourceTypeSchema(typeSchema): boolean

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

Parameters

NameTypeDescription
typeSchemaTypeSchemaThe type schema to check.

Returns

boolean

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

Defined in

packages/core/src/types.ts:334


getResourceTypes

getResourceTypes(): ResourceType[]

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

ResourceType[]

An array of all resource types.

Defined in

packages/core/src/types.ts:349


getResourceTypeSchema

getResourceTypeSchema(resourceType): TypeSchema

Returns the type schema for the resource type.

Parameters

NameTypeDescription
resourceTypestringThe resource type.

Returns

TypeSchema

The type schema for the resource type.

Defined in

packages/core/src/types.ts:364


getSearchParameters

getSearchParameters(resourceType): Record<string, SearchParameter> | undefined

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

Parameters

NameTypeDescription
resourceTypestringThe resource type.

Returns

Record<string, SearchParameter> | undefined

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

Defined in

packages/core/src/types.ts:373


getPropertyDisplayName

getPropertyDisplayName(path): string

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

Parameters

NameTypeDescription
pathstringThe FHIR element definition path.

Returns

string

The best guess of the display name.

Defined in

packages/core/src/types.ts:382


getElementDefinition

getElementDefinition(typeName, propertyName): ElementDefinition | undefined

Returns an element definition by type and property name. Handles content references.

Parameters

NameTypeDescription
typeNamestringThe type name.
propertyNamestringThe property name.

Returns

ElementDefinition | undefined

The element definition if found.

Defined in

packages/core/src/types.ts:419


isResource

isResource(value): value is Resource

Typeguard to validate that an object is a FHIR resource

Parameters

NameTypeDescription
valueunknownThe object to check

Returns

value is Resource

True if the input is of type 'object' and contains property 'resourceType'

Defined in

packages/core/src/types.ts:447


isReference

isReference(value): value is Reference<Resource> & Object

Typeguard to validate that an object is a FHIR resource

Parameters

NameTypeDescription
valueunknownThe object to check

Returns

value is Reference<Resource> & Object

True if the input is of type 'object' and contains property 'reference'

Defined in

packages/core/src/types.ts:456


parseStructureDefinition

parseStructureDefinition(sd): InternalTypeSchema

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

Parameters

NameTypeDescription
sdStructureDefinitionThe StructureDefinition resource to parse

Returns

InternalTypeSchema

The parsed schema for the given resource type

Defined in

packages/core/src/typeschema/types.ts:70


loadDataTypes

loadDataTypes(bundle): void

Parameters

NameType
bundleBundle<StructureDefinition>

Returns

void

Defined in

packages/core/src/typeschema/types.ts:76


getDataType

getDataType(type): InternalTypeSchema

Parameters

NameType
typestring

Returns

InternalTypeSchema

Defined in

packages/core/src/typeschema/types.ts:92


subsetResource

subsetResource<T>(resource, properties): T | undefined

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)

Type parameters

NameType
Textends Resource

Parameters

NameTypeDescription
resourceundefined | TThe resource to subset
propertiesstring[]The minimum properties to include in the subset

Returns

T | undefined

The modified resource, containing the listed properties and possibly other mandatory ones

Defined in

packages/core/src/typeschema/types.ts:347


validate

validate(resource, profile?): void

Parameters

NameType
resourceResource
profile?StructureDefinition

Returns

void

Defined in

packages/core/src/typeschema/validation.ts:84


createReference

createReference<T>(resource): Reference<T>

Creates a reference resource.

Type parameters

NameType
Textends Resource

Parameters

NameTypeDescription
resourceTThe FHIR reesource.

Returns

Reference<T>

A reference resource.

Defined in

packages/core/src/utils.ts:39


getReferenceString

getReferenceString(resource): string

Returns a reference string for a resource.

Parameters

NameTypeDescription
resourceResourceThe FHIR resource.

Returns

string

A reference string of the form resourceType/id.

Defined in

packages/core/src/utils.ts:50


resolveId

resolveId(reference): string | undefined

Returns the ID portion of a reference.

Parameters

NameTypeDescription
referenceundefined | Reference<Resource>A FHIR reference.

Returns

string | undefined

The ID portion of a reference.

Defined in

packages/core/src/utils.ts:59


parseReference

parseReference(reference): [ResourceType, string] | undefined

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

Parameters

NameTypeDescription
referenceReference<Resource>A reference to a FHIR resource.

Returns

[ResourceType, string] | undefined

A tuple containing the ResourceType and the ID of the resource or undefined when undefined or an invalid reference is passed.

Defined in

packages/core/src/utils.ts:68

parseReference(reference): undefined

Parameters

NameType
referenceundefined

Returns

undefined

Defined in

packages/core/src/utils.ts:69


isProfileResource

isProfileResource(resource): resource is ProfileResource

Returns true if the resource is a "ProfileResource".

Parameters

NameTypeDescription
resourceResourceThe FHIR resource.

Returns

resource is ProfileResource

True if the resource is a "ProfileResource".

Defined in

packages/core/src/utils.ts:86


getDisplayString

getDisplayString(resource): string

Returns a display string for the resource.

Parameters

NameTypeDescription
resourceResourceThe input resource.

Returns

string

Human friendly display string.

Defined in

packages/core/src/utils.ts:99


getImageSrc

getImageSrc(resource): string | undefined

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

Parameters

NameTypeDescription
resourceResourceThe input resource.

Returns

string | undefined

The image URL for the resource or undefined.

Defined in

packages/core/src/utils.ts:159


getDateProperty

getDateProperty(date): Date | undefined

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.

Parameters

NameTypeDescription
dateundefined | stringThe date property value, which could be a string or a Date object.

Returns

Date | undefined

A Date object.

Defined in

packages/core/src/utils.ts:197


calculateAge

calculateAge(birthDateStr, endDateStr?): Object

Calculates the age in years from the birth date.

Parameters

NameTypeDescription
birthDateStrstringThe birth date or start date in ISO-8601 format YYYY-MM-DD.
endDateStr?stringOptional end date in ISO-8601 format YYYY-MM-DD. Default value is today.

Returns

Object

The age in years, months, and days.

NameType
yearsnumber
monthsnumber
daysnumber

Defined in

packages/core/src/utils.ts:207


calculateAgeString

calculateAgeString(birthDateStr, endDateStr?): string | undefined

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.

Parameters

NameTypeDescription
birthDateStrstringThe birth date or start date in ISO-8601 format YYYY-MM-DD.
endDateStr?stringOptional end date in ISO-8601 format YYYY-MM-DD. Default value is today.

Returns

string | undefined

The age string.

Defined in

packages/core/src/utils.ts:249


getQuestionnaireAnswers

getQuestionnaireAnswers(response): Record<string, QuestionnaireResponseItemAnswer>

Returns all questionnaire answers as a map by link ID.

Parameters

NameTypeDescription
responseQuestionnaireResponseThe questionnaire response resource.

Returns

Record<string, QuestionnaireResponseItemAnswer>

Questionnaire answers mapped by link ID.

Defined in

packages/core/src/utils.ts:265


getIdentifier

getIdentifier(resource, system): string | undefined

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.

Parameters

NameTypeDescription
resourceResourceThe resource to check.
systemstringThe identifier system.

Returns

string | undefined

The identifier value if found; otherwise undefined.

Defined in

packages/core/src/utils.ts:302


getExtensionValue

getExtensionValue(resource, ...urls): string | undefined

Returns an extension value by extension URLs.

Parameters

NameTypeDescription
resourceanyThe base resource.
...urlsstring[]Array of extension URLs. Each entry represents a nested extension.

Returns

string | undefined

The extension value if found; undefined otherwise.

Defined in

packages/core/src/utils.ts:322


getExtension

getExtension(resource, ...urls): Extension | undefined

Returns an extension by extension URLs.

Parameters

NameTypeDescription
resourceanyThe base resource.
...urlsstring[]Array of extension URLs. Each entry represents a nested extension.

Returns

Extension | undefined

The extension object if found; undefined otherwise.

Defined in

packages/core/src/utils.ts:340


stringify

stringify(value, pretty?): string

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

Parameters

NameTypeDescription
valueanyThe input value.
pretty?booleanOptional flag to pretty-print the JSON.

Returns

string

The resulting JSON string.

Defined in

packages/core/src/utils.ts:361


isEmpty

isEmpty(v): boolean

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

Parameters

NameTypeDescription
vanyAny value.

Returns

boolean

True if the value is an empty string or an empty object.

Defined in

packages/core/src/utils.ts:391


deepEquals

deepEquals(object1, object2, path?): boolean

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

Parameters

NameTypeDescription
object1unknownThe first object.
object2unknownThe second object.
path?stringOptional path string.

Returns

boolean

True if the objects are equal.

Defined in

packages/core/src/utils.ts:407


deepIncludes

deepIncludes(value, pattern): boolean

Checks if object2 includes all fields and values of object1. It doesn't matter if object2 has extra fields.

Parameters

NameTypeDescription
valueanyThe object to test if contained in pattern.
patternanyThe object to test against.

Returns

boolean

True if pattern includes all fields and values of value.

Defined in

packages/core/src/utils.ts:474


deepClone

deepClone<T>(input): T

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

Type parameters

Name
T

Parameters

NameTypeDescription
inputTThe input to clone.

Returns

T

A deep clone of the input.

Defined in

packages/core/src/utils.ts:516


isUUID

isUUID(input): boolean

Returns true if the input string is a UUID.

Parameters

NameTypeDescription
inputstringThe input string.

Returns

boolean

True if the input string matches the UUID format.

Defined in

packages/core/src/utils.ts:525


isObject

isObject(obj): obj is Record<string, unknown>

Returns true if the input is an object.

Parameters

NameTypeDescription
objunknownThe candidate object.

Returns

obj is Record<string, unknown>

True if the input is a non-null non-undefined object.

Defined in

packages/core/src/utils.ts:534


isStringArray

isStringArray(arr): arr is string[]

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

Parameters

NameTypeDescription
arrany[]Input array.

Returns

arr is string[]

True if the input array is an array of strings.

Defined in

packages/core/src/utils.ts:543


arrayBufferToHex

arrayBufferToHex(arrayBuffer): string

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

Parameters

NameTypeDescription
arrayBufferArrayBufferThe input array buffer.

Returns

string

The resulting hex string.

Defined in

packages/core/src/utils.ts:560


arrayBufferToBase64

arrayBufferToBase64(arrayBuffer): string

Converts an ArrayBuffer to a base-64 encoded string.

Parameters

NameTypeDescription
arrayBufferArrayBufferThe input array buffer.

Returns

string

The base-64 encoded string.

Defined in

packages/core/src/utils.ts:574


capitalize

capitalize(word): string

Parameters

NameType
wordstring

Returns

string

Defined in

packages/core/src/utils.ts:583


isLowerCase

isLowerCase(c): boolean

Parameters

NameType
cstring

Returns

boolean

Defined in

packages/core/src/utils.ts:587


getCodeBySystem

getCodeBySystem(concept, system): string | undefined

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

Parameters

NameTypeDescription
conceptCodeableConceptThe codeable concept.
systemstringThe system string.

Returns

string | undefined

The code if found; otherwise undefined.

Defined in

packages/core/src/utils.ts:597


setCodeBySystem

setCodeBySystem(concept, system, code): void

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

Parameters

NameTypeDescription
conceptCodeableConceptThe codeable concept.
systemstringThe system string.
codestringThe code value.

Returns

void

Defined in

packages/core/src/utils.ts:607


findObservationInterval

findObservationInterval(definition, patient, value, category?): ObservationDefinitionQualifiedInterval | undefined

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

Parameters

NameTypeDescription
definitionObservationDefinitionThe observation definition.
patientPatientThe patient.
valuenumberThe observation value.
category?"reference" | "critical" | "absolute"Optional interval category restriction.

Returns

ObservationDefinitionQualifiedInterval | undefined

The observation interval if found; otherwise undefined.

Defined in

packages/core/src/utils.ts:627


findObservationReferenceRange

findObservationReferenceRange(definition, patient, names): ObservationDefinitionQualifiedInterval | undefined

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

Parameters

NameTypeDescription
definitionObservationDefinitionThe observation definition.
patientPatientThe patient.
namesstring[]The condition names.

Returns

ObservationDefinitionQualifiedInterval | undefined

The observation interval if found; otherwise undefined.

Defined in

packages/core/src/utils.ts:648


matchesRange

matchesRange(value, range, precision?): boolean

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

Parameters

NameTypeDescription
valuenumberThe numeric value.
rangeRangeThe numeric range.
precision?numberOptional precision in number of digits.

Returns

boolean

True if the value is within the range.

Defined in

packages/core/src/utils.ts:713


preciseRound

preciseRound(a, precision): number

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

Parameters

NameTypeDescription
anumberThe input number.
precisionnumberThe precision in number of digits.

Returns

number

The number rounded to the specified number of digits.

Defined in

packages/core/src/utils.ts:726


preciseEquals

preciseEquals(a, b, precision?): boolean

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

Parameters

NameTypeDescription
anumberThe first number.
bnumberThe second number.
precision?numberOptional precision in number of digits.

Returns

boolean

True if the two numbers are equal to the given precision.

Defined in

packages/core/src/utils.ts:737


preciseLessThan

preciseLessThan(a, b, precision?): boolean

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

Parameters

NameTypeDescription
anumberThe first number.
bnumberThe second number.
precision?numberOptional precision in number of digits.

Returns

boolean

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

Defined in

packages/core/src/utils.ts:748


preciseGreaterThan

preciseGreaterThan(a, b, precision?): boolean

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

Parameters

NameTypeDescription
anumberThe first number.
bnumberThe second number.
precision?numberOptional precision in number of digits.

Returns

boolean

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

Defined in

packages/core/src/utils.ts:759


preciseLessThanOrEquals

preciseLessThanOrEquals(a, b, precision?): boolean

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

Parameters

NameTypeDescription
anumberThe first number.
bnumberThe second number.
precision?numberOptional precision in number of digits.

Returns

boolean

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

Defined in

packages/core/src/utils.ts:770


preciseGreaterThanOrEquals

preciseGreaterThanOrEquals(a, b, precision?): boolean

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

Parameters

NameTypeDescription
anumberThe first number.
bnumberThe second number.
precision?numberOptional precision in number of digits.

Returns

boolean

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

Defined in

packages/core/src/utils.ts:781


findResourceByCode

findResourceByCode(resources, code, system): ResourceWithCode | undefined

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

Parameters

NameTypeDescription
resourcesResourceWithCode[]The array of resources to search.
codestring | CodeableConceptThe code to search for.
systemstringThe system to search for.

Returns

ResourceWithCode | undefined

The first resource in the input array that matches the specified code and system, or undefined if no such resource is found.

Defined in

packages/core/src/utils.ts:806


arrayify

arrayify<T>(value): T[] | undefined

Type parameters

Name
T

Parameters

NameType
valueundefined | T | T[]

Returns

T[] | undefined

Defined in

packages/core/src/utils.ts:818


sleep

sleep(ms): Promise<void>

Sleeps for the specified number of milliseconds.

Parameters

NameTypeDescription
msnumberTime delay in milliseconds

Returns

Promise<void>

A promise that resolves after the specified number of milliseconds.

Defined in

packages/core/src/utils.ts:833