Add pump alerts as notes
This commit is contained in:
parent
5022a77711
commit
f8d4dbf6a1
7 changed files with 119 additions and 6 deletions
|
@ -1230,6 +1230,15 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
scheduleCareportalEventChange();
|
scheduleCareportalEventChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CareportalEvent getCareportalEventFromTimestamp(long timestamp) {
|
||||||
|
try {
|
||||||
|
return getDaoCareportalEvents().queryForId(timestamp);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public CareportalEvent getLastCareportalEvent(String event) {
|
public CareportalEvent getLastCareportalEvent(String event) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.PumpInsight.history;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.db.CareportalEvent;
|
import info.nightscout.androidaps.db.CareportalEvent;
|
||||||
import info.nightscout.androidaps.db.TDD;
|
import info.nightscout.androidaps.db.TDD;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
|
@ -141,8 +142,7 @@ class HistoryIntentAdapter {
|
||||||
|
|
||||||
private void uploadCareportalEvent(Date date, String event) {
|
private void uploadCareportalEvent(Date date, String event) {
|
||||||
if (SP.getBoolean("insight_automatic_careportal_events", false)) {
|
if (SP.getBoolean("insight_automatic_careportal_events", false)) {
|
||||||
CareportalEvent careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(event);
|
if (MainApp.getDbHelper().getCareportalEventFromTimestamp(date.getTime()) != null) return;
|
||||||
if (careportalEvent == null || careportalEvent.date == date.getTime()) return;
|
|
||||||
try {
|
try {
|
||||||
JSONObject data = new JSONObject();
|
JSONObject data = new JSONObject();
|
||||||
String enteredBy = SP.getString("careportal_enteredby", "");
|
String enteredBy = SP.getString("careportal_enteredby", "");
|
||||||
|
@ -155,4 +155,49 @@ class HistoryIntentAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void processOccurenceOfAlertIntent(Intent intent) {
|
||||||
|
if (SP.getBoolean("insight_automatic_careportal_events", false)) {
|
||||||
|
Date date = getDateExtra(intent, HistoryBroadcast.EXTRA_EVENT_TIME);
|
||||||
|
String alertType = intent.getStringExtra(HistoryBroadcast.EXTRA_ALERT_TYPE);
|
||||||
|
if (MainApp.getDbHelper().getCareportalEventFromTimestamp(date.getTime()) != null) return;
|
||||||
|
try {
|
||||||
|
JSONObject data = new JSONObject();
|
||||||
|
String enteredBy = SP.getString("careportal_enteredby", "");
|
||||||
|
if (!enteredBy.equals("")) data.put("enteredBy", enteredBy);
|
||||||
|
data.put("created_at", DateUtil.toISOString(date));
|
||||||
|
data.put("eventType", CareportalEvent.NOTE);
|
||||||
|
data.put("notes", MainApp.instance().getString(getAlertText(alertType)));
|
||||||
|
NSUpload.uploadCareportalEntryToNS(data);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getAlertText(String type) {
|
||||||
|
if (type.equals("Error6MechanicalError")) return R.string.alert_e6;
|
||||||
|
if (type.equals("Error7ElectronicError")) return R.string.alert_e7;
|
||||||
|
if (type.equals("Error10RewindError")) return R.string.alert_e10;
|
||||||
|
if (type.equals("Error13LanguageError")) return R.string.alert_e13;
|
||||||
|
if (type.equals("Maintenance20CartridgeNotInserted")) return R.string.alert_m20;
|
||||||
|
if (type.equals("Maintenance21CartridgeEmpty")) return R.string.alert_m21;
|
||||||
|
if (type.equals("Maintenance22BatteryEmpty")) return R.string.alert_m22;
|
||||||
|
if (type.equals("Maintenance23AutomaticOff")) return R.string.alert_m23;
|
||||||
|
if (type.equals("Maintenance24Occlusion")) return R.string.alert_m24;
|
||||||
|
if (type.equals("Maintenance25LoantimeOver")) return R.string.alert_m25;
|
||||||
|
if (type.equals("Maintenance26CartridgeChangeNotCompleted")) return R.string.alert_m26;
|
||||||
|
if (type.equals("Maintenance27DataDownloadFailed")) return R.string.alert_m27;
|
||||||
|
if (type.equals("Maintenance28PauseModeTimeout")) return R.string.alert_m28;
|
||||||
|
if (type.equals("Maintenance29BatteryTypeNotSet")) return R.string.alert_m29;
|
||||||
|
if (type.equals("Maintenance30CartridgeTypeNotSet")) return R.string.alert_m30;
|
||||||
|
if (type.equals("Warning31CartridgeLow")) return R.string.alert_w31;
|
||||||
|
if (type.equals("Warning32BatteryLow")) return R.string.alert_w32;
|
||||||
|
if (type.equals("Warning33InvalidDateTime")) return R.string.alert_w33;
|
||||||
|
if (type.equals("Warning34EndOfWarranty")) return R.string.alert_w34;
|
||||||
|
if (type.equals("Warning36TBRCancelled")) return R.string.alert_w36;
|
||||||
|
if (type.equals("Warning38BolusCancelled")) return R.string.alert_w38;
|
||||||
|
if (type.equals("Warning39LoantimeWarning")) return R.string.alert_w39;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,9 @@ public class HistoryReceiver {
|
||||||
case ACTION_BATTERY_INSERTED:
|
case ACTION_BATTERY_INSERTED:
|
||||||
intentAdapter.processBatteryInsertedIntent(intent);
|
intentAdapter.processBatteryInsertedIntent(intent);
|
||||||
break;
|
break;
|
||||||
|
case ACTION_OCCURENCE_OF_ALERT:
|
||||||
|
intentAdapter.processOccurenceOfAlertIntent(intent);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
27
app/src/main/res/values-de/alerts.xml
Normal file
27
app/src/main/res/values-de/alerts.xml
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string name="alert_w31">Warnung W31: Ampulle fast leer</string>
|
||||||
|
<string name="alert_w32">Warnung W32: Batterie fast leer</string>
|
||||||
|
<string name="alert_w33">Warnung W33: Zeit/Datum ungültig</string>
|
||||||
|
<string name="alert_w34">Warnung W34: Garantie abgelaufen</string>
|
||||||
|
<string name="alert_w36">Warnung W36: TBR abgebrochen</string>
|
||||||
|
<string name="alert_w38">Warnung W38: Bolus abgebrochen</string>
|
||||||
|
<string name="alert_w39">Warnung W39: Leihdauer-Warnung</string>
|
||||||
|
|
||||||
|
<string name="alert_m20">Wartung M20: Keine Ampulle eingesetzt</string>
|
||||||
|
<string name="alert_m21">Wartung M21: Ampulle leer</string>
|
||||||
|
<string name="alert_m22">Wartung M22: Batterie leer</string>
|
||||||
|
<string name="alert_m23">Wartung M23: Sicherheitsabschaltung</string>
|
||||||
|
<string name="alert_m24">Wartung M24: Verstopfung</string>
|
||||||
|
<string name="alert_m25">Wartung M25: Leihdauer abgelaufen</string>
|
||||||
|
<string name="alert_m26">Wartung M26: Ampullenwechsel nicht abgeschlossen</string>
|
||||||
|
<string name="alert_m27">Wartung M27: Datenübertragung fehlgeschlagen</string>
|
||||||
|
<string name="alert_m28">Wartung M28: Zeitüberschreitung bei Pause</string>
|
||||||
|
<string name="alert_m29">Wartung M29: Batterietyp nicht eingestellt</string>
|
||||||
|
<string name="alert_m30">Wartung M30: Ampullentyp nicht eingestellt</string>
|
||||||
|
|
||||||
|
<string name="alert_e6">Fehler E6: Mechanikfehler</string>
|
||||||
|
<string name="alert_e7">Fehler E7: Elektronikfehler</string>
|
||||||
|
<string name="alert_e10">Fehler E10: Fehler beim Zurückfahren</string>
|
||||||
|
<string name="alert_e13">Fehler E13: Fehler in der Sprachanzeige</string>
|
||||||
|
</resources>
|
27
app/src/main/res/values/alerts.xml
Normal file
27
app/src/main/res/values/alerts.xml
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string name="alert_w31">Warning W31: Cartridge low</string>
|
||||||
|
<string name="alert_w32">Warning W32: Battery low</string>
|
||||||
|
<string name="alert_w33">Warning W33: Invalid time/date</string>
|
||||||
|
<string name="alert_w34">Warning W34: End of warranty</string>
|
||||||
|
<string name="alert_w36">Warning W36: TBR cancelled</string>
|
||||||
|
<string name="alert_w38">Warning W38: Bolus canelled</string>
|
||||||
|
<string name="alert_w39">Warning W39: Loantime warning</string>
|
||||||
|
|
||||||
|
<string name="alert_m20">Maintenance M20: Cartridge not inserted</string>
|
||||||
|
<string name="alert_m21">Maintenance M21: Cartridge empty</string>
|
||||||
|
<string name="alert_m22">Maintenance M22: Battery empty</string>
|
||||||
|
<string name="alert_m23">Maintenance M23: Automatic off</string>
|
||||||
|
<string name="alert_m24">Maintenance M24: Occlusion</string>
|
||||||
|
<string name="alert_m25">Maintenance M25: Loantime over - end of operation</string>
|
||||||
|
<string name="alert_m26">Maintenance M26: Cartridge change not completed</string>
|
||||||
|
<string name="alert_m27">Maintenance M27: Data download failed</string>
|
||||||
|
<string name="alert_m28">Maintenance M28: Pause mode timeout</string>
|
||||||
|
<string name="alert_m29">Maintenance M29: Battery type not set</string>
|
||||||
|
<string name="alert_m30">Maintenance M30: Cartridge type not set</string>
|
||||||
|
|
||||||
|
<string name="alert_e6">Error E6: Mechanical error</string>
|
||||||
|
<string name="alert_e7">Error E7: Electronic error</string>
|
||||||
|
<string name="alert_e10">Error E10: Rewind error</string>
|
||||||
|
<string name="alert_e13">Error E13: Language error</string>
|
||||||
|
</resources>
|
|
@ -989,4 +989,6 @@
|
||||||
<string name="iobcobcalculator" translatable="false">IobCobCalculator</string>
|
<string name="iobcobcalculator" translatable="false">IobCobCalculator</string>
|
||||||
<string name="waitingfortimesynchronization">Waiting for time synchronization (%d sec)</string>
|
<string name="waitingfortimesynchronization">Waiting for time synchronization (%d sec)</string>
|
||||||
<string name="loopdisconnectedfor">Disconnected (%d m)</string>
|
<string name="loopdisconnectedfor">Disconnected (%d m)</string>
|
||||||
|
<string name="automatic_careportal_events">Automatic careportal events</string>
|
||||||
|
<string name="automatically_upload_insulin_cannula_and_battery_changes_to_nightscout">Automatically upload insulin, cannula and battery changes to Nightscout</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
android:summary="@string/automatically_connect_when"/>
|
android:summary="@string/automatically_connect_when"/>
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="insight_real_tbr_cancel"
|
android:key="insight_automatic_careportal_events"
|
||||||
android:title="@string/insight_use_real_tbr_cancels"
|
android:title="@string/automatic_careportal_events"
|
||||||
android:summary="@string/insight_actually_cancel_tbr_summary"/>
|
android:summary="@string/automatically_upload_insulin_cannula_and_battery_changes_to_nightscout"/>
|
||||||
</PreferenceScreen >
|
</PreferenceScreen>
|
Loading…
Reference in a new issue