autosens-prepare-24.js 1008 B

123456789101112131415161718192021222324252627282930313233
  1. // для settings/autosens.json параметры: monitor/glucose.json monitor/pumphistory-24h-zoned.json settings/basal_profile.json settings/profile.json monitor/carbhistory.json settings/temptargets.json
  2. function generate(glucose_data, pumphistory_data, basalprofile, profile_data, carb_data = {}, temptarget_data = {}, now = null) {
  3. if (glucose_data.length < 72) {
  4. return { "ratio": 1, "error": "not enough glucose data to calculate autosens" };
  5. };
  6. if (now) {
  7. now = new Date(now);
  8. } else {
  9. now = new Date();
  10. }
  11. var iob_inputs = {
  12. history: pumphistory_data,
  13. profile: profile_data,
  14. clock: now
  15. };
  16. var detection_inputs = {
  17. iob_inputs: iob_inputs,
  18. carbs: carb_data,
  19. glucose_data: glucose_data,
  20. basalprofile: basalprofile,
  21. temptargets: temptarget_data
  22. };
  23. // 24 hours only
  24. detection_inputs.deviations = 288;
  25. return trio_autosens(detection_inputs, now);
  26. }