From d6131f465508da033d8874dfa696c43d698cd8d6 Mon Sep 17 00:00:00 2001 From: root <root@prc.prc.parkinson.lu> Date: Tue, 7 Mar 2017 16:57:32 +0100 Subject: [PATCH] newxt appointment should start a year after starting previous visit --- smash/web/models.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/smash/web/models.py b/smash/web/models.py index 2de5fe18..acd7adac 100644 --- a/smash/web/models.py +++ b/smash/web/models.py @@ -215,12 +215,12 @@ class Visit(models.Model): self.is_finished = True self.save() - visit_finished = self.datetime_begin + visit_started = self.datetime_end appointments = Appointment.objects.filter(visit=self) for appointment in appointments: - visit_finished = max(visit_finished,appointment.datetime_when) + visit_started = min(visit_started,appointment.datetime_when) time_to_next_visit = datetime.timedelta(days=365) if self.subject.type== Subject.SUBJECT_TYPE_CHOICES_CONTROL: @@ -228,8 +228,8 @@ class Visit(models.Model): Visit.objects.create( subject = self.subject, - datetime_begin = visit_finished+time_to_next_visit, - datetime_end = visit_finished+time_to_next_visit+datetime.timedelta(days=93) + datetime_begin = visit_started+time_to_next_visit, + datetime_end = visit_started+time_to_next_visit+datetime.timedelta(days=93) ) -- GitLab