apimodel

package
v0.0.0-...-a2a2cd2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2023 License: MIT, MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

View Source
const (
	UNDEFINED_READ       = -1
	DAY_OF_DATA_DURATION = time.Duration(24) * time.Hour
)
View Source
const (
	GLUCOSE_READ_TAG = "GlucoseRead"

	// Units
	MMOL_PER_L                       = "mmolPerL"
	MG_PER_DL                        = "mgPerDL"
	UNKNOWN_GLUCOSE_MEASUREMENT_UNIT = "Unknown"
)
View Source
const (
	CALIBRATION_READ_TAG = "CalibrationRead"
)
View Source
const (
	CARB_TAG = "Carbs"
)
View Source
const (
	EXERCISE_TAG = "Exercise"
)
View Source
const (
	INSULIN_TAG = "Insulin"
)

Variables

View Source
var UNDEFINED_CALIBRATION_READ = CalibrationRead{Time{0, "UTC"}, "NONE", -1.}
View Source
var UNDEFINED_GLUCOSE_READ = GlucoseRead{Time{GetTimeMillis(util.GLUKIT_EPOCH_TIME), "UTC"}, "NONE", UNDEFINED_READ}

Functions

func GetBoundariesOfElementsInRange

func GetBoundariesOfElementsInRange(slice Interface, lowerBound, upperBound time.Time) (startIndex, endIndex int)

filter filters out any value that is outside of the lower and upper bounds. The two bounds are inclusive and the returned indexes are inclusive too.

func GetTimeMillis

func GetTimeMillis(time time.Time) int64

Types

type CalibrationRead

type CalibrationRead struct {
	Time  Time        `json:"time" datastore:"time,noindex"`
	Unit  GlucoseUnit `json:"unit" datastore:"unit,noindex"`
	Value float32     `json:"value" datastore:"value,noindex"`
}

