Skip to content
Snippets Groups Projects
Commit d4c4e50c authored by Carlos Vega's avatar Carlos Vega
Browse files

fixed problem with the duration of auto created follow up visits. relative...

fixed problem with the duration of auto created follow up visits. relative date was in days instead of months
parent 754c8d3d
No related branches found
No related tags found
1 merge request!188Feature/improve management of visits from subject list
...@@ -9,6 +9,8 @@ from django.dispatch import receiver ...@@ -9,6 +9,8 @@ from django.dispatch import receiver
from web.models.constants import BOOL_CHOICES, SUBJECT_TYPE_CHOICES_CONTROL from web.models.constants import BOOL_CHOICES, SUBJECT_TYPE_CHOICES_CONTROL
from web.models import Study from web.models import Study
import logging
logger = logging.getLogger(__name__)
class Visit(models.Model): class Visit(models.Model):
...@@ -79,10 +81,12 @@ class Visit(models.Model): ...@@ -79,10 +81,12 @@ class Visit(models.Model):
time_to_next_visit = relativedelta(**args) * (follow_up_number - 1) #calculated from first visit time_to_next_visit = relativedelta(**args) * (follow_up_number - 1) #calculated from first visit
logger.warn('new visit: {} {} {}'.format(args, relativedelta(**args), time_to_next_visit))
Visit.objects.create( Visit.objects.create(
subject=self.subject, subject=self.subject,
datetime_begin=visit_started + time_to_next_visit, datetime_begin=visit_started + time_to_next_visit,
datetime_end=visit_started + time_to_next_visit + datetime.timedelta(days=study.default_visit_duration_in_months) datetime_end=visit_started + time_to_next_visit + relativedelta(months=study.default_visit_duration_in_months)
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment