tidepool-org/in-d-gestion — pull request #5 by cheddar (2014-03-27 17:37:12+00:00)
Title: Carelink parser to fabricate basals based on the current schedule 

This pull request introduce changes to have the carelink parser fabricate basal records based on the current schedule in progress.

This process is necessary because when a temp basal is active, carelink doesn't actually provide the scheduled basal events that would have been in place during the time period. So, we have to generate them based on what we know about the schedule.

Luckily, these events generally line up with data that we are already getting from carelink, so it's not all that bad. Except, it's possible that we get some events that don't actually line up. This can happen because we do not actually have the right schedule for the pump at the time, or it can happen because the data about the basal is not correct.

We choose to always trust the data about the basal rate that we get from carelink and distrust the schedule. Thus, when we get mis-matched basal rate changes, we assume our schedule is off and update the schedule accordingly.

@kentquirk, please look this over. Fwiw, I'm not necessarily happy with the logic that does all of this. I feel like it could be simpler, but I also don't have the time or mental capacity right now to figure out how to simplify it. If you have ideas, I'd love them.