CalibrationRead represents a CGM read (not to be confused with a MeterRead which is a calibration value from an external meter

func (CalibrationRead) GetNormalizedValue

func (element CalibrationRead) GetNormalizedValue(unit GlucoseUnit) (float32, error)

GetNormalizedValue gets the normalized value to the requested unit

func (CalibrationRead) GetTime

func (element CalibrationRead) GetTime() time.Time

GetTime gets the time of a Timestamp value

type CalibrationReadSlice

type CalibrationReadSlice []CalibrationRead

func (CalibrationReadSlice) Get

func (slice CalibrationReadSlice) Get(i int) float64

func (CalibrationReadSlice) GetEpochTime

func (slice CalibrationReadSlice) GetEpochTime(i int) (epochTime int64)

func (CalibrationReadSlice) Len

func (slice CalibrationReadSlice) Len() int

func (CalibrationReadSlice) Less

func (slice CalibrationReadSlice) Less(i, j int) bool

func (CalibrationReadSlice) Swap

func (slice CalibrationReadSlice) Swap(i, j int)

func (CalibrationReadSlice) ToDataPointSlice

func (slice CalibrationReadSlice) ToDataPointSlice() (dataPoints []DataPoint)

ToDataPointSlice converts a CalibrationReadSlice into a generic DataPoint array

type DataPoint

type DataPoint struct {
	LocalTime string      `json:"label"`
	EpochTime int64       `json:"x"`
	Y         float32     `json:"y"`
	Value     float32     `json:"value"`
	Tag       string      `json:"tag"`
	Unit      GlucoseUnit `json:"unit"`
}

Represents a generic data point in time

func MergeDataPointArrays

func MergeDataPointArrays(first, second []DataPoint) []DataPoint

type DataPointSlice

type DataPointSlice []DataPoint

func (DataPointSlice) Len

func (slice DataPointSlice) Len() int

func (DataPointSlice) Less

func (slice DataPointSlice) Less(i, j int) bool

func (DataPointSlice) Swap

func (slice DataPointSlice) Swap(i, j int)

type DayOfCalibrationReads

type DayOfCalibrationReads struct {
	Reads     []CalibrationRead `datastore:"calibrations,noindex"`
	StartTime time.Time         `datastore:"startTime"`
	EndTime   time.Time         `datastore:"endTime"`
}

This holds an array of reads for a whole day

func NewDayOfCalibrationReads

func NewDayOfCalibrationReads(reads []CalibrationRead) DayOfCalibrationReads

type DayOfExercises

type DayOfExercises struct {
	Exercises []Exercise `datastore:"exercises,noindex"`
	StartTime time.Time  `datastore:"startTime"`
	EndTime   time.Time  `datastore:"endTime"`
}

This holds an array of exercise events for a whole day

func NewDayOfExercises

func NewDayOfExercises(exercises []Exercise) DayOfExercises

type DayOfGlucoseReads

type DayOfGlucoseReads struct {
	Reads     []GlucoseRead `datastore:"reads,noindex"`
	StartTime time.Time     `datastore:"startTime"`
	EndTime   time.Time     `datastore:"endTime"`
}

This holds an array of reads for a whole day

func NewDayOfGlucoseReads

func NewDayOfGlucoseReads(reads []GlucoseRead) DayOfGlucoseReads

type DayOfInjections

type DayOfInjections struct {
	Injections []Injection `datastore:"injections,noindex"`
	StartTime  time.Time   `datastore:"startTime"`
	EndTime    time.Time   `datastore:"endTime"`
}

This holds an array of injections for a whole day

func NewDayOfInjections

func NewDayOfInjections(injections []Injection) DayOfInjections

type DayOfMeals

type DayOfMeals struct {
	Meals     []Meal    `datastore:"meals,noindex"`
	StartTime time.Time `datastore:"startTime"`
	EndTime   time.Time `datastore:"endTime"`
}

This holds an array of injections for a whole day

func NewDayOfMeals

func NewDayOfMeals(meals []Meal) DayOfMeals

type Exercise

type Exercise struct {
	Time            Time   `json:"time" datastore:"time,noindex"`
	DurationMinutes int    `json:"durationInMinutes" datastore:"durationInMinutes,noindex"`
	Intensity       string `json:"intensity" datastore:"intensity,noindex"`
	Description     string `json:"description" datastore:"description,noindex"`
}

func (Exercise) GetTime

func (element Exercise) GetTime() time.Time

GetTime gets the time of a Timestamp value

type ExerciseSlice

type ExerciseSlice []Exercise

func (ExerciseSlice) GetEpochTime

func (slice ExerciseSlice) GetEpochTime(i int) (epochTime int64)

func (ExerciseSlice) Len

func (slice ExerciseSlice) Len() int

func (ExerciseSlice) Less

func (slice ExerciseSlice) Less(i, j int) bool

func (ExerciseSlice) Swap

func (slice ExerciseSlice) Swap(i, j int)

func (ExerciseSlice) ToDataPointSlice

func (slice ExerciseSlice) ToDataPointSlice(matchingReads []GlucoseRead, glucoseUnit GlucoseUnit) (dataPoints []DataPoint)

ToDataPointSlice converts an ExerciseSlice into a generic DataPoint array

type GlucoseRead

type GlucoseRead struct {
	Time  Time        `json:"time" datastore:"time,noindex"`
	Unit  GlucoseUnit `json:"unit" datastore:"unit,noindex"`
	Value float32     `json:"value" datastore:"value,noindex"`
}

GlucoseRead represents a CGM read (not to be confused with a MeterRead which is a calibration value from an external meter

func (GlucoseRead) GetNormalizedValue

func (element GlucoseRead) GetNormalizedValue(unit GlucoseUnit) (float32, error)

GetNormalizedValue gets the normalized value to the requested unit

func (GlucoseRead) GetTime

func (element GlucoseRead) GetTime() time.Time

GetTime gets the time of a Timestamp value

type GlucoseReadSlice

type GlucoseReadSlice []GlucoseRead

func (GlucoseReadSlice) Get

func (slice GlucoseReadSlice) Get(i int) float64

func (GlucoseReadSlice) GetEpochTime

func (slice GlucoseReadSlice) GetEpochTime(i int) (epochTime int64)

func (GlucoseReadSlice) Len

func (slice GlucoseReadSlice) Len() int

func (GlucoseReadSlice) Less

func (slice GlucoseReadSlice) Less(i, j int) bool

func (GlucoseReadSlice) Swap

func (slice GlucoseReadSlice) Swap(i, j int)

func (GlucoseReadSlice) ToDataPointSlice

func (slice GlucoseReadSlice) ToDataPointSlice(glucoseUnit GlucoseUnit) (dataPoints []DataPoint)

ToDataPointSlice converts a GlucoseReadSlice into a generic DataPoint array

type GlucoseUnit

type GlucoseUnit string

type Injection

type Injection struct {
	Time        Time    `json:"time" datastore:"time,noindex"`
	Units       float32 `json:"units" datastore:"units,noindex"`
	InsulinName string  `json:"insulinName" datastore:"insulinName,noindex"`
	InsulinType string  `json:"insulinType" datastore:"insulinType,noindex"`
}

Injection represents an insulin injection

func (Injection) GetTime

func (element Injection) GetTime() time.Time

GetTime gets the time of a Timestamp value

type InjectionSlice

type InjectionSlice []Injection

func (InjectionSlice) GetEpochTime

func (slice InjectionSlice) GetEpochTime(i int) (epochTime int64)

func (InjectionSlice) Len

func (slice InjectionSlice) Len() int

func (InjectionSlice) Less

func (slice InjectionSlice) Less(i, j int) bool

func (InjectionSlice) Swap

func (slice InjectionSlice) Swap(i, j int)

func (InjectionSlice) ToDataPointSlice

func (slice InjectionSlice) ToDataPointSlice(matchingReads []GlucoseRead, glucoseUnit GlucoseUnit) (dataPoints []DataPoint)

ToDataPointSlice converts an InjectionSlice into a generic DataPoint array

type Interface

type Interface interface {
	sort.Interface
	GetEpochTime(i int) (epochTime int64)
}

type Meal

type Meal struct {
	Time          Time    `json:"time" datastore:"time,noindex"`
	Carbohydrates float32 `json:"carbohydrates" datastore:"carbohydrates,noindex"`
	Proteins      float32 `json:"proteins" datastore:"proteins,noindex"`
	Fat           float32 `json:"fat" datastore:"fat,noindex"`
	SaturatedFat  float32 `json:"saturatedFat" datastore:"saturatedFat,noindex"`
}

Meal is the data structure that represents a meal of food intake. Only carbohydrates are fully supported at the moment.

func (Meal) GetTime

func (element Meal) GetTime() time.Time

GetTime gets the time of a Timestamp value

type MealSlice

type MealSlice []Meal

func (MealSlice) GetEpochTime

func (slice MealSlice) GetEpochTime(i int) (epochTime int64)

func (MealSlice) Len

func (slice MealSlice) Len() int

func (MealSlice) Less

func (slice MealSlice) Less(i, j int) bool

func (MealSlice) Swap

func (slice MealSlice) Swap(i, j int)

func (MealSlice) ToDataPointSlice

func (slice MealSlice) ToDataPointSlice(matchingReads []GlucoseRead, glucoseUnit GlucoseUnit) (dataPoints []DataPoint)

ToDataPointSlice converts an MealSlice into a generic DataPoint array

type Time

type Time struct {
	Timestamp  int64  `json:"timestamp" datastore:"timestamp,noindex"`
	TimeZoneId string `json:"timezone" datastore:"timezone,noindex"`
}

func (Time) Format

func (element Time) Format() (formatted string, err error)

func (Time) GetTime

func (element Time) GetTime() (timeValue time.Time)

GetTime gets the time of a Timestamp value

type TimeSlice

type TimeSlice []Time

func (TimeSlice) GetEpochTime

func (slice TimeSlice) GetEpochTime(i int) (epochTime int64)

func (TimeSlice) Len

func (slice TimeSlice) Len() int

func (TimeSlice) Less

func (slice TimeSlice) Less(i, j int) bool

func (TimeSlice) Swap

func (slice TimeSlice) Swap(i, j int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL