Esempio n. 1
0
class SpecialistReview(models.EpisodeSubrecord):
    _angular_service = 'RequestReceive'
    specialist_type = ForeignKeyOrFreeText(SpecialistType)
    requested_timestamp = fields.DateTimeField(null=True, blank=True)
    received_timestamp = fields.DateTimeField(null=True, blank=True)
    requested = fields.NullBooleanField()
    received = fields.NullBooleanField()
Esempio n. 2
0
class Dyspnoea(models.EpisodeSubrecord):
    _title = 'mMRC Dispnoea'
    breathless = fields.NullBooleanField()
    short_of_breath = fields.NullBooleanField()
    slower_than_most = fields.NullBooleanField()
    stops_for_breath = fields.NullBooleanField()
    dressing_undressing = fields.NullBooleanField()
Esempio n. 3
0
class SmokingHistory(models.EpisodeSubrecord):
    _title = 'Smoking History'
    ever_smoked = fields.NullBooleanField()
    current_smoker = fields.NullBooleanField()
    start_smoking_age = fields.CharField(max_length=20, blank=True, null=True)
    stop_smoking_age = fields.CharField(max_length=20, blank=True, null=True)
    cigarettes_per_day = fields.CharField(max_length=20, blank=True, null=True)
    what_do_you_smoke = fields.TextField(blank=True, null=True)
Esempio n. 4
0
class Imaging(models.EpisodeSubrecord):
    _angular_service = 'RequestReceive'
    _icon = "fa fa-picture-o"
    test_type = ForeignKeyOrFreeText(ImagingTestType)
    requested_timestamp = fields.DateTimeField(null=True, blank=True)
    reviewed_timestamp = fields.DateTimeField(null=True, blank=True)
    requested = fields.NullBooleanField()
    reviewed = fields.NullBooleanField()
Esempio n. 5
0
class LabTest(models.EpisodeSubrecord):
    _angular_service = 'RequestReceive'
    _title = "Investigation"
    _icon = "fa fa-flask"
    test_type = ForeignKeyOrFreeText(LabTestType)
    requested_timestamp = fields.DateTimeField(null=True, blank=True)
    reviewed_timestamp = fields.DateTimeField(null=True, blank=True)
    requested = fields.NullBooleanField()
    reviewed = fields.NullBooleanField()
Esempio n. 6
0
class DischargeStep(models.EpisodeSubrecord):
    _angular_service = 'RequestReceive'
    discharge_type = ForeignKeyOrFreeText(DischargeType)
    requested_timestamp = fields.DateTimeField(null=True, blank=True)
    received_timestamp = fields.DateTimeField(null=True, blank=True)
    requested = fields.NullBooleanField()
    transport_type = ForeignKeyOrFreeText(TransportType)
    destination_type = ForeignKeyOrFreeText(DestinationType)
    reviewed = fields.NullBooleanField()
    reviewed_timestamp = fields.DateTimeField(null=True, blank=True)
Esempio n. 7
0
class Schedule(_Model):
    from django.db.models.fields import related as _related
    from django.db.models import deletion as _deletion
    from django.db.models import fields as _field
    from app.fields import timezone as _timezone

    employee = _related.ForeignKey(
        'holding.Employee',
        on_delete=_deletion.SET_NULL,
        null=True,
        blank=False,  # For admin panel?
        related_name="schedules",
    )

    start = _field.DateTimeField("Начало")
    end = _field.DateTimeField("Конец")

    is_wanted = _field.NullBooleanField(
        verbose_name="Хочет работать",
        default=None,
    )

    timezone = _timezone.TimeZoneField(
        verbose_name="Временная зона",
        null=True,
        blank=True,
    )

    def save(self,
             force_insert=False,
             force_update=False,
             using=None,
             update_fields=None):
        if self.timezone is None:
            self.timezone = self.company.timezone

        return super(Schedule, self).save(force_insert, force_update, using,
                                          update_fields)

    @property
    def employee_fullname(self):
        return "%s %s" % (self.employee.first_name, self.employee.last_name)

    employee_fullname.fget.short_description = "Сотрудник"

    @property
    def company(self):
        return self.employee.company

    company.fget.short_description = "Компания"

    @property
    def company_name(self):
        return self.company.name

    company_name.fget.short_description = "Компания"

    def __str__(self):
        return "%s %s [%s]:(%s - %s)" % (
            self.employee.first_name, self.employee.last_name,
            self.start.date(), self.start.time(), self.end.time())

    class Meta:
        verbose_name = "График сотрудника"
        verbose_name_plural = "Графики сотрудников"
Esempio n. 8
0
class ManyToManyFieldDefinition(RelatedFieldDefinition):
    symmetrical = fields.NullBooleanField(_('symmetrical'))
    through = fields.related.ForeignKey(ContentType, blank=True, null=True,
                                        related_name='+',
                                        help_text=through_help_text)
    # TODO: This should not be a SlugField
    db_table = fields.SlugField(max_length=30, blank=True, null=True,
                                help_text=db_table_help_text)

    class Meta:
        app_label = 'mutant'
        defined_field_class = fields.related.ManyToManyField
        defined_field_options = ('symmetrical', 'db_table')

    def clean(self):
        try:
            super(ManyToManyFieldDefinition, self).clean()
        except ValidationError as e:
            messages = e.message_dict
        else:
            messages = {}

        if (self.symmetrical is not None and
            not self.is_recursive_relationship):
            msg = _("The relationship can only be symmetrical or not if it's "
                    "recursive, i. e. it points to 'self'")
            messages['symmetrical'] = [msg]

        if self.through:
            if self.db_table:
                msg = _('Cannot specify a db_table if an intermediate '
                        'model is used.')
                messages['db_table'] = [msg]

            if self.symmetrical:
                msg = _('Many-to-many fields with intermediate model cannot '
                        'be symmetrical.')
                messages.setdefault('symmetrical', []).append(msg)

            seen_from, seen_to = 0, 0
            to_model = self.to.model_class()
            through_class = self.through.model_class()
            from_model = self.model_def.cached_model
            for field in through_class._meta.fields:
                rel_to = getattr(field.rel, 'to', None)
                if rel_to == from_model:
                    seen_from += 1
                elif rel_to == to_model:
                    seen_to += 1
            if self.is_recursive_relationship():
                if seen_from > 2:
                    msg = _('Intermediary model %s has more than two foreign '
                            'keys to %s, which is ambiguous and is not permitted.')
                    formated_msg = msg % (through_class._meta.object_name,
                                          from_model._meta.object_name)
                    messages.setdefault('through', []).append(formated_msg)
            else:
                msg = _('Intermediary model %s has more than one foreign key '
                        ' to %s, which is ambiguous and is not permitted.')
                if seen_from > 1:
                    formated_msg = msg % (through_class._meta.object_name,
                                          from_model._meta.object_name)
                    messages.setdefault('through', []).append(formated_msg)
                if seen_to > 1:
                    formated_msg = msg % (through_class._meta.object_name,
                                          to_model._meta.object_name)
                    messages.setdefault('through', []).append(formated_msg)

        if messages:
            raise ValidationError(messages)

    def get_field_options(self, **overrides):
        options = super(ManyToManyFieldDefinition, self).get_field_options(**overrides)
        if self.through:
            options['through'] = self.through.model_class()
        return options

    def get_bound_field(self):
        opts = self.model_def.model_class(force_create=True)._meta
        for field in opts.many_to_many:
            if getattr(field, self.FIELD_DEFINITION_PK_ATTR, None) == self.pk:
                return field