@medplum/core
Enumerations
Classes
Interfaces
- AddressFormatOptions
- BotEvent
- FetchLike
- Filter
- GoogleCredentialResponse
- HumanNameFormatOptions
- IndexedStructureDefinition
- LoginAuthenticationResponse
- LoginProfileResponse
- LoginRequest
- LoginScopeResponse
- LoginState
- MedplumClientOptions
- RegisterRequest
- SearchParameterDetails
- SearchRequest
- SortRule
- TokenResponse
- TypeSchema
Type aliases
ProfileResource
Ƭ ProfileResource: Patient
| Practitioner
| RelatedPerson
Defined in
Variables
COMPONENT_SEPARATOR
• Const
COMPONENT_SEPARATOR: "^"
Defined in
DEFAULT_SEARCH_COUNT
• Const
DEFAULT_SEARCH_COUNT: 20
Defined in
FIELD_SEPARATOR
• Const
FIELD_SEPARATOR: "|"
Defined in
SEGMENT_SEPARATOR
• Const
SEGMENT_SEPARATOR: "\r"
Defined in
accessDenied
• Const
accessDenied: OperationOutcome
Defined in
packages/core/src/outcomes.ts:80
allOk
• Const
allOk: OperationOutcome
Defined in
packages/core/src/outcomes.ts:10
created
• Const
created: OperationOutcome
Defined in
packages/core/src/outcomes.ts:24
gone
• Const
gone: OperationOutcome
Defined in
packages/core/src/outcomes.ts:66
notFound
• Const
notFound: OperationOutcome
Defined in
packages/core/src/outcomes.ts:52
notModified
• Const
notModified: OperationOutcome
Defined in
packages/core/src/outcomes.ts:38
Functions
arrayBufferToBase64
▸ arrayBufferToBase64(arrayBuffer
): string
Converts an ArrayBuffer to a base-64 encoded string.
Parameters
Name | Type | Description |
---|---|---|
arrayBuffer | ArrayBuffer | The input array buffer. |
Returns
string
The base-64 encoded string.
Defined in
packages/core/src/utils.ts:440
arrayBufferToHex
▸ arrayBufferToHex(arrayBuffer
): string
Converts an ArrayBuffer to hex string. See: https://stackoverflow.com/a/55200387
Parameters
Name | Type | Description |
---|---|---|
arrayBuffer | ArrayBuffer | The input array buffer. |
Returns
string
The resulting hex string.
Defined in
packages/core/src/utils.ts:426
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
Name | Type | Description |
---|---|---|
outcome | OperationOutcome | The operation outcome. |
resource | undefined | T | The resource that may or may not have been returned. |
Returns
asserts resource is T
Defined in
packages/core/src/outcomes.ts:145
badRequest
▸ badRequest(details
, expression?
): OperationOutcome
Parameters
Name | Type |
---|---|
details | string |
expression? | string |
Returns
OperationOutcome
Defined in
packages/core/src/outcomes.ts:94
buildTypeName
▸ buildTypeName(components
): string
Parameters
Name | Type |
---|---|
components | string [] |
Returns
string
Defined in
packages/core/src/types.ts:234
calculateAge
▸ calculateAge(birthDateStr
, endDateStr?
): Object
Calculates the age in years from the birth date.
Parameters
Name | Type | Description |
---|---|---|
birthDateStr | string | The birth date or start date in ISO-8601 format YYYY-MM-DD. |
endDateStr? | string | Optional end date in ISO-8601 format YYYY-MM-DD. Default value is today. |
Returns
Object
The age in years, months, and days.
Name | Type |
---|---|
days | number |
months | number |
years | number |
Defined in
packages/core/src/utils.ts:170
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
Name | Type | Description |
---|---|---|
birthDateStr | string | The birth date or start date in ISO-8601 format YYYY-MM-DD. |
endDateStr? | string | Optional 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:212
capitalize
▸ capitalize(word
): string
Parameters
Name | Type |
---|---|
word | string |
Returns
string
Defined in
packages/core/src/utils.ts:449
createReference
▸ createReference<T
>(resource
): Reference
<T
>
Creates a reference resource.
Type parameters
Name | Type |
---|---|
T | extends Resource |
Parameters
Name | Type | Description |
---|---|---|
resource | T | The FHIR reesource. |
Returns
Reference
<T
>
A reference resource.
Defined in
createSchema
▸ createSchema(): IndexedStructureDefinition
Creates a new empty IndexedStructureDefinition.
Returns
The empty IndexedStructureDefinition.
Defined in
packages/core/src/types.ts:121
createTypeSchema
▸ createTypeSchema(typeName
, description
): TypeSchema
Parameters
Name | Type |
---|---|
typeName | string |
description | undefined | string |
Returns
Defined in
packages/core/src/types.ts:125
deepEquals
▸ deepEquals(object1
, object2
, path?
): boolean
Resource equality. Ignores meta.versionId and meta.lastUpdated.
Parameters
Name | Type | Description |
---|---|---|
object1 | unknown | The first object. |
object2 | unknown | The second object. |
path? | string | - |
Returns
boolean
True if the objects are equal.
Defined in
packages/core/src/utils.ts:326
formatAddress
▸ formatAddress(address
, options?
): string
Parameters
Name | Type |
---|---|
address | Address |
options? | AddressFormatOptions |
Returns
string
Defined in
packages/core/src/format.ts:15
formatFamilyName
▸ formatFamilyName(name
): string
Parameters
Name | Type |
---|---|
name | HumanName |
Returns
string
Defined in
packages/core/src/format.ts:75
formatGivenName
▸ formatGivenName(name
): string
Parameters
Name | Type |
---|---|
name | HumanName |
Returns
string
Defined in
packages/core/src/format.ts:67
formatHumanName
▸ formatHumanName(name
, options?
): string
Parameters
Name | Type |
---|---|
name | HumanName |
options? | HumanNameFormatOptions |
Returns
string
Defined in
packages/core/src/format.ts:41
formatSearchQuery
▸ formatSearchQuery(definition
): string
Formats a search definition object into a query string. Note: The return value does not include the resource type.
Parameters
Name | Type | Description |
---|---|---|
definition | SearchRequest | The search definition. |
Returns
string
Formatted URL.
Defined in
packages/core/src/search.ts:196
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
Name | Type | Description |
---|---|---|
date | undefined | string | The 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:160
getDisplayString
▸ getDisplayString(resource
): string
Returns a display string for the resource.
Parameters
Name | Type | Description |
---|---|---|
resource | Resource | The input resource. |
Returns
string
Human friendly display string.
Defined in
getExpressionForResourceType
▸ getExpressionForResourceType(resourceType
, expression
): string
| undefined
Parameters
Name | Type |
---|---|
resourceType | string |
expression | string |
Returns
string
| undefined
Defined in
packages/core/src/searchparams.ts:126
getExtensionValue
▸ getExtensionValue(resource
, ...urls
): string
| undefined
Returns an extension value by extension URLs.
Parameters
Name | Type | Description |
---|---|---|
resource | Resource | The base resource. |
...urls | string [] | 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:261
getImageSrc
▸ getImageSrc(resource
): string
| undefined
Returns an image URL for the resource, if one is available.
Parameters
Name | Type | Description |
---|---|---|
resource | Resource | The input resource. |
Returns
string
| undefined
The image URL for the resource or undefined.
Defined in
packages/core/src/utils.ts:125
getPropertyDisplayName
▸ getPropertyDisplayName(property
): string
Parameters
Name | Type |
---|---|
property | ElementDefinition |
Returns
string
Defined in
packages/core/src/types.ts:238
getQuestionnaireAnswers
▸ getQuestionnaireAnswers(response
): Record
<string
, QuestionnaireResponseItemAnswer
>
Returns all questionnaire answers as a map by link ID.
Parameters
Name | Type | Description |
---|---|---|
response | QuestionnaireResponse | The questionnaire response resource. |
Returns
Record
<string
, QuestionnaireResponseItemAnswer
>
Questionnaire answers mapped by link ID.
Defined in
packages/core/src/utils.ts:228
getReferenceString
▸ getReferenceString(resource
): string
Returns a reference string for a resource.
Parameters
Name | Type | Description |
---|---|---|
resource | Resource | The FHIR resource. |
Returns
string
A reference string of the form resourceType/id.
Defined in
getSearchParameterDetails
▸ getSearchParameterDetails(structureDefinitions
, 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
Name | Type | Description |
---|---|---|
structureDefinitions | IndexedStructureDefinition | Collection of StructureDefinition resources indexed by name. |
resourceType | string | The root resource type. |
searchParam | SearchParameter | The search parameter. |
Returns
The search parameter type details.
Defined in
packages/core/src/searchparams.ts:38
getStatus
▸ getStatus(outcome
): number
Parameters
Name | Type |
---|---|
outcome | OperationOutcome |
Returns
number
Defined in
packages/core/src/outcomes.ts:122
indexSearchParameter
▸ indexSearchParameter(schema
, searchParam
): void
Indexes a SearchParameter resource for fast lookup. Indexes by SearchParameter.code, which is the query string parameter name.
Parameters
Name | Type | Description |
---|---|---|
schema | IndexedStructureDefinition | The output IndexedStructureDefinition. |
searchParam | SearchParameter | The SearchParameter resource. |
Returns
void
Defined in
packages/core/src/types.ts:215
indexStructureDefinition
▸ indexStructureDefinition(schema
, structureDefinition
): void
Indexes a StructureDefinition for fast lookup. See comments on IndexedStructureDefinition for more details.
Parameters
Name | Type | Description |
---|---|---|
schema | IndexedStructureDefinition | The output IndexedStructureDefinition. |
structureDefinition | StructureDefinition | The original StructureDefinition. |
Returns
void
Defined in
packages/core/src/types.ts:147
isGone
▸ isGone(outcome
): boolean
Parameters
Name | Type |
---|---|
outcome | OperationOutcome |
Returns
boolean
Defined in
packages/core/src/outcomes.ts:118
isLowerCase
▸ isLowerCase(c
): boolean
Parameters
Name | Type |
---|---|
c | string |
Returns
boolean
Defined in
packages/core/src/utils.ts:453
isNotFound
▸ isNotFound(outcome
): boolean
Parameters
Name | Type |
---|---|
outcome | OperationOutcome |
Returns
boolean
Defined in
packages/core/src/outcomes.ts:114
isObject
▸ isObject(obj
): obj is Record<string, unknown>
Returns true if the input is an object.
Parameters
Name | Type |
---|---|
obj | unknown |
Returns
obj is Record<string, unknown>
True if the input is a non-null non-undefined object.
Defined in
packages/core/src/utils.ts:400
isOk
▸ isOk(outcome
): boolean
Parameters
Name | Type |
---|---|
outcome | OperationOutcome |
Returns
boolean
Defined in
packages/core/src/outcomes.ts:110
isProfileResource
▸ isProfileResource(resource
): boolean
Returns true if the resource is a "ProfileResource".
Parameters
Name | Type | Description |
---|---|---|
resource | Resource | The FHIR resource. |
Returns
boolean
True if the resource is a "ProfileResource".
Defined in
isStringArray
▸ isStringArray(arr
): arr is string[]
Returns true if the input array is an array of strings.
Parameters
Name | Type | Description |
---|---|---|
arr | any [] | Input array. |
Returns
arr is string[]
True if the input array is an array of strings.
Defined in
packages/core/src/utils.ts:409
isUUID
▸ isUUID(input
): boolean
Returns true if the input string is a UUID.
Parameters
Name | Type | Description |
---|---|---|
input | string | The input string. |
Returns
boolean
True if the input string matches the UUID format.
Defined in
packages/core/src/utils.ts:391
parseSearchDefinition
▸ parseSearchDefinition(url
): SearchRequest
Parses a URL into a SearchRequest.
See the FHIR search spec: http://hl7.org/fhir/r4/search.html
Parameters
Name | Type | Description |
---|---|---|
url | string | The URL to parse. |
Returns
Parsed search definition.
Defined in
packages/core/src/search.ts:90
resolveId
▸ resolveId(reference
): string
| undefined
Returns the ID portion of a reference.
Parameters
Name | Type | Description |
---|---|---|
reference | undefined | Reference <Resource > | A FHIR reference. |
Returns
string
| undefined
The ID portion of a reference.
Defined in
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
Name | Type | Description |
---|---|---|
value | any | The input value. |
pretty? | boolean | Optional flag to pretty-print the JSON. |
Returns
string
The resulting JSON string.