Merge pull request #2813 from Philoul/CompareProfileFix
Fix defaultprofile and compareprofile units
This commit is contained in:
commit
58b156eab5
2 changed files with 18 additions and 5 deletions
|
@ -25,21 +25,21 @@ class DefaultProfile @Inject constructor(val injector: HasAndroidInjector) {
|
||||||
val ic = Round.roundTo(250.0 / _tdd, 1.0)
|
val ic = Round.roundTo(250.0 / _tdd, 1.0)
|
||||||
profile.put("carbratio", singleValueArray(ic, arrayOf(0.0, -4.0, -1.0, -2.0, -4.0, 0.0, -4.0)))
|
profile.put("carbratio", singleValueArray(ic, arrayOf(0.0, -4.0, -1.0, -2.0, -4.0, 0.0, -4.0)))
|
||||||
val isf = Round.roundTo(200.0 / _tdd, 0.1)
|
val isf = Round.roundTo(200.0 / _tdd, 0.1)
|
||||||
profile.put("sens", singleValueArray(isf, arrayOf(0.0, -2.0, -0.0, -0.0, -2.0, 0.0, -2.0)))
|
profile.put("sens", singleValueArrayFromMmolToUnits(isf, arrayOf(0.0, -2.0, -0.0, -0.0, -2.0, 0.0, -2.0),units))
|
||||||
} else if (age >= 6 && age < 12) {
|
} else if (age >= 6 && age < 12) {
|
||||||
val _tdd = if (tdd == 0.0) 0.8 * weight else tdd
|
val _tdd = if (tdd == 0.0) 0.8 * weight else tdd
|
||||||
closest(sixToEleven, _tdd * 0.4)?.let { array -> profile.put("basal", arrayToJson(array)) }
|
closest(sixToEleven, _tdd * 0.4)?.let { array -> profile.put("basal", arrayToJson(array)) }
|
||||||
val ic = Round.roundTo(375.0 / _tdd, 1.0)
|
val ic = Round.roundTo(375.0 / _tdd, 1.0)
|
||||||
profile.put("carbratio", singleValueArray(ic, arrayOf(0.0, -3.0, 0.0, -1.0, -3.0, 0.0, -2.0)))
|
profile.put("carbratio", singleValueArray(ic, arrayOf(0.0, -3.0, 0.0, -1.0, -3.0, 0.0, -2.0)))
|
||||||
val isf = Round.roundTo(170.0 / _tdd, 0.1)
|
val isf = Round.roundTo(170.0 / _tdd, 0.1)
|
||||||
profile.put("sens", singleValueArray(isf, arrayOf(0.0, -1.0, -0.0, -0.0, -1.0, 0.0, -1.0)))
|
profile.put("sens", singleValueArrayFromMmolToUnits(isf, arrayOf(0.0, -1.0, -0.0, -0.0, -1.0, 0.0, -1.0),units))
|
||||||
} else if (age >= 12 && age < 17) {
|
} else if (age >= 12 && age < 18) {
|
||||||
val _tdd = if (tdd == 0.0) 1.0 * weight else tdd
|
val _tdd = if (tdd == 0.0) 1.0 * weight else tdd
|
||||||
closest(twelveToSeventeen, _tdd * 0.5)?.let { array -> profile.put("basal", arrayToJson(array)) }
|
closest(twelveToSeventeen, _tdd * 0.5)?.let { array -> profile.put("basal", arrayToJson(array)) }
|
||||||
val ic = Round.roundTo(500.0 / _tdd, 1.0)
|
val ic = Round.roundTo(500.0 / _tdd, 1.0)
|
||||||
profile.put("carbratio", singleValueArray(ic, arrayOf(0.0, -1.0, 0.0, 0.0, -1.0, 0.0, -1.0)))
|
profile.put("carbratio", singleValueArray(ic, arrayOf(0.0, -1.0, 0.0, 0.0, -1.0, 0.0, -1.0)))
|
||||||
val isf = Round.roundTo(100.0 / _tdd, 0.1)
|
val isf = Round.roundTo(100.0 / _tdd, 0.1)
|
||||||
profile.put("sens", singleValueArray(isf, arrayOf(0.2, 0.0, 0.2, 0.2, 0.0, 0.2, 0.2)))
|
profile.put("sens", singleValueArrayFromMmolToUnits(isf, arrayOf(0.2, 0.0, 0.2, 0.2, 0.0, 0.2, 0.2),units))
|
||||||
} else if (age >= 18) {
|
} else if (age >= 18) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ class DefaultProfile @Inject constructor(val injector: HasAndroidInjector) {
|
||||||
profile.put("timezone", TimeZone.getDefault().getID())
|
profile.put("timezone", TimeZone.getDefault().getID())
|
||||||
profile.put("target_high", JSONArray().put(JSONObject().put("time", "00:00").put("value", Profile.fromMgdlToUnits(108.0, units))))
|
profile.put("target_high", JSONArray().put(JSONObject().put("time", "00:00").put("value", Profile.fromMgdlToUnits(108.0, units))))
|
||||||
profile.put("target_low", JSONArray().put(JSONObject().put("time", "00:00").put("value", Profile.fromMgdlToUnits(108.0, units))))
|
profile.put("target_low", JSONArray().put(JSONObject().put("time", "00:00").put("value", Profile.fromMgdlToUnits(108.0, units))))
|
||||||
|
profile.put("units", units)
|
||||||
return Profile(injector, profile, units)
|
return Profile(injector, profile, units)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,4 +147,16 @@ class DefaultProfile @Inject constructor(val injector: HasAndroidInjector) {
|
||||||
array.put(JSONObject().put("time", "19:00").put("value", value + sample[6]))
|
array.put(JSONObject().put("time", "19:00").put("value", value + sample[6]))
|
||||||
return array
|
return array
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun singleValueArrayFromMmolToUnits(value: Double, sample: Array<Double>, units: String): JSONArray {
|
||||||
|
val array = JSONArray()
|
||||||
|
array.put(JSONObject().put("time", "00:00").put("value", Profile.fromMmolToUnits(value + sample[0],units)))
|
||||||
|
array.put(JSONObject().put("time", "06:00").put("value", Profile.fromMmolToUnits(value + sample[1],units)))
|
||||||
|
array.put(JSONObject().put("time", "09:00").put("value", Profile.fromMmolToUnits(value + sample[2],units)))
|
||||||
|
array.put(JSONObject().put("time", "11:00").put("value", Profile.fromMmolToUnits(value + sample[3],units)))
|
||||||
|
array.put(JSONObject().put("time", "14:00").put("value", Profile.fromMmolToUnits(value + sample[4],units)))
|
||||||
|
array.put(JSONObject().put("time", "16:00").put("value", Profile.fromMmolToUnits(value + sample[5],units)))
|
||||||
|
array.put(JSONObject().put("time", "19:00").put("value", Profile.fromMmolToUnits(value + sample[6],units)))
|
||||||
|
return array
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -225,7 +225,7 @@ class ProfileViewerDialog : DaggerDialogFragment() {
|
||||||
val val1 = Profile.fromMgdlToUnits(profile1.getIsfMgdlTimeFromMidnight(hour * 60 * 60), profile1.units)
|
val val1 = Profile.fromMgdlToUnits(profile1.getIsfMgdlTimeFromMidnight(hour * 60 * 60), profile1.units)
|
||||||
val val2 = Profile.fromMgdlToUnits(profile2.getIsfMgdlTimeFromMidnight(hour * 60 * 60), profile1.units)
|
val val2 = Profile.fromMgdlToUnits(profile2.getIsfMgdlTimeFromMidnight(hour * 60 * 60), profile1.units)
|
||||||
if (val1 != prev1 || val2 != prev2) {
|
if (val1 != prev1 || val2 != prev2) {
|
||||||
s.append(formatColors(Profile.format_HH_MM(hour * 60 * 60), val1, val2, DecimalFormat("0.0"), resourceHelper.gs(R.string.profile_carbs_per_unit)))
|
s.append(formatColors(Profile.format_HH_MM(hour * 60 * 60), val1, val2, DecimalFormat("0.0"), profile1.units + resourceHelper.gs(R.string.profile_per_unit)))
|
||||||
s.append("<br>")
|
s.append("<br>")
|
||||||
}
|
}
|
||||||
prev1 = val1
|
prev1 = val1
|
||||||
|
|
Loading…
Reference in a new issue