def create_consent_options(self):
     """Returns a dictionary of options to create a new
     unpersisted consent model instance.
     """
     options = dict(subject_identifier=self.object.subject_identifier,
                    consent_identifier=get_uuid(),
                    version=self.consent_object.version)
     return options
    def empty_consent(self):
        """Returns an unsaved consent model instance.

        Override to include additional attrs to instantiate.
        """
        return self.consent_object.model_cls(
            subject_identifier=self.subject_identifier,
            consent_identifier=get_uuid(),
            version=self.consent_object.version)
 def empty_consent(self):
     """Returns a new unsaved mock consent model.
     """
     consent_model = django_apps.get_model(*self.consent_model.split('.'))
     return consent_model(
         consent_identifier=get_uuid(),
         household_member=self.household_member,
         survey_schedule=self.household_member.survey_schedule_object.field_value,
         version=self.consent_object.version)
 def create_consent_options(self):
     """Returns a dictionary of options to create a new
     unpersisted consent model instance.
     """
     options = dict(
         subject_identifier=self.object.subject_identifier,
         consent_identifier=get_uuid(),
         version=self.consent_object.version)
     return options
 def consent(self):
     """Returns a wrapped saved or unsaved consent.
     """
     consent_model_wrapper_class = SubjectConsentModelWrapper
     try:
         consent = self.consent_object.model.objects.get(
             version=self.consent_object.version,
             screening_identifier=self.object.screening_identifier,
         )
     except ObjectDoesNotExist:
         consent = self.consent_object.model(
             subject_identifier=self.object.subject_identifier,
             consent_identifier=get_uuid(),
             screening_identifier=self.object.screening_identifier,
             version=self.consent_object.version)
         consent = consent_model_wrapper_class(consent)
     if consent:
         consent = consent_model_wrapper_class(consent)
     return consent
 def create_consent_options(self):
     """Returns a dictionary of options to create a new
     unpersisted consent model instance.
     """
     options = dict(
         screening_identifier=self.screening_identifier,
         consent_identifier=get_uuid(),
         version=self.consent_version)
     if getattr(self, 'bhp_prior_screening_model_obj'):
         bhp_prior_screening = self.bhp_prior_screening_model_obj
         flourish_participation = bhp_prior_screening.flourish_participation
         locator_obj = getattr(self, 'locator_model_obj', None)
         if flourish_participation == 'interested' and locator_obj:
             first_name = locator_obj.first_name.upper() if locator_obj.first_name else None
             last_name = locator_obj.last_name.upper() if locator_obj.last_name else None
             initials = self.set_initials(first_name, last_name)
             options.update(
                 {'first_name': first_name,
                  'last_name': last_name,
                  'initials': initials,
                  'gender': FEMALE})
     return options
Esempio n. 7
0
    def create_consent_options(self):
        """Returns a dictionary of options to create a new
        unpersisted consent model instance.
        """
        options = dict(screening_identifier=self.screening_identifier,
                       consent_identifier=get_uuid(),
                       version=self.consent_version)
        if self.consent_version_1_model_obj:
            consent_version_1 = self.consent_version_1_model_obj.__dict__
            exclude_options = [
                '_state', 'consent_datetime', 'report_datetime',
                'consent_identifier', 'version', 'id',
                'subject_identifier_as_pk', 'created', 'modified', 'site_id',
                'device_created', 'device_modified', 'hostname_modified',
                'hostname_created', 'user_created', 'subject_identifier',
                'screening_identifier'
            ]
            for option in exclude_options:
                del consent_version_1[option]

            options.update(**consent_version_1)

        if getattr(self, 'bhp_prior_screening_model_obj'):
            bhp_prior_screening = self.bhp_prior_screening_model_obj
            flourish_participation = bhp_prior_screening.flourish_participation
            locator_obj = getattr(self, 'locator_model_obj', None)
            if flourish_participation == 'interested' and locator_obj:
                first_name = locator_obj.first_name.upper(
                ) if locator_obj.first_name else None
                last_name = locator_obj.last_name.upper(
                ) if locator_obj.last_name else None
                initials = self.set_initials(first_name, last_name)
                options.update({
                    'first_name': first_name,
                    'last_name': last_name,
                    'initials': initials,
                    'gender': FEMALE,
                })
        return options
 def consent(self):
     """Returns a wrapped saved or unsaved consent.
     """
     # FIXME: self.object.consent_object should
     # return a consent object
     if self.object.consent:
         consent = self.object.consent
     else:
         try:
             model = self.object.consent_object.model
         except AttributeError:
             consent = None
         else:
             consent = model(
                 subject_identifier=self.object.subject_identifier,
                 consent_identifier=get_uuid(),
                 household_member=self.object,
                 survey_schedule=self.object.survey_schedule_object.field_value,
                 version=self.object.consent_object.version)
             consent = self.consent_model_wrapper_cls(consent)
     if consent:
         consent = self.consent_model_wrapper_cls(consent)
     return consent
 def save(self, *args, **kwargs):
     if not self.requisition_identifier:
         self.requisition_identifier = get_uuid()
     self.protocol_number = self.get_protocol_number()
     self.requisition_identifier = self.get_requisition_identifier()
     super().save(*args, **kwargs)