Receive sit-to-stand progress and metrics from an embedded fall risk test.
Embed /fall-risk/{fallRiskResultId}/sit-to-stand, usually using the
sitToStandTestUrl returned by the fall risk create route:
<iframe
id="sitToStandIframe"
title="Sit-to-stand test"
src="https://your-client.gofa.app/fall-risk/result-id/sit-to-stand"
allow="camera; microphone"
></iframe>All messages use source: "gofa-sit-to-stand" and a type/payload envelope.
type | Payload | Meaning |
|---|---|---|
STATE_TRANSITION | State and current metrics | The flow changed state. |
ASSESSMENT_STARTED | Current metrics | The timed assessment began. |
ASSESSMENT_ENDED | Final metrics | The timed assessment ended. |
REP_COUNT_UPDATED | count, and the current averageShoulderTilt when available | A repetition was counted. |
RESULTS_SET | count, fiveRepsTimeTaken, and shoulderTilts | Final metrics were set. |
TIMER_COMPLETE | None | The 30-second timer completed. |
TIMER_ERROR | Error payload | The timer reported an error. |
EARLY_EXIT | None | The participant exited early. |
The final stored result uses count, nullable fiveRepsTimeTaken, and a
shoulderTilts array. Progress events can contain a smaller or intermediate
metrics object.
const iframe = document.getElementById("sitToStandIframe") as HTMLIFrameElement | null;
const expectedOrigin = "https://your-client.gofa.app";
window.addEventListener("message", (event) => {
const { source, type, payload } = event.data ?? {};
if (
event.origin !== expectedOrigin ||
event.source !== iframe?.contentWindow ||
source !== "gofa-sit-to-stand"
) return;
switch (type) {
case "REP_COUNT_UPDATED":
updateRepCount(payload?.count);
break;
case "RESULTS_SET":
// Fetch the authenticated API result if the host needs an authoritative copy.
handleCompletedTest(payload);
break;
case "EARLY_EXIT":
handleEarlyExit();
break;
}
});The page currently posts with a wildcard target origin, so the parent must enforce its own origin and iframe-window checks. Keep camera-derived metrics private and avoid logging complete payloads.