Sending Continuous Measurements

We assume that your gateway is already paired with your device, and you are able to receive data from your device to the gateway.

Create & Start Usage Session

Measurements are always sent to BioT in the context of a Usage Session. To create and start a session, you should have the device ID needed to start the session.

📘

Note

The device ID is usually obtained from the device itself in cases where devices are provisioned to BioT through the gateway during initial sign up. However, it could also be the other way around where the patient gets a preassigned device, and then you can use BioT APIs to query which device belongs to the patient. In this flow, we’re using the former assumption.

Get device information by device id (device service) (Step 3)

  • Request: GET
  • URL: https://<your api endpoint>/device/v2/devices/<deviceId>

Get the patient id from the response:

  • response._patient.id
  • Let’s call it “patient-id

Get the device template id from the response:

  • response._template.id
  • Let’s call it “device-template-id

Get usage session type id (settings service) (Step 4)

  • In settings service: search template entities by filter (minimized).
  • parentTemplateId is the device template id from the device search response.
  • Request: GET
  • URL: https://<your api endpoint>/settings/v1/templates/minimized
  • Body:
{
"filter": {
      "entityTypeName": { "in": ["usage-session"] },
      "parentTemplateId": { "in": ["device-template-id"] }
   }
}
  • response.data is an array of usage sessions that are relevant to the device in hand, go to the wanted index (the wanted usage session)
  • The usage session type id is: response.data[index].id.
  • Let’s call it “usage-session-type-id

Create and start a usage session for the device (device service) (Step 5)

  • Start a new usage session
  • Request: POST
  • URL: https://<your api endpoint>/device/v1/devices/<deviceId>/usage-sessions/remote-control/start
  • Body:
{
   "_usage": {
      "_usageTypeId": "usage-session-type-id"
   },
   "_patient": "patient-id"
}

Keep the usage session Id for pause resume and stopping the session

  • response._id
  • Let’s call it “usage-session-id

Expected Errors and misuse

  • A wrong _usageTypeId or _patient provided to create and start a usage session for the device will result in an error with 404 - not found error code.

  • If either _usageTypeId or _patient are not provided to create and start a usage session for the device, a 400 - validation failed error will occur.

  • If the wrong device-id is provided to create and start a usage session for the device, there are two possible outcomes:

    1. If the wrong device-id is logged in the system, the session will be created and started for the wrong device-id (the one provided in the call).
    2. The call will result in 404 - not found error code.

Send Measurements

Please refer to Device Integration: Implement The Basic Functionality to learn how to implement the device interface in order to get the context from the Start Session MQTTMQTT - MQTT is an OASIS standard messaging protocol for the Internet of Things (IoT). notification Respond to Session Commands and use it to send measurements.

Stop Usage Session (Step 6)

Once your user stops using the device, stop the BioT session.

Stop an existing usage session

  • Request: POST
  • URL: https://<your api endpoint>/device/v1/devices/<deviceId>/usage-sessions/<sessionId>/remote-control/stop

Expected Errors and misuse (for pause, resume and stop)

  • A wrong usage-session-id will result in a 404 - not found error code
  • If a device-id that is not the session’s device-id is provided, the call will result in a 409 - session wrong device-id error.
    *If the current session’s state is one that is not able to change to the wanted state (e.g. state is idle, and a resume call is made), the call will result in a 409 - Session cannot change state from IDLE to RESUMING.

Advanced - Pausing and Resuming a Usage Session

To pause measuring the patient for any reason, AND to let BioT users know that you paused, use the following APIs:

Pause an existing usage session

  • Request: POST
  • URL: https://<your api endpoint>/device​/v1​/devices​/<deviceId>/usage-sessions​/<sessionId>/remote-control​/pause

Resume an existing usage session

  • Request: POST
  • URL: https://<your api endpoint>/device/v1/devices/<deviceId>/usage-sessions/<sessionId>/remote-control/resume

The rest of the interaction of the device with BioT will include:

  • Sending device statuses
  • Receiving configurations

For more information, see Device Integration


What’s Next
Did this page help you?