public static synchronized Treatments SensorStart(long timestamp) { if (timestamp == 0) { timestamp = new Date().getTime(); } final Treatments Treatment = new Treatments(); Treatment.enteredBy = XDRIP_TAG; Treatment.eventType = "Sensor Start"; Treatment.created_at = DateUtil.toISOString(timestamp); Treatment.uuid = UUID.randomUUID().toString(); Treatment.save(); pushTreatmentSync(Treatment); return Treatment; }
public static Treatments byTimestamp(long timestamp) { return byTimestamp(timestamp, 1500); }
public static void delete_by_uuid(String uuid, boolean from_interactive) { Treatments thistreat = byuuid(uuid); if (thistreat != null) { //KS UploaderQueue.newEntry("delete", thistreat); if (from_interactive) { //KS GcmActivity.push_delete_treatment(thistreat); //KS SyncService.startSyncService(3000); // sync in 3 seconds } thistreat.delete(); //KS Home.staticRefreshBGCharts(); } }
public static Treatments delete_last(boolean from_interactive) { Treatments thistreat = last(); if (thistreat != null) { if (from_interactive) { //KS GcmActivity.push_delete_treatment(thistreat); //GoogleDriveInterface gdrive = new GoogleDriveInterface(); //gdrive.deleteTreatmentAtRemote(thistreat.uuid); } //KS UploaderQueue.newEntry("delete",thistreat); thistreat.delete(); } return null; }
@Override public void onClick(View v) { // proccess and approve treatment textCarbohydrates.setVisibility(View.INVISIBLE); btnCarbohydrates.setVisibility(View.INVISIBLE); reset_viewport = true; Treatments.create(thiscarbsnumber, 0, Treatments.getTimeStampWithOffset(thistimeoffset)); thiscarbsnumber = 0; if (hideTreatmentButtonsIfAllDone()) { updateCurrentBgInfo("carbs button"); } } });
public static synchronized boolean pushTreatmentFromJson(String json, boolean from_interactive) { Log.d(TAG, "converting treatment from json: "); Treatments mytreatment = fromJSON(json); if (mytreatment != null) { if (mytreatment.uuid == null) { Treatments dupe_treatment = byTimestamp(mytreatment.timestamp); if (dupe_treatment != null) { Log.i(TAG, "Duplicate treatment for: " + mytreatment.timestamp); fixUpTable(); dupe_treatment.save(); Log.d(TAG,"Saved updated treatement notes"); fixUpTable(); long x = mytreatment.save(); Log.d(TAG, "Saving treatment result: " + x); if (from_interactive) { pushTreatmentSync(mytreatment);
if (d) Log.d(TAG, "Treatment: Carbs: " + carbs + " Insulin: " + insulin + " timestamp: " + timestamp); Treatments existing = Treatments.byuuid(nightscout_id); if (existing == null) existing = Treatments.byuuid(uuid); if ((existing == null) && (!from_xdrip)) { existing = Treatments.byTimestamp(timestamp, 60000); if (!((existing != null) && (JoH.roundDouble(existing.insulin, 2) == JoH.roundDouble(insulin, 2)) && (JoH.roundDouble(existing.carbs, 2) == JoH.roundDouble(carbs, 2)) final Treatments t; if ((carbs > 0) || (insulin > 0)) { t = Treatments.create(carbs, insulin, timestamp, nightscout_id); if (notes != null) t.notes = notes; } else { t = Treatments.create_note(notes, timestamp, -1, nightscout_id); if (t == null) { Log.d(TAG, "Create note baulked and returned null, so skipping"); t.save(); pushTreatmentSyncToWatch(t, true); new_data = true; } else { existing.save(); if (Home.get_show_wear_treatments()) pushTreatmentSyncToWatch(existing, false); new_data = true;
Treatments Treatment = byTimestamp(timestamp, 60 * 1000 * 5); Treatment = new Treatments(); Log.d(TAG, "Creating new treatment entry for note"); is_new = true; Treatment.save(); pushTreatmentSync(Treatment, is_new, suggested_uuid);
Treatments existing_by_uuid = Treatments.byuuid(suggested_uuid); if (existing_by_uuid != null) { UserError.Log.d(TAG, "Existing record matching uuid: " + suggested_uuid); final Treatments existing = Treatments.byTimestamp(record.timestamp, 120000); final Treatments treatment = Treatments.create(0, record.insulin, record.timestamp, suggested_uuid); if (treatment != null) { treatment.enteredBy += " " + PENDIQ_TAG; treatment.save(); } else { UserError.Log.wtf(TAG, "Could not create treatment entry, possible dupe: " + suggested_uuid);
JoH.static_toast_long("Treatment processed"); WatchUpdaterService.sendWearLocalToast("Treatment processed", Toast.LENGTH_LONG); long time = Treatments.getTimeStampWithOffset(mytimeoffset); final Treatments exists = Treatments.byTimestamp(time); if (exists == null) { Log.d(TAG, "processAndApproveTreatment create watchkeypad Treatment carbs=" + thiscarbsnumber + " insulin=" + thisinsulinnumber + " timestamp=" + JoH.dateTimeText(time) + " uuid=" + thisuuid); Treatments.create(thiscarbsnumber, thisinsulinnumber, time, thisuuid); Pendiq.handleTreatment(thisinsulinnumber); } else { Treatments.create(thiscarbsnumber, thisinsulinnumber, Treatments.getTimeStampWithOffset(mytimeoffset)); Pendiq.handleTreatment(thisinsulinnumber);
|| allWords.contentEquals("cancel last treatment") || allWords.contentEquals("erase last treatment")) { Treatments.delete_last(true); updateCurrentBgInfo("delete last treatment"); } else if ((allWords.contentEquals("delete all treatments")) || (allWords.contentEquals("delete all treatment"))) { Treatments.delete_all(true); updateCurrentBgInfo("delete all treatment"); } else if (allWords.contentEquals("delete all glucose data")) { Treatments.create_note(note_text, JoH.tsl()); staticRefreshBGCharts(); break; // don't process any more
if (item.Treatment_uuid != null) { try { item.saved_data = Treatments.byuuid(item.Treatment_uuid).toJSON(); item.expires = JoH.ts() + EXPIRY_TIME; redo_queue.add(item); undo_queue.remove(location); Treatments.delete_by_uuid(item.Treatment_uuid,true); } catch (NullPointerException e) { UserError.Log.wtf(TAG, "Null pointer exception in undoNext()");
public static void delete_by_timestamp(long timestamp, int accuracy, boolean from_interactive) { final Treatments t = byTimestamp(timestamp, accuracy); // do we need to alter default accuracy? if (t != null) { Log.d(TAG, "Deleting treatment closest to: " + JoH.dateTimeText(timestamp) + " matches uuid: " + t.uuid); delete_by_uuid(t.uuid, from_interactive); } else { Log.e(TAG, "Couldn't find a treatment near enough to " + JoH.dateTimeText(timestamp) + " to delete!"); } }
public static synchronized Treatments create(final double carbs, final double insulin, final String notes, long timestamp, double position, String suggested_uuid) { fixUpTable(); Log.d(TAG, "Creating treatment: Insulin: " + Double.toString(insulin) + " / Carbs: " + Double.toString(carbs)); Treatments Treatment = new Treatments(); Treatment.systimestamp = new Date().getTime(); Treatment.save();
public static synchronized Treatments create_note(String note, long timestamp, double position) { return create_note(note, timestamp, position, null); }
Log.i(TAG, "Attempting GCM delete all treatments"); if (Home.get_master_or_follower() && Home.follower_or_accept_follower()) Treatments.delete_all(); } else if (action.equals("dt")) { Log.i(TAG, "Attempting GCM delete specific treatment"); if (Home.get_master_or_follower() && Home.follower_or_accept_follower()) Treatments.delete_by_uuid(filter(payload)); } else if (action.equals("clc")) { Log.i(TAG, "Attempting to clear last calibration");
public static synchronized Treatments create(final double carbs, final double insulin, long timestamp) { return create(carbs, insulin, timestamp, null); }
if (record != null) { Treatments data = gson.fromJson(record, Treatments.class); Treatments exists = Treatments.byuuid(data.uuid); if (exists != null) { Log.d(TAG, "syncTreatmentsData save existing Treatments for action insert uuid=" + data.uuid + " timestamp=" + data.timestamp + " timeString=" + JoH.dateTimeText(data.timestamp) + " carbs=" + data.carbs + " insulin=" + data.insulin + " exists.systime=" + JoH.dateTimeText(exists.systimestamp)); exists.timestamp = data.timestamp; exists.systimestamp = exists.systimestamp > 0 ? exists.systimestamp : data.timestamp < last_send_previous_treatments ? data.timestamp : last_send_previous_treatments > 0 ? last_send_previous_treatments - 1 : JoH.tsl(); exists.save(); } else { changed = true; data.systimestamp = data.timestamp < last_send_previous_treatments ? data.timestamp : last_send_previous_treatments > 0 ? last_send_previous_treatments - 1 : JoH.tsl(); data.save(); Log.d(TAG, "syncTreatmentsData create new treatment for action insert uuid=" + data.uuid + " timestamp=" + data.timestamp + " timeString=" + JoH.dateTimeText(data.timestamp) + " carbs=" + data.carbs + " insulin=" + data.insulin + " systime=" + JoH.dateTimeText(data.systimestamp));
public static void delete_by_uuid(String uuid) { delete_by_uuid(uuid,false); }
public static void delete_all() { delete_all(false); }