fhir

In this section

Type Aliases

CheckinBundle

type CheckinBundle = {
  bundle: Record<string, unknown>;
  entries: CheckinBundleEntry[];
};

Defined in: src/fhir/index.ts:51

What buildCheckinBundle returns: the resources to write, and the same as a transaction Bundle.

Properties

bundle
bundle: Record<string, unknown>;

Defined in: src/fhir/index.ts:55

The transaction Bundle equivalent of the plan.

entries
entries: CheckinBundleEntry[];

Defined in: src/fhir/index.ts:53

Each resource to write, with the artifact it came from.


CheckinBundleContext

type CheckinBundleContext = {
  appointment?: string;
  patient?: string;
};

Defined in: src/fhir/index.ts:33

The chart context to record on the Provenance. Nothing is matched: what you pass is what's written.

Properties

appointment?
optional appointment?: string;

Defined in: src/fhir/index.ts:37

An Appointment reference, such as "Appointment/456".

patient?
optional patient?: string;

Defined in: src/fhir/index.ts:35

A Patient reference, such as "Patient/123".


CheckinBundleEntry

type CheckinBundleEntry = {
  artifactId?: string;
  fullUrl: string;
  resource: Record<string, unknown>;
};

Defined in: src/fhir/index.ts:41

One resource to write.

Properties

artifactId?
optional artifactId?: string;

Defined in: src/fhir/index.ts:47

Artifact id this entry came from; the Provenance entry has none.

fullUrl
fullUrl: string;

Defined in: src/fhir/index.ts:43

The entry's urn:uuid: fullUrl.

resource
resource: Record<string, unknown>;

Defined in: src/fhir/index.ts:45

The resource to create.


FetchLike

type FetchLike = (input, init?) => Promise<Response>;

Defined in: src/fetch-like.ts:9

The minimal fetch signature the library accepts, so callers can inject their own client — auth headers, retries, tracing — without the library depending on any particular one.

Lives on its own because both the check-in path and the optional FHIR helper need it, and the check-in path must never import the FHIR module.

Parameters

Parameter Type
input string | URL | Request
init? RequestInit

Returns

Promise<Response>


PostMode

type PostMode = "transaction" | "individual";

Defined in: src/fhir/index.ts:27

"transaction": one transaction Bundle. "individual": one POST per resource, then the Provenance, for servers that handle transactions poorly.


PostResult

type PostResult = {
  bundle: unknown;
  mode: PostMode;
  result: unknown;
};

Defined in: src/fhir/index.ts:214

What postCheckinBundle sent and what the server said.

Properties

bundle
bundle: unknown;

Defined in: src/fhir/index.ts:218

The plan's transaction Bundle.

mode
mode: PostMode;

Defined in: src/fhir/index.ts:216

How it was sent.

result
result: unknown;

Defined in: src/fhir/index.ts:220

What the server returned: the transaction response, or in "individual" mode one response body per POST.

Variables

CHECKIN_APPOINTMENT_SYSTEM

const CHECKIN_APPOINTMENT_SYSTEM: "https://smart-health-checkin.github.io/appointment-context" = "https://smart-health-checkin.github.io/appointment-context";

Defined in: src/fhir/index.ts:60


CHECKIN_REQUEST_ID_SYSTEM

const CHECKIN_REQUEST_ID_SYSTEM: "https://smart-health-checkin.github.io/checkin-request-id" = "https://smart-health-checkin.github.io/checkin-request-id";

Defined in: src/fhir/index.ts:58

Functions

buildCheckinBundle()

function buildCheckinBundle(input): CheckinBundle;

Defined in: src/fhir/index.ts:67

Map a check-in response to a FHIR transaction Bundle. Pure — no network. Inspect or edit the result before sending it anywhere.

Parameters

Parameter Type
input { context?: CheckinBundleContext; now?: () => Date; provenance?: boolean; request: SmartCheckinRequest; response: SmartCheckinResponse; }
input.context? CheckinBundleContext
input.now? () => Date
input.provenance? boolean
input.request SmartCheckinRequest
input.response SmartCheckinResponse

Returns

CheckinBundle


postCheckinBundle()

function postCheckinBundle(plan, options): Promise<PostResult>;

Defined in: src/fhir/index.ts:228

Post a bundle to a FHIR server. A convenience for demos and simple apps — production deployments usually have their own client and auth, in which case use buildCheckinBundle alone and send it yourself.

Parameters

Parameter Type Description
plan CheckinBundle -
options { fetchImpl?: FetchLike; fhirBase: string; mode?: PostMode; } -
options.fetchImpl? FetchLike Your own fetch, with your credentials, retries, and tracing.
options.fhirBase string The FHIR server's base URL.
options.mode? PostMode "transaction" (default) or "individual".

Returns

Promise<PostResult>