Collection
Life / Healthcare · v0.2.0Validated
See who covers the current clinical shift, where they are and whether they have acknowledged a page.
Clinical On-Call Coverage · Preview
Loading widget…
Preparing source code…
Idle
Life / Healthcare · v0.2.0Validated
See who covers the current clinical shift, where they are and whether they have acknowledged a page.
Loading widget…
Preparing source code…
Load the Lumo theme once in your app entry point. The example uses the local Lumo workspace packages.
import "@lumo/tokens/tokens.css";
import { OnCallWidget } from "@lumo/widgets/catalog/healthcare/on-call";
export default function Example() {
return <OnCallWidget />;
}Props for integrating the React component in your app.
snapshotClinicalOnCallSnapshot | null (optional)onAction(action: ClinicalOnCallAction) => void | Promise<void>{
"snapshot": {
"unit": "North wing",
"shiftLabel": "19:00–07:00",
"clinicians": [
{
"id": "cl-23",
"name": "Dr. Maya Sato",
"role": "Hospital medicine",
"presence": "in-house",
"coverage": "primary",
"location": "Ward 3"
}
]
}
}"use client";
import { Stethoscope } from "lucide-react";
import { useOperationSnapshot } from "../../shared/operation-snapshot";
import { WidgetOperations, type OperationRow } from "../../shared/WidgetOperations";
import { clinicalDemo } from "./on-call.constants";
import type { ClinicalOnCallSnapshot, ClinicalOnCallAction, OnCallClinician } from "./on-call.types";
export type { ClinicalOnCallSnapshot, ClinicalOnCallAction, OnCallClinician } from "./on-call.types";
const presence: Record<OnCallClinician["presence"], NonNullable<OperationRow<never>["status"]>> = {
"in-house": { label: "In house", tone: "success" }, busy: { label: "Busy", tone: "warning" },
backup: { label: "Backup", tone: "info" }, unavailable: { label: "Unavailable", tone: "neutral" },
};
export function OnCallWidget({ snapshot, onAction }: {
index?: number; snapshot?: ClinicalOnCallSnapshot | null;
onAction?: (action: ClinicalOnCallAction) => void | Promise<void>;
} = {}) {
const { data, action } = useOperationSnapshot(snapshot, clinicalDemo, onAction, (state, request) => ({
...state, clinicians: state.clinicians.map(person => person.id === request.clinicianId ? { ...person, page: { status: "pending" as const } } : person),
}));
const primary = data?.clinicians.find(person => person.coverage === "primary");
const rows = data?.clinicians.map<OperationRow<ClinicalOnCallAction>>(person => ({
id: person.id, label: person.name, caption: person.role, person,
status: person.page?.status === "pending" ? { label: "Page pending", tone: "info" }
: person.page?.status === "acknowledged" ? { label: "Acknowledged", tone: "success" } : presence[person.presence],
details: [["Presence", presence[person.presence].label], ["Coverage", person.coverage ?? "Not assigned"],
["Location", person.location ?? "Not reported"], ["Last page", person.page?.label ?? person.page?.status ?? "None reported"]],
actions: person.presence !== "unavailable" && person.page?.status !== "pending"
? [{ label: "Page clinician", command: { type: "page", clinicianId: person.id }, confirmation: `Page ${person.name} on the current shift?` }] : [],
})) ?? null;
return <WidgetOperations title="On Call" icon={<Stethoscope />} description={data && `${data.unit} · ${data.shiftLabel}` || undefined}
rows={rows} onAction={action} empty="No clinicians assigned" summary={data && <span>{primary ? `Primary · ${primary.name}` : "Primary coverage not reported"}</span>} />;
}
lucide-reactmotionreactreact-dom