def save(self, *args, **kwargs):
     if self.dx_ago:
         self.dx_estimated_date = edc_models.duration_to_date(
             self.dx_ago, self.report_datetime)
     if self.arv_initiation_ago:
         self.arv_initiation_estimated_date = edc_models.duration_to_date(
             self.arv_initiation_ago, self.report_datetime)
     super().save(*args, **kwargs)
Пример #2
0
 def estimated_date_from_ago(self, f1):
     """Returns the estimated date using `duration_to_date` or None."""
     estimated_date = None
     if self.cleaned_data.get(f1):
         try:
             estimated_date = edc_models.duration_to_date(
                 self.cleaned_data.get(f1),
                 self.cleaned_data.get("report_datetime").date(),
             )
         except InvalidFormat as e:
             raise forms.ValidationError({f1: str(e)})
     return estimated_date
    def save(self, *args, **kwargs):
        complications = [
            "stroke",
            "heart_attack",
            "renal_disease",
            "vision",
            "numbness",
            "foot_ulcers",
        ]
        for complication in complications:
            if getattr(self, f"{complication}_ago", None):
                duration = edc_models.duration_to_date(
                    getattr(self, f"{complication}_ago", None),
                    self.report_datetime)
                setattr(self, f"{complication}_estimated_date", duration)

        super().save(*args, **kwargs)
 def save(self, *args, **kwargs):
     if self.med_start_ago:
         self.med_start_estimated_date = edc_models.duration_to_date(
             self.med_start_ago, self.report_datetime)
     super().save(*args, **kwargs)