public class PEPPERSafetySystem extends java.lang.Object implements SafetySystem
Modifier and Type | Method and Description |
---|---|
void |
acceptCarbRecommendation(java.util.Date date)
Notifies the safety system that a carbohydrate recommendation has been accepted
|
void |
addCarbs(java.util.Date date,
double carbs)
Registers a manual carbohydrate intake with the safety system.
|
void |
addInsulin(java.util.Date date,
double insulin)
Registers a manual insulin administration with the safety system.
|
void |
addRecommendation(org.json.JSONObject caseJson)
Registers a finalised case with the safety system.
|
void |
clearDatabase()
Clears the database, this should be called after a successful JSON export.
|
double |
constrainBolus(org.json.JSONObject caseJson)
Returns the bolus and manipulates the case JSON.
|
org.json.JSONObject |
createJsonExport()
Creates and returns the Safety System JSON Object (SafetySystemResponse).
|
void |
declineCarbRecommendation(java.util.Date date)
Registers with the safety system that a carbohydrate recommendation has been declined.
|
SafetyAlarmProfile |
getAlarmProfile()
Returns the current alarm profile.
|
double |
getCarbRecommendation()
Returns the carbohydrate recommendation.
|
java.lang.String |
getCarbRecommendationAsString()
Returns the carbohydrate recommendation as a String.
|
double |
getCarbsOnBoard()
Returns the carbohydrates on board for the latest reading.
|
java.lang.String |
getCarbsOnBoardAsString()
Returns the carbohydrates on board for the latest reading as a String.
|
SafetyCarerAlarm |
getCarerAlarm()
Returns the carer alarm value for the latest reading.
|
double |
getCurrentICR()
Returns the users current ICR value for the current system time.
|
double |
getCurrentISF()
Returns the users current ISF value for the current system time.
|
SafetyFault |
getFault()
Determines whether there is a fault associated with the latest reading.
|
SafetyGlucoseAlarm |
getGlucoseAlarm()
Returns the glucose alarm value for the latest reading.
|
SafetyGlucoseAlert |
getGlucoseAlert()
Returns the glucose alert value for the latest reading.
|
double |
getGlucoseDerivative()
Returns the glucose derivative.
|
double |
getGlucoseForecast()
Returns the glucose forecast value for the latest reading.
|
java.lang.String |
getGlucoseForecastAsString()
Returns the glucose forecast value for the latest reading as a String.
|
SafetyGlucoseTrend |
getGlucoseTrend()
Returns the glucose trend.
|
double |
getHyperThreshold()
Gets the hyper threshold of the safety system.
|
double |
getHypoThreshold()
Gets the hypo threshold of the safety system.
|
double |
getInsulinOnBoard()
Returns the insulin on board for the latest reading.
|
java.lang.String |
getInsulinOnBoardAsString()
Returns the insulin on board for the latest reading as a String.
|
SafetyLowGlucoseSuspend |
getLowGlucoseSuspend()
Returns the glucose derivative value for the latest reading.
|
java.lang.String |
getPatientId()
Returns the patient's unique id.
|
boolean |
hasCarbRecommendation()
Returns true if there is a carbohydrate recommendation.
|
boolean |
hasCarerAlarm()
Returns true if there is a carer alarm.
|
boolean |
hasFault()
Returns true if there is a fault.
|
boolean |
hasGlucoseAlarm()
Returns true if there is a glucose alarm.
|
boolean |
hasGlucoseAlert()
Returns true if there is a glucose alert.
|
boolean |
initSafetySystem(org.json.JSONObject json)
Initialising the Safety System through a JSON object, the Safety System must be initialised
prior to using the Safety System.
|
boolean |
isActive()
Returns true if the safety system is active.
|
boolean |
isCarerHyperAlarmEnabled()
Returns true if carer hyper alarms are enabled.
|
boolean |
isInitialised()
Returns true if the Safety System has been initialised, otherwise false.
|
static boolean |
isValidPatientObject(org.json.JSONObject patientObject)
Method for validating a patient object JSON.
|
void |
recalculateInsulin(double insulinAdministered)
Removes insulin from the Safety System Model for IoB correction when
the pump is stopped
|
void |
resumePumpOverride()
Forces the pump to fully resume for 60 minutes.
|
void |
setActive(boolean active)
Set whether the safety system is active or not.
|
void |
setAlarmProfile(SafetyAlarmProfile profile)
Sets or updates the safety system alarm profile.
|
void |
setCarerHyperAlarmEnabled(boolean enabled)
Enables or disables carer hyper alarms.
|
void |
setHyperThreshold(double hyperThreshold)
Updates the hyper threshold of the safety system.
|
void |
setHypoThreshold(double hypoThreshold)
Updates the hypo threshold of the safety system.
|
void |
snoozeAlarm(java.util.Date date)
Snoozes the safety system alarms.
|
void |
update(java.util.Date date,
double glucose)
Runs the main algorithms of the Safety System, returning a Reading with the computed values.
|
public static boolean isValidPatientObject(org.json.JSONObject patientObject)
patientObject
- the patient object JSON to checkpublic boolean initSafetySystem(org.json.JSONObject json)
initSafetySystem
in interface SafetySystem
json
- the JSON to initialise the main Safety System object.public boolean isInitialised()
isInitialised
in interface SafetySystem
public boolean isActive()
isActive
in interface SafetySystem
public void setActive(boolean active)
setActive
in interface SafetySystem
public void update(java.util.Date date, double glucose)
update
in interface SafetySystem
date
- the datetime at which the update occurredglucose
- the latest CGM glucose readingIllegalSafetySystemStateException
- if the Safety System has not yet been initialisedpublic void addRecommendation(org.json.JSONObject caseJson) throws org.json.JSONException, java.text.ParseException
addRecommendation
in interface SafetySystem
caseJson
- the CBR JSON object after a case is completeIllegalSafetySystemStateException
- if the Safety System has not yet been initialisedorg.json.JSONException
- if the JSON is malformedjava.text.ParseException
- if there is an error parsing the JSONpublic void addCarbs(java.util.Date date, double carbs)
This should be called whenever manual carbs are input.
addCarbs
in interface SafetySystem
date
- the datetime at which the update occurredcarbs
- the carbohydrate intake in gramsIllegalSafetySystemStateException
- if the Safety System has not yet been initialisedpublic void addInsulin(java.util.Date date, double insulin)
This should be called whenever a manual bolus is input.
addInsulin
in interface SafetySystem
date
- the datetime at which the update occurredinsulin
- the insulin doseIllegalSafetySystemStateException
- if the Safety System has not yet been initialisedpublic void snoozeAlarm(java.util.Date date)
snoozeAlarm
in interface SafetySystem
date
- the datetime at which the update occurredIllegalSafetySystemStateException
- if the Safety System has not yet been initialisedpublic void acceptCarbRecommendation(java.util.Date date)
acceptCarbRecommendation
in interface SafetySystem
date
- the datetime at which the update occurredIllegalSafetySystemStateException
- if the Safety System has not yet been initialisedpublic void declineCarbRecommendation(java.util.Date date)
declineCarbRecommendation
in interface SafetySystem
date
- the datetime at which the update occurredIllegalSafetySystemStateException
- if the Safety System has not yet been initialisedpublic double constrainBolus(org.json.JSONObject caseJson) throws org.json.JSONException, java.text.ParseException
constrainBolus
in interface SafetySystem
caseJson
- A JSON object containing a CBR case.org.json.JSONException
- if the JSON is malformedjava.text.ParseException
- if there is an error parsing the JSONpublic org.json.JSONObject createJsonExport() throws org.json.JSONException
createJsonExport
in interface SafetySystem
org.json.JSONException
- if there is an error generating the JSON Object.IllegalSafetySystemStateException
- if the Safety System has not yet been initialisedpublic double getCarbsOnBoard()
getCarbsOnBoard
in interface SafetySystem
IllegalSafetySystemStateException
- if the Safety System has not yet been initialisedpublic java.lang.String getCarbsOnBoardAsString()
getCarbsOnBoardAsString
in interface SafetySystem
IllegalSafetySystemStateException
- if the Safety System has not yet been initialisedpublic double getInsulinOnBoard()
getInsulinOnBoard
in interface SafetySystem
IllegalSafetySystemStateException
- if the Safety System has not yet been initialisedpublic java.lang.String getInsulinOnBoardAsString()
getInsulinOnBoardAsString
in interface SafetySystem
IllegalSafetySystemStateException
- if the Safety System has not yet been initialisedpublic double getGlucoseForecast()
getGlucoseForecast
in interface SafetySystem
IllegalSafetySystemStateException
- if the Safety System has not yet been initialisedpublic java.lang.String getGlucoseForecastAsString()
getGlucoseForecastAsString
in interface SafetySystem
IllegalSafetySystemStateException
- if the Safety System has not yet been initialisedpublic SafetyGlucoseTrend getGlucoseTrend()
getGlucoseTrend
in interface SafetySystem
IllegalSafetySystemStateException
- if the Safety System has not yet been initialisedpublic SafetyLowGlucoseSuspend getLowGlucoseSuspend()
getLowGlucoseSuspend
in interface SafetySystem
IllegalSafetySystemStateException
- if the Safety System has not yet been initialisedpublic boolean hasCarbRecommendation()
hasCarbRecommendation
in interface SafetySystem
IllegalSafetySystemStateException
- if the Safety System has not yet been initalisedpublic double getCarbRecommendation()
getCarbRecommendation
in interface SafetySystem
IllegalSafetySystemStateException
- if the Safety System has not yet been initialisedpublic java.lang.String getCarbRecommendationAsString()
getCarbRecommendationAsString
in interface SafetySystem
IllegalSafetySystemStateException
- if the Safety System has not yet been initialisedpublic SafetyGlucoseAlert getGlucoseAlert()
getGlucoseAlert
in interface SafetySystem
IllegalSafetySystemStateException
- if the Safety System has not yet been initialisedpublic boolean hasGlucoseAlert()
hasGlucoseAlert
in interface SafetySystem
IllegalSafetySystemStateException
- if the Safety System has not yet been initialisedpublic SafetyGlucoseAlarm getGlucoseAlarm()
getGlucoseAlarm
in interface SafetySystem
IllegalSafetySystemStateException
- if the Safety System has not yet been initialisedpublic boolean hasGlucoseAlarm()
hasGlucoseAlarm
in interface SafetySystem
IllegalSafetySystemStateException
- if the Safety System has not yet been initialisedpublic boolean hasFault()
hasFault
in interface SafetySystem
IllegalSafetySystemStateException
- if the Safety System has not yet been initalisedpublic SafetyFault getFault()
getFault
in interface SafetySystem
IllegalSafetySystemStateException
- if the Safety System has not yet been initialisedpublic SafetyCarerAlarm getCarerAlarm()
getCarerAlarm
in interface SafetySystem
IllegalSafetySystemStateException
- if the Safety System has not yet been initialisedpublic boolean hasCarerAlarm()
hasCarerAlarm
in interface SafetySystem
IllegalSafetySystemStateException
- if the Safety System has not yet been initialisedpublic java.lang.String getPatientId()
getPatientId
in interface SafetySystem
IllegalSafetySystemStateException
- if the Safety System has not yet been initialisedpublic SafetyAlarmProfile getAlarmProfile()
getAlarmProfile
in interface SafetySystem
public void setAlarmProfile(SafetyAlarmProfile profile)
setAlarmProfile
in interface SafetySystem
profile
- the alarm profile to be usedpublic double getGlucoseDerivative()
getGlucoseDerivative
in interface SafetySystem
public void clearDatabase()
clearDatabase
in interface SafetySystem
IllegalSafetySystemStateException
- if the Safety System has not yet been initalisedpublic double getHypoThreshold()
getHypoThreshold
in interface SafetySystem
IllegalSafetySystemStateException
- if the Safety System has not yet been initalisedpublic void setHypoThreshold(double hypoThreshold)
setHypoThreshold
in interface SafetySystem
hypoThreshold
- the hypo thresholdIllegalSafetySystemStateException
- if the Safety System has not yet been initalisedpublic double getHyperThreshold()
getHyperThreshold
in interface SafetySystem
IllegalSafetySystemStateException
- if the Safety System has not yet been initalisedpublic void setHyperThreshold(double hyperThreshold)
setHyperThreshold
in interface SafetySystem
hyperThreshold
- the hypo thresholdIllegalSafetySystemStateException
- if the Safety System has not yet been initalisedpublic double getCurrentISF()
getCurrentISF
in interface SafetySystem
IllegalSafetySystemStateException
- if the Safety System has not yet been initalised or
if the users ISF values are invalidpublic double getCurrentICR()
getCurrentICR
in interface SafetySystem
IllegalSafetySystemStateException
- if the Safety System has not yet been initalised or
if the users ISF values are invalidpublic void resumePumpOverride()
resumePumpOverride
in interface SafetySystem
public void recalculateInsulin(double insulinAdministered)
recalculateInsulin
in interface SafetySystem
insulinAdministered
- insulin actually administeredpublic boolean isCarerHyperAlarmEnabled()
isCarerHyperAlarmEnabled
in interface SafetySystem
public void setCarerHyperAlarmEnabled(boolean enabled)
setCarerHyperAlarmEnabled
in interface SafetySystem
enabled
- if true Hyper alarms for carers will be triggered.