scheduleFor method

List<TaskInstance> scheduleFor(
  1. DateTime dateTime
)

Implementation

List<TaskInstance> scheduleFor(DateTime dateTime) {
  final activeIntervention = getInterventionForDate(dateTime);
  final List<TaskInstance> taskSchedule = [];
  if (activeIntervention == null) return taskSchedule;

  for (final task in activeIntervention.tasks) {
    if (task.title == null) continue;
    for (final completionPeriod in task.schedule.completionPeriods) {
      taskSchedule.add(TaskInstance(task, completionPeriod.id));
    }
  }
  for (final observation in study.observations) {
    for (final completionPeriod in observation.schedule.completionPeriods) {
      taskSchedule.add(TaskInstance(observation, completionPeriod.id));
    }
  }
  return taskSchedule;
}