NHS31xx SW API

Detailed Description

The Therapy Adherence Therapy Component is responsible for managing the therapy adherence status. It makes use of:

Via the Therapy Component, other components can:

  1. Check the current state of the therapy.
  2. Start a new therapy.
  3. Stop an ongoing therapy.
  4. Reset the status of the therapy to pristine state.
  5. Force an update of the internal status.
Groups:
The available pills in the blister are divided into groups. Each group is defined by its drive pin (HW connection). Depending on the sensing principle, a group can have one ore more sensing pins. Depending on the sensing principle, a group can be capable of:
  • Sensing a specific individual pill removal.
  • Sensing the number of removed pills, this means all pills in such a group are treated as equals.

Modules

 Sensing Component
 

Data Structures

struct  THERAPY_PILLREMOVAL_INFO_T
 

Macros

#define THERAPY_MAX_REMOVALS   36
 

Enumerations

enum  THERAPY_STATE_T {
  THERAPY_STATE_ID_NOTSTARTED = 0x10,
  THERAPY_STATE_ID_ONGOING = 0x11,
  THERAPY_STATE_ID_STOPPED = 0x12
}
 

Functions

void Therapy_Init (void)
 
void Therapy_DeInit (void)
 
THERAPY_STATE_T Therapy_GetState (void)
 
uint32_t Therapy_GetStartTime (void)
 
uint32_t Therapy_GetCheckPeriod (void)
 
int Therapy_GetInitialPillCount (void)
 
int Therapy_GetIntakeCount (void)
 
uint32_t Therapy_GetLastIntakeTime (void)
 
void Therapy_Start (uint32_t start, uint32_t interval)
 
void Therapy_Reset (void)
 
void Therapy_Stop (void)
 
void Therapy_Update (void)
 

Data Structure Documentation

◆ THERAPY_PILLREMOVAL_INFO_T

struct THERAPY_PILLREMOVAL_INFO_T

All information required to be recorded when a pill removal occurs:, i.e. when a pill removal has been detected.

Data Fields
uint32_t time

The time in epoch seconds when the removal occurred. A value of 0 indicates no event is recorded in this slot.

uint8_t group

The number of the group where the event occurred.

uint32_t position
  • When in the group specific pills are to be tracked, this value indicates which pill was taken:
    • a value of 0 for the first pill
    • a value of n for the n-th pill
  • When in the group only the amount of pills taken can be tracked reporting is starting with the highest pill number.

Macro Definition Documentation

◆ THERAPY_MAX_REMOVALS

#define THERAPY_MAX_REMOVALS   36

Maximum pill removals to be tracked. This number is defined by HW. The maximum capacity is obtained by a 6x6 matrix. (GPIO)

Enumeration Type Documentation

◆ THERAPY_STATE_T

A list of all possible states a therapy can be in. As state data will be stored in EEPROM, make sure the reset value (0x00) is not a valid state id.

Enumerator
THERAPY_STATE_ID_NOTSTARTED 

State indicating a therapy is not yet started.

THERAPY_STATE_ID_ONGOING 

State indicating a therapy is ongoing.

THERAPY_STATE_ID_STOPPED 

State indicating a therapy is stopped (all pills taken).

Function Documentation

◆ Therapy_Init()

void Therapy_Init ( void  )

Init function for the therapy module. It makes sure that internal status info is retrieved from memory.

◆ Therapy_DeInit()

void Therapy_DeInit ( void  )

De-Init function for the therapy module. It makes sure that internal status info is stored in memory.

◆ Therapy_GetState()

THERAPY_STATE_T Therapy_GetState ( void  )

Function to get the current state of the therapy.

Returns
The current status of the therapy.

◆ Therapy_GetStartTime()

uint32_t Therapy_GetStartTime ( void  )

Function to get the start time of the therapy (expressed in epoch seconds). .

Returns
The therapy start time (not valid if the status is THERAPY_STATE_ID_NOTSTARTED).

◆ Therapy_GetCheckPeriod()

uint32_t Therapy_GetCheckPeriod ( void  )

Function to get the period on which the therapy needs to be updated (pill removal check).

Returns
The therapy's check period (not valid if the status is THERAPY_STATE_ID_NOTSTARTED).

◆ Therapy_GetInitialPillCount()

int Therapy_GetInitialPillCount ( void  )

Function to get the amount of pills present at start of therapy.

Returns
The therapy's initial pill count (not valid if the status is THERAPY_STATE_ID_NOTSTARTED).

◆ Therapy_GetIntakeCount()

int Therapy_GetIntakeCount ( void  )

Function to get the amount of pill intakes currently recorded.

Returns
The amount of sensed pill removals (not valid if the status is THERAPY_STATE_ID_NOTSTARTED).

◆ Therapy_GetLastIntakeTime()

uint32_t Therapy_GetLastIntakeTime ( void  )

Function to get the last experienced pill removal time (expressed in epoch seconds).

Returns
The time (expressed in epoch seconds) at which the last pill removal was sensed (not valid if the status is THERAPY_STATE_ID_NOTSTARTED).

◆ Therapy_Start()

void Therapy_Start ( uint32_t  start,
uint32_t  interval 
)

Starts a new therapy

Parameters
start: The time (expressed in epoch seconds) at which the therapy is started
interval: The interval at which an update of the therapy status is needed.

◆ Therapy_Reset()

void Therapy_Reset ( void  )

Resets the therapy (Pristine state) All Status data is reseted, Therapy state is set to THERAPY_STATE_ID_NOTSTARTED.

◆ Therapy_Stop()

void Therapy_Stop ( void  )

Stops the therapy (All pills removed) Therapy state is set to THERAPY_STATE_ID_STOPPED, restarting the Therapy is not possible, this is since from the moment the Therapy is stopped knowledge of current time is lost.

◆ Therapy_Update()

void Therapy_Update ( void  )

Updates the therapy's status, it will check (via the sense module) if since the last call, extra pills where removed and will update its status accordingly. If all pills are taken, Therapy will be stopped THERAPY_STATE_ID_STOPPED