Ejemplo n.º 1
0
 public ScheduledVisitsView()
 {
     InitializeComponent();
     vm             = new ScheduledVisitsViewModel(null);
     BindingContext = vm;
     vm.GetScheduledVisits();
 }
Ejemplo n.º 2
0
        public List <ScheduledVisitsViewModel> GetSchedulledVisits()
        {
            var curentWeek = GetIso8601WeekOfYear(DateTime.Now.Date);

            if (DateTime.Now.Date.DayOfWeek == DayOfWeek.Sunday)
            {
                curentWeek += 1;
            }

            var scheduledVisits   = context.Schedules;
            var scheduledVisitsVM = new List <ScheduledVisitsViewModel>();
            var schedules         = new List <Schedule>();

            foreach (var scheduledVisit in scheduledVisits)
            {
                var visitdateWeek = GetIso8601WeekOfYear(scheduledVisit.WindowStart.Value.Date);
                if (visitdateWeek == curentWeek)
                {
                    var nextVisitStage  = scheduledVisit.VisitStage + 1;
                    var participantId   = context.Participants.Where(p => p.StudyId == scheduledVisit.studyId).FirstOrDefault().Id;
                    var participantCame = ParticipantCame(participantId, scheduledVisit.VisitStage);

                    var scheduledVisitVM = new ScheduledVisitsViewModel();

                    scheduledVisitVM.StudyId       = scheduledVisit.studyId;
                    scheduledVisitVM.ParticipantId = context.Participants.Where(p => p.StudyId == scheduledVisit.studyId).FirstOrDefault().Id;
                    scheduledVisitVM.VisitDate     = scheduledVisit.WindowStart.Value;
                    scheduledVisitVM.VisitStage    = context.VisitSettings.Where(v => v.VisitStage == scheduledVisit.VisitStage).FirstOrDefault().VisitType;

                    scheduledVisitsVM.Add(scheduledVisitVM);
                }
            }

            var scheduled_Visits = context.Visits
                                   .Where(v => v.NextAppointment >= DateTime.Now.Date && v.Deleted != 1);

            foreach (var visit in scheduled_Visits)
            {
                var visitdateWeek  = GetIso8601WeekOfYear(visit.NextAppointment.Value.Date);
                var visitSettingId = visit.VisitSettingId;

                if (visitdateWeek == curentWeek)
                {
                    if (visitSettingId <= 9)
                    {
                        var nextVisitStage = visitSettingId + 1;

                        if (nextVisitStage > 9)
                        {
                            continue;
                        }

                        var studyId = GetStudyId(visit.ParticipantId);

                        var participantCame = ParticipantCame(visit.ParticipantId, nextVisitStage);

                        var scheduledVisitVM = new ScheduledVisitsViewModel();

                        scheduledVisitVM.StudyId       = studyId;
                        scheduledVisitVM.ParticipantId = visit.ParticipantId;

                        if (nextVisitStage != 9)
                        {
                            scheduledVisitVM.VisitDate = visit.NextAppointment.Value;
                        }

                        scheduledVisitVM.VisitStage = context.VisitSettings.Where(v => v.VisitStage == nextVisitStage).FirstOrDefault().VisitType;

                        scheduledVisitsVM.Add(scheduledVisitVM);
                    }
                    else
                    {
                        var nextVisitStage = visitSettingId + 1;

                        if (nextVisitStage > 17)
                        {
                            continue;
                        }

                        var studyId = GetStudyId(visit.ParticipantId);

                        var participantCame = ParticipantCame(visit.ParticipantId, nextVisitStage);

                        var scheduledVisitVM = new ScheduledVisitsViewModel();

                        scheduledVisitVM.StudyId       = studyId;
                        scheduledVisitVM.ParticipantId = visit.ParticipantId;

                        if (nextVisitStage != 17)
                        {
                            scheduledVisitVM.VisitDate = visit.NextAppointment.Value;
                        }

                        scheduledVisitVM.VisitStage = context.VisitSettings.Where(v => v.VisitStage == nextVisitStage).FirstOrDefault().VisitType;

                        scheduledVisitsVM.Add(scheduledVisitVM);
                    }
                }
            }

            return(scheduledVisitsVM);
        }
Ejemplo n.º 3
0
 public ScheduledVisitsView(IEnumerable <Visitor> results)
 {
     InitializeComponent();
     BindingContext = new ScheduledVisitsViewModel(results);
 }