XUND
Guides

JS API

Initialize the Health Check App from your own script and react to events.

The JS API gives your page control over the Health Check App: you start it from your own script and react when a check starts or the report is shown.

Working examples

The frontend integration guide on GitHub covers the Health Check JS API and has runnable projects.

The examples on this page use await; run them inside an async function or a <script type="module">.

Initialization

<div id="xund-container" style="width: 100%; height: 100vh;"></div>
<script src="https://frame.health-check.class2.xund.solutions/embed.js"></script>
<script>
  (async () => {
    const xundApp = await XUND.hc.init({
      clientId: 'YOUR-CLIENT-ID',
      webappCode: 'YOUR-WEBAPP-CODE',
      authCode: 'AUTH-CODE-FROM-YOUR-SERVER',
      webappBaseUrl: 'https://frame.health-check.class2.xund.solutions',
      targetContainerId: 'xund-container',
    })
  })()
</script>
  • init returns a promise. await it before you call any method on the app.
  • webappBaseUrl is required for Health Check. Without it, the Symptom & Illness Check App is loaded instead.
  • XUND.hc.init exists only when the page has no <script client-id="…"> tag — use either the script embed or the JS API on a page, not both.
  • The element named by targetContainerId must exist when init runs.

Instance methods

MethodDescription
destroy()Removes the app from the page.

To get the report in your page, use onReportShown (see Events).

Events

const xundApp = await XUND.hc.init({
  clientId: 'YOUR-CLIENT-ID',
  webappCode: 'YOUR-WEBAPP-CODE',
  authCode: 'AUTH-CODE-FROM-YOUR-SERVER',
  webappBaseUrl: 'https://frame.health-check.class2.xund.solutions',
  targetContainerId: 'xund-container',
  customization: {
    onCheckStart: ({ checkId }) => {
      trackCheckStart(checkId) // your own function, not part of the XUND API
    },
    onReportShown: ({ checkId, reportData }) => {
      saveReport(checkId, reportData) // your own function, not part of the XUND API
    },
  },
})

trackCheckStart and saveReport stand for your own code, for example calls to your backend. Don't log report data: it is medical data about the patient.

CallbackCalled when
onCheckStart({ checkId })A check starts, or an unfinished check is opened again.
onReportShown({ checkId, reportData })The patient sees the report.

For language, profile data, risk topics, and display options, see Customization.

Last updated on

On this page