O3 Framework API Reference

This page provides a reference for the APIs provided by the O3 framework. Its content is generated from comments in the source code.

 

Table of contents

API Functions

Breadcrumb Functions

Config Functions

Config Validation Functions

Context Functions

Date and Time Functions

Dynamic Loading Functions

Error Handling Functions

Extension Functions

Feature Flags Functions

Framework Functions

Navigation Functions

Offline Functions

Other Functions

Store Functions

Translation Functions

UI Functions

Utility Functions

Workspace Functions

API Type Aliases

CurrentPatient

Ƭ CurrentPatient: fhir.Patient | FetchResponse<fhir.Patient>

Defined in

packages/framework/esm-api/src/shared-api-objects/current-patient.ts:7


LoadedSessionStore

Ƭ LoadedSessionStore: Object

Type declaration

Name

Type

Name

Type

loaded

true

session

Session

Defined in

packages/framework/esm-api/src/shared-api-objects/current-user.ts:11


NullablePatient

Ƭ NullablePatient: fhir.Patient | null

Defined in

packages/framework/esm-react-utils/src/usePatient.ts:6


PatientUuid

Ƭ PatientUuid: string | null

Defined in

packages/framework/esm-api/src/shared-api-objects/current-patient.ts:20


SessionStore

Ƭ SessionStore: LoadedSessionStore | UnloadedSessionStore

Defined in

packages/framework/esm-api/src/shared-api-objects/current-user.ts:9


UnloadedSessionStore

Ƭ UnloadedSessionStore: Object

Type declaration

Name

Type

Name

Type

loaded

false

session

null

Defined in

packages/framework/esm-api/src/shared-api-objects/current-user.ts:16


Context Type Aliases

ContextCallback

Ƭ ContextCallback<T>: (state: Readonly<T> | null | undefined) => void

Type parameters

Name

Type

Name

Type

T

extends Object = {}

Type declaration

▸ (state): void

Parameters

Name

Type

Name

Type

state

Readonly<T> | null | undefined

Returns

void

Defined in

packages/framework/esm-context/src/context.ts:90


Date and Time Type Aliases

DateInput

Ƭ DateInput: string | number | Date

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:26


FormatDateMode

Ƭ FormatDateMode: "standard" | "wide"

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:140


FormatDateOptions

Ƭ FormatDateOptions: Object

Type declaration

Name

Type

Description

Name

Type

Description

calendar?

string

The calendar to use when formatting this date.

day

boolean

Whether to include the day number

locale?

string

The locale to use when formatting this date

mode

FormatDateMode

  • standard: "03 Feb 2022" - wide: "03 — Feb — 2022"

month

boolean

Whether to include the month number

noToday

boolean

Disables the special handling of dates that are today. If false (the default), then dates that are today will be formatted as "Today" in the locale language. If true, then dates that are today will be formatted the same as all other dates.

numberingSystem?

string

The unicode numbering system to use

time

boolean | "for today"

Whether the time should be included in the output always (true), never (false), or only when the input date is today (for today).

year

boolean

Whether to include the year

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:142


Extension Type Aliases

ExtensionProps

Ƭ ExtensionProps: { state?: Record<string, any> ; wrap?: (slot: ReactNode, extension: ExtensionData) => null | ReactElement<any, any> } & Omit<React.HTMLAttributes<HTMLDivElement>, "children"> & { children?: React.ReactNode | (slot: React.ReactNode, extension?: ExtensionData) => React.ReactNode }

Defined in

packages/framework/esm-react-utils/src/Extension.tsx:8


ExtensionSlotProps

Ƭ ExtensionSlotProps: OldExtensionSlotBaseProps | ExtensionSlotBaseProps & Omit<React.HTMLAttributes<HTMLDivElement>, "children"> & { children?: React.ReactNode | (extension: ConnectedExtension) => React.ReactNode }

Defined in

packages/framework/esm-react-utils/src/ExtensionSlot.tsx:24


Navigation Type Aliases

TemplateParams

Ƭ TemplateParams: Object

Index signature

▪ [key: string]: string

Defined in

packages/framework/esm-navigation/src/navigation/navigate.ts:10


Offline Type Aliases

KnownOmrsServiceWorkerMessages

Ƭ KnownOmrsServiceWorkerMessages: OnImportMapChangedMessage | ClearDynamicRoutesMessage | RegisterDynamicRouteMessage

Defined in

packages/framework/esm-offline/src/service-worker-messaging.ts:41


OfflineMode

Ƭ OfflineMode: "on" | "off" | "unavailable"

Defined in

packages/framework/esm-offline/src/mode.ts:34


OmrsOfflineCachingStrategy

Ƭ OmrsOfflineCachingStrategy: "network-only-or-cache-only" | "network-first"

Defined in

packages/framework/esm-offline/src/service-worker-http-headers.ts:15


OmrsOfflineHttpHeaderNames

Ƭ OmrsOfflineHttpHeaderNames: keyof OmrsOfflineHttpHeaders

Defined in

packages/framework/esm-offline/src/service-worker-http-headers.ts:40


OmrsOfflineHttpHeaders

Ƭ OmrsOfflineHttpHeaders: Object

Defines the keys of the custom headers which can be appended to an HTTP request. HTTP requests with these headers are handled in a special way by the SPA's service worker.

Type declaration

Name

Type

Description

Name

Type

Description

x-omrs-offline-caching-strategy?

OmrsOfflineCachingStrategy

Instructs the service worker to use a specific caching strategy for this request.

x-omrs-offline-response-body?

string

If the client is offline and the request cannot be read from the cache (i.e. if there is no way to receive any kind of data for this request), the service worker will return a response with the body in this header.

x-omrs-offline-response-status?

`${number}`

If the client is offline and the request cannot be read from the cache (i.e. if there is no way to receive any kind of data for this request), the service worker will return a response with the status code defined in this header.

Defined in

packages/framework/esm-offline/src/service-worker-http-headers.ts:21


Other Type Aliases

ConfigValue

Ƭ ConfigValue: string | number | boolean | void | any[] | object

Defined in

packages/framework/esm-config/src/types.ts:40


DateInputValue

Ƭ DateInputValue: CalendarDate | CalendarDateTime | ZonedDateTime | Date | Dayjs | string | number | null | undefined

A type for any of the acceptable date formats

Defined in

packages/framework/esm-styleguide/src/datepicker/index.tsx:58


ExtensionDefinition

Ƭ ExtensionDefinition: { featureFlag?: string ; meta?: { [k: string]: unknown; } ; name: string ; offline?: boolean ; online?: boolean ; order?: number ; privileges?: string | string[] ; slot?: string ; slots?: string[] } & { component: string } | { component?: never }

A definition of an extension as extracted from an app's routes.json

Defined in

packages/framework/esm-globals/src/types.ts:177


IconProps

Ƭ IconProps: Object

Type declaration

Name

Type

Name

Type

className?

Argument

fill?

string

size?

number

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:6


ModalDefinition

Ƭ ModalDefinition: { name: string } & { component: string } | { component?: never }

A definition of a modal as extracted from an app's routes.json

Defined in

packages/framework/esm-globals/src/types.ts:242


NameUse

Ƭ NameUse: "usual" | "official" | "temp" | "nickname" | "anonymous" | "old" | "maiden"

Defined in

packages/framework/esm-globals/src/types.ts:403


OpenmrsRoutes

Ƭ OpenmrsRoutes: Record<string, OpenmrsAppRoutes>

This interfaces describes the format of the overall rotues.json loaded by the app shell. Basically, this is the same as the app routes, with each routes definition keyed by the app's name

Defined in

packages/framework/esm-globals/src/types.ts:394


PageDefinition

Ƭ PageDefinition: { component: string ; offline?: boolean ; online?: boolean ; order?: number } & { route: string | boolean ; routeRegex?: never } | { route?: never ; routeRegex: string }

A definition of a page extracted from an app's routes.json

Defined in

packages/framework/esm-globals/src/types.ts:121


PictogramProps

Ƭ PictogramProps: Object

Type declaration

Name

Type

Name

Type

className?

Argument

size?

number

Defined in

packages/framework/esm-styleguide/src/pictograms/pictograms.tsx:5


ProvidedConfig

Ƭ ProvidedConfig: Object

Type declaration

Name

Type

Name

Type

config

Config

source

string

Defined in

packages/framework/esm-config/src/types.ts:62


RegisteredPageDefinition

Ƭ RegisteredPageDefinition: Omit<PageDefinition, "order"> & AppComponent & { order: number }

A definition of a page after the app has been registered.

Defined in

packages/framework/esm-globals/src/types.ts:172


SpaEnvironment

Ƭ SpaEnvironment: "production" | "development" | "test"

Defined in

packages/framework/esm-globals/src/types.ts:76


SvgIconProps

Ƭ SvgIconProps: Object

Type declaration

Name

Type

Name

Type

icon

string

iconProps

IconProps

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:592


SvgPictogramProps

Ƭ SvgPictogramProps: Object

Type declaration

Name

Type

Description

Name

Type

Description

pictogram

string

the id of the pictogram

pictogramProps

PictogramProps

properties when using the pictogram

Defined in

packages/framework/esm-styleguide/src/pictograms/pictograms.tsx:10


UpdateVisitPayload

Ƭ UpdateVisitPayload: NewVisitPayload & {}

Defined in

packages/framework/esm-api/src/types/visit-resource.ts:16


Validator

Ƭ Validator: (value: any) => void | string

Type declaration

▸ (value): void | string

Parameters

Name

Type

Name

Type

value

any

Returns

void | string

Defined in

packages/framework/esm-config/src/types.ts:69


ValidatorFunction

Ƭ ValidatorFunction: (value: any) => boolean

Type declaration

▸ (value): boolean

Parameters

Name

Type

Name

Type

value

any

Returns

boolean

Defined in

packages/framework/esm-config/src/types.ts:67


WorkspaceDefinition

Ƭ WorkspaceDefinition: { canHide?: boolean ; canMaximize?: boolean ; hasOwnSidebar?: boolean ; name: string ; preferredWindowSize?: WorkspaceWindowState ; sidebarFamily?: string ; title: string ; type: string ; width?: "narrow" | "wider" | "extra-wide" } & { component: string } | { component?: never }

A definition of a workspace as extracted from an app's routes.json

Defined in

packages/framework/esm-globals/src/types.ts:276


WorkspaceWindowState

Ƭ WorkspaceWindowState: "maximized" | "hidden" | "normal"

Defined in

packages/framework/esm-globals/src/types.ts:271


Store Type Aliases

ActionFunction

Ƭ ActionFunction<T>: (state: T, ...args: any[]) => Partial<T>

Type parameters

Name

Name

T

Type declaration

▸ (state, ...args): Partial<T>

Parameters

Name

Type

Name

Type

state

T

...args

any[]

Returns

Partial<T>

Defined in

packages/framework/esm-react-utils/src/useStore.ts:6


Actions

Ƭ Actions<T>: (store: StoreApi<T>) => Record<string, ActionFunction<T>> | Record<string, ActionFunction<T>>

Type parameters

Name

Name

T

Defined in

packages/framework/esm-react-utils/src/useStore.ts:7


BoundActions

Ƭ BoundActions: Object

Index signature

▪ [key: string]: (...args: any[]) => void

Defined in

packages/framework/esm-react-utils/src/useStore.ts:10


Translation Type Aliases

CoreTranslationKey

Ƭ CoreTranslationKey: keyof typeof coreTranslations

Defined in

packages/framework/esm-translations/src/index.ts:47


UI Type Aliases

ActionableNotificationType

Ƭ ActionableNotificationType: "error" | "info" | "info-square" | "success" | "warning" | "warning-alt"

Defined in

packages/framework/esm-styleguide/src/notifications/actionable-notification.component.tsx:24


InlineNotificationType

Ƭ InlineNotificationType: "error" | "info" | "info-square" | "success" | "warning" | "warning-alt"

Defined in

packages/framework/esm-styleguide/src/notifications/notification.component.tsx:22


LayoutType

Ƭ LayoutType: "phone" | "tablet" | "small-desktop" | "large-desktop"

Defined in

packages/framework/esm-react-utils/src/useLayoutType.ts:4


SnackbarType

Ƭ SnackbarType: "error" | "info" | "info-square" | "success" | "warning" | "warning-alt"

Defined in

packages/framework/esm-styleguide/src/snackbars/snackbar.component.tsx:29


ToastType

Ƭ ToastType: "error" | "info" | "info-square" | "success" | "warning" | "warning-alt"

Defined in

packages/framework/esm-styleguide/src/toasts/toast.component.tsx:23


Utility Type Aliases

ArgumentsTuple

Ƭ ArgumentsTuple: [any, ...unknown[]]

Defined in

packages/framework/esm-react-utils/src/useOpenmrsSWR.ts:8


Key

Ƭ Key: string | ArgumentsTuple | undefined | null

Defined in

packages/framework/esm-react-utils/src/useOpenmrsSWR.ts:9


UseOpenmrsSWROptions

Ƭ UseOpenmrsSWROptions: Object

