Fast Acting Insulin Prolonged
This commit is contained in:
parent
0a2105ac50
commit
90a55966b1
9 changed files with 275 additions and 0 deletions
|
@ -48,9 +48,15 @@ android {
|
||||||
buildConfigField "String", "VERSION", '"' + version + '"'
|
buildConfigField "String", "VERSION", '"' + version + '"'
|
||||||
buildConfigField "String", "BUILDVERSION", generateGitBuild()
|
buildConfigField "String", "BUILDVERSION", generateGitBuild()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dexOptions {
|
||||||
|
jumboMode true
|
||||||
|
}
|
||||||
|
|
||||||
lintOptions {
|
lintOptions {
|
||||||
disable 'MissingTranslation'
|
disable 'MissingTranslation'
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
minifyEnabled false
|
minifyEnabled false
|
||||||
|
|
|
@ -22,6 +22,7 @@ import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.plugins.Actions.ActionsFragment;
|
import info.nightscout.androidaps.plugins.Actions.ActionsFragment;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
||||||
|
import info.nightscout.androidaps.plugins.InsulinFastactingProlonged.InsulinFastactingProlongedFragment;
|
||||||
import info.nightscout.androidaps.plugins.ProfileCircadianPercentage.CircadianPercentageProfileFragment;
|
import info.nightscout.androidaps.plugins.ProfileCircadianPercentage.CircadianPercentageProfileFragment;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
@ -88,6 +89,7 @@ public class MainApp extends Application {
|
||||||
pluginsList.add(OverviewFragment.getPlugin());
|
pluginsList.add(OverviewFragment.getPlugin());
|
||||||
if (Config.ACTION) pluginsList.add(ActionsFragment.getPlugin());
|
if (Config.ACTION) pluginsList.add(ActionsFragment.getPlugin());
|
||||||
pluginsList.add(InsulinFastactingFragment.getPlugin());
|
pluginsList.add(InsulinFastactingFragment.getPlugin());
|
||||||
|
pluginsList.add(InsulinFastactingProlongedFragment.getPlugin());
|
||||||
if (Config.DANAR) pluginsList.add(DanaRFragment.getPlugin());
|
if (Config.DANAR) pluginsList.add(DanaRFragment.getPlugin());
|
||||||
if (Config.DANARKOREAN) pluginsList.add(DanaRKoreanFragment.getPlugin());
|
if (Config.DANARKOREAN) pluginsList.add(DanaRKoreanFragment.getPlugin());
|
||||||
pluginsList.add(CareportalFragment.getPlugin());
|
pluginsList.add(CareportalFragment.getPlugin());
|
||||||
|
|
|
@ -11,6 +11,7 @@ import info.nightscout.androidaps.db.Treatment;
|
||||||
|
|
||||||
public interface InsulinInterface {
|
public interface InsulinInterface {
|
||||||
final int FASTACTINGINSULIN = 0;
|
final int FASTACTINGINSULIN = 0;
|
||||||
|
final int FASTACTINGINSULINPROLONGED = 1;
|
||||||
|
|
||||||
int getId();
|
int getId();
|
||||||
String getFriendlyName();
|
String getFriendlyName();
|
||||||
|
|
|
@ -1,7 +1,18 @@
|
||||||
package info.nightscout.androidaps.plugins.InsulinFastacting;
|
package info.nightscout.androidaps.plugins.InsulinFastacting;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.Unbinder;
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.interfaces.FragmentBase;
|
import info.nightscout.androidaps.interfaces.FragmentBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,5 +26,32 @@ public class InsulinFastactingFragment extends Fragment implements FragmentBase
|
||||||
return insulinFastactingPlugin;
|
return insulinFastactingPlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Unbinder unbinder;
|
||||||
|
@BindView(R.id.insulin_name)
|
||||||
|
TextView insulinName;
|
||||||
|
@BindView(R.id.insulin_comment)
|
||||||
|
TextView insulinComment;
|
||||||
|
@BindView(R.id.insulin_activity)
|
||||||
|
ImageView insulinActivity;
|
||||||
|
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
View view = inflater.inflate(R.layout.insulin_fragment, container, false);
|
||||||
|
|
||||||
|
unbinder = ButterKnife.bind(this, view);
|
||||||
|
|
||||||
|
insulinName.setText(insulinFastactingPlugin.getFriendlyName());
|
||||||
|
insulinComment.setText(insulinFastactingPlugin.getComment());
|
||||||
|
insulinActivity.setImageDrawable(MainApp.sResources.getDrawable(insulinFastactingPlugin.getResourcePicture()));
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
unbinder.unbind();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
package info.nightscout.androidaps.plugins.InsulinFastactingProlonged;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.Unbinder;
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.interfaces.FragmentBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 17.04.2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class InsulinFastactingProlongedFragment extends Fragment implements FragmentBase {
|
||||||
|
static InsulinFastactingProlongedPlugin insulinFastactingProlongedPlugin = new InsulinFastactingProlongedPlugin();
|
||||||
|
|
||||||
|
static public InsulinFastactingProlongedPlugin getPlugin() {
|
||||||
|
return insulinFastactingProlongedPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Unbinder unbinder;
|
||||||
|
@BindView(R.id.insulin_name)
|
||||||
|
TextView insulinName;
|
||||||
|
@BindView(R.id.insulin_comment)
|
||||||
|
TextView insulinComment;
|
||||||
|
@BindView(R.id.insulin_activity)
|
||||||
|
ImageView insulinActivity;
|
||||||
|
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
View view = inflater.inflate(R.layout.insulin_fragment, container, false);
|
||||||
|
|
||||||
|
unbinder = ButterKnife.bind(this, view);
|
||||||
|
|
||||||
|
insulinName.setText(insulinFastactingProlongedPlugin.getFriendlyName());
|
||||||
|
insulinComment.setText(insulinFastactingProlongedPlugin.getComment());
|
||||||
|
insulinActivity.setImageDrawable(MainApp.sResources.getDrawable(insulinFastactingProlongedPlugin.getResourcePicture()));
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
unbinder.unbind();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,129 @@
|
||||||
|
package info.nightscout.androidaps.plugins.InsulinFastactingProlonged;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.Constants;
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.data.Iob;
|
||||||
|
import info.nightscout.androidaps.db.Treatment;
|
||||||
|
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||||
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 17.04.2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class InsulinFastactingProlongedPlugin implements PluginBase, InsulinInterface {
|
||||||
|
|
||||||
|
private static boolean fragmentEnabled = true;
|
||||||
|
private static boolean fragmentVisible = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getType() {
|
||||||
|
return INSULIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getFragmentClass() {
|
||||||
|
return InsulinFastactingProlongedFragment.class.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return MainApp.sResources.getString(R.string.fastactinginsulinprolonged);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getNameShort() {
|
||||||
|
return MainApp.sResources.getString(R.string.insulin_shortname);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled(int type) {
|
||||||
|
return type == INSULIN && fragmentEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isVisibleInTabs(int type) {
|
||||||
|
return type == INSULIN && fragmentVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canBeHidden(int type) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||||
|
if (type == INSULIN) this.fragmentEnabled = fragmentEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||||
|
if (type == INSULIN) this.fragmentVisible = fragmentVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insulin interface
|
||||||
|
@Override
|
||||||
|
public int getId() {
|
||||||
|
return FASTACTINGINSULINPROLONGED;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getFriendlyName() {
|
||||||
|
return MainApp.sResources.getString(R.string.fastactinginsulinprolonged);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getComment() {
|
||||||
|
return MainApp.sResources.getString(R.string.fastactinginsulincomment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getResourcePicture() {
|
||||||
|
return R.drawable.insulin1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getDia() {
|
||||||
|
ProfileInterface profileInterface = MainApp.getConfigBuilder().getActiveProfile();
|
||||||
|
if (profileInterface.getProfile() != null)
|
||||||
|
return profileInterface.getProfile().getDia();
|
||||||
|
return Constants.defaultDIA;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iob iobCalc(Treatment treatment, Date time, Double dia) {
|
||||||
|
Iob result = new Iob();
|
||||||
|
|
||||||
|
//Double scaleFactor = 3.0 / dia;
|
||||||
|
Double peak = 75d * dia / 6.0;
|
||||||
|
Double tail = 180d * dia / 6.0;
|
||||||
|
Double end = 360d * dia / 6.0;
|
||||||
|
Double Total = 2 * peak + (tail - peak) * 5 / 2 + (end - tail) / 2;
|
||||||
|
|
||||||
|
if (treatment.insulin != 0d) {
|
||||||
|
Long bolusTime = treatment.created_at.getTime();
|
||||||
|
Double minAgo = (time.getTime() - bolusTime) / 1000d / 60d;
|
||||||
|
|
||||||
|
if (minAgo < peak) {
|
||||||
|
Double x1 = 6 / dia * minAgo / 5d + 1;
|
||||||
|
result.iobContrib = treatment.insulin * (1 - 0.0012595 * x1 * x1 + 0.0012595 * x1);
|
||||||
|
// units: BG (mg/dL) = (BG/U) * U insulin * scalar
|
||||||
|
result.activityContrib = treatment.insulin * ((2 * peak / Total) * 2 / peak / peak * minAgo);
|
||||||
|
} else if (minAgo < tail) {
|
||||||
|
Double x2 = (6 / dia * (minAgo - peak)) / 5;
|
||||||
|
result.iobContrib = treatment.insulin * (0.00074 * x2 * x2 - 0.0403 * x2 + 0.69772);
|
||||||
|
result.activityContrib = treatment.insulin * (-((2 * peak / Total) * 2 / peak * 3 / 4) / (tail - peak) * (minAgo - peak) + (2 * peak / Total) * 2 / peak);
|
||||||
|
} else if (minAgo < end) {
|
||||||
|
Double x3 = (6 / dia * (minAgo - tail)) / 5;
|
||||||
|
result.iobContrib = treatment.insulin * (0.0001323 * x3 * x3 - 0.0097 * x3 + 0.17776);
|
||||||
|
result.activityContrib = treatment.insulin * (-((2 * peak / Total) * 2 / peak * 1 / 4) / (end - tail) * (minAgo - tail) + (2 * peak / Total) * 2 / peak / 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
BIN
app/src/main/res/drawable/insulin1.png
Normal file
BIN
app/src/main/res/drawable/insulin1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
41
app/src/main/res/layout/insulin_fragment.xml
Normal file
41
app/src/main/res/layout/insulin_fragment.xml
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context="info.nightscout.androidaps.plugins.InsulinFastacting.InsulinFastactingFragment">
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/insulin_name"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/insulin_comment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/insulin_activity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="20dp"
|
||||||
|
app:srcCompat="@drawable/insulin0" />
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
|
||||||
|
</FrameLayout>
|
|
@ -588,4 +588,5 @@
|
||||||
<string name="fastactinginsulin">Fast Acting Insulin</string>
|
<string name="fastactinginsulin">Fast Acting Insulin</string>
|
||||||
<string name="fastactinginsulincomment">Novorapid, Novolog, Humalog</string>
|
<string name="fastactinginsulincomment">Novorapid, Novolog, Humalog</string>
|
||||||
<string name="insulin_shortname">INS</string>
|
<string name="insulin_shortname">INS</string>
|
||||||
|
<string name="fastactinginsulinprolonged">Fast Acting Insuin Prolonged</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue