bolus wizard full functionality

This commit is contained in:
Milos Kozak 2016-07-16 22:37:10 +02:00
parent 489037df1a
commit 82a16efcc2
11 changed files with 770 additions and 483 deletions

View file

@ -23,8 +23,8 @@ android {
applicationId "info.nightscout.androidaps" applicationId "info.nightscout.androidaps"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 23 targetSdkVersion 23
versionCode 1008 versionCode 1009
versionName "1.0.08" versionName "1.0.09"
} }
buildTypes { buildTypes {
release { release {

View file

@ -20,6 +20,7 @@ import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.data.Iob; import info.nightscout.androidaps.data.Iob;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
import info.nightscout.client.data.DbLogger; import info.nightscout.client.data.DbLogger;
import info.nightscout.client.data.NSProfile; import info.nightscout.client.data.NSProfile;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
@ -99,10 +100,6 @@ public class Treatment {
} }
public void sendToNSClient() { public void sendToNSClient() {
Context context = MainApp.instance().getApplicationContext();
Bundle bundle = new Bundle();
bundle.putString("action", "dbAdd");
bundle.putString("collection", "treatments");
JSONObject data = new JSONObject(); JSONObject data = new JSONObject();
try { try {
data.put("eventType", "Meal Bolus"); data.put("eventType", "Meal Bolus");
@ -113,12 +110,7 @@ public class Treatment {
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
bundle.putString("data", data.toString()); ConfigBuilderFragment.uploadCareportalEntryToNS(data);
Intent intent = new Intent(Intents.ACTION_DATABASE);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
DbLogger.dbAdd(intent, data.toString(), Treatment.class);
} }
public void updateToNSClient() { public void updateToNSClient() {

View file

@ -46,6 +46,7 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment; import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
import info.nightscout.androidaps.plugins.Overview.Dialogs.NewExtendedBolusDialog; import info.nightscout.androidaps.plugins.Overview.Dialogs.NewExtendedBolusDialog;
import info.nightscout.client.data.DbLogger; import info.nightscout.client.data.DbLogger;
import info.nightscout.client.data.NSProfile; import info.nightscout.client.data.NSProfile;
@ -396,7 +397,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
if (layoutPercent.getVisibility() != View.GONE) if (layoutPercent.getVisibility() != View.GONE)
data.put("percent", SafeParse.stringToDouble(percentEdit.getText().toString())); data.put("percent", SafeParse.stringToDouble(percentEdit.getText().toString()));
if (layoutAbsolute.getVisibility() != View.GONE) if (layoutAbsolute.getVisibility() != View.GONE)
data.put("absolute", profileSpinner.getSelectedItem().toString()); data.put("absolute", SafeParse.stringToDouble(absoluteEdit.getText().toString()));
if (options.profile) data.put("profile", profileSpinner.getSelectedItem().toString()); if (options.profile) data.put("profile", profileSpinner.getSelectedItem().toString());
if (SafeParse.stringToDouble(carbTimeEdit.getText().toString()) != 0d) if (SafeParse.stringToDouble(carbTimeEdit.getText().toString()) != 0d)
data.put("preBolus", SafeParse.stringToDouble(carbTimeEdit.getText().toString())); data.put("preBolus", SafeParse.stringToDouble(carbTimeEdit.getText().toString()));
@ -512,40 +513,11 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
builder.setMessage(confirmText); builder.setMessage(confirmText);
builder.setPositiveButton(getContext().getString(R.string.ok), new DialogInterface.OnClickListener() { builder.setPositiveButton(getContext().getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
sendTreatmentToNS(data); ConfigBuilderFragment.uploadCareportalEntryToNS(data);
} }
}); });
builder.setNegativeButton(getContext().getString(R.string.cancel), null); builder.setNegativeButton(getContext().getString(R.string.cancel), null);
builder.show(); builder.show();
} }
static void sendTreatmentToNS(JSONObject data) {
try {
if (data.has("preBolus") && data.has("carbs")) {
JSONObject prebolus = new JSONObject();
prebolus.put("carbs", data.get("carbs"));
data.remove("carbs");
prebolus.put("eventType", data.get("eventType"));
if (data.has("enteredBy")) prebolus.put("enteredBy", data.get("enteredBy"));
if (data.has("notes")) prebolus.put("notes", data.get("notes"));
long mills = DateUtil.fromISODateString(data.getString("created_at")).getTime();
Date preBolusDate = new Date(mills + data.getInt("preBolus") * 60000L);
prebolus.put("created_at", DateUtil.toISOString(preBolusDate));
sendTreatmentToNS(prebolus);
}
Context context = MainApp.instance().getApplicationContext();
Bundle bundle = new Bundle();
bundle.putString("action", "dbAdd");
bundle.putString("collection", "treatments");
bundle.putString("data", data.toString());
Intent intent = new Intent(Intents.ACTION_DATABASE);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
DbLogger.dbAdd(intent, data.toString(), NewExtendedBolusDialog.class);
} catch (Exception e) {
e.printStackTrace();
}
}
} }

View file

@ -28,6 +28,7 @@ import org.slf4j.LoggerFactory;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -54,6 +55,7 @@ import info.nightscout.androidaps.plugins.Loop.APSResult;
import info.nightscout.androidaps.plugins.Loop.DeviceStatus; import info.nightscout.androidaps.plugins.Loop.DeviceStatus;
import info.nightscout.androidaps.plugins.Loop.LoopFragment; import info.nightscout.androidaps.plugins.Loop.LoopFragment;
import info.nightscout.androidaps.plugins.OpenAPSMA.DetermineBasalResult; import info.nightscout.androidaps.plugins.OpenAPSMA.DetermineBasalResult;
import info.nightscout.androidaps.plugins.Overview.Dialogs.NewExtendedBolusDialog;
import info.nightscout.client.data.DbLogger; import info.nightscout.client.data.DbLogger;
import info.nightscout.client.data.NSProfile; import info.nightscout.client.data.NSProfile;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
@ -284,6 +286,69 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
return activePump.getExtendedBolus(); return activePump.getExtendedBolus();
} }
/*
{
"_id": {
"$oid": "5789fea07ef0c37deb388240"
},
"boluscalc": {
"profile": "Posunuta snidane",
"eventTime": "2016-07-16T09:30:14.139Z",
"targetBGLow": "5.6",
"targetBGHigh": "5.6",
"isf": "17",
"ic": "26",
"iob": "0.89",
"cob": "0",
"insulincob": "0",
"bg": "3.6",
"insulinbg": "-0.12",
"bgdiff": "-2",
"carbs": "42",
"gi": "2",
"insulincarbs": "1.62",
"othercorrection": "0",
"insulin": "0.6000000000000001",
"roundingcorrection": "-0.009999999999999898",
"carbsneeded": "0"
},
"enteredBy": "",
"eventType": "Bolus Wizard",
"glucose": 3.6,
"glucoseType": "Sensor",
"units": "mmol",
"carbs": 42,
"insulin": 0.6,
"created_at": "2016-07-16T09:30:12.783Z"
}
*/
public PumpEnactResult deliverTreatmentFromBolusWizard(Double insulin, Integer carbs, Double glucose, String glucoseType, int carbTime, JSONObject boluscalc) {
insulin = applyBolusConstraints(insulin);
carbs = applyCarbsConstraints(carbs);
PumpEnactResult result = activePump.deliverTreatment(insulin, carbs);
if (Config.logCongigBuilderActions)
log.debug("deliverTreatmentFromBolusWizard insulin: " + insulin + " carbs: " + carbs + " success: " + result.success + " enacted: " + result.enacted + " bolusDelivered: " + result.bolusDelivered);
if (result.success) {
Treatment t = new Treatment();
t.insulin = result.bolusDelivered;
t.carbs = (double) result.carbsDelivered;
t.created_at = new Date();
try {
MainApp.getDbHelper().getDaoTreatments().create(t);
} catch (SQLException e) {
e.printStackTrace();
}
t.setTimeIndex(t.getTimeIndex());
uploadBolusWizardRecord(t, glucose, glucoseType, carbTime, boluscalc);
MainApp.bus().post(new EventTreatmentChange());
}
return result;
}
@Override @Override
public PumpEnactResult deliverTreatment(Double insulin, Integer carbs) { public PumpEnactResult deliverTreatment(Double insulin, Integer carbs) {
insulin = applyBolusConstraints(insulin); insulin = applyBolusConstraints(insulin);
@ -1033,4 +1098,53 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
e.printStackTrace(); e.printStackTrace();
} }
} }
public void uploadBolusWizardRecord(Treatment t, double glucose, String glucoseType, int carbTime, JSONObject boluscalc) {
JSONObject data = new JSONObject();
try {
data.put("eventType", "Bolus Wizard");
if (t.insulin != 0d) data.put("insulin", t.insulin);
if (t.carbs != 0d) data.put("carbs", t.carbs.intValue());
data.put("created_at", DateUtil.toISOString(t.created_at));
data.put("timeIndex", t.timeIndex);
if (glucose != 0d) data.put("glucose", glucose);
data.put("glucoseType", glucoseType);
data.put("boluscalc", boluscalc);
if (carbTime != 0) data.put("preBolus", carbTime);
} catch (JSONException e) {
e.printStackTrace();
}
uploadCareportalEntryToNS(data);
}
public static void uploadCareportalEntryToNS(JSONObject data) {
try {
if (data.has("preBolus") && data.has("carbs")) {
JSONObject prebolus = new JSONObject();
prebolus.put("carbs", data.get("carbs"));
data.remove("carbs");
prebolus.put("eventType", data.get("eventType"));
if (data.has("enteredBy")) prebolus.put("enteredBy", data.get("enteredBy"));
if (data.has("notes")) prebolus.put("notes", data.get("notes"));
long mills = DateUtil.fromISODateString(data.getString("created_at")).getTime();
Date preBolusDate = new Date(mills + data.getInt("preBolus") * 60000L);
prebolus.put("created_at", DateUtil.toISOString(preBolusDate));
uploadCareportalEntryToNS(prebolus);
}
Context context = MainApp.instance().getApplicationContext();
Bundle bundle = new Bundle();
bundle.putString("action", "dbAdd");
bundle.putString("collection", "treatments");
bundle.putString("data", data.toString());
Intent intent = new Intent(Intents.ACTION_DATABASE);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
DbLogger.dbAdd(intent, data.toString(), NewExtendedBolusDialog.class);
} catch (Exception e) {
e.printStackTrace();
}
}
} }