Type declaration

Name

Type

Name

Type

abortController?

AbortController

fetchInit?

FetchConfig

swrConfig?

SWRConfiguration

url?

string | (key: Key) => string

Defined in

packages/framework/esm-react-utils/src/useOpenmrsSWR.ts:10

API Variables

UserHasAccess

  • Const UserHasAccess: React.FC<UserHasAccessProps>

Defined in

packages/framework/esm-react-utils/src/UserHasAccess.tsx:12


attachmentUrl

  • Const attachmentUrl: string

Defined in

packages/framework/esm-api/src/attachments.ts:5


defaultVisitCustomRepresentation

  • Const defaultVisitCustomRepresentation: string

Defined in

packages/framework/esm-api/src/shared-api-objects/visit-utils.ts:9


fhirBaseUrl

  • Const fhirBaseUrl: "/ws/fhir2/R4"

Defined in

packages/framework/esm-api/src/openmrs-fetch.ts:11


getStartedVisit

  • Const getStartedVisit: BehaviorSubject<null | VisitItem>

deprecated

Defined in

packages/framework/esm-api/src/shared-api-objects/visit-utils.ts:103


restBaseUrl

  • Const restBaseUrl: "/ws/rest/v1"

Defined in

packages/framework/esm-api/src/openmrs-fetch.ts:9


sessionEndpoint

  • Const sessionEndpoint: string

Defined in

packages/framework/esm-api/src/openmrs-fetch.ts:13


Config Validation Variables

validators

  • Const validators: Object

Type declaration

Name

Type

Name

Type

inRange

(min: number, max: number) => Validator

isUrl

Validator

isUrlWithTemplateParameters

(allowedTemplateParameters: string[] | readonly string[]) => Validator

oneOf

(allowedValues: any[] | readonly any[]) => Validator

Defined in

packages/framework/esm-config/src/validators/validators.ts:65


Extension Variables

Extension

  • Const Extension: React.FC<ExtensionProps>

Represents the position in the DOM where each extension within an extension slot is rendered.

Renders once for each extension attached to that extension slot.

Usage of this component must have an ancestor <ExtensionSlot>, and must only be used once within that <ExtensionSlot>.

Defined in

packages/framework/esm-react-utils/src/Extension.tsx:25


Offline Variables

offlineUuidPrefix

  • Const offlineUuidPrefix: "OFFLINE+"

Defined in

packages/framework/esm-offline/src/uuid.ts:4


omrsOfflineCachingStrategyHttpHeaderName

  • Const omrsOfflineCachingStrategyHttpHeaderName: "x-omrs-offline-caching-strategy"

Defined in

packages/framework/esm-offline/src/service-worker-http-headers.ts:5


omrsOfflineResponseBodyHttpHeaderName

  • Const omrsOfflineResponseBodyHttpHeaderName: "x-omrs-offline-response-body"

Defined in

packages/framework/esm-offline/src/service-worker-http-headers.ts:3


omrsOfflineResponseStatusHttpHeaderName

  • Const omrsOfflineResponseStatusHttpHeaderName: "x-omrs-offline-response-status"

Defined in

packages/framework/esm-offline/src/service-worker-http-headers.ts:4


Other Variables

ActivityIcon

  • Const ActivityIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:14


AddIcon

  • Const AddIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:22


AllergiesIcon

  • Const AllergiesIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>> = WarningIcon

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:566


ArrowDownIcon

  • Const ArrowDownIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:30


ArrowLeftIcon

  • Const ArrowLeftIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:38


ArrowRightIcon

  • Const ArrowRightIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:46


ArrowUpIcon

  • Const ArrowUpIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:54


AttachmentIcon

  • Const AttachmentIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>> = DocumentAttachmentIcon

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:571


CalendarHeatMapIcon

  • Const CalendarHeatMapIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:62


CalendarIcon

  • Const CalendarIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:70


CaretDownIcon

  • Const CaretDownIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:78


CaretLeftIcon

  • Const CaretLeftIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:86


CaretRightIcon

  • Const CaretRightIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:94


CaretUpIcon

  • Const CaretUpIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:102


ChartAverageIcon

  • Const ChartAverageIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:110


ChemistryIcon

  • Const ChemistryIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:118


ChevronDownIcon

  • Const ChevronDownIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:126


ChevronLeftIcon

  • Const ChevronLeftIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:134


ChevronRightIcon

  • Const ChevronRightIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:142


ChevronUpIcon

  • Const ChevronUpIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:150


CloseFilledIcon

  • Const CloseFilledIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:158


CloseIcon

  • Const CloseIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:174


CloseOutlineIcon

  • Const CloseOutlineIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:166


ConditionsIcon

  • Const ConditionsIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>> = ListCheckedIcon

Conditions

Note this is an alias for ListCheckedIcon

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:578


DocumentAttachmentIcon

  • Const DocumentAttachmentIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:182


DocumentIcon

  • Const DocumentIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:190


DownloadIcon

  • Const DownloadIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:198


EditIcon

  • Const EditIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:206


ErrorState

  • Const ErrorState: React.FC<ErrorStateProps>

Defined in

packages/framework/esm-styleguide/src/error-state/error-state.component.tsx:12


EventScheduleIcon

  • Const EventScheduleIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:214


EventsIcon

  • Const EventsIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:222


GroupAccessIcon

  • Const GroupAccessIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:238


GroupIcon

  • Const GroupIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:230


HospitalBedIcon

  • Const HospitalBedIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:246


Icon

  • Const Icon: MemoExoticComponent<ForwardRefExoticComponent<SvgIconProps & RefAttributes<SVGSVGElement>>>

This is a utility type for custom icons that use the svg-sprite-loader to bundle custom icons

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:600


ImageMedicalIcon

  • Const ImageMedicalIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:254


InventoryManagementIcon

  • Const InventoryManagementIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:262


ListCheckedIcon

  • Const ListCheckedIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:270


LocationIcon

  • Const LocationIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:278


MaximizeIcon

  • Const MaximizeIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:286


MedicationIcon

  • Const MedicationIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:294


MessageQueueIcon

  • Const MessageQueueIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:302


MicroscopeIcon

  • Const MicroscopeIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:310


MoneyIcon

  • Const MoneyIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Billing

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:319


MovementIcon

  • Const MovementIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:327


OpenmrsDatePicker

  • Const OpenmrsDatePicker: ForwardRefExoticComponent<OpenmrsDatePickerProps & RefAttributes<HTMLDivElement>>

A date picker component to select a single date. Based on React Aria, but styled to look like Carbon.

Defined in

packages/framework/esm-styleguide/src/datepicker/index.tsx:251


OverflowMenuHorizontalIcon

  • Const OverflowMenuHorizontalIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:335


OverflowMenuVerticalIcon

  • Const OverflowMenuVerticalIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:343


PasswordIcon

  • Const PasswordIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:523


PedestrianFamilyIcon

  • Const PedestrianFamilyIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:351


PenIcon

  • Const PenIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:359


Pictogram

  • Const Pictogram: MemoExoticComponent<ForwardRefExoticComponent<SvgPictogramProps & RefAttributes<SVGSVGElement>>>

This is a utility type for custom pictograms

Defined in

packages/framework/esm-styleguide/src/pictograms/pictograms.tsx:20


PrinterIcon

  • Const PrinterIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:367


RadiologyIcon

  • Const RadiologyIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>> = ImageMedicalIcon

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:583


RenewIcon

  • Const RenewIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:375


ResetIcon

  • Const ResetIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:383


SaveIcon

  • Const SaveIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:399


SearchIcon

  • Const SearchIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:407


ShoppingCartAddItemIcon

  • Const ShoppingCartAddItemIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>> = ShoppingCartArrowDownIcon

Used as a button to add an item to the Order basket from a search

Note this is an alias for ShoppingCartArrowDownIcon

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:590


ShoppingCartArrowDownIcon

  • Const ShoppingCartArrowDownIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Used as a button to add an item to the Order basket from a search

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:433


ShoppingCartIcon

  • Const ShoppingCartIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Order Basket, the UI to enter Orders for Medications, Referrals, Labs, Procedures and more

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:424


StickyNoteAddIcon

  • Const StickyNoteAddIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Used as action button to open ward in-patient note workspace

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:442


SwitcherIcon

  • Const SwitcherIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:415


TableIcon

  • Const TableIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:459


TableOfContentsIcon

  • Const TableOfContentsIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Used as a button to add an item to the Order basket from a search

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:451


TimeIcon

  • Const TimeIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Lab investigations

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:468


ToolsIcon

  • Const ToolsIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:476


TranslateIcon

  • Const TranslateIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:391


TrashCanIcon

  • Const TrashCanIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:484


TreeViewAltIcon

  • Const TreeViewAltIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:492


UserAvatarIcon

  • Const UserAvatarIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

User of OpenMRS e.g. My Account

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:501


UserFollowIcon

  • Const UserFollowIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:509


UserIcon

  • Const UserIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:531


UserXrayIcon

  • Const UserXrayIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:517


ViewIcon

  • Const ViewIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:547


ViewOffIcon

  • Const ViewOffIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:539


WarningIcon

  • Const WarningIcon: MemoExoticComponent<ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>>

Defined in

packages/framework/esm-styleguide/src/icons/icons.tsx:555


backendDependencies

  • Const backendDependencies: Object

Type declaration

Name

Type

Name

Type

fhir2

string

webservices.rest

string

Defined in

packages/framework/esm-api/src/openmrs-backend-dependencies.ts:1


UI Variables

LeftNavMenu

  • Const LeftNavMenu: ForwardRefExoticComponent<SideNavProps & RefAttributes<HTMLElement>>

Defined in

packages/framework/esm-styleguide/src/left-nav/index.tsx:31


ResponsiveWrapper

  • Const ResponsiveWrapper: React.FC<ResponsiveWrapperProps>

ResponsiveWrapper enables a responsive behavior for the component its wraps, providing a different rendering based on the current layout type. On desktop, it renders the children as is, while on a tablet, it wraps them in a Carbon Layer Carbon Components React component. This provides a light background for form inputs on tablets, in accordance with the design requirements.

Defined in

packages/framework/esm-styleguide/src/responsive-wrapper/responsive-wrapper.component.tsx:15


Workspace Variables

ActionMenuButton

  • Const ActionMenuButton: React.FC<ActionMenuButtonProps>

Defined in

packages/framework/esm-styleguide/src/workspaces/action-menu-button/action-menu-button.component.tsx:38

API Functions

clearCurrentUser

clearCurrentUser(): void

Returns

void

Defined in

packages/framework/esm-api/src/shared-api-objects/current-user.ts:168


createAttachment

createAttachment(patientUuid, fileToUpload): Promise<FetchResponse<any>>

Parameters

Name

Type

Name

Type

patientUuid

string

fileToUpload

UploadedFile

Returns

Promise<FetchResponse<any>>

Defined in

packages/framework/esm-api/src/attachments.ts:19


deleteAttachmentPermanently

deleteAttachmentPermanently(attachmentUuid, abortController): Promise<FetchResponse<any>>

Parameters

Name

Type

Name

Type

attachmentUuid

string

abortController

AbortController

Returns

Promise<FetchResponse<any>>

Defined in

packages/framework/esm-api/src/attachments.ts:38


fetchCurrentPatient

fetchCurrentPatient(patientUuid, fetchInit?, includeOfflinePatients?): Promise<fhir.Patient | null>

Parameters

Name

Type

Default value

Name

Type

Default value

patientUuid

PatientUuid

undefined

fetchInit?

FetchConfig

undefined

includeOfflinePatients

boolean

true

Returns

Promise<fhir.Patient | null>

Defined in

packages/framework/esm-api/src/shared-api-objects/current-patient.ts:22


getAttachmentByUuid

getAttachmentByUuid(attachmentUuid, abortController): Promise<FetchResponse<any>>

Parameters

Name

Type

Name

Type

attachmentUuid

string

abortController

AbortController

Returns

Promise<FetchResponse<any>>

Defined in

packages/framework/esm-api/src/attachments.ts:7


getAttachments

getAttachments(patientUuid, includeEncounterless, abortController): Promise<FetchResponse<any>>

Parameters

Name

Type

Name

Type

patientUuid

string

includeEncounterless

boolean

abortController

AbortController

Returns

Promise<FetchResponse<any>>

Defined in

packages/framework/esm-api/src/attachments.ts:13


getCurrentUser

getCurrentUser(): Observable<Session>

The getCurrentUser function returns an observable that produces zero or more values, over time. It will produce zero values by default if the user is not logged in. And it will provide a first value when the logged in user is fetched from the server. Subsequent values will be produced whenever the user object is updated.

Returns

Observable<Session>

An Observable that produces zero or more values (as described above). The values produced will be a user object (if includeAuthStatus is set to false) or an object with a session and authenticated property (if includeAuthStatus is set to true).

Example

import { getCurrentUser } from '@openmrs/esm-api' const subscription = getCurrentUser().subscribe( user => console.log(user) ) subscription.unsubscribe() getCurrentUser({includeAuthStatus: true}).subscribe( data => console.log(data.authenticated) )

