save Careportal events directly to DB
This commit is contained in:
parent
42c2d89f98
commit
9098eb2da0
4 changed files with 40 additions and 0 deletions
|
@ -1524,6 +1524,12 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
|||
data.put("created_at", DateUtil.toISOString(date));
|
||||
data.put("eventType", CareportalEvent.NOTE);
|
||||
data.put("notes", note);
|
||||
CareportalEvent careportalEvent = new CareportalEvent();
|
||||
careportalEvent.date = date;
|
||||
careportalEvent.source = Source.USER;
|
||||
careportalEvent.eventType = CareportalEvent.NOTE;
|
||||
careportalEvent.json = data.toString();
|
||||
MainApp.getDbHelper().createOrUpdate(careportalEvent);
|
||||
NSUpload.uploadCareportalEntryToNS(data);
|
||||
} catch (JSONException e) {
|
||||
log.error("Unhandled exception", e);
|
||||
|
@ -1552,6 +1558,12 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
|||
if (!enteredBy.equals("")) data.put("enteredBy", enteredBy);
|
||||
data.put("created_at", DateUtil.toISOString(date));
|
||||
data.put("eventType", event);
|
||||
CareportalEvent careportalEvent = new CareportalEvent();
|
||||
careportalEvent.date = date;
|
||||
careportalEvent.source = Source.USER;
|
||||
careportalEvent.eventType = event;
|
||||
careportalEvent.json = data.toString();
|
||||
MainApp.getDbHelper().createOrUpdate(careportalEvent);
|
||||
NSUpload.uploadCareportalEntryToNS(data);
|
||||
} catch (JSONException e) {
|
||||
log.error("Unhandled exception", e);
|
||||
|
|
|
@ -528,6 +528,12 @@ public class MedtronicHistoryData {
|
|||
if (!enteredBy.equals("")) data.put("enteredBy", enteredBy);
|
||||
data.put("created_at", DateUtil.toISOString(date));
|
||||
data.put("eventType", event);
|
||||
CareportalEvent careportalEvent = new CareportalEvent();
|
||||
careportalEvent.date = date;
|
||||
careportalEvent.source = Source.USER;
|
||||
careportalEvent.eventType = event;
|
||||
careportalEvent.json = data.toString();
|
||||
MainApp.getDbHelper().createOrUpdate(careportalEvent);
|
||||
NSUpload.uploadCareportalEntryToNS(data);
|
||||
} catch (JSONException e) {
|
||||
LOG.error("Unhandled exception", e);
|
||||
|
|
|
@ -9,6 +9,8 @@ import info.nightscout.androidaps.R
|
|||
import info.nightscout.androidaps.activities.RequestDexcomPermissionActivity
|
||||
import info.nightscout.androidaps.db.BgReading
|
||||
import info.nightscout.androidaps.db.CareportalEvent
|
||||
import info.nightscout.androidaps.db.Source
|
||||
import info.nightscout.androidaps.dialogs.CareDialog
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface
|
||||
import info.nightscout.androidaps.interfaces.PluginBase
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||
|
@ -96,6 +98,13 @@ object SourceDexcomPlugin : PluginBase(PluginDescription()
|
|||
jsonObject.put("glucoseType", "Finger")
|
||||
jsonObject.put("glucose", meter.getInt("meterValue"))
|
||||
jsonObject.put("units", Constants.MGDL)
|
||||
|
||||
val careportalEvent = CareportalEvent()
|
||||
careportalEvent.date = timestamp
|
||||
careportalEvent.source = Source.USER
|
||||
careportalEvent.eventType = CareportalEvent.BGCHECK
|
||||
careportalEvent.json = jsonObject.toString()
|
||||
MainApp.getDbHelper().createOrUpdate(careportalEvent)
|
||||
NSUpload.uploadCareportalEntryToNS(jsonObject)
|
||||
}
|
||||
}
|
||||
|
@ -110,6 +119,12 @@ object SourceDexcomPlugin : PluginBase(PluginDescription()
|
|||
jsonObject.put("enteredBy", "AndroidAPS-Dexcom$sensorType")
|
||||
jsonObject.put("created_at", DateUtil.toISOString(sensorInsertionTime))
|
||||
jsonObject.put("eventType", CareportalEvent.SENSORCHANGE)
|
||||
val careportalEvent = CareportalEvent()
|
||||
careportalEvent.date = sensorInsertionTime
|
||||
careportalEvent.source = Source.USER
|
||||
careportalEvent.eventType = CareportalEvent.SENSORCHANGE
|
||||
careportalEvent.json = jsonObject.toString()
|
||||
MainApp.getDbHelper().createOrUpdate(careportalEvent)
|
||||
NSUpload.uploadCareportalEntryToNS(jsonObject)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import info.nightscout.androidaps.MainApp;
|
|||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.db.BgReading;
|
||||
import info.nightscout.androidaps.db.CareportalEvent;
|
||||
import info.nightscout.androidaps.db.Source;
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
|
@ -143,6 +144,12 @@ public class SourceEversensePlugin extends PluginBase implements BgSourceInterfa
|
|||
data.put("glucoseType", "Finger");
|
||||
data.put("glucose", calibrationGlucoseLevels[i]);
|
||||
data.put("units", Constants.MGDL);
|
||||
CareportalEvent careportalEvent = new CareportalEvent();
|
||||
careportalEvent.date = calibrationTimestamps[i];
|
||||
careportalEvent.source = Source.USER;
|
||||
careportalEvent.eventType = CareportalEvent.BGCHECK;
|
||||
careportalEvent.json = data.toString();
|
||||
MainApp.getDbHelper().createOrUpdate(careportalEvent);
|
||||
NSUpload.uploadCareportalEntryToNS(data);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
|
|
Loading…
Reference in a new issue