View file

@ -387,6 +387,7 @@ public class DanaConnection {
} }
public void bolus(Double amount, Treatment t) { public void bolus(Double amount, Treatment t) {
// TODO: progress dialog
bolusingTreatment = t; bolusingTreatment = t;
MsgBolusStart start = new MsgBolusStart(amount); MsgBolusStart start = new MsgBolusStart(amount);
MsgBolusProgress progress = new MsgBolusProgress(MainApp.bus(), amount, t); MsgBolusProgress progress = new MsgBolusProgress(MainApp.bus(), amount, t);

View file

@ -14,12 +14,20 @@ import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.ArrayAdapter;
import android.widget.Button; import android.widget.Button;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import org.json.JSONException;
import org.json.JSONObject;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Date;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
@ -29,8 +37,10 @@ import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.interfaces.TempBasalsInterface; import info.nightscout.androidaps.interfaces.TempBasalsInterface;
import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal; import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal;
import info.nightscout.client.data.NSProfile; import info.nightscout.client.data.NSProfile;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.PlusMinusEditText; import info.nightscout.utils.PlusMinusEditText;
import info.nightscout.utils.Round; import info.nightscout.utils.Round;
@ -55,13 +65,17 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
CheckBox basalIobCheckbox; CheckBox basalIobCheckbox;
TextView correctionInsulin; TextView correctionInsulin;
TextView total, totalInsulin; TextView total, totalInsulin;
EditText carbTimeEdit;
Spinner profileSpinner;
PlusMinusEditText editBg; PlusMinusEditText editBg;
PlusMinusEditText editCarbs; PlusMinusEditText editCarbs;
PlusMinusEditText editCorr; PlusMinusEditText editCorr;
PlusMinusEditText editCarbTime;
Integer calculatedCarbs = 0; Integer calculatedCarbs = 0;
Double calculatedTotalInsulin = 0d; Double calculatedTotalInsulin = 0d;
JSONObject boluscalcJSON;
Handler mHandler; Handler mHandler;
public static HandlerThread mHandlerThread; public static HandlerThread mHandlerThread;
@ -69,7 +83,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
public WizardDialog() { public WizardDialog() {
mHandlerThread = new HandlerThread(NewExtendedBolusDialog.class.getSimpleName()); mHandlerThread = new HandlerThread(NewExtendedBolusDialog.class.getSimpleName());
mHandlerThread.start(); mHandlerThread.start();
this.mHandler = new Handler(mHandlerThread.getLooper()); mHandler = new Handler(mHandlerThread.getLooper());
} }
final private TextWatcher textWatcher = new TextWatcher() { final private TextWatcher textWatcher = new TextWatcher() {
@ -126,6 +140,8 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
correctionInsulin = (TextView) view.findViewById(R.id.treatments_wizard_correctioninsulin); correctionInsulin = (TextView) view.findViewById(R.id.treatments_wizard_correctioninsulin);
total = (TextView) view.findViewById(R.id.treatments_wizard_total); total = (TextView) view.findViewById(R.id.treatments_wizard_total);
totalInsulin = (TextView) view.findViewById(R.id.treatments_wizard_totalinsulin); totalInsulin = (TextView) view.findViewById(R.id.treatments_wizard_totalinsulin);
carbTimeEdit = (EditText) view.findViewById(R.id.treatments_wizard_carbtimeinput);
profileSpinner = (Spinner) view.findViewById(R.id.treatments_wizard_profile);
bgCheckbox.setOnCheckedChangeListener(onCheckedChangeListener); bgCheckbox.setOnCheckedChangeListener(onCheckedChangeListener);
basalIobCheckbox.setOnCheckedChangeListener(onCheckedChangeListener); basalIobCheckbox.setOnCheckedChangeListener(onCheckedChangeListener);
@ -137,7 +153,9 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
editBg = new PlusMinusEditText(view, R.id.treatments_wizard_bginput, R.id.treatments_wizard_bginput_plus, R.id.treatments_wizard_bginput_minus, 0d, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false); editBg = new PlusMinusEditText(view, R.id.treatments_wizard_bginput, R.id.treatments_wizard_bginput_plus, R.id.treatments_wizard_bginput_minus, 0d, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false);
editCarbs = new PlusMinusEditText(view, R.id.treatments_wizard_carbsinput, R.id.treatments_wizard_carbsinput_plus, R.id.treatments_wizard_carbsinput_minus, 0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false); editCarbs = new PlusMinusEditText(view, R.id.treatments_wizard_carbsinput, R.id.treatments_wizard_carbsinput_plus, R.id.treatments_wizard_carbsinput_minus, 0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false);
editCorr = new PlusMinusEditText(view, R.id.treatments_wizard_correctioninput, R.id.treatments_wizard_correctioninput_plus, R.id.treatments_wizard_correctioninput_minus, 0d, 0d, maxCorrection, 0.05d, new DecimalFormat("0.00"), false); editCorr = new PlusMinusEditText(view, R.id.treatments_wizard_correctioninput, R.id.treatments_wizard_correctioninput_plus, R.id.treatments_wizard_correctioninput_minus, 0d, 0d, maxCorrection, 0.05d, new DecimalFormat("0.00"), false);
editCarbTime = new PlusMinusEditText(view, R.id.treatments_wizard_carbtimeinput, R.id.treatments_wizard_carbtime_plus, R.id.treatments_wizard_carbtime_minus, 0d, -60d, 60d, 5d, new DecimalFormat("0"), false);
initDialog(); initDialog();
return view; return view;
} }
@ -155,7 +173,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
confirmMessage += "\n" + getString(R.string.bolus) + ": " + formatNumber2decimalplaces.format(insulinAfterConstraints) + "U"; confirmMessage += "\n" + getString(R.string.bolus) + ": " + formatNumber2decimalplaces.format(insulinAfterConstraints) + "U";
confirmMessage += "\n" + getString(R.string.carbs) + ": " + carbsAfterConstraints + "g"; confirmMessage += "\n" + getString(R.string.carbs) + ": " + carbsAfterConstraints + "g";
if (insulinAfterConstraints - calculatedTotalInsulin != 0 || carbsAfterConstraints != calculatedCarbs) { if (insulinAfterConstraints - calculatedTotalInsulin != 0 || carbsAfterConstraints != calculatedCarbs) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(getContext().getString(R.string.treatmentdeliveryerror)); builder.setTitle(getContext().getString(R.string.treatmentdeliveryerror));
builder.setMessage(getString(R.string.constraints_violation) + "\n" + getString(R.string.changeyourinput)); builder.setMessage(getString(R.string.constraints_violation) + "\n" + getString(R.string.changeyourinput));
@ -167,17 +185,24 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
final Double finalInsulinAfterConstraints = insulinAfterConstraints; final Double finalInsulinAfterConstraints = insulinAfterConstraints;
final Integer finalCarbsAfterConstraints = carbsAfterConstraints; final Integer finalCarbsAfterConstraints = carbsAfterConstraints;
AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext()); AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(this.getContext().getString(R.string.confirmation)); builder.setTitle(getContext().getString(R.string.confirmation));
builder.setMessage(confirmMessage); builder.setMessage(confirmMessage);
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
if (finalInsulinAfterConstraints > 0 || finalCarbsAfterConstraints > 0) { if (finalInsulinAfterConstraints > 0 || finalCarbsAfterConstraints > 0) {
final PumpInterface pump = MainApp.getConfigBuilder().getActivePump(); final ConfigBuilderFragment pump = MainApp.getConfigBuilder();
mHandler.post(new Runnable() { mHandler.post(new Runnable() {
@Override @Override
public void run() { public void run() {
PumpEnactResult result = pump.deliverTreatment(finalInsulinAfterConstraints, finalCarbsAfterConstraints); PumpEnactResult result = pump.deliverTreatmentFromBolusWizard(
finalInsulinAfterConstraints,
finalCarbsAfterConstraints,
SafeParse.stringToDouble(bgInput.getText().toString()),
"Manual",
SafeParse.stringToInt(carbTimeEdit.getText().toString()),
boluscalcJSON
);
if (!result.success) { if (!result.success) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(getContext().getString(R.string.treatmentdeliveryerror)); builder.setTitle(getContext().getString(R.string.treatmentdeliveryerror));
@ -207,13 +232,25 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
return; return;
} }
ArrayList<CharSequence> profileList;
profileList = profile.getProfileList();
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(getContext(),
android.R.layout.simple_spinner_item, profileList);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
profileSpinner.setAdapter(adapter);
// set selected to actual profile
for (int p = 0; p < profileList.size(); p++) {
if (profileList.get(p).equals(profile.getActiveProfile()))
profileSpinner.setSelection(p);
}
String units = profile.getUnits(); String units = profile.getUnits();
bgUnits.setText(units); bgUnits.setText(units);
if (units.equals(Constants.MGDL)) editBg.setStep(1d); if (units.equals(Constants.MGDL)) editBg.setStep(1d);
else editBg.setStep(0.1d); else editBg.setStep(0.1d);
// Set BG if not old // Set BG if not old
BgReading lastBg = MainApp.getDbHelper().lastBg(); BgReading lastBg = MainApp.getDbHelper().actualBg();
if (lastBg != null) { if (lastBg != null) {
Double lastBgValue = lastBg.valueToUnits(units); Double lastBgValue = lastBg.valueToUnits(units);
@ -250,21 +287,25 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
IobTotal bolusIob = treatments.getLastCalculation(); IobTotal bolusIob = treatments.getLastCalculation();
IobTotal basalIob = tempBasals.getLastCalculation(); IobTotal basalIob = tempBasals.getLastCalculation();
bolusIobInsulin.setText("-" + DecimalFormatter.to2Decimal(bolusIob.iob) + "U"); bolusIobInsulin.setText(DecimalFormatter.to2Decimal(-bolusIob.iob) + "U");
basalIobInsulin.setText("-" + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U"); basalIobInsulin.setText(DecimalFormatter.to2Decimal(-basalIob.basaliob) + "U");
totalInsulin.setText(""); totalInsulin.setText("");
wizardDialogDeliverButton.setVisibility(Button.INVISIBLE); wizardDialogDeliverButton.setVisibility(Button.INVISIBLE);
} }
private void calculateInsulin() { private void calculateInsulin() {
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile(); NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
if (profileSpinner == null || profileSpinner.getSelectedItem() == null)
return; // not initialized yet
String selectedAlternativeProfile = profileSpinner.getSelectedItem().toString();
JSONObject specificProfile = profile.getSpecificProfile(selectedAlternativeProfile);
// Entered values // Entered values
Double c_bg = SafeParse.stringToDouble(this.bgInput.getText().toString()); Double c_bg = SafeParse.stringToDouble(bgInput.getText().toString());
Integer c_carbs = SafeParse.stringToInt(this.carbsInput.getText().toString()); Integer c_carbs = SafeParse.stringToInt(carbsInput.getText().toString());
Double c_correction = SafeParse.stringToDouble(this.correctionInput.getText().toString()); Double c_correction = SafeParse.stringToDouble(correctionInput.getText().toString());
Double corrAfterConstraint = MainApp.getConfigBuilder().applyBolusConstraints(c_correction); Double corrAfterConstraint = MainApp.getConfigBuilder().applyBolusConstraints(c_correction);
if (c_correction - corrAfterConstraint != 0) { // c_correction != corrAfterConstraint doesn't work if (c_correction - corrAfterConstraint != 0) { // c_correction != corrAfterConstraint doesn't work
correctionInput.removeTextChangedListener(textWatcher); correctionInput.removeTextChangedListener(textWatcher);
@ -286,9 +327,9 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
// Insulin from BG // Insulin from BG
Double sens = profile.getIsf(NSProfile.secondsFromMidnight()); Double sens = profile.getIsf(specificProfile, NSProfile.secondsFromMidnight());
Double targetBGLow = profile.getTargetLow(NSProfile.secondsFromMidnight()); Double targetBGLow = profile.getTargetLow(specificProfile, NSProfile.secondsFromMidnight());
Double targetBGHigh = profile.getTargetHigh(NSProfile.secondsFromMidnight()); Double targetBGHigh = profile.getTargetHigh(specificProfile, NSProfile.secondsFromMidnight());
Double bgDiff; Double bgDiff;
if (c_bg <= targetBGLow) { if (c_bg <= targetBGLow) {
bgDiff = c_bg - targetBGLow; bgDiff = c_bg - targetBGLow;
@ -300,7 +341,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
bgInsulin.setText(DecimalFormatter.to2Decimal(insulinFromBG) + "U"); bgInsulin.setText(DecimalFormatter.to2Decimal(insulinFromBG) + "U");
// Insuling from carbs // Insuling from carbs
Double ic = profile.getIc(NSProfile.secondsFromMidnight()); Double ic = profile.getIc(specificProfile, NSProfile.secondsFromMidnight());
Double insulinFromCarbs = c_carbs / ic; Double insulinFromCarbs = c_carbs / ic;
carbs.setText(DecimalFormatter.to0Decimal(c_carbs) + "g IC: " + DecimalFormatter.to0Decimal(ic)); carbs.setText(DecimalFormatter.to0Decimal(c_carbs) + "g IC: " + DecimalFormatter.to0Decimal(ic));
carbsInsulin.setText(DecimalFormatter.to2Decimal(insulinFromCarbs) + "U"); carbsInsulin.setText(DecimalFormatter.to2Decimal(insulinFromCarbs) + "U");
@ -346,5 +387,28 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
} else { } else {
wizardDialogDeliverButton.setVisibility(Button.INVISIBLE); wizardDialogDeliverButton.setVisibility(Button.INVISIBLE);
} }
boluscalcJSON = new JSONObject();
try {
boluscalcJSON.put("profile", selectedAlternativeProfile);
boluscalcJSON.put("eventTime", DateUtil.toISOString(new Date()));
boluscalcJSON.put("targetBGLow", targetBGLow);
boluscalcJSON.put("targetBGHigh", targetBGHigh);
boluscalcJSON.put("isf", sens);
boluscalcJSON.put("ic", ic);
boluscalcJSON.put("iob", -(insulingFromBolusIOB + insulingFromBasalsIOB));
boluscalcJSON.put("bolusiobused", bolusIobCheckbox.isChecked());
boluscalcJSON.put("basaliobused", basalIobCheckbox.isChecked());
boluscalcJSON.put("bg", c_bg);
boluscalcJSON.put("insulinbg", insulinFromBG);
boluscalcJSON.put("insulinbgused", bgCheckbox.isChecked());
boluscalcJSON.put("bgdiff", bgDiff);
boluscalcJSON.put("insulincarbs", insulinFromCarbs);
boluscalcJSON.put("carbs", c_carbs);
boluscalcJSON.put("othercorrection", corrAfterConstraint);
boluscalcJSON.put("insulin", calculatedTotalInsulin);
} catch (JSONException e) {
e.printStackTrace();
}
} }
} }

View file

@ -651,6 +651,7 @@ public class OverviewFragment extends Fragment implements PluginBase {
bgGraph.getViewport().setMinY(0); bgGraph.getViewport().setMinY(0);
bgGraph.getViewport().setYAxisBoundsManual(true); bgGraph.getViewport().setYAxisBoundsManual(true);
bgGraph.getGridLabelRenderer().setNumVerticalLabels(numOfHorizLines); bgGraph.getGridLabelRenderer().setNumVerticalLabels(numOfHorizLines);
// TODO: add treatments
} }
} }

View file

@ -177,7 +177,7 @@ public class VirtualPumpFragment extends Fragment implements PluginBase, PumpInt
@Override @Override
public TempBasal getTempBasal(Date time) { public TempBasal getTempBasal(Date time) {
return MainApp.getConfigBuilder().getActiveTempBasals().getTempBasal(new Date()); return MainApp.getConfigBuilder().getActiveTempBasals().getTempBasal(time);
} }
@Override @Override

View file

@ -31,13 +31,25 @@ public class NSProfile {
defaultProfileName = (String) json.get("defaultProfile"); defaultProfileName = (String) json.get("defaultProfile");
store = json.getJSONObject("store"); store = json.getJSONObject("store");
if (activeProfile != null && store.has(activeProfile)) { if (activeProfile != null && store.has(activeProfile)) {
defaultProfileName = activeProfile; defaultProfileName = activeProfile;
} }
profile = store.getJSONObject(defaultProfileName); profile = store.getJSONObject(defaultProfileName);
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
return profile;
}
public JSONObject getSpecificProfile(String profileName) {
JSONObject profile = null;
try {
JSONObject store = json.getJSONObject("store");
if (store.has(profileName)) {
profile = store.getJSONObject(profileName);
}
} catch (JSONException e) {
e.printStackTrace();
}
return profile; return profile;
} }
@ -50,7 +62,7 @@ public class NSProfile {
store = json.getJSONObject("store"); store = json.getJSONObject("store");
Iterator<?> keys = store.keys(); Iterator<?> keys = store.keys();
while( keys.hasNext() ) { while (keys.hasNext()) {
String profileName = (String) keys.next(); String profileName = (String) keys.next();
ret.add(profileName); ret.add(profileName);
} }
@ -63,7 +75,7 @@ public class NSProfile {
public String log() { public String log() {
String ret = "\n"; String ret = "\n";
for (Integer hour = 0; hour < 24; hour ++) { for (Integer hour = 0; hour < 24; hour++) {
double value = getBasal(hour * 60 * 60); double value = getBasal(hour * 60 * 60);
ret += "NS basal value for " + hour + ":00 is " + value + "\n"; ret += "NS basal value for " + hour + ":00 is " + value + "\n";
} }
@ -71,13 +83,16 @@ public class NSProfile {
return ret; return ret;
} }
public JSONObject getData () { public JSONObject getData() {
return json; return json;
} }
public Double getDia() { public Double getDia() {
return getDia(getDefaultProfile());
}
public Double getDia(JSONObject profile) {
Double dia; Double dia;
JSONObject profile = getDefaultProfile();
if (profile != null) { if (profile != null) {
try { try {
dia = profile.getDouble("dia"); dia = profile.getDouble("dia");
@ -89,9 +104,12 @@ public class NSProfile {
return 3D; return 3D;
} }
public Double getCarbAbsorbtionRate() { public Double getCarbAbsorbtionRate() {
return getCarbAbsorbtionRate(getDefaultProfile());
}
public Double getCarbAbsorbtionRate(JSONObject profile) {
Double carbAbsorptionRate; Double carbAbsorptionRate;
JSONObject profile = getDefaultProfile();
if (profile != null) { if (profile != null) {
try { try {
carbAbsorptionRate = profile.getDouble("carbs_hr"); carbAbsorptionRate = profile.getDouble("carbs_hr");
@ -100,13 +118,16 @@ public class NSProfile {
e.printStackTrace(); e.printStackTrace();
} }
} }
return 0D; return 0D;
} }
// mmol or mg/dl // mmol or mg/dl
public String getUnits() { public String getUnits() {
String units; return getUnits(getDefaultProfile());
JSONObject profile = getDefaultProfile(); }
public String getUnits(JSONObject profile) {
String units;
if (profile != null) { if (profile != null) {
try { try {
units = profile.getString("units"); units = profile.getString("units");
@ -115,12 +136,15 @@ public class NSProfile {
e.printStackTrace(); e.printStackTrace();
} }
} }
return "mg/dl"; return "mg/dl";
} }
public TimeZone getTimeZone() { public TimeZone getTimeZone() {
TimeZone timeZone; return getTimeZone(getDefaultProfile());
JSONObject profile = getDefaultProfile(); }
public TimeZone getTimeZone(JSONObject profile) {
TimeZone timeZone;
if (profile != null) { if (profile != null) {
try { try {
return TimeZone.getTimeZone(profile.getString("timezone")); return TimeZone.getTimeZone(profile.getString("timezone"));
@ -128,13 +152,13 @@ public class NSProfile {
e.printStackTrace(); e.printStackTrace();
} }
} }
return TimeZone.getDefault(); return TimeZone.getDefault();
} }
public Double getValueToTime(JSONArray array, Integer timeAsSeconds) { public Double getValueToTime(JSONArray array, Integer timeAsSeconds) {
Double lastValue = null; Double lastValue = null;
for(Integer index = 0; index < array.length(); index++) { for (Integer index = 0; index < array.length(); index++) {
try { try {
JSONObject o = array.getJSONObject(index); JSONObject o = array.getJSONObject(index);
Integer tas = o.getInt("timeAsSeconds"); Integer tas = o.getInt("timeAsSeconds");
@ -154,7 +178,7 @@ public class NSProfile {
public String getValuesList(JSONArray array, JSONArray array2, DecimalFormat format, String units) { public String getValuesList(JSONArray array, JSONArray array2, DecimalFormat format, String units) {
String retValue = ""; String retValue = "";
for(Integer index = 0; index < array.length(); index++) { for (Integer index = 0; index < array.length(); index++) {
try { try {
JSONObject o = array.getJSONObject(index); JSONObject o = array.getJSONObject(index);
retValue += o.getString("time"); retValue += o.getString("time");
@ -175,10 +199,13 @@ public class NSProfile {
} }
public Double getIsf(Integer timeAsSeconds) { public Double getIsf(Integer timeAsSeconds) {
JSONObject profile = getDefaultProfile(); return getIsf(getDefaultProfile(), timeAsSeconds);
}
public Double getIsf(JSONObject profile, Integer timeAsSeconds) {
if (profile != null) { if (profile != null) {
try { try {
return getValueToTime(profile.getJSONArray("sens"),timeAsSeconds); return getValueToTime(profile.getJSONArray("sens"), timeAsSeconds);
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -187,7 +214,10 @@ public class NSProfile {
} }
public String getIsfList() { public String getIsfList() {
JSONObject profile = getDefaultProfile(); return getIsfList(getDefaultProfile());
}
public String getIsfList(JSONObject profile) {
if (profile != null) { if (profile != null) {
try { try {
return getValuesList(profile.getJSONArray("sens"), null, new DecimalFormat("0.0"), getUnits() + "/U"); return getValuesList(profile.getJSONArray("sens"), null, new DecimalFormat("0.0"), getUnits() + "/U");
@ -199,10 +229,13 @@ public class NSProfile {
} }
public Double getIc(Integer timeAsSeconds) { public Double getIc(Integer timeAsSeconds) {
JSONObject profile = getDefaultProfile(); return getIc(getDefaultProfile(), timeAsSeconds);
}
public Double getIc(JSONObject profile, Integer timeAsSeconds) {
if (profile != null) { if (profile != null) {
try { try {
return getValueToTime(profile.getJSONArray("carbratio"),timeAsSeconds); return getValueToTime(profile.getJSONArray("carbratio"), timeAsSeconds);
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -211,7 +244,10 @@ public class NSProfile {
} }
public String getIcList() { public String getIcList() {
JSONObject profile = getDefaultProfile(); return getIcList(getDefaultProfile());
}
public String getIcList(JSONObject profile) {
if (profile != null) { if (profile != null) {
try { try {
return getValuesList(profile.getJSONArray("carbratio"), null, new DecimalFormat("0.0"), "g"); return getValuesList(profile.getJSONArray("carbratio"), null, new DecimalFormat("0.0"), "g");
@ -223,10 +259,13 @@ public class NSProfile {
} }
public Double getBasal(Integer timeAsSeconds) { public Double getBasal(Integer timeAsSeconds) {
JSONObject profile = getDefaultProfile(); return getBasal(getDefaultProfile(), timeAsSeconds);
}
public Double getBasal(JSONObject profile, Integer timeAsSeconds) {
if (profile != null) { if (profile != null) {
try { try {
return getValueToTime(profile.getJSONArray("basal"),timeAsSeconds); return getValueToTime(profile.getJSONArray("basal"), timeAsSeconds);
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -235,7 +274,10 @@ public class NSProfile {
} }
public String getBasalList() { public String getBasalList() {
JSONObject profile = getDefaultProfile(); return getBasalList(getDefaultProfile());
}
public String getBasalList(JSONObject profile) {
if (profile != null) { if (profile != null) {
try { try {
return getValuesList(profile.getJSONArray("basal"), null, new DecimalFormat("0.00"), "U"); return getValuesList(profile.getJSONArray("basal"), null, new DecimalFormat("0.00"), "U");
@ -247,10 +289,13 @@ public class NSProfile {
} }
public Double getTargetLow(Integer timeAsSeconds) { public Double getTargetLow(Integer timeAsSeconds) {
JSONObject profile = getDefaultProfile(); return getTargetLow(getDefaultProfile(), timeAsSeconds);
}
public Double getTargetLow(JSONObject profile, Integer timeAsSeconds) {
if (profile != null) { if (profile != null) {
try { try {
return getValueToTime(profile.getJSONArray("target_low"),timeAsSeconds); return getValueToTime(profile.getJSONArray("target_low"), timeAsSeconds);
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -259,7 +304,10 @@ public class NSProfile {
} }
public Double getTargetHigh(Integer timeAsSeconds) { public Double getTargetHigh(Integer timeAsSeconds) {
JSONObject profile = getDefaultProfile(); return getTargetHigh(getDefaultProfile(), timeAsSeconds);
}
public Double getTargetHigh(JSONObject profile, Integer timeAsSeconds) {
if (profile != null) { if (profile != null) {
try { try {
return getValueToTime(profile.getJSONArray("target_high"), timeAsSeconds); return getValueToTime(profile.getJSONArray("target_high"), timeAsSeconds);
@ -270,11 +318,14 @@ public class NSProfile {
return 0D; return 0D;
} }
public String getTargetList() { public String getTargetList() {
JSONObject profile = getDefaultProfile(); return getTargetList(getDefaultProfile());
}
public String getTargetList(JSONObject profile) {
if (profile != null) { if (profile != null) {
try { try {
return getValuesList(profile.getJSONArray("target_low"),profile.getJSONArray("target_high"), new DecimalFormat("0.0"), getUnits()); return getValuesList(profile.getJSONArray("target_low"), profile.getJSONArray("target_high"), new DecimalFormat("0.0"), getUnits());
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -288,7 +339,7 @@ public class NSProfile {
public Double getMaxDailyBasal() { public Double getMaxDailyBasal() {
Double max = 0d; Double max = 0d;
for (Integer hour = 0; hour < 24; hour ++) { for (Integer hour = 0; hour < 24; hour++) {
double value = getBasal(hour * 60 * 60); double value = getBasal(hour * 60 * 60);
if (value > max) max = value; if (value > max) max = value;
} }

View file

@ -9,11 +9,12 @@ import java.util.TimeZone;
* The Class DateUtil. A simple wrapper around SimpleDateFormat to ease the handling of iso date string &lt;-&gt; date obj * The Class DateUtil. A simple wrapper around SimpleDateFormat to ease the handling of iso date string &lt;-&gt; date obj
* with TZ * with TZ
*/ */
public class DateUtil public class DateUtil {
{
/** The date format in iso. */ /**
public static String FORMAT_DATE_ISO="yyyy-MM-dd'T'HH:mm:ss'Z'"; * The date format in iso.
*/
public static String FORMAT_DATE_ISO = "yyyy-MM-dd'T'HH:mm:ss'Z'";
/** /**
* Takes in an ISO date string of the following format: * Takes in an ISO date string of the following format:
@ -24,29 +25,30 @@ public class DateUtil
* @throws Exception the exception * @throws Exception the exception
*/ */
public static Date fromISODateString(String isoDateString) public static Date fromISODateString(String isoDateString)
throws Exception throws Exception {
{ SimpleDateFormat f = new SimpleDateFormat(FORMAT_DATE_ISO);
DateFormat f = new SimpleDateFormat(FORMAT_DATE_ISO); f.setTimeZone(TimeZone.getTimeZone("UTC"));
return f.parse(isoDateString); Date date = f.parse(isoDateString);
return date;
} }
/** /**
* Render date * Render date
* *
* @param date the date obj * @param date the date obj
* @param format - if not specified, will use FORMAT_DATE_ISO * @param format - if not specified, will use FORMAT_DATE_ISO
* @param tz - tz to set to, if not specified uses local timezone * @param tz - tz to set to, if not specified uses local timezone
* @return the iso-formatted date string * @return the iso-formatted date string
*/ */
public static String toISOString(Date date, String format, TimeZone tz) public static String toISOString(Date date, String format, TimeZone tz) {
{ if (format == null) format = FORMAT_DATE_ISO;
if( format == null ) format = FORMAT_DATE_ISO; if (tz == null) tz = TimeZone.getDefault();
if( tz == null ) tz = TimeZone.getDefault();
DateFormat f = new SimpleDateFormat(format); DateFormat f = new SimpleDateFormat(format);
f.setTimeZone(tz); f.setTimeZone(tz);
return f.format(date); return f.format(date);
} }
public static String toISOString(Date date) public static String toISOString(Date date) {
{ return toISOString(date,FORMAT_DATE_ISO,TimeZone.getTimeZone("UTC")); } return toISOString(date, FORMAT_DATE_ISO, TimeZone.getTimeZone("UTC"));
}
} }

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:focusableInTouchMode="true" android:focusableInTouchMode="true"
@ -10,418 +11,507 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:width="120dp"
android:padding="10dp"
android:text="@string/treatments_wizard_bg_label"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ImageView
android:id="@+id/treatments_wizard_bginput_minus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_minus"
android:tint="#ffffff" />
<EditText
android:id="@+id/treatments_wizard_bginput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="0.5"
android:gravity="center_horizontal"
android:inputType="numberDecimal"
android:padding="10dp"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="@+id/treatments_wizard_bginput_plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_add"
android:tint="#ffffff" />
<TextView
android:id="@+id/treatments_wizard_bgunits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="left"
android:minWidth="40dp"
android:paddingLeft="5dp"
android:text="mg/dl"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:width="120dp"
android:padding="10dp"
android:text="@string/treatments_wizard_carbs_label"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ImageView
android:id="@+id/treatments_wizard_carbsinput_minus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_minus"
android:tint="#ffffff" />
<EditText
android:id="@+id/treatments_wizard_carbsinput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="0.5"
android:gravity="center_horizontal"
android:inputType="numberDecimal"
android:minWidth="200dp"
android:padding="10dp"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="@+id/treatments_wizard_carbsinput_plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_add"
android:tint="#ffffff" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="left"
android:minWidth="40dp"
android:paddingLeft="5dp"
android:text="g"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:width="120dp"
android:padding="10dp"
android:text="@string/treatments_wizard_correction_label"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ImageView
android:id="@+id/treatments_wizard_correctioninput_minus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_minus"
android:tint="#ffffff" />
<EditText
android:id="@+id/treatments_wizard_correctioninput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="0.5"
android:gravity="center_horizontal"
android:inputType="numberSigned|numberDecimal"
android:minWidth="200dp"
android:padding="10dp"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="@+id/treatments_wizard_correctioninput_plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_add"
android:tint="#ffffff" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="left"
android:minWidth="40dp"
android:paddingLeft="5dp"
android:text="@string/treatments_wizard_unit_label"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:id="@+id/treatments_wizard_carbtime_layout"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:width="80dp" android:orientation="horizontal">
android:padding="10dp"
android:text="@string/treatments_wizard_bg_label"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView <TextView
android:id="@+id/treatments_wizard_bginput_minus" android:layout_width="wrap_content"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_height="wrap_content" android:width="120dp"
android:layout_gravity="center" android:padding="10dp"
android:background="@drawable/circle" android:text="@string/careportal_newnstreatment_carbtime_label"
android:backgroundTint="#ffffff" android:textAppearance="?android:attr/textAppearanceMedium" />
android:src="@drawable/ic_action_minus"
android:tint="#ffffff" />
<EditText <ImageView
android:id="@+id/treatments_wizard_bginput" android:id="@+id/treatments_wizard_carbtime_minus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_minus"
android:tint="#ffffff" />
<EditText
android:id="@+id/treatments_wizard_carbtimeinput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="0.5"
android:gravity="center_horizontal"
android:inputType="numberDecimal"
android:minWidth="200dp"
android:padding="10dp"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="@+id/treatments_wizard_carbtime_plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_add"
android:tint="#ffffff" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="left"
android:minWidth="40dp"
android:paddingLeft="5dp"
android:text="min"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:id="@+id/treatments_wizard_profile_layout"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_weight="0.5" android:orientation="horizontal">
android:gravity="center_horizontal"
android:inputType="numberDecimal"
android:padding="10dp"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView <TextView
android:id="@+id/treatments_wizard_bginput_plus" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="120dp"
android:padding="10dp"
android:text="@string/careportal_newnstreatment_profile_label"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Spinner
android:id="@+id/treatments_wizard_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:background="@drawable/circle" android:orientation="horizontal">
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_add"
android:tint="#ffffff" />
<TextView <CheckBox
android:id="@+id/treatments_wizard_bgunits" android:id="@+id/treatments_wizard_bgcheckbox"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:width="32dp"
android:gravity="left" android:checked="true" />
android:minWidth="40dp"
android:paddingLeft="5dp"
android:text="mg/dl"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout> <TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="80dp"
android:text="@string/treatments_wizard_bg_label"
android:textAppearance="?android:attr/textAppearanceSmall" />
<LinearLayout <TextView
android:layout_width="match_parent" android:id="@+id/treatments_wizard_bg"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:orientation="horizontal"> android:layout_height="wrap_content"
android:width="100dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView <TextView
android:layout_width="wrap_content" android:id="@+id/treatments_wizard_bginsulin"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_gravity="center_horizontal" android:layout_height="wrap_content"
android:width="80dp" android:width="50dp"
android:padding="10dp" android:gravity="end"
android:text="@string/treatments_wizard_carbs_label" android:textAppearance="?android:attr/textAppearanceSmall" />
android:textAppearance="?android:attr/textAppearanceLarge" /> </LinearLayout>
<ImageView <LinearLayout
android:id="@+id/treatments_wizard_carbsinput_minus"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:background="@drawable/circle" android:orientation="horizontal">
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_minus"
android:tint="#ffffff" />
<EditText <TextView
android:id="@+id/treatments_wizard_carbsinput" android:layout_width="wrap_content"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_height="wrap_content" android:width="32dp" />
android:layout_gravity="center_horizontal"
android:layout_weight="0.5"
android:gravity="center_horizontal"
android:inputType="numberDecimal"
android:minWidth="200dp"
android:padding="10dp"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView <TextView
android:id="@+id/treatments_wizard_carbsinput_plus" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="80dp"
android:text="@string/treatments_wizard_carbs_label"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/treatments_wizard_carbs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="100dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/treatments_wizard_carbsinsulin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="50dp"
android:gravity="end"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:background="@drawable/circle" android:orientation="horizontal">
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_add"
android:tint="#ffffff" />
<TextView <CheckBox
android:layout_width="wrap_content" android:id="@+id/treatments_wizard_bolusiobcheckbox"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_gravity="center_vertical" android:layout_height="wrap_content"
android:gravity="left" android:width="32dp"
android:minWidth="40dp" android:checked="true" />
android:paddingLeft="5dp"
android:text="g"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="130dp"
android:text="@string/treatments_wizard_bolusiob_label"
android:textAppearance="?android:attr/textAppearanceSmall" />
<LinearLayout <TextView
android:layout_width="match_parent" android:id="@+id/treatments_wizard_bolusiob"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:orientation="horizontal"> android:layout_height="wrap_content"
android:width="50dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView <TextView
android:layout_width="wrap_content" android:id="@+id/treatments_wizard_bolusiobinsulin"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_gravity="center_horizontal" android:layout_height="wrap_content"
android:width="80dp" android:width="50dp"
android:padding="10dp" android:gravity="end"
android:text="@string/treatments_wizard_correction_label" android:textAppearance="?android:attr/textAppearanceSmall" />
android:textAppearance="?android:attr/textAppearanceLarge" /> </LinearLayout>
<ImageView <LinearLayout
android:id="@+id/treatments_wizard_correctioninput_minus"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:background="@drawable/circle" android:orientation="horizontal">
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_minus"
android:tint="#ffffff" />
<EditText <CheckBox
android:id="@+id/treatments_wizard_correctioninput" android:id="@+id/treatments_wizard_basaliobcheckbox"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:width="32dp"
android:layout_weight="0.5" android:checked="true" />
android:gravity="center_horizontal"
android:inputType="numberSigned|numberDecimal"
android:minWidth="200dp"
android:padding="10dp"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView <TextView
android:id="@+id/treatments_wizard_correctioninput_plus" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="130dp"
android:text="@string/treatments_wizard_basaliob_label"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/treatments_wizard_basaliob"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="50dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/treatments_wizard_basaliobinsulin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="50dp"
android:gravity="end"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:background="@drawable/circle" android:orientation="horizontal">
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_add"
android:tint="#ffffff" />
<TextView <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="32dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="80dp"
android:text="@string/treatments_wizard_correction_label"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/treatments_wizard_correction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="100dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/treatments_wizard_correctioninsulin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="50dp"
android:gravity="end"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center"
android:gravity="left" android:orientation="horizontal">
android:minWidth="40dp"
android:paddingLeft="5dp" <TextView
android:text="@string/treatments_wizard_unit_label" android:layout_width="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall" /> android:layout_height="wrap_content"
android:width="32dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="80dp"
android:height="30dp"
android:gravity="center_vertical"
android:text="@string/treatments_wizard_total_label"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/accent_material_light"
android:textStyle="bold" />
<TextView
android:id="@+id/treatments_wizard_total"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="100dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/treatments_wizard_totalinsulin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="50dp"
android:gravity="center_vertical|end"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/accent_material_light"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:orientation="horizontal"
android:padding="10dp">
<Button
android:id="@+id/treatments_wizard_deliverButton"
style="?android:attr/buttonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="10dp"
android:text="SEND TO PUMP"
android:textAllCaps="false"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout> </LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal">
<CheckBox
android:id="@+id/treatments_wizard_bgcheckbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="32dp"
android:checked="true" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="80dp"
android:text="@string/treatments_wizard_bg_label"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/treatments_wizard_bg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="100dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/treatments_wizard_bginsulin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="50dp"
android:gravity="end"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="32dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="80dp"
android:text="@string/treatments_wizard_carbs_label"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/treatments_wizard_carbs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="100dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/treatments_wizard_carbsinsulin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="50dp"
android:gravity="end"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal">
<CheckBox
android:id="@+id/treatments_wizard_bolusiobcheckbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="32dp"
android:checked="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="130dp"
android:text="@string/treatments_wizard_bolusiob_label"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/treatments_wizard_bolusiob"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="50dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/treatments_wizard_bolusiobinsulin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="50dp"
android:gravity="end"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal">
<CheckBox
android:id="@+id/treatments_wizard_basaliobcheckbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="32dp"
android:checked="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="130dp"
android:text="@string/treatments_wizard_basaliob_label"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/treatments_wizard_basaliob"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="50dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/treatments_wizard_basaliobinsulin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="50dp"
android:gravity="end"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="32dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="80dp"
android:text="@string/treatments_wizard_correction_label"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/treatments_wizard_correction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="100dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/treatments_wizard_correctioninsulin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="50dp"
android:gravity="end"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="32dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="80dp"
android:height="30dp"
android:gravity="center_vertical"
android:text="@string/treatments_wizard_total_label"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/accent_material_light"
android:textStyle="bold" />
<TextView
android:id="@+id/treatments_wizard_total"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="100dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/treatments_wizard_totalinsulin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="50dp"
android:gravity="center_vertical|end"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/accent_material_light"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:orientation="horizontal"
android:padding="10dp">
<Button
android:id="@+id/treatments_wizard_deliverButton"
style="?android:attr/buttonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="10dp"
android:text="SEND TO PUMP"
android:textAllCaps="false"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>