Be sure to unsubscribe when your component unmounts

Otherwise your code will continue getting updates to the user object even after the UI component is gone from the screen. This is a memory leak and source of bugs.

Defined in

packages/framework/esm-api/src/shared-api-objects/current-user.ts:65

getCurrentUser(opts): Observable<Session>

Parameters

Name

Type

Name

Type

opts

Object

opts.includeAuthStatus

true

Returns

Observable<Session>

Defined in

packages/framework/esm-api/src/shared-api-objects/current-user.ts:66

getCurrentUser(opts): Observable<LoggedInUser>

Parameters

Name

Type

Name

Type

opts

Object

opts.includeAuthStatus

false

Returns

Observable<LoggedInUser>

Defined in

packages/framework/esm-api/src/shared-api-objects/current-user.ts:67


getLocations

getLocations(tagUuidOrName?): Observable<Location[]>

Parameters

Name

Type

Default value

Name

Type

Default value

tagUuidOrName

null | string

null

Returns

Observable<Location[]>

Defined in

packages/framework/esm-api/src/shared-api-objects/location.ts:14


getLoggedInUser

getLoggedInUser(): Promise<LoggedInUser>

Returns

Promise<LoggedInUser>

Defined in

packages/framework/esm-api/src/shared-api-objects/current-user.ts:192


getSessionLocation

getSessionLocation(): Promise<undefined | SessionLocation>

Returns

Promise<undefined | SessionLocation>

Defined in

packages/framework/esm-api/src/shared-api-objects/current-user.ts:210


getSessionStore

getSessionStore(): StoreApi<SessionStore>

Returns

StoreApi<SessionStore>

Defined in

packages/framework/esm-api/src/shared-api-objects/current-user.ts:92


getVisitStore

getVisitStore(): StoreApi<VisitStoreState>

Returns

StoreApi<VisitStoreState>

Defined in

packages/framework/esm-api/src/shared-api-objects/visit-utils.ts:30


getVisitTypes

getVisitTypes(): Observable<VisitType[]>

Returns

Observable<VisitType[]>

Defined in

packages/framework/esm-api/src/shared-api-objects/visit-type.ts:15


getVisitsForPatient

getVisitsForPatient(patientUuid, abortController, v?): Observable<FetchResponse<{ results: Visit[] }>>

Parameters

Name

Type

Name

Type

patientUuid

string

abortController

AbortController

v?

string

Returns

Observable<FetchResponse<{ results: Visit[] }>>

Defined in

packages/framework/esm-api/src/shared-api-objects/visit-utils.ts:54


makeUrl

makeUrl(path): string

Append path to the OpenMRS SPA base.

Example

makeUrl('/foo/bar'); // => '/openmrs/foo/bar'

Parameters

Name

Type

Name

Type

path

string

Returns

string

Defined in

packages/framework/esm-api/src/openmrs-fetch.ts:25


openmrsFetch

openmrsFetch<T>(path, fetchInit?): Promise<FetchResponse<T>>

The openmrsFetch function is a wrapper around the browser's built-in fetch function, with extra handling for OpenMRS-specific API behaviors, such as request headers, authentication, authorization, and the API urls.

Type parameters

Name

Type

Name

Type

T

any

Parameters

Name

Type

Description

Name

Type

Description

path

string

A string url to make the request to. Note that the openmrs base url (by default /openmrs) will be automatically prepended to the URL, so there is no need to include it.

fetchInit

FetchConfig

A fetch init object. Note that the body property does not need to be JSON.stringify()ed because openmrsFetch will do that for you.

Returns

Promise<FetchResponse<T>>

A Promise that resolves with a Response object. Note that the openmrs version of the Response object has already downloaded the HTTP response body as json, and has an additional data property with the HTTP response json as a javascript object.

Example

import { openmrsFetch } from '@openmrs/esm-api' const abortController = new AbortController(); openmrsFetch(`${restBaseUrl}/session', {signal: abortController.signal}) .then(response => { console.log(response.data.authenticated) }) .catch(err => { console.error(err.status); }) abortController.abort(); openmrsFetch(`${restBaseUrl}/session', { method: 'POST', body: { username: 'hi', password: 'there', } })

Cancellation

To cancel a network request, use an AbortController. It is best practice to cancel your network requests when the user navigates away from a page while the request is pending request, to free up memory and network resources and to prevent race conditions.

Defined in

packages/framework/esm-api/src/openmrs-fetch.ts:85


openmrsObservableFetch

openmrsObservableFetch<T>(url, fetchInit?): Observable<FetchResponse<T>>

The openmrsObservableFetch function is a wrapper around openmrsFetch that returns an Observable instead of a promise. It exists in case using an Observable is preferred or more convenient than a promise.

Type parameters

Name

Name

T

Parameters

Name

Type

Description

Name

Type

Description

url

string

See openmrsFetch

fetchInit

FetchConfig

See openmrsFetch

Returns

Observable<FetchResponse<T>>

An Observable that produces exactly one Response object. The response object is exactly the same as for openmrsFetch.

Example

Cancellation

To cancel the network request, simply call subscription.unsubscribe();

Defined in

packages/framework/esm-api/src/openmrs-fetch.ts:265


refetchCurrentUser

refetchCurrentUser(username?, password?): Promise<SessionStore>

The refetchCurrentUser function causes a network request to redownload the user. All subscribers to the current user will be notified of the new users once the new version of the user object is downloaded.

Parameters

Name

Type

Name

Type

username?

string

password?

string

Returns

Promise<SessionStore>

The same observable as returned by getCurrentUser.

Example

Defined in

packages/framework/esm-api/src/shared-api-objects/current-user.ts:154


saveVisit

saveVisit(payload, abortController): Observable<FetchResponse<any>>

Parameters

Name

Type

Name

Type

payload

NewVisitPayload

abortController

AbortController

Returns

Observable<FetchResponse<any>>

Defined in

packages/framework/esm-api/src/shared-api-objects/visit-utils.ts:76


setCurrentVisit

setCurrentVisit(patientUuid, visitUuid): void

Parameters

Name

Type

Name

Type

patientUuid

string

visitUuid

string

Returns

void

Defined in

packages/framework/esm-api/src/shared-api-objects/visit-utils.ts:34


setSessionLocation

setSessionLocation(locationUuid, abortController): Promise<any>

Parameters

Name

Type

Name

Type

locationUuid

string

abortController

AbortController

Returns

Promise<any>

Defined in

packages/framework/esm-api/src/shared-api-objects/current-user.ts:219


setUserLanguage

setUserLanguage(data): void

Parameters

Name

Type

Name

Type

data

Session

Returns

void

Defined in

packages/framework/esm-api/src/shared-api-objects/current-user.ts:115


setUserProperties

setUserProperties(userUuid, userProperties, abortController?): Promise<SessionStore>

Parameters

Name

Type

Name

Type

userUuid

string

userProperties

Object

abortController?

AbortController

Returns

Promise<SessionStore>

Defined in

packages/framework/esm-api/src/shared-api-objects/current-user.ts:232


toLocationObject

toLocationObject(openmrsRestForm): Location

Parameters

Name

Type

Name

Type

openmrsRestForm

any

Returns

Location

Defined in

packages/framework/esm-api/src/shared-api-objects/location.ts:7


toVisitTypeObject

toVisitTypeObject(openmrsRestForm): VisitType

Parameters

Name

Type

Name

Type

openmrsRestForm

any

Returns

VisitType

Defined in

packages/framework/esm-api/src/shared-api-objects/visit-type.ts:7


updateVisit

updateVisit(uuid, payload, abortController): Observable<any>

Parameters

Name

Type

Name

Type

uuid

string

payload

NewVisitPayload

abortController

AbortController

Returns

Observable<any>

Defined in

packages/framework/esm-api/src/shared-api-objects/visit-utils.ts:87


useAttachments

useAttachments(patientUuid, includeEncounterless): Object

Parameters

Name

Type

Name

Type

patientUuid

string

includeEncounterless

boolean

Returns

Object

Name

Type

Name

Type

data

AttachmentResponse[]

error

any

isLoading

boolean

isValidating

boolean

mutate

KeyedMutator<FetchResponse<{ results: AttachmentResponse[] }>>

Defined in

packages/framework/esm-react-utils/src/useAttachments.ts:6


useLocations

useLocations(tagUuidOrName?): Location[]

Parameters

Name

Type

Default value

Name

Type

Default value

tagUuidOrName

null | string

null

Returns

Location[]

Defined in

packages/framework/esm-react-utils/src/useLocations.tsx:6


usePatient

usePatient(patientUuid?): Object

This React hook returns a patient object. If the patientUuid is provided as a parameter, then the patient for that UUID is returned. If the parameter is not provided, the patient UUID is obtained from the current route, and a route listener is set up to update the patient whenever the route changes.

Parameters

Name

Type

Name

Type

patientUuid?

string

Returns

Object

Name

Type

Name

Type

error

null | Error

isLoading

boolean

patient

NullablePatient

patientUuid

null | string

Defined in

packages/framework/esm-react-utils/src/usePatient.ts:90


usePrimaryIdentifierCode

usePrimaryIdentifierCode(): Object

Returns

Object

Name

Type

Name

Type

error

Error | undefined

isLoading

boolean

primaryIdentifierCode

string | undefined

Defined in

packages/framework/esm-react-utils/src/usePrimaryIdentifierResource.ts:13


useSession

useSession(): Session

Gets the current user session information. Returns an object with property authenticated == false if the user is not logged in.

Uses Suspense. This hook will always either return a Session object or throw for Suspense. It will never return null/undefined.

Returns

Session

Current user session information

Defined in

packages/framework/esm-react-utils/src/useSession.ts:17


useVisit

useVisit(patientUuid, representation?): VisitReturnType

This React hook returns visit information if the patient UUID is not null. There are potentially two relevant visits at a time: "active" and "current".

The active visit is the most recent visit without an end date. The presence of an active visit generally means that the patient is in the facility.

The current visit is the active visit, unless a retrospective visit has been selected. If there is no active visit and no selected retrospective visit, then there is no current visit. If there is no active visit but there is a retrospective visit, then the retrospective visit is the current visit. currentVisitIsRetrospective tells you whether the current visit is a retrospective visit.

The active visit and current visit require two separate API calls. error contains the error from either one, if there is an error. isValidating is true if either API call is in progress. mutate refreshes the data from both API calls.

Parameters

Name

Type

Default value

Description

Name

Type

Default value

Description

patientUuid

string

undefined

Unique patient identifier string

representation

string

defaultVisitCustomRepresentation

The custom representation of the visit

Returns

VisitReturnType

Defined in

packages/framework/esm-react-utils/src/useVisit.ts:42


useVisitTypes

useVisitTypes(): VisitType[]

Returns

VisitType[]

Defined in

packages/framework/esm-react-utils/src/useVisitTypes.ts:6


userHasAccess

userHasAccess(requiredPrivilege, user): boolean

Parameters

Name

Type

Name

Type

requiredPrivilege

string | string[]

user

Object

user.privileges

Privilege[]

user.roles

Role[]

Returns

boolean

Defined in

packages/framework/esm-api/src/shared-api-objects/current-user.ts:175


Breadcrumb Functions

filterBreadcrumbs

filterBreadcrumbs(list, path): BreadcrumbRegistration[]

Parameters

Name

Type

Name

Type

list

BreadcrumbRegistration[]

path

string

Returns

BreadcrumbRegistration[]

Defined in

packages/framework/esm-navigation/src/breadcrumbs/filter.ts:34


getBreadcrumbs

getBreadcrumbs(): BreadcrumbRegistration[]

Returns

BreadcrumbRegistration[]

Defined in

packages/framework/esm-navigation/src/breadcrumbs/db.ts:32


getBreadcrumbsFor

getBreadcrumbsFor(path): BreadcrumbRegistration[]

Parameters

Name

Type

Name

Type

path

string

Returns

BreadcrumbRegistration[]

Defined in

packages/framework/esm-navigation/src/breadcrumbs/filter.ts:54


registerBreadcrumb

registerBreadcrumb(breadcrumb): void

Parameters

Name

Type

Name

Type

breadcrumb

BreadcrumbSettings

Returns

void

Defined in

packages/framework/esm-navigation/src/breadcrumbs/db.ts:18


registerBreadcrumbs

registerBreadcrumbs(breadcrumbs): void

Parameters

Name

Type

Name

Type

breadcrumbs

BreadcrumbSettings[]

Returns

void

Defined in

packages/framework/esm-navigation/src/breadcrumbs/db.ts:22


Config Functions

defineConfigSchema

defineConfigSchema(moduleName, schema): void

This defines a configuration schema for a module. The schema tells the configuration system how the module can be configured. It specifies what makes configuration valid or invalid.

See Configuration System for more information about defining a config schema.

Parameters

Name

Type

Description

Name

Type

Description

moduleName

string

Name of the module the schema is being defined for. Generally should be the one in which the defineConfigSchema call takes place.

schema

ConfigSchema

The config schema for the module

Returns

void

Defined in

packages/framework/esm-config/src/module-config/module-config.ts:164


defineExtensionConfigSchema

defineExtensionConfigSchema(extensionName, schema): void

This defines a configuration schema for an extension. When a schema is defined for an extension, that extension will receive the configuration corresponding to that schema, rather than the configuration corresponding to the module in which it is defined.

The schema tells the configuration system how the module can be configured. It specifies what makes configuration valid or invalid.

See Configuration System for more information about defining a config schema.

Parameters

Name

Type

Description

Name

Type

Description

extensionName

string

Name of the extension the schema is being defined for. Should match the name of one of the extensions entries being returned by setupOpenMRS.

schema

ConfigSchema

The config schema for the extension

Returns

void

Defined in

packages/framework/esm-config/src/module-config/module-config.ts:225


getConfig

getConfig<T>(moduleName): Promise<T>

A promise-based way to access the config as soon as it is fully loaded. If it is already loaded, resolves the config in its present state.

This is a useful function if you need to get the config in the course of the execution of a function.

Type parameters

Name

Type

Name

Type

T

Record<string, any>

Parameters

Name

Type

Description

Name

Type

Description

moduleName

string

The name of the module for which to look up the config

Returns

Promise<T>

Defined in

packages/framework/esm-config/src/module-config/module-config.ts:257


provide

provide(config, sourceName?): void

Parameters

Name

Type

Default value

Name

Type

Default value

config

Config

undefined

sourceName

string

'provided'

Returns

void

Defined in

packages/framework/esm-config/src/module-config/module-config.ts:241


useConfig

useConfig<T>(options?): T

Use this React Hook to obtain your module's configuration.

Type parameters

Name

Type

Name

Type

T

Record<string, any>

Parameters

Name

Type

Description

Name

Type

Description

options?

UseConfigOptions

Additional options that can be passed to useConfig()

Returns

T

Defined in

packages/framework/esm-react-utils/src/useConfig.ts:139


Config Validation Functions

inRange

inRange(min, max): Validator

Verifies that the value is between the provided minimum and maximum

Parameters

Name

Type

Description

Name

Type

Description

min

number

Minimum acceptable value

max

number

Maximum acceptable value

Returns

Validator

Defined in

packages/framework/esm-config/src/validators/validators.ts:10


isUrl

isUrl(value): string | void

Verifies that a string contains only the default URL template parameters.

category Navigation

Parameters

Name

Type

Name

Type

value

any

Returns

string | void

Defined in

packages/framework/esm-config/src/validators/validators.ts:52


isUrlWithTemplateParameters

isUrlWithTemplateParameters(allowedTemplateParameters): Validator

Verifies that a string contains only the default URL template parameters, plus any specified in allowedTemplateParameters.

category Navigation

Parameters

Name

Type

Description

Name

Type

Description

allowedTemplateParameters

string[] | readonly string[]

To be added to openmrsBase and openmrsSpaBase

Returns

Validator

Defined in

packages/framework/esm-config/src/validators/validators.ts:21


oneOf

oneOf(allowedValues): Validator

Verifies that the value is one of the allowed options.

Parameters

Name

Type

Description

Name

Type

Description

allowedValues

any[] | readonly any[]

The list of allowable values

Returns

Validator

Defined in

packages/framework/esm-config/src/validators/validators.ts:58


validator

validator(validationFunction, message): Validator

Constructs a custom validator.

Example

Parameters

Name

Type

Description

Name

Type

Description

validationFunction

ValidatorFunction

Takes the configured value as input. Returns true if it is valid, false otherwise.

message

string | (value: any) => string

A string message that explains why the value is invalid. Can also be a function that takes the value as input and returns a string.

Returns

Validator

A validator ready for use in a config schema

Defined in

packages/framework/esm-config/src/validators/validator.ts:25


Context Functions

OpenmrsAppContext

OpenmrsAppContext<T>(__namedParameters): null

OpenmrsAppContext is a simple React component meant to function similarly to React's Context, but built on top of the OpenmrsAppContext.

example

Notes on usage: Unlike a proper React context where the value is limited to the subtree under the context component, the OpenmrsAppContext is inherently global in scope. That means that all applications will see the values that you set for the namespace if they load the value of the namespace.

Type parameters

Name

Type

Name

Type

T

extends Object

Parameters

Name

Type

Name

Type

__namedParameters

OpenmrsAppContextProps<T>

Returns

null

Defined in

packages/framework/esm-react-utils/src/OpenmrsContext.ts:24


getContext

getContext<T>(namespace): Readonly<T> | null

Returns an immutable version of the state of the namespace as it is currently

Type parameters

Name

Type

Description

Name

Type

Description

T

extends Object = {}

The type of the value stored in the namespace

Parameters

Name

Type

Description

Name

Type

Description

namespace

string

The namespace to load properties from

Returns

Readonly<T> | null

Defined in

packages/framework/esm-context/src/context.ts:55


registerContext

registerContext<T>(namespace, initialValue?): void

Used by callers to register a new namespace in the application context. Attempting to register an already-registered namespace will display a warning and make no modifications to the state.

Type parameters

Name

Type

Name

Type

T

extends Object = {}

Parameters

Name

Type

Default value

Description

Name

Type

Default value

Description

namespace

string

undefined

the namespace to register

initialValue

T

nothing

the initial value of the namespace

Returns

void

Defined in

packages/framework/esm-context/src/context.ts:29


subscribeToContext

subscribeToContext<T>(namespace, callback): () => void

Subscribes to updates of a given namespace. Note that the returned object is immutable.

Type parameters

Name

Type

Name

Type

T

extends Object = {}

Parameters

Name

Type

Description

Name

Type

Description

namespace

string

the namespace to subscribe to

callback

ContextCallback<T>

a function invoked with the current context whenever

Returns

fn

A function to unsubscribe from the context

▸ (): void

Returns

void

Defined in

packages/framework/esm-context/src/context.ts:99


unregisterContext

unregisterContext(namespace): void

Used by caller to unregister a namespace in the application context. Unregistering a namespace will remove the namespace and all associated data.

Parameters

Name

Type

Name

Type

namespace

string

Returns

void

Defined in

packages/framework/esm-context/src/context.ts:46


updateContext

updateContext<T>(namespace, update): void

Updates a namespace in the global context. If the namespace does not exist, it is registered.

Type parameters

Name

Type

Name

Type

T

extends Object = {}

Parameters

Name

Type

Name

Type

namespace

string

update

(state: T) => T

Returns

void

Defined in

packages/framework/esm-context/src/context.ts:79


useAppContext

useAppContext<T>(namespace): Readonly<T> | undefined

This hook is used to access a namespace within the overall AppContext, so that a component can use any shared contextual values. A selector may be provided to further restrict the properties returned from the namespace.

example

example

Type parameters

Name

Type

Description

Name

Type

Description

T

extends Object = {}

The type of the value stored in the namespace

Parameters

Name

Type

Description

Name

Type

Description

namespace

string

The namespace to load properties from

Returns

Readonly<T> | undefined

Defined in

packages/framework/esm-react-utils/src/useAppContext.ts:26


useDefineAppContext

useDefineAppContext<T>(namespace, value?): (update: (state: T) => T) => void

This hook is used to register a namespace in the AppContext. The component that registers the namespace is responsible for updating the value associated with the namespace. The namespace will be automatically removed when the component using this hook is unmounted.

example

example

Note that the AppContext does not allow the storing of undefined values in a namespace. Use null instead.

Type parameters

Name

Type

Description

Name

Type

Description

T

extends Object

The type of the value of the namespace

Parameters

Name

Type

Description

Name

Type

Description

namespace

string

The name of the namespace in the application context. Note that the namespace must be unique among currently registered namespaces in the application context.

value?

T

The value to associate with this namespace. Updating the value property will update the namespace value.

Returns

fn

A function which can be used to update the state associated with the namespace

▸ (update): void

Parameters

Name

Type

Name

Type

update

(state: T) => T

Returns

void

Defined in

packages/framework/esm-react-utils/src/useDefineAppContext.ts:37


Date and Time Functions

convertToLocaleCalendar

convertToLocaleCalendar(date, locale): CalendarDate | CalendarDateTime | ZonedDateTime

Converts a calendar date to the equivalent locale calendar date.

Parameters

Name

Type

Name

Type

date

CalendarDate | CalendarDateTime | ZonedDateTime

locale

string | Locale

Returns

CalendarDate | CalendarDateTime | ZonedDateTime

CalendarDate

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:404


formatDate

formatDate(date, options?): string

Formats the input date according to the current locale and the given options.

Default options:

  • mode: "standard",

  • time: "for today",

  • day: true,

  • month: true,

  • year: true

  • noToday: false

If the date is today then "Today" is produced (in the locale language). This behavior can be disabled with noToday: true.

When time is included, it is appended with a comma and a space. This agrees with the output of Date.prototype.toLocaleString for most locales.

Parameters

Name

Type

Name

Type

date

Date

options?

Partial<FormatDateOptions>

Returns

string

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:278


formatDatetime

formatDatetime(date, options?): string

Formats the input into a string showing the date and time, according to the current locale. The mode parameter is as described for formatDate.

This is created by concatenating the results of formatDate and formatTime with a comma and space. This agrees with the output of Date.prototype.toLocaleString for most locales.

Parameters

Name

Type

Name

Type

date

Date

options?

Partial<Omit<FormatDateOptions, "time">>

Returns

string

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:381


formatTime

formatTime(date): string

Formats the input as a time, according to the current locale. 12-hour or 24-hour clock depends on locale.

Parameters

Name

Type

Name

Type

date

Date

Returns

string

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:365


getDefaultCalendar

getDefaultCalendar(locale): undefined | string

Retrieves the default calendar for the specified locale if any.

Parameters

Name

Type

Description

Name

Type

Description

locale

undefined | string | Locale

the locale to look-up

Returns

undefined | string

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:252


getLocale

getLocale(): string

Returns the current locale of the application.

Returns

string

string

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:389


isOmrsDateStrict

isOmrsDateStrict(omrsPayloadString): boolean

This function checks whether a date string is the OpenMRS ISO format. The format should be YYYY-MM-DDTHH:mm:ss.SSSZZ

Parameters

Name

Type

Name

Type

omrsPayloadString

string

Returns

boolean

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:34


isOmrsDateToday

isOmrsDateToday(date): boolean

Parameters

Name

Type

Description

Name

Type

Description

date

DateInput

Checks if the provided date is today.

Returns

boolean

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:63


parseDate

parseDate(dateString): Date

Utility function to parse an arbitrary string into a date. Uses dayjs(dateString).

Parameters

Name

Type

Name

Type

dateString

string

Returns

Date

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:136


registerDefaultCalendar

registerDefaultCalendar(locale, calendar): void

Provides the name of the calendar to associate, as a default, with the given base locale.

example

Parameters

Name

Type

Description

Name

Type

Description

locale

string

the locale to register this calendar for

calendar

string

the calendar to use for this registration

Returns

void

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:243


toDateObjectStrict

toDateObjectStrict(omrsDateString): Date | null

Converts the object to a date object if it is an OpenMRS ISO date time string. Otherwise returns null.

Parameters

Name

Type

Name

Type

omrsDateString

string

Returns

Date | null

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:71


toOmrsDateFormat

toOmrsDateFormat(date, format?): string

deprecated use formatDate(date) Formats the input as a date string. By default the format "YYYY-MMM-DD" is used.

Parameters

Name

Type

Default value

Name

Type

Default value

date

DateInput

undefined

format

string

'YYYY-MMM-DD'

Returns

string

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:128


toOmrsDayDateFormat

toOmrsDayDateFormat(date): string

deprecated use formatDate(date, "wide") Formats the input as a date string using the format "DD - MMM - YYYY".

Parameters

Name

Type

Name

Type

date

DateInput

Returns

string

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:112


toOmrsIsoString

toOmrsIsoString(date, toUTC?): string

Formats the input to OpenMRS ISO format: "YYYY-MM-DDTHH:mm:ss.SSSZZ".

Parameters

Name

Type

Default value

Name

Type

Default value

date

DateInput

undefined

toUTC

boolean

false

Returns

string

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:82


toOmrsTimeString

toOmrsTimeString(date): string

deprecated use formatTime Formats the input as a time string using the format "HH:mm A".

Parameters

Name

Type

Name

Type

date

DateInput

Returns

string

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:104


toOmrsTimeString24

toOmrsTimeString24(date): string

deprecated use formatTime Formats the input as a time string using the format "HH:mm".

Parameters

Name

Type

Name

Type

date

DateInput

Returns

string

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:96


toOmrsYearlessDateFormat

toOmrsYearlessDateFormat(date): string

deprecated use formatDate(date, "no year") Formats the input as a date string using the format "DD-MMM".

Parameters

Name

Type

Name

Type

date

DateInput

Returns

string

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:120


Dynamic Loading Functions

importDynamic

importDynamic<T>(jsPackage, share?, options?): Promise<T>

Loads the named export from a named package. This might be used like:

Type parameters

Name

Type

Name

Type

T

any

Parameters

Name

Type

Default value

Description

Name

Type

Default value

Description

jsPackage

string

undefined

The package to load the export from.

share

string

'./start'

Indicates the name of the shared module; this is an advanced feature if the package you are loading doesn't use the default OpenMRS shared module name "./start".

options?

Object

undefined

Additional options to control loading this script.

options.importMap?

ImportMap

undefined

 

options.maxLoadingTime?

number

undefined

 

Returns

Promise<T>

Defined in

packages/framework/esm-dynamic-loading/src/dynamic-loading.ts:37


Error Handling Functions

createErrorHandler

createErrorHandler(): (incomingErr: any) => void

Returns

fn

▸ (incomingErr): void

Parameters

Name

Type

Name

Type

incomingErr

any

Returns

void

Defined in

packages/framework/esm-error-handling/src/index.ts:30


reportError

reportError(err): void

Parameters

Name

Type

Name

Type

err

any

Returns

void

Defined in

packages/framework/esm-error-handling/src/index.ts:23


Extension Functions

ExtensionSlot

ExtensionSlot(__namedParameters): Element

An extension slot. A place with a name. Extensions that get connected to that name will be rendered into this.

example Passing a react node as children

example Passing a function as children

Parameters

Name

Type

Name

Type

__namedParameters

ExtensionSlotProps

Returns

Element

Defined in

packages/framework/esm-react-utils/src/ExtensionSlot.tsx:81


attach

attach(slotName, extensionId): void

Attach an extension to an extension slot.

This will cause the extension to be rendered into the specified extension slot, unless it is removed by configuration. Using attach is an alternative to specifying the slot or slots in the extension declaration.

It is particularly useful when creating a slot into which you want to render an existing extension. This enables you to do so without modifying the extension's declaration, which may be impractical or inappropriate, for example if you are writing a module for a specific implementation.

Parameters

Name

Type

Description

Name

Type

Description

slotName

string

a name uniquely identifying the slot

extensionId

string

an extension name, with an optional #-suffix to distinguish it from other instances of the same extension attached to the same slot.

Returns

void

Defined in

packages/framework/esm-extensions/src/extensions.ts:143


detach

detach(extensionSlotName, extensionId): void

deprecated Avoid using this. Extension attachments should be considered declarative.

Parameters

Name

Type

Name

Type

extensionSlotName

string

extensionId

string

Returns

void

Defined in

packages/framework/esm-extensions/src/extensions.ts:176


detachAll

detachAll(extensionSlotName): void

deprecated Avoid using this. Extension attachments should be considered declarative.

Parameters

Name

Type

Name

Type

extensionSlotName

string

Returns

void

Defined in

packages/framework/esm-extensions/src/extensions.ts:200


getAssignedExtensions

getAssignedExtensions(slotName): AssignedExtension[]

Gets the list of extensions assigned to a given slot

Parameters

Name

Type

Description

Name

Type

Description

slotName

string

The slot to load the assigned extensions for

Returns

AssignedExtension[]

An array of extensions assigned to the named slot

Defined in

packages/framework/esm-extensions/src/extensions.ts:335


getConnectedExtensions

getConnectedExtensions(assignedExtensions, online?, enabledFeatureFlags?): ConnectedExtension[]

Filters a list of extensions according to whether they support the current connectivity status.

Parameters

Name

Type

Default value

Description

Name

Type

Default value

Description

assignedExtensions

AssignedExtension[]

undefined

The list of extensions to filter.

online

null | boolean

null

Whether the app is currently online. If null, uses navigator.onLine.

enabledFeatureFlags

null | string[]

null

The names of all enabled feature flags. If null, looks up the feature flags using the feature flags API.

Returns

ConnectedExtension[]

A list of extensions that should be rendered

Defined in

packages/framework/esm-extensions/src/extensions.ts:260


getExtensionNameFromId

getExtensionNameFromId(extensionId): string

Given an extension ID, which is a string uniquely identifying an instance of an extension within an extension slot, this returns the extension name.

example

Parameters

Name

Type

Name

Type

extensionId

string

Returns

string

Defined in

packages/framework/esm-extensions/src/extensions.ts:91


getExtensionStore

getExtensionStore(): StoreApi<ExtensionStore>

This returns a store that modules can use to get information about the state of the extension system.

Returns

StoreApi<ExtensionStore>

Defined in

packages/framework/esm-extensions/src/store.ts:124


renderExtension

renderExtension(domElement, extensionSlotName, extensionSlotModuleName, extensionId, renderFunction?, additionalProps?): Promise<Parcel | null>

Mounts into a DOM node (representing an extension slot) a lazy-loaded component from any frontend module that registered an extension component for this slot.

Parameters

Name

Type

Name

Type

domElement

HTMLElement

extensionSlotName

string

extensionSlotModuleName

string

extensionId

string

renderFunction

(application: ParcelConfig<CustomProps>) => ParcelConfig<CustomProps>

additionalProps

Record<string, any>

Returns

Promise<Parcel | null>

Defined in

packages/framework/esm-extensions/src/render.ts:18


useAssignedExtensionIds

useAssignedExtensionIds(slotName): string[]

Gets the assigned extension ids for a given extension slot name. Does not consider if offline or online.

deprecated Use useAssignedExtensions

Parameters

Name

Type

Description

Name

Type

Description

slotName

string

The name of the slot to get the assigned IDs for.

Returns

string[]

Defined in

packages/framework/esm-react-utils/src/useAssignedExtensionIds.ts:13


useAssignedExtensions

useAssignedExtensions(slotName): AssignedExtension[]

Gets the assigned extensions for a given extension slot name. Does not consider if offline or online.

Parameters

Name

Type

Description

Name

Type

Description

slotName

string

The name of the slot to get the assigned extensions for.

Returns

AssignedExtension[]

Defined in

packages/framework/esm-react-utils/src/useAssignedExtensions.ts:10


useConnectedExtensions

useConnectedExtensions(slotName): ConnectedExtension[]

Gets the assigned extension for a given extension slot name. Considers if offline or online, and what feature flags are enabled.

Parameters

Name

Type

Description

Name

Type

Description

slotName

string

The name of the slot to get the assigned extensions for.

Returns

ConnectedExtension[]

Defined in

packages/framework/esm-react-utils/src/useConnectedExtensions.ts:15


useExtensionSlotMeta

useExtensionSlotMeta<T>(extensionSlotName): Object

Extract meta data from all extension for a given extension slot.

Type parameters

Name

Type

Name

Type

T

ExtensionMeta

Parameters

Name

Type

Name

Type

extensionSlotName

string

Returns

Object

Defined in

packages/framework/esm-react-utils/src/useExtensionSlotMeta.ts:10


useExtensionStore

useExtensionStore(): T

Returns

T

Defined in

packages/framework/esm-react-utils/src/useExtensionStore.ts:6

useExtensionStore(actions): T & BoundActions

Parameters

Name

Type

Name

Type

actions

Actions<ExtensionStore>

Returns

T & BoundActions

Defined in

packages/framework/esm-react-utils/src/useExtensionStore.ts:6

useExtensionStore(actions?): T & BoundActions

Parameters

Name

Type

Name

Type

actions?

Actions<ExtensionStore>

Returns

T & BoundActions

Defined in

packages/framework/esm-react-utils/src/useExtensionStore.ts:6


useRenderableExtensions

useRenderableExtensions(name): React.FC<Pick<ExtensionProps, "state">>[]

This is an advanced hook for use-cases where its useful to use the extension system, but not the ExtensionSlot component's rendering of extensions. Use of this hook should be avoided if possible.

Functionally, this hook is very similar to the ExtensionSlot component, but whereas an ExtensionSlot renders a DOM tree of extensions bound to the slot, this hook simply returns the extensions as an array of React components that can be wired into a component however makes sense.

example

Parameters

Name

Type

Description

Name

Type

Description

name

string

The name of the extension slot

Returns

React.FC<Pick<ExtensionProps, "state">>[]

Defined in

packages/framework/esm-react-utils/src/useRenderableExtensions.tsx:31


Feature Flags Functions

getFeatureFlag

getFeatureFlag(flagName): boolean

Use this function to access the current value of the feature flag

If you are using React, use useFeatureFlag instead.

Parameters

Name

Type

Name

Type

flagName

string

Returns

boolean

Defined in

packages/framework/esm-feature-flags/src/feature-flags.ts:71


registerFeatureFlag

registerFeatureFlag(flagName, label, description): void

This function creates a feature flag. Call it in top-level code anywhere. It will not reset whether the flag is enabled or not, so it's safe to call it multiple times. Once a feature flag is created, it will appear with a toggle in the Implementer Tools. It can then be used to turn on or off features in the code.

Parameters

Name

Type

Description

Name

Type

Description

flagName

string

A code-friendly name for the flag, which will be used to reference it in code

label

string

A human-friendly name which will be displayed in the Implementer Tools

description

string

An explanation of what the flag does, which will be displayed in the Implementer Tools

Returns

void

Defined in

packages/framework/esm-feature-flags/src/feature-flags.ts:54


useFeatureFlag

useFeatureFlag(flagName): boolean

Use this function to tell whether a feature flag is toggled on or off.

Example:

Parameters

Name

Type

Name

Type

flagName

string

Returns

boolean

Defined in

packages/framework/esm-react-utils/src/useFeatureFlag.ts:19


Framework Functions

getAsyncExtensionLifecycle

getAsyncExtensionLifecycle<T>(lazy, options): () => Promise<any>

deprecated Use getAsyncLifecycle instead.

Type parameters

Name

Name

T

Parameters

Name

Type

Name

Type

lazy

() => Promise<{ default: ComponentType<T> }>

options

ComponentDecoratorOptions

Returns

fn

▸ (): Promise<any>

Returns

Promise<any>

Defined in

packages/framework/esm-react-utils/src/getLifecycle.ts:32


getAsyncLifecycle

getAsyncLifecycle<T>(lazy, options): () => Promise<any>

Type parameters

Name

Name

T

Parameters

Name

Type

Name

Type

lazy

() => Promise<{ default: ComponentType<T> }>

options

ComponentDecoratorOptions

Returns

fn

▸ (): Promise<any>

Returns

Promise<any>

Defined in

packages/framework/esm-react-utils/src/getLifecycle.ts:18


getLifecycle

getLifecycle<T>(Component, options): any

Type parameters

Name

Name

T

Parameters

Name

Type

Name

Type

Component

ComponentType<T>

options

ComponentDecoratorOptions

Returns

any

Defined in

packages/framework/esm-react-utils/src/getLifecycle.ts:10


getSyncLifecycle

getSyncLifecycle<T>(Component, options): () => Promise<any>

Type parameters

Name

Name

T

Parameters

Name

Type

Name

Type

Component

ComponentType<T>

options

ComponentDecoratorOptions

Returns

fn

▸ (): Promise<any>

Returns

Promise<any>

Defined in

packages/framework/esm-react-utils/src/getLifecycle.ts:25


Navigation Functions

ConfigurableLink

ConfigurableLink(__namedParameters): Element

A React link component which calls navigate when clicked

Parameters

Name

Type

Name

Type

__namedParameters

PropsWithChildren<ConfigurableLinkProps>

Returns

Element

Defined in

packages/framework/esm-react-utils/src/ConfigurableLink.tsx:53


getHistory

getHistory(): string[]

Returns a list of URLs representing the history of the current window session.

Returns

string[]

Defined in

packages/framework/esm-navigation/src/history/history.ts:47


goBackInHistory

goBackInHistory(toUrl:): void

Rolls back the history to the specified point and navigates to that URL.

Parameters

Name

Type

Description

Name

Type

Description

toUrl:

Object

The URL in the history to navigate to. History after that index will be deleted. If the URL is not found in the history, an error will be thrown.

toUrl:.toUrl

string

 

Returns

void

Defined in

packages/framework/esm-navigation/src/history/history.ts:58


interpolateString

interpolateString(template, params): string

Interpolates values of params into the template string.

Example usage:

Parameters

Name

Type

Description

Name

Type

Description

template

string

With optional params wrapped in ${ }

params

Object

Values to interpolate into the string template

Returns

string

Defined in

packages/framework/esm-navigation/src/navigation/interpolate-string.ts:60


interpolateUrl

interpolateUrl(template, additionalParams?): string

Interpolates a string with openmrsBase and openmrsSpaBase.

Useful for accepting ${openmrsBase} or ${openmrsSpaBase}plus additional template parameters in configurable URLs.

Example usage:

This can be used in conjunction with the navigate function like so

Parameters

Name

Type

Description

Name

Type

Description

template

string

A string to interpolate

additionalParams?

Object

Additional values to interpolate into the string template

Returns

string

Defined in

packages/framework/esm-navigation/src/navigation/interpolate-string.ts:36


navigate

navigate(to): void

Calls location.assign for non-SPA paths and navigateToUrl for SPA paths

Example usage:

Example behavior::

Parameters

Name

Type

Description

Name

Type

Description

to

NavigateOptions

The target path or URL. Supports templating with 'openmrsBase', 'openmrsSpaBase', and any additional template parameters defined in templateParams. For example, ${openmrsSpaBase}/home will resolve to /openmrs/spa/home for implementations using the standard OpenMRS and SPA base paths. If templateParams contains { foo: "bar" }, then the URL ${openmrsBase}/${foo} will become /openmrs/bar.

Returns

void

Defined in

packages/framework/esm-navigation/src/navigation/navigate.ts:49


Offline Functions

beginEditSynchronizationItem

beginEditSynchronizationItem(id): Promise<void>

Triggers an edit flow for the given synchronization item. If this is not possible, throws an error.

Parameters

Name

Type

Description

Name

Type

Description

id

number

The ID of the synchronization item to be edited.

Returns

Promise<void>

Defined in

packages/framework/esm-offline/src/sync.ts:330


canBeginEditSynchronizationItemsOfType

canBeginEditSynchronizationItemsOfType(type): boolean

Returns whether editing synchronization items of the given type is supported by the currently registered synchronization handlers.

Parameters

Name

Type

Description

Name

Type

Description

type

string

The identifying type of the synchronization item which should be edited.

Returns

boolean

Defined in

packages/framework/esm-offline/src/sync.ts:320


deleteSynchronizationItem

deleteSynchronizationItem(id): Promise<void>

Deletes a queued up sync item with the given ID.

Parameters

Name

Type

Description

Name

Type

Description

id

number

The ID of the synchronization item to be deleted.

Returns

Promise<void>

Defined in

packages/framework/esm-offline/src/sync.ts:350


generateOfflineUuid

generateOfflineUuid(): string

Generates a UUID-like string which is used for uniquely identifying objects while offline.

Returns

string

Defined in

packages/framework/esm-offline/src/uuid.ts:7


getCurrentOfflineMode

getCurrentOfflineMode(): OfflineModeResult

Returns

OfflineModeResult

Defined in

packages/framework/esm-offline/src/mode.ts:45


getDynamicOfflineDataEntries

getDynamicOfflineDataEntries<T>(type?): Promise<T[]>

Returns all DynamicOfflineData entries which registered for the currently logged in user. Optionally returns only entries of a given type.

Type parameters

Name

Type

Name

Type

T

extends DynamicOfflineData

Parameters

Name

Type

Description

Name

Type

Description

type?

string

The type of the entries to be returned. If undefined, returns all types.

Returns

Promise<T[]>

Defined in

packages/framework/esm-offline/src/dynamic-offline-data.ts:128


getDynamicOfflineDataEntriesFor

getDynamicOfflineDataEntriesFor<T>(userId, type?): Promise<T[]>

Returns all DynamicOfflineData entries which registered for the given user. Optionally returns only entries of a given type.

Type parameters

Name

Type

Name

Type

T

extends DynamicOfflineData

Parameters

Name

Type

Description

Name

Type

Description

userId

string

The ID of the user whose entries are to be retrieved.

type?

string

The type of the entries to be returned. If undefined, returns all types.

Returns

Promise<T[]>

Defined in

packages/framework/esm-offline/src/dynamic-offline-data.ts:139


getDynamicOfflineDataHandlers

getDynamicOfflineDataHandlers(): DynamicOfflineDataHandler[]

Returns all handlers which have been setup using the setupDynamicOfflineDataHandler function.

Returns

DynamicOfflineDataHandler[]

Defined in

packages/framework/esm-offline/src/dynamic-offline-data.ts:104


getFullSynchronizationItems

getFullSynchronizationItems<T>(type?): Promise<SyncItem<T>[]>

Returns all currently queued up sync items of the currently signed in user.

Type parameters

Name

Name

T

Parameters

Name

Type

Description

Name

Type

Description

type?

string

The identifying type of the synchronization items to be returned.

Returns

Promise<SyncItem<T>[]>

Defined in

packages/framework/esm-offline/src/sync.ts:302


getFullSynchronizationItemsFor

getFullSynchronizationItemsFor<T>(userId, type?): Promise<SyncItem<T>[]>

Returns all currently queued up sync items of a given user.

Type parameters

Name

Name

T

Parameters

Name

Type

Description

Name

Type

Description

userId

string

The ID of the user whose synchronization items should be returned.

type?

string

The identifying type of the synchronization items to be returned..

Returns

Promise<SyncItem<T>[]>

Defined in

packages/framework/esm-offline/src/sync.ts:281


getOfflinePatientDataStore

getOfflinePatientDataStore(): StoreApi<OfflinePatientDataSyncStore>

deprecated Will be removed once all modules have been migrated to the new dynamic offline data API.

Returns

StoreApi<OfflinePatientDataSyncStore>

Defined in

packages/framework/esm-offline/src/offline-patient-data.ts:39


getSynchronizationItem

getSynchronizationItem<T>(id): Promise<SyncItem<T> | undefined>

Returns a queued sync item with the given ID or undefined if no such item exists.

Type parameters

Name

Type

Name

Type

T

any

Parameters

Name

Type

Description

Name

Type

Description

id

number

The ID of the requested sync item.

Returns

Promise<SyncItem<T> | undefined>

Defined in

packages/framework/esm-offline/src/sync.ts:311


getSynchronizationItems

getSynchronizationItems<T>(type?): Promise<T[]>

Returns the content of all currently queued up sync items of the currently signed in user.

Type parameters

Name

Name

T

Parameters

Name

Type

Description

Name

Type

Description

type?

string

The identifying type of the synchronization items to be returned.

Returns

Promise<T[]>

Defined in

packages/framework/esm-offline/src/sync.ts:293


isOfflineUuid

isOfflineUuid(uuid): boolean

Checks whether the given string has the format of an offline UUID generated by generateOfflineUuid

Parameters

Name

Type

Name

Type

uuid

string

Returns

boolean

Defined in

packages/framework/esm-offline/src/uuid.ts:12


messageOmrsServiceWorker

messageOmrsServiceWorker(message): Promise<MessageServiceWorkerResult<any>>

Sends the specified message to the application's service worker.

Parameters

Name

Type

Description

Name

Type

Description

message

KnownOmrsServiceWorkerMessages

The message to be sent.

Returns

Promise<MessageServiceWorkerResult<any>>

A promise which completes when the message has been successfully processed by the Service Worker.

Defined in

packages/framework/esm-offline/src/service-worker-messaging.ts:11


putDynamicOfflineData

putDynamicOfflineData(type, identifier): Promise<void>

Declares that dynamic offline data of the given type with the given identifier should be made available offline for the currently logged in user.

Parameters

Name

Type

Description

Name

Type

Description

type

string

The type of the offline data. See DynamicOfflineData for details.

identifier

string

The identifier of the offline data. See DynamicOfflineData for details.

Returns

Promise<void>

Defined in

packages/framework/esm-offline/src/dynamic-offline-data.ts:157


putDynamicOfflineDataFor

putDynamicOfflineDataFor(userId, type, identifier): Promise<void>

Declares that dynamic offline data of the given type with the given identifier should be made available offline for the user with the given ID.

Parameters

Name

Type

Description

Name

Type

Description

userId

string

The ID of the user for whom the dynamic offline data should be made available.

type

string

The type of the offline data. See DynamicOfflineData for details.

identifier

string

The identifier of the offline data. See DynamicOfflineData for details.

Returns

Promise<void>

Defined in

packages/framework/esm-offline/src/dynamic-offline-data.ts:169


queueSynchronizationItem

queueSynchronizationItem<T>(type, content, descriptor?): Promise<number>

Enqueues a new item in the sync queue and associates the item with the currently signed in user.

Type parameters

Name

Name

T

Parameters

Name

Type

Description

Name

Type

Description

type

string

The identifying type of the synchronization item.

content

T

The actual data to be synchronized.

descriptor?

QueueItemDescriptor

An optional descriptor providing additional metadata about the sync item.

Returns

Promise<number>

Defined in

packages/framework/esm-offline/src/sync.ts:261


registerOfflinePatientHandler

registerOfflinePatientHandler(identifier, handler): void

deprecated Will be removed once all modules have been migrated to the new dynamic offline data API.

Parameters

Name

Type

Name

Type

identifier

string

handler

OfflinePatientDataSyncHandler

Returns

void

Defined in

packages/framework/esm-offline/src/offline-patient-data.ts:45


removeDynamicOfflineData

removeDynamicOfflineData(type, identifier): Promise<void>

Declares that dynamic offline data of the given type with the given identifier no longer needs to be available offline for the currently logged in user.

Parameters

Name

Type

Description

Name

Type

Description

type

string

The type of the offline data. See DynamicOfflineData for details.

identifier

string

The identifier of the offline data. See DynamicOfflineData for details.

Returns

Promise<void>

Defined in

packages/framework/esm-offline/src/dynamic-offline-data.ts:201


removeDynamicOfflineDataFor

removeDynamicOfflineDataFor(userId, type, identifier): Promise<void>

Declares that dynamic offline data of the given type with the given identifier no longer needs to be available offline for the user with the given ID.

Parameters

Name

Type

Description

Name

Type

Description

userId

string

The ID of the user who doesn't require the specified offline data.

type

string

The type of the offline data. See DynamicOfflineData for details.

identifier

string

The identifier of the offline data. See DynamicOfflineData for details.

Returns

Promise<void>

Defined in

packages/framework/esm-offline/src/dynamic-offline-data.ts:213


setupDynamicOfflineDataHandler

setupDynamicOfflineDataHandler(handler): void

Sets up a handler for synchronizing dynamic offline data. See DynamicOfflineDataHandler for details.

Parameters

Name

Type

Description

Name

Type

Description

handler

DynamicOfflineDataHandler

The handler to be setup.

Returns

void

Defined in

packages/framework/esm-offline/src/dynamic-offline-data.ts:113


setupOfflineSync

setupOfflineSync<T>(type, dependsOn, process, options?): void

Registers a new synchronization handler which is able to synchronize data of a specific type.

Type parameters

Name

Name

T

Parameters

Name

Type

Description

Name

Type

Description

type

string

The identifying type of the synchronization items which can be handled by this handler.

dependsOn

string[]

An array of other sync item types which must be synchronized before this handler can synchronize its own data. Items of these types are effectively dependencies of the data synchronized by this handler.

process

ProcessSyncItem<T>

A function which, when invoked, performs the actual client-server synchronization of the given item (which is the actual data to be synchronized).

options

SetupOfflineSyncOptions<T>

Additional options which can optionally be provided when setting up a synchronization callback for a specific synchronization item type.

Returns

void

Defined in

packages/framework/esm-offline/src/sync.ts:365


subscribeConnectivity

subscribeConnectivity(cb): () => void

Parameters

Name

Type

Name

Type

cb

(ev: ConnectivityChangedEvent) => void

Returns

fn

▸ (): void

Returns

void

Defined in

packages/framework/esm-globals/src/events.ts:23


subscribeConnectivityChanged

subscribeConnectivityChanged(cb): () => void

Parameters

Name

Type

Name

Type

cb

(ev: ConnectivityChangedEvent) => void

Returns

fn

▸ (): void

Returns

void

Defined in

packages/framework/esm-globals/src/events.ts:12


subscribePrecacheStaticDependencies

subscribePrecacheStaticDependencies(cb): () => void

Parameters

Name

Type

Name

Type

cb

(data: PrecacheStaticDependenciesEvent) => void

Returns

fn

▸ (): void

Returns

void

Defined in

packages/framework/esm-globals/src/events.ts:37


syncAllDynamicOfflineData

syncAllDynamicOfflineData(type, abortSignal?): Promise<void>

Synchronizes all offline data entries of the given type for the currently logged in user.

Parameters

Name

Type

Description

Name

Type

Description

type

string

The type of the offline data. See DynamicOfflineData for details.

abortSignal?

AbortSignal

An {@link AbortSignal} which can be used to cancel the operation.

Returns

Promise<void>

Defined in

packages/framework/esm-offline/src/dynamic-offline-data.ts:241


syncDynamicOfflineData

syncDynamicOfflineData(type, identifier, abortSignal?): Promise<void>

Synchronizes a single offline data entry of the given type for the currently logged in user.

Parameters

Name

Type

Description

Name

Type

Description

type

string

The type of the offline data. See DynamicOfflineData for details.

identifier

string

The identifier of the offline data. See DynamicOfflineData for details.

abortSignal?

AbortSignal

An {@link AbortSignal} which can be used to cancel the operation.

Returns

Promise<void>

Defined in

packages/framework/esm-offline/src/dynamic-offline-data.ts:254


syncOfflinePatientData

syncOfflinePatientData(patientUuid): Promise<void>

deprecated Will be removed once all modules have been migrated to the new dynamic offline data API.

Parameters

Name

Type

Name

Type

patientUuid

string

Returns

Promise<void>

Defined in

packages/framework/esm-offline/src/offline-patient-data.ts:62


useConnectivity

useConnectivity(): boolean

Returns

boolean

Defined in

packages/framework/esm-react-utils/src/useConnectivity.ts:6


Other Functions

WorkspaceContainer

WorkspaceContainer(__namedParameters): Element

Use this component to render the workspace window in an app such as the patient chart, or a workspace overlay in an app such as the clinic dashboard. This allows workspaces to be opened on the page where this component is mounted. This component must not be mounted multiple times on the same page. If there are multiple apps on a page, only one of those apps should use this component—it "hosts" the workspaces.

Workspaces may be opened with the launchWorkspace function from @openmrs/esm-framework (among other options).

The overlay prop determines whether the workspace is rendered as an overlay or a window. When a workspace window is opened, the other content on the screen will be pushed to the left. When an overlay is opened, it will cover other content on the screen.

The context key is a string that appears in the URL, which defines the pages on which workspaces are valid. If the URL changes in a way such that it no longer contains the context key, then all workspaces will be closed. This ensures that, for example, workspaces on the home page do not stay open when the user transitions to the patient dashboard; and also that workspaces do not stay open when the user navigates to a different patient. The context key must be a valid sub-path of the URL, with no initial or trailing slash. So if the URL is https://example.com/patient/123/foo, then patient and patient/123 and 123/foo are valid context keys, but patient/12 and pati are not.

An extension slot is provided in the workspace header. Its name is derived from the featureName of the top-level component in which it is defined (feature names are generally provided in the lifecycle functions in an app's index.ts file). The slot is named workspace-header-${featureName}-slot. For the patient chart, this is workspace-header-patient-chart-slot.

This component also provides the Siderail and Bottom Nav. To use this, pass the showSiderailAndBottomNav prop. The Siderail is rendered on the right side of the screen on desktop, and the Bottom Nav is rendered at the bottom of the screen on tablet or mobile. The sidebar/bottom-nav menu provides an extension slot, to which buttons are attached as extensions. The slot derives its name from the featureName of the top-level component in which this WorkspaceContainer appears (feature names are generally provided in the lifecycle functions in an app's index.ts file). The slot is named action-menu-${featureName}-items-slot. For the patient chart, this is action-menu-patient-chart-items-slot.

This component also provides everything needed for workspace notifications to be rendered.

Parameters

Name

Type

Name

Type

__namedParameters

WorkspaceContainerProps

Returns

Element

Defined in

packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx:67


isOnline

isOnline(online?): boolean

Parameters

Name

Type

Name

Type

online?

boolean

Returns

boolean

Defined in

packages/framework/esm-utils/src/is-online.ts:3


Store Functions

createGlobalStore

createGlobalStore<T>(name, initialState): StoreApi<T>

Creates a Zustand store.

Type parameters

Name

Name

T

Parameters

Name

Type

Description

Name

Type

Description

name

string

A name by which the store can be looked up later. Must be unique across the entire application.

initialState

T

An object which will be the initial state of the store.

Returns

StoreApi<T>

The newly created store.

Defined in

packages/framework/esm-state/src/state.ts:29


createUseStore

createUseStore<T>(store): () => T(actions: Actions<T>) => T & BoundActions(actions?: Actions<T>) => T & BoundActions

Whenever possible, use useStore(yourStore) instead. This function is for creating a custom hook for a specific store.

Type parameters

Name

Name

T

Parameters

Name

Type

Name

Type

store

StoreApi<T>

Returns

fn

▸ (): T

Returns

T

▸ (actions): T & BoundActions

Parameters

Name

Type

Name

Type

actions

Actions<T>

Returns

T & BoundActions

▸ (actions?): T & BoundActions

Parameters

Name

Type

Name

Type

actions?

Actions<T>

Returns

T & BoundActions

Defined in

packages/framework/esm-react-utils/src/useStore.ts:60


getGlobalStore

getGlobalStore<T>(name, fallbackState?): StoreApi<T>

Returns the existing store named name, or creates a new store named name if none exists.

Type parameters

Name

Name

T

Parameters

Name

Type

Description

Name

Type

Description

name

string

The name of the store to look up.

fallbackState?

T

The initial value of the new store if no store named name exists.

Returns

StoreApi<T>

The found or newly created store.

Defined in

packages/framework/esm-state/src/state.ts:91


subscribeTo

subscribeTo<T, U>(store, select, handle): () => void

Type parameters

Name

Name

T

U

Parameters

Name

Type

Name

Type

store

StoreApi<T>

select

(state: T) => U

handle

(subState: U) => void

Returns

fn

▸ (): void

Returns

void

Defined in

packages/framework/esm-state/src/state.ts:106


useStore

useStore<T, U>(store): T

Type parameters

Name

Name

T

U

Parameters

Name

Type

Name

Type

store

StoreApi<T>

Returns

T

Defined in

packages/framework/esm-react-utils/src/useStore.ts:33

useStore<T, U>(store, select): U

Type parameters

Name

Name

T

U

Parameters

Name

Type

Name

Type

store

StoreApi<T>

select

(state: T) => U

Returns

U

Defined in

packages/framework/esm-react-utils/src/useStore.ts:34

useStore<T, U>(store, select, actions): T & BoundActions

Type parameters

Name

Name

T

U

Parameters

Name

Type

Name

Type

store

StoreApi<T>

select

undefined

actions

Actions<T>

Returns

T & BoundActions

Defined in

packages/framework/esm-react-utils/src/useStore.ts:35

useStore<T, U>(store, select, actions): U & BoundActions

Type parameters

Name

Name

T

U

Parameters

Name

Type

Name

Type

store

StoreApi<T>

select

(state: T) => U

actions

Actions<T>

Returns

U & BoundActions

Defined in

packages/framework/esm-react-utils/src/useStore.ts:36


useStoreWithActions

useStoreWithActions<T>(store, actions): T & BoundActions

Type parameters

Name

Name

T

Parameters

Name

Type

Description

Name

Type

Description

store

StoreApi<T>

A zustand store

actions

Actions<T>

 

Returns

T & BoundActions

Defined in

packages/framework/esm-react-utils/src/useStore.ts:52


Translation Functions

getCoreTranslation

getCoreTranslation(key, defaultText?, options?): string

Use this function to obtain a translation from the core translations. This is a way to avoid having to define common translations in your app, and to ensure that translations are consistent across different apps. This function is also used to obtain translations in the framework and app shell.

The complete set of core translations is available on the CoreTranslationKey type. Providing an invalid key to this function will result in a type error.

Parameters

Name

Type

Description

Name

Type

Description

key

"error" | "change" | "close" | "other" | "actions" | "address" | "age" | "cancel" | "confirm" | "contactAdministratorIfIssuePersists" | "contactDetails" | "errorCopy" | "female" | "hideDetails" | "loading" | "male" | "patientIdentifierSticker" | "patientLists" | "print" | "printError" | "printErrorExplainer" | "printIdentifierSticker" | "printing" | "relationships" | "resetOverrides" | "scriptLoadingFailed" | "scriptLoadingError" | "seeMoreLists" | "sex" | "showDetails" | "unknown" | "closeAllOpenedWorkspaces" | "closingAllWorkspacesPromptBody" | "closingAllWorkspacesPromptTitle" | "discard" | "hide" | "maximize" | "minimize" | "openAnyway" | "unsavedChangesInOpenedWorkspace" | "unsavedChangesInWorkspace" | "unsavedChangesTitleText" | "workspaceHeader" | "address1" | "address2" | "address3" | "address4" | "address5" | "address6" | "city" | "cityVillage" | "country" | "countyDistrict" | "postalCode" | "state" | "stateProvince"

-

defaultText?

string

-

options?

object

Object passed to the i18next t function. See https://www.i18next.com/translation-function/essentials#overview-options for more information. ns and defaultValue are already set and may not be used.

Returns

string

Defined in

packages/framework/esm-translations/src/index.ts:60


translateFrom

translateFrom(moduleName, key, fallback?, options?): string

This function is for getting a translation from a specific module. Use this only if the translation is neither in the app making the call, nor in the core translations. This function is useful, for example, in libraries that are used by multiple apps, since libraries can't define their own translations.

Translations within the current app should be accessed with the i18next API, using useTranslation and t as usual. Core translations should be accessed with the getCoreTranslation function.

IMPORTANT: This function creates a hidden dependency on the module. Worse yet, it creates a dependency specifically on that module's translation keys, which are often regarded as "implementation details" and therefore may be volatile. This function should therefore be avoided when possible.

Parameters

Name

Type

Description

Name

Type

Description

moduleName

string

The module to get the translation from, e.g. '@openmrs/esm-login-app'

key

string

The i18next translation key

fallback?

string

Fallback text for if the lookup fails

options?

object

Options object passed to the i18next t function. See https://www.i18next.com/translation-function/essentials#overview-options for more information. ns and defaultValue are already set and may not be used.

Returns

string

The translated text as a string

Defined in

packages/framework/esm-translations/src/index.ts:39


UI Functions

CustomOverflowMenu

CustomOverflowMenu(__namedParameters): Element

Parameters

Name

Type

Name

Type

__namedParameters

CustomOverflowMenuProps

Returns

Element

Defined in

packages/framework/esm-styleguide/src/custom-overflow-menu/custom-overflow-menu.component.tsx:13


PatientBannerActionsMenu

PatientBannerActionsMenu(__namedParameters): Element

Parameters

Name

Type

Name

Type

__namedParameters

PatientBannerActionsMenuProps

Returns

Element

Defined in

packages/framework/esm-styleguide/src/patient-banner/actions-menu/patient-banner-actions-menu.component.tsx:20


PatientBannerContactDetails

PatientBannerContactDetails(__namedParameters): Element

Parameters

Name

Type

Name

Type

__namedParameters

ContactDetailsProps

Returns

Element

Defined in

packages/framework/esm-styleguide/src/patient-banner/contact-details/patient-banner-contact-details.component.tsx:179


PatientBannerPatientInfo

PatientBannerPatientInfo(__namedParameters): Element

Parameters

Name

Type

Name

Type

__namedParameters

PatientBannerPatientInfoProps

Returns

Element

Defined in

packages/framework/esm-styleguide/src/patient-banner/patient-info/patient-banner-patient-info.component.tsx:14


PatientBannerToggleContactDetailsButton

PatientBannerToggleContactDetailsButton(__namedParameters): Element

Parameters

Name

Type

Name

Type

__namedParameters

PatientBannerToggleContactDetailsButtonProps

Returns

Element

Defined in

packages/framework/esm-styleguide/src/patient-banner/contact-details/patient-banner-toggle-contact-details-button.component.tsx:16


PatientPhoto

PatientPhoto(__namedParameters): Element

A component which displays the patient photo. If there is no photo, it will display a generated avatar. The default size is 80px. Set the size prop to 'small' to display a 48px avatar.

Parameters

Name

Type

Name

Type

__namedParameters

PatientPhotoProps

Returns

Element

Defined in

packages/framework/esm-styleguide/src/patient-photo/patient-photo.component.tsx:18


isDesktop

isDesktop(layout): boolean

Parameters

Name

Type

Name

Type

layout

LayoutType

Returns

boolean

Defined in

packages/framework/esm-react-utils/src/useLayoutType.ts:40


setLeftNav

setLeftNav(__namedParameters): void

Parameters

Name

Type

Name

Type

__namedParameters

Object

Returns

void

Defined in

packages/framework/esm-styleguide/src/left-nav/index.tsx:19


showActionableNotification

showActionableNotification(notification): void

Displays an actionable notification in the UI.

Parameters

Name

Type

Description

Name

Type

Description

notification

ActionableNotificationDescriptor

The description of the notification to display.

Returns

void

Defined in

packages/framework/esm-styleguide/src/notifications/index.tsx:85


showModal

showModal(modalName, props?, onClose?): () => void

Shows a modal dialog.

The modal must have been registered by name. This should be done in the routes.json file of the app that defines the modal. Note that both the <ModalHeader> and <ModalBody> should be at the top level of the modal component (wrapped in a React.Fragment), or else the content of the modal body might not vertical-scroll properly.

Parameters

Name

Type

Description

Name

Type

Description

modalName

string

The name of the modal to show.

props

Record<string, any>

The optional props to provide to the modal.

onClose

() => void

The optional callback to call when the modal is closed.

Returns

fn

The dispose function to force closing the modal dialog.

▸ (): void

Returns

void

Defined in

packages/framework/esm-styleguide/src/modals/index.tsx:208


showNotification

showNotification(notification): void

Displays an inline notification in the UI.

Parameters

Name

Type

Description

Name

Type

Description

notification

NotificationDescriptor

The description of the notification to display.

Returns

void

Defined in

packages/framework/esm-styleguide/src/notifications/index.tsx:43


showSnackbar

showSnackbar(snackbar): void

Displays a snack bar notification in the UI.

Parameters

Name

Type

Description

Name

Type

Description

snackbar

SnackbarDescriptor

The description of the snack bar to display.

Returns

void

Defined in

packages/framework/esm-styleguide/src/snackbars/index.tsx:32


showToast

showToast(toast): void

Displays a toast notification in the UI.

Parameters

Name

Type

Description

Name

Type

Description

toast

ToastDescriptor

The description of the toast to display.

Returns

void

Defined in

packages/framework/esm-styleguide/src/toasts/index.tsx:36


subscribeActionableNotificationShown

subscribeActionableNotificationShown(cb): () => void

Parameters

Name

Type

Name

Type

cb

(data: ShowActionableNotificationEvent) => void

Returns

fn

▸ (): void

Returns

void

Defined in

packages/framework/esm-globals/src/events.ts:111


subscribeNotificationShown

subscribeNotificationShown(cb): () => void

Parameters

Name

Type

Name

Type

cb

(data: ShowNotificationEvent) => void

Returns

fn

▸ (): void

Returns

void

Defined in

packages/framework/esm-globals/src/events.ts:104


subscribeSnackbarShown

subscribeSnackbarShown(cb): () => void

Parameters

Name

Type

Name

Type

cb

(data: ShowSnackbarEvent) => void

Returns

fn

▸ (): void

Returns

void

Defined in

packages/framework/esm-globals/src/events.ts:125


subscribeToastShown

subscribeToastShown(cb): () => void

Parameters

Name

Type

Name

Type

cb

(data: ShowToastEvent) => void

Returns

fn

▸ (): void

Returns

void

Defined in

packages/framework/esm-globals/src/events.ts:118


unsetLeftNav

unsetLeftNav(name): void

Parameters

Name

Type

Name

Type

name

any

Returns

void

Defined in

packages/framework/esm-styleguide/src/left-nav/index.tsx:23


useBodyScrollLock

useBodyScrollLock(active): void

Parameters

Name

Type

Name

Type

active

boolean

Returns

void

Defined in

packages/framework/esm-react-utils/src/useBodyScrollLock.ts:4


useLayoutType

useLayoutType(): LayoutType

Returns

LayoutType

Defined in

packages/framework/esm-react-utils/src/useLayoutType.ts:26


useOnClickOutside

useOnClickOutside<T>(handler, active?): RefObject<T>

Type parameters

Name

Type

Name

Type

T

extends HTMLElement<T> = HTMLElement

Parameters

Name

Type

Default value

Name

Type

Default value

handler

(event: MouseEvent) => void

undefined

active

boolean

true

Returns

RefObject<T>

Defined in

packages/framework/esm-react-utils/src/useOnClickOutside.ts:4


usePagination

usePagination<T>(data?, resultsPerPage?): Object

Type parameters

Name

Name

T

Parameters

Name

Type

Default value

Name

Type

Default value

data

T[]

[]

resultsPerPage

number

defaultResultsPerPage

Returns

Object

Name

Type

Name

Type

currentPage

number

goTo

(page: number) => void

goToNext

() => void

goToPrevious

() => void

paginated

boolean

results

T[]

showNextButton

boolean

showPreviousButton

boolean

totalPages

number

Defined in

packages/framework/esm-react-utils/src/usePagination.ts:6


usePatientPhoto

usePatientPhoto(patientUuid): UsePatientPhotoResult

Parameters

Name

Type

Name

Type

patientUuid

string

Returns

UsePatientPhotoResult

Defined in

packages/framework/esm-styleguide/src/patient-photo/usePatientPhoto.ts:30


Utility Functions

age

age(dateString): string

Gets a human readable and locale supported age represention of the provided date string.

Parameters

Name

Type

Description

Name

Type

Description

dateString

string

The stringified date.

Returns

string

A human-readable string version of the age.

Defined in

packages/framework/esm-utils/src/age-helpers.ts:36


canAccessStorage

canAccessStorage(storage?): boolean

Simple utility function to determine if an object implementing the WebStorage API is actually available. Useful for testing the availability of localStorage or sessionStorage.

Parameters

Name

Type

Default value

Description

Name

Type

Default value

Description

storage

Storage

window.localStorage

The WebStorage API object to check. Defaults to localStorage.

Returns

boolean

True if the WebStorage API object is able to be accessed, false otherwise

Defined in

packages/framework/esm-utils/src/storage.ts:11


daysIntoYear

daysIntoYear(date): number

Gets the number of days in the year of the given date.

Parameters

Name

Type

Description

Name

Type

Description

date

Date

The date to compute the days within the year.

Returns

number

The number of days.

Defined in

packages/framework/esm-utils/src/age-helpers.ts:9


displayName

displayName(patient): string

deprecated Use getPatientName

Parameters

Name

Type

Name

Type

patient

Patient

Returns

string

Defined in

packages/framework/esm-utils/src/patient-helpers.ts:20


formatPatientName

formatPatientName(name): string

Get a formatted display string for an FHIR name.

Parameters

Name

Type

Description

Name

Type

Description

name

undefined | HumanName

The name to be formatted.

Returns

string

The formatted display name or an empty string if name is undefined.

Defined in

packages/framework/esm-utils/src/patient-helpers.ts:29


formattedName

formattedName(name): string

deprecated Use formatPatientName

Parameters

Name

Type

Name

Type

name

undefined | HumanName

Returns

string

Defined in

packages/framework/esm-utils/src/patient-helpers.ts:35


getDefaultsFromConfigSchema

getDefaultsFromConfigSchema<T>(schema): T

Given a config schema, this returns an object like is returned by useConfig with all default values.

This should be used in tests and not in production code.

If all you need is the default values in your tests, these are returned by default from the useConfig/getConfig mock. This function is useful if you need to override some of the default values.

Type parameters

Name

Type

Name

Type

T

Record<string, any>

Parameters

Name

Type

Name

Type

schema

any

Returns

T

Defined in

packages/framework/esm-utils/src/test-helpers.ts:13


getPatientName

getPatientName(patient): string

Gets the formatted display name for a patient.

The display name will be taken from the patient's 'usual' name, or may fall back to the patient's 'official' name.

Parameters

Name

Type

Description

Name

Type

Description

patient

Patient

The patient details in FHIR format.

Returns

string

The patient's display name or an empty string if name is not present.

Defined in

packages/framework/esm-utils/src/patient-helpers.ts:14


isSameDay

isSameDay(firstDate, secondDate): boolean

Checks if two dates are representing the same day.

Parameters

Name

Type

Description

Name

Type

Description

firstDate

Date

The first date.

secondDate

Date

The second date.

Returns

boolean

True if both are located on the same day.

Defined in

packages/framework/esm-utils/src/age-helpers.ts:25


isVersionSatisfied

isVersionSatisfied(requiredVersion, installedVersion): boolean

Parameters

Name

Type

Name

Type

requiredVersion

string

installedVersion

string

Returns

boolean

Defined in

packages/framework/esm-utils/src/version.ts:22


retry

retry<T>(fn, options?): Promise<T>

Executes the specified function and retries executing on failure with a custom backoff strategy defined by the options.

If not configured otherwise, this function uses the following default options:

  • Retries 5 times beyond the initial attempt.

  • Uses an exponential backoff starting with an initial delay of 1000ms.

throws Rethrows the final error of running fn when the function stops retrying.

Type parameters

Name

Name

T

Parameters

Name

Type

Description

Name

Type

Description

fn

() => Promise<T>

The function to be executed and retried on failure.

options

RetryOptions

Additional options which configure the retry behavior.

Returns

Promise<T>

The result of successfully executing fn.

Defined in

packages/framework/esm-utils/src/retry.ts:40


selectPreferredName

selectPreferredName(patient, ...preferredNames): fhir.HumanName | undefined

Select the preferred name from the collection of names associated with a patient.

Names may be specified with a usage such as 'usual', 'official', 'nickname', 'maiden', etc. A name with no usage specified is treated as the 'usual' name.

The chosen name will be selected according to the priority order of preferredNames,

example // normal use case; prefer usual name, fallback to official name displayNameByUsage(patient, 'usual', 'official')

example // prefer usual name over nickname, fallback to official name displayNameByUsage(patient, 'usual', 'nickname', 'official')

Parameters

Name

Type

Description

Name

Type

Description

patient

Patient

The patient from whom a name will be selected.

...preferredNames

NameUse[]

Optional ordered sequence of preferred name usages; defaults to 'usual' if not specified.

Returns

fhir.HumanName | undefined

the preferred name for the patient, or undefined if no acceptable name could be found.

Defined in

packages/framework/esm-utils/src/patient-helpers.ts:57


shallowEqual

shallowEqual(a, b): boolean

Checks whether two objects are equal, using a shallow comparison, similar to React.

In essence, shallowEquals ensures two objects have the same own properties and that the values of these are equal (===) to each other.

Parameters

Name

Type

Description

Name

Type

Description

a

unknown

The first value to compare

b

unknown

The second value to compare

Returns

boolean

true if the objects are shallowly equal to each other

Defined in

packages/framework/esm-utils/src/shallowEqual.ts:13


useAbortController

useAbortController(): AbortController

beta

This hook creates an AbortController that lasts either until the previous AbortController is aborted or until the component unmounts. This can be used to ensure that all fetch requests are cancelled when a component is unmounted.

example

Returns

AbortController

Defined in

packages/framework/esm-react-utils/src/useAbortController.ts:25


useDebounce

useDebounce<T>(value, delay?): T

This hook debounces a state variable. That state variable can then be used as the value of a controlled input, while the return value of this hook is used for making a request.

example

Type parameters

Name

Name

T

Parameters

Name

Type

Default value

Description

Name

Type

Default value

Description

value

T

undefined

The value that will be used to set debounceValue

delay

number

300

The number of milliseconds to wait before updating debounceValue

Returns

T

The debounced value

Defined in

packages/framework/esm-react-utils/src/useDebounce.ts:32


useOpenmrsSWR

useOpenmrsSWR<DataType, ErrorType>(key, options?): SWRResponse<FetchResponse<DataType>, ErrorType, undefined | Partial<PublicConfiguration<FetchResponse<DataType>, ErrorType, BareFetcher<FetchResponse<DataType>>>>>

beta

This hook is intended to simplify using openmrsFetch in useSWR, while also ensuring that all useSWR usages properly use an abort controller, so that fetch requests are cancelled if the React component unmounts.

example

Note that if you are using a complex SWR key you must provide a url function to the options parameter, which translates the key into a URL to be sent to openmrsFetch()

example

Type parameters

Name

Type

Name

Type

DataType

any

ErrorType

any

Parameters

Name

Type

Description

Name

Type

Description

key

Key

The SWR key to use

options

UseOpenmrsSWROptions

An object of optional parameters to provide, including a FetchConfig object to pass to openmrsFetch or options to pass to SWR

Returns

SWRResponse<FetchResponse<DataType>, ErrorType, undefined | Partial<PublicConfiguration<FetchResponse<DataType>, ErrorType, BareFetcher<FetchResponse<DataType>>>>>

Defined in

packages/framework/esm-react-utils/src/useOpenmrsSWR.ts:70


Workspace Functions

closeWorkspace

closeWorkspace(name, options?): boolean

Function to close an opened workspace

Parameters

Name

Type

Description

Name

Type

Description

name

string

Workspace registration name

options

CloseWorkspaceOptions

Options to close workspace

Returns

boolean

Defined in

packages/framework/esm-styleguide/src/workspaces/workspaces.ts:327


launchWorkspace

launchWorkspace<T>(name, additionalProps?): void

This launches a workspace by its name. The workspace must have been registered. Workspaces should be registered in the routes.json file.

For the workspace to appear, there must be either a <WorkspaceOverlay /> or a <WorkspaceWindow /> component rendered.

The behavior of this function is as follows:

  • If no workspaces are open, or if no other workspaces with the same type are open, it will be opened and focused.

  • If a workspace with the same name is already open, it will be displayed/focused, if it was not already.

  • If a workspace is launched and a workspace which cannot be hidden is already open, a confirmation modal will pop up warning about closing the currently open workspace.

  • If another workspace with the same type is open, the workspace will be brought to the front and then a confirmation modal will pop up warning about closing the opened workspace

Note that this function just manipulates the workspace store. The UI logic is handled by the components that display workspaces.

Additional props can be passed to the workspace component being launched. Passing a prop named workspaceTitle will override the title of the workspace.

Type parameters

Name

Type

Name

Type

T

extends object | DefaultWorkspaceProps = DefaultWorkspaceProps & { [key: string]: any; }

Parameters

Name

Type

Description

Name

Type

Description

name

string

The name of the workspace to launch

additionalProps?

Omit<T, keyof DefaultWorkspaceProps> & { workspaceTitle?: string }

Props to pass to the workspace component being launched. Passing a prop named workspaceTitle will override the title of the workspace.

Returns

void

Defined in

packages/framework/esm-styleguide/src/workspaces/workspaces.ts:210


navigateAndLaunchWorkspace

navigateAndLaunchWorkspace(__namedParameters): void

Use this function to navigate to a new page and launch a workspace on that page.

Parameters

Name

Type

Name

Type

__namedParameters

Object

__namedParameters.additionalProps?

object

__namedParameters.contextKey

string

__namedParameters.targetUrl

string

__namedParameters.workspaceName

string

Returns

void

Defined in

packages/framework/esm-styleguide/src/workspaces/workspaces.ts:290


useWorkspaces

useWorkspaces(): WorkspacesInfo

Returns

WorkspacesInfo

Defined in

packages/framework/esm-styleguide/src/workspaces/workspaces.ts:429