Example #1
0
class OperationNote(models.EpisodeSubrecord):

    start_time = fields.TimeField()
    end_time = fields.TimeField()
    date = fields.DateField()

    lead_surgeon = models.ForeignKeyOrFreeText(
        StaffMember, related_name="%(class)s_lead_surgeon")
    lead_anaesthetist = models.ForeignKeyOrFreeText(
        StaffMember, related_name="%(class)s_lead_anaesthetist")

    surgeon = ManyToManyField(StaffMember, related_name="%(class)s_surgeon")
    assistant = ManyToManyField(StaffMember,
                                related_name="%(class)s_assistant")
    anaesthetist = ManyToManyField(StaffMember,
                                   related_name="%(class)s_anaesthetist")

    dvt_heparin = fields.BooleanField(default=False)
    dvt_ted_stockings = fields.BooleanField(default=False)
    dvt_pnematic = fields.BooleanField(default=False)
    dvt_aspirin = fields.BooleanField(default=False)

    antibiotics = fields.CharField(max_length=40)
    indication = fields.CharField(max_length=20)
    position = fields.CharField(max_length=20)
    incision = fields.CharField(max_length=20)
    findings = fields.TextField()
    procedure = fields.TextField()

    anaesthetic = models.ForeignKeyOrFreeText(AnaestheticType)
    cancer = models.ForeignKeyOrFreeText(CancerType)
    asa = models.ForeignKeyOrFreeText(AsaType)
    urgency = models.ForeignKeyOrFreeText(Urgency)
Example #2
0
class Fp17Declaration(models.EpisodeSubrecord):
    _is_singleton = True

    necessary_care_provided = fields.BooleanField(default=False)
    necessary_care_carried_out = fields.BooleanField(default=False)

    signature = fields.CharField(max_length=255, blank=True, null=True)
    signature_date = fields.DateField(blank=True, null=True)
Example #3
0
class Fp17IncompleteTreatment(models.EpisodeSubrecord):
    _is_singleton = True
    _title = 'FP17 Treatment Course'

    incomplete_treatment_band_1 = fields.BooleanField(default=False)
    incomplete_treatment_band_2 = fields.BooleanField(default=False)
    incomplete_treatment_band_3 = fields.BooleanField(default=False)
    date_of_acceptance = fields.DateField(blank=True, null=True)
    completion_or_last_visit = fields.DateField(blank=True, null=True)
Example #4
0
class Fp17OtherDentalServices(models.EpisodeSubrecord):
    _is_singleton = True
    _title = "FP17 Other Dental Services"

    treatment_on_referral = fields.BooleanField(default=False)
    free_repair_or_replacement = fields.BooleanField(default=False)
    further_treatment_within_2_months = fields.BooleanField(default=False)
    domicillary_services = fields.BooleanField(default=False)
    sedation_services = fields.BooleanField(default=False)
Example #5
0
class DateFieldDefinition(FieldDefinition):
    auto_now = fields.BooleanField(_('auto now'), default=False,
                                   help_text=auto_now_help_text)
    auto_now_add = fields.BooleanField(_('auto now add'), default=False,
                                       help_text=auto_now_add_help_text)

    objects = FieldDefinitionManager()

    class Meta:
        app_label = 'temporal'
        defined_field_class = fields.DateField
        defined_field_options = ('auto_now', 'auto_now_add',)
        defined_field_category = _('Temporal')
Example #6
0
class Fp17TreatmentCategory(models.EpisodeSubrecord):
    _is_singleton = True
    _title = "Treatment Category"

    treatment_category_band_1 = fields.BooleanField(default=False)
    treatment_category_band_2 = fields.BooleanField(default=False)
    treatment_category_band_3 = fields.BooleanField(default=False)
    urgent_treatment = fields.BooleanField(default=False)
    regulation_11_replacement_appliance = fields.BooleanField(default=False)
    prescription_only = fields.BooleanField(default=False)
    denture_repairs = fields.BooleanField(default=False)
    bridge_repairs = fields.BooleanField(default=False)
    arrest_of_bleeding = fields.BooleanField(default=False)
    removal_of_sutures = fields.BooleanField(default=False)
Example #7
0
class OrthodonticTreatment(models.EpisodeSubrecord):
    _is_singleton = True

    patient_failed_to_return = fields.BooleanField(
        default=False,
        verbose_name="Treatment abandoned - patient failed to return")
    patient_requested_stop = fields.BooleanField(
        default=False, verbose_name="Treatment abandoned - patient requested")
    treatment_discontinued = fields.BooleanField(default=False, )
    treatment_completed = fields.BooleanField(default=False)
    par_scores_calculated = fields.BooleanField(default=False,
                                                verbose_name="PAR ")
    iotn = fields.IntegerField(blank=True, null=True, verbose_name="IOTN")
    # Index of Orthodontic Treatment Need
    # Only accepts 1-5
    iotn = fields.IntegerField(blank=True, null=True, verbose_name="IOTN")
    # Only accepts 1-10
    aesthetic_component = fields.IntegerField(blank=True, null=True)
    iotn_not_applicable = fields.BooleanField(
        default=False, verbose_name="IOTN not applicable")
    repair = fields.BooleanField(
        default=False,
        verbose_name="Repair to appliance fitted by another dentist")
    replacement = fields.BooleanField(
        default=False, verbose_name="Regulation 11 replacement appliance")
    date_of_completion = fields.DateField(
        blank=True, null=True, verbose_name="Date of completion or last visit")
Example #8
0
class Node(APIUser):
    foreign_username = fields.CharField(max_length=32)
    foreign_pass = fields.CharField(max_length=32)
    outbound = fields.BooleanField(default=False)
    image_sharing = fields.BooleanField(default=True)

    # Used to set parent "type" to "Node"
    def __init__(self, *args, **kwargs):
        for f in self._meta.fields:
            if f.attname == "type":
                f.default = "Node"
                super(Node, self).__init__(*args, **kwargs)

    def __unicode__(self):
        return u'%s:%s' % (self.id, self.host)
Example #9
0
class Coinwidget(plugin_base.CMSPlugin):
    currency = fields.CharField(max_length=30, choices=CURRENCY_CHOICES, default=CURRENCY_CHOICES[0][0])
    wallet_address = fields.CharField(max_length=255)
    counter = fields.CharField(max_length=6, choices=COUNTER_CHOICES, default=COUNTER_CHOICES[0][0], help_text=_("Toggle what is shown in the counter next to the main button."))
    qr_code = fields.BooleanField(_("QR code"), default=True, help_text=_("Set to true if you want to show the QR code generator that appears at the bottom left of the window. Set to false to hide the QR code icon."))
    auto_show = fields.BooleanField(default=False, help_text=_("Set to true if you want the window to auto appear as soon as the counter finishes loading."))
    decimals = fields.SmallIntegerField(default=4, validators=[
        validators.MinValueValidator(0),
        validators.MaxValueValidator(10),
    ], help_text=_("Adjust the number of decimals shown on the amount received statistic."))
    button_label = fields.CharField(max_length=255, default="Donate", help_text=_("Change the text of the label on the main button."))
    address_label = fields.CharField(max_length=255, default="My Bitcoin Address:", help_text=_("The text that appears above your wallet address within the window."))
    count_label = fields.CharField(max_length=255, default="donations", help_text=_("The text that appears in the window under the total number of transactions."))
    amount_label = fields.CharField(max_length=255, default="BTC", help_text=_("The text that appears in the window under the total amount received."))
    window_alignment = fields.CharField(max_length=2, choices=WINDOW_ALIGNMENT_CHOICES, default=WINDOW_ALIGNMENT_CHOICES[0][0])
class DeliveryPack(Model):
    pack_id = fields.AutoField(primary_key=True)
    courier = ForeignKey(Courier,
                         on_delete=CASCADE,
                         default=None,
                         blank=True,
                         null=True)
    assign_time = fields.DateTimeField()
    delivery_type = fields.CharField(max_length=4,
                                     choices=Courier.COURIER_TYPE_CHOICES,
                                     default='foot')
    delivery_ended = fields.BooleanField(default=False)
    last_complete_time = fields.DateTimeField()
    total_weight = fields.FloatField(default=0)

    def orders(self):
        return self.order_set.all()

    def assign_order(self, order):
        order.delivery_pack = self
        self.total_weight += order.weight
        order.save()
        self.save()

    def make_order_free(self, order):
        if order not in self.orders():
            return
        order.delivery_pack = None
        order.delivery_time = None
        self.total_weight -= order.weight
        order.save()
        self.save()
Example #11
0
class Structure(Model):
    name = fields.CharField(max_length=50, blank=True, null=True)
    address = models.ForeignKey(Address, blank=True, null=True)
    description = fields.CharField(max_length=250, blank=True, null=True)
    total_seats = fields.IntegerField(blank=True, null=True)
    available_seats = fields.IntegerField(blank=True, null=True)
    active = fields.BooleanField(default=True)
    owner = models.ForeignKey(Volunteer, blank=True, null=True)

    def update_availability(self):
        occupied_sits = 0
        for evacuee in self.evacuees.all():
            occupied_sits += evacuee.group_size
        self.available_seats = self.total_seats - occupied_sits
        self.save()

    def notify_assignation(self, evacuee):
        if self.owner.user and evacuee.user:
            Notification.objects.create(
                time=datetime.now(),
                kind='assignation',
                message='Struttura "{}" assegnata a "{} {}"'.format(
                    self.name, evacuee.name, evacuee.surname),
                user=self.owner.user)
            Notification.objects.create(
                time=datetime.now(),
                kind='assignation',
                message='Assegnata struttura "{}" da "{} {}"'.format(
                    self.name, self.owner.name, self.owner.surname),
                user=evacuee.user)
Example #12
0
class Leg(models.Model):
    date = fields.DateField(default=now)
    name = fields.CharField(max_length=40, unique=True)
    slug = fields.SlugField(max_length=40, db_index=True, editable=False)
    start = fields.CharField(max_length=30)
    end = fields.CharField(max_length=30)
    description = fields.TextField(max_length=320, blank=True)
    duration = fields.DecimalField(decimal_places=1, max_digits=2, default=1.0)
    distanceKM = fields.IntegerField()
    morning = fields.BooleanField(default=True)
    map = models.FileField(upload_to=get_map_path, blank=True)

    class Meta:
        unique_together = ('date', 'morning')

    def __str__(self):
        return "{} - {} {}: {}km from {} to {}".format(
            self.name, self.date, "am" if self.morning else "pm",
            self.distanceKM, self.start, self.end)

    @classmethod
    def Totals(cls):
        return cls.objects.aggregate(distance=Sum('distanceKM'),
                                     days=Count('date', distinct=True))

    prepopulated_fields = {"slug": ("title", )}
Example #13
0
class Exists(Subquery):
    template = 'EXISTS(%(subquery)s)'
    output_field = fields.BooleanField()

    def __init__(self, queryset, negated=False, **kwargs):
        self.negated = negated
        super().__init__(queryset, **kwargs)
        self.query = self.query.exists()

    def __invert__(self):
        clone = self.copy()
        clone.negated = not self.negated
        return clone

    def as_sql(self, compiler, connection, template=None, **extra_context):
        sql, params = super().as_sql(compiler, connection, template, **extra_context)
        if self.negated:
            sql = 'NOT {}'.format(sql)
        return sql, params

    def select_format(self, compiler, sql, params):
        # Wrap EXISTS() with a CASE WHEN expression if a database backend
        # (e.g. Oracle) doesn't support boolean expression in SELECT or GROUP
        # BY list.
        if not compiler.connection.features.supports_boolean_expr_in_select_clause:
            sql = 'CASE WHEN {} THEN 1 ELSE 0 END'.format(sql)
        return sql, params
Example #14
0
    def order_by(self, *field_names):
        obj = self._clone()
        obj.query.clear_ordering(force_empty=False)

        for field_name in field_names:
            if field_name.startswith('translations__'):
                (_, field) = field_name.split('__')
                sub_query = self.model.translations.field.model.objects.filter(
                    master=OuterRef('pk')).annotate(is_current_language=Case(
                        When(language_code=self._language, then=True),
                        default=False,
                        output_field=fields.BooleanField())).order_by(
                            '-is_current_language').values(field)[:1]

                obj = obj.annotate(
                    **{
                        'translated_{}'.format(field): Subquery(sub_query)
                    }).order_by('translated_{}'.format(field))

        field_names = [
            field_name.replace('translations__', 'translated_')
            for field_name in field_names
        ]

        obj.query.add_ordering(*field_names)

        return obj
Example #15
0
class TrackedModelCheck(models.Model):
    """
    Represents the result of running a single check against a single model.

    The ``TrackedModelCheck`` only gets created once the check is complete, and
    hence success should always be known. The reason is that a single model
    check is atomic (i.e. there is no smaller structure) and so it's either done
    or not, and it can't be "resumed".
    """

    model = models.ForeignKey(
        TrackedModel,
        related_name="checks",
        on_delete=models.CASCADE,
    )

    transaction_check = models.ForeignKey(
        TransactionCheck,
        on_delete=models.CASCADE,
        related_name="model_checks",
    )

    check_name = fields.CharField(max_length=255)
    """A string identifying the type of check carried out."""

    successful = fields.BooleanField()
    """True if the check was successful."""

    message = fields.TextField(null=True)
    """The text content returned by the check, if any."""
Example #16
0
class Exists(Subquery):
    template = "EXISTS(%(subquery)s)"
    output_field = fields.BooleanField()

    def __init__(self, queryset, negated=False, **kwargs):
        # As a performance optimization, remove ordering since EXISTS doesn't
        # care about it, just whether or not a row matches.
        queryset = queryset.order_by()
        self.negated = negated
        super().__init__(queryset, **kwargs)

    def __invert__(self):
        clone = self.copy()
        clone.negated = not self.negated
        return clone

    def as_sql(self, compiler, connection, template=None, **extra_context):
        sql, params = super().as_sql(compiler, connection, template, **extra_context)
        if self.negated:
            sql = "NOT {}".format(sql)
        return sql, params

    def select_format(self, compiler, sql, params):
        # Wrap EXISTS() with a CASE WHEN expression if a database backend
        # (e.g. Oracle) doesn't support boolean expression in SELECT or GROUP
        # BY list.
        if not compiler.connection.features.supports_boolean_expr_in_select_clause:
            sql = "CASE WHEN {} THEN 1 ELSE 0 END".format(sql)
        return sql, params
Example #17
0
class AnimalCard(models.Model):
    name = f.CharField(max_length=20, verbose_name='Имя')
    animal = models.ForeignKey(Animal,
                               on_delete=models.PROTECT,
                               verbose_name='Животное')
    breed = f.CharField(max_length=15, blank=True, verbose_name='Порода')
    gender = f.CharField(max_length=7,
                         choices=GENDER_CHOICES,
                         verbose_name='Пол')
    age = f.CharField(max_length=15, blank=True, verbose_name='Возраст')
    state_time_admission = f.CharField(
        max_length=18,
        choices=ANIMAL_CONDITION_CHOICES,
        verbose_name='Состояние на момент приема')
    reason_getting_shelter = f.TextField(verbose_name='Причина приема')
    additional_inform = f.TextField(blank=True,
                                    verbose_name='Дополнительная информация')
    date_receipt = f.DateTimeField(auto_now_add=True,
                                   verbose_name='Дата приема')
    # photo = f.ImageField()
    is_adopted = f.BooleanField(blank=True,
                                default=False,
                                verbose_name='Усыновлен ли')

    def __str__(self):
        return self.name
Example #18
0
class Exists(Subquery):
    template = 'EXISTS(%(subquery)s)'
    output_field = fields.BooleanField()

    def __init__(self, *args, negated=False, **kwargs):
        self.negated = negated
        super().__init__(*args, **kwargs)

    def __invert__(self):
        return type(self)(self.queryset,
                          negated=(not self.negated),
                          **self.extra)

    def resolve_expression(self, query=None, *args, **kwargs):
        # As a performance optimization, remove ordering since EXISTS doesn't
        # care about it, just whether or not a row matches.
        self.queryset = self.queryset.order_by()
        return super().resolve_expression(query, *args, **kwargs)

    def as_sql(self, compiler, connection, template=None, **extra_context):
        sql, params = super().as_sql(compiler, connection, template,
                                     **extra_context)
        if self.negated:
            sql = 'NOT {}'.format(sql)
        return sql, params

    def as_oracle(self, compiler, connection, template=None, **extra_context):
        # Oracle doesn't allow EXISTS() in the SELECT list, so wrap it with a
        # CASE WHEN expression. Change the templates since the When expression
        # requires a left hand side (column) to compare against.
        sql, params = self.as_sql(compiler, connection, template,
                                  **extra_context)
        sql = 'CASE WHEN {} THEN 1 ELSE 0 END'.format(sql)
        return sql, params
Example #19
0
class DebtLoan(models.Model):
    DEBT = 0
    LOAN = 1
    CATEGORY_CHOICES = (
        (DEBT, 'debt'),
        (LOAN, 'loan'),
    )

    with_who = fields.CharField(max_length=255)
    title = fields.CharField(max_length=255, null=True, blank=True)
    amount = fields.DecimalField(max_digits=10, decimal_places=2)
    category = fields.PositiveSmallIntegerField(choices=CATEGORY_CHOICES)
    created = fields.DateTimeField(default=timezone.now, editable=False)
    modified = fields.DateTimeField(default=timezone.now)
    active = fields.BooleanField(default=True)
    user = models.ForeignKey(User, on_delete=models.CASCADE)

    def __str__(self):
        if self.title:
            return "{}: {}".format(self.with_who, self.title)
        else:
            return "{}".format(self.with_who)

    def deactivate(self):
        if self.active:
            self.active = False
            self.save()
Example #20
0
class GenericIPAddressFieldDefinition(CharFieldDefinition):
    PROTOCOL_BOTH = 'both'
    PROTOCOL_IPV4 = 'IPv4'
    PROTOCOL_IPV6 = 'IPv6'

    PROTOCOL_CHOICES = (
        (PROTOCOL_BOTH, _('both')),
        (PROTOCOL_IPV4, _('IPv4')),
        (PROTOCOL_IPV6, _('IPv6'))
    )

    protocol = fields.CharField(
        _('protocol'), max_length=4,
        choices=PROTOCOL_CHOICES, default=PROTOCOL_BOTH
    )
    unpack_ipv4 = fields.BooleanField(_('unpack ipv4'), default=False)

    objects = FieldDefinitionManager()

    class Meta(_WebMeta):
        app_label = 'mutant'
        defined_field_class = fields.GenericIPAddressField
        defined_field_options = ('protocol', 'unpack_ipv4',)
        defined_field_description = _('generic IP address')

    def clean(self):
        if self.unpack_ipv4 and self.procotol != 'both':
            msg = _("Can only be used when ``protocol`` is set to 'both'.")
            raise ValidationError({'unpack_ipv4': msg})
Example #21
0
class Preparation(models.EpisodeSubrecord):
    _is_singleton = True

    cannula_in_situ = fields.BooleanField(
        help_text="Does the patient have a peripheral venous cannula in situ?",
        default=False
    )
Example #22
0
 def test_expr(self):
     expr = expressions.ExpressionWrapper(
         models.Q(submitted_date__isnull=False),
         output_field=fields.BooleanField())
     self._test_ordering('submitted',
                         ddl.OrderingFilter(fields={'submitted': expr}),
                         self.order2)
Example #23
0
class EpiduralRequest(models.EpisodeSubrecord):

    # this may change if we decide to handle the State of EpiduralRequest differently
    # in the Ruby version this was an Enum
    # Could this be handled as a SNOMED-CT lookuplist?
    epidural_status = fields.PositiveIntegerField(
        null=True,
        help_text=
        "Internal field for managing the state of the epidural request - ordered, in progress, completed, attempted-failed, etc)",
    )

    history = fields.TextField(
        null=True,
        help_text=
        "Focused summary of the relevant history. Use this area to let the amaesthetist know about any relevant hazards ar special circumstances",
    )

    cannula_in_situ = fields.BooleanField(
        help_text="Does the patient have a peripheral venous cannula in situ?",
    )

    anticoagulants = fields.BooleanField(
        help_text=
        "Is the patient currently taking anticolagulants, antiplatelet agents, or any other medication that 'thins' blood or affects coagulation?",
    )

    pyrexia = fields.BooleanField(
        help_text="Does the patient have a recent history of pyrexia?",
        # TODO definition of pyrexia should be explicitly stated (temp, duration, what is 'recent' etc)
    )

    hypertension = fields.BooleanField(
        help_text="Does the patient have pregnancy-induced hypertension (PIH)?",
    )

    # TODO this field could be autopopulated from the lab, also needs a timestamp to give meaning to 'latest'
    platelet_count = fields.CharField(
        null=True,
        max_length=20,
        help_text="Patient's latest Platelet count",
    )

    request_date_time = fields.DateTimeField(
        null=True,
        # default=timezone.now, (causes an Opal APIerror if uncommented)
        help_text="Date and time of the epidural request",
    )
Example #24
0
class Currency(models.Model):
    id = fields.AutoField(
        verbose_name=_('ID'),
        primary_key=True,
    )
    iso_code = fields.CharField(
        verbose_name=_('ISO Code'),
        max_length=3,
        null=False,
        blank=False,
        unique=True,
    )
    title = fields.CharField(
        verbose_name=_('Title'),
        max_length=255,
        null=False,
        blank=False,
    )
    prefix = fields.CharField(
        verbose_name=_('Prefix'),
        max_length=255,
        null=False,
        blank=True,
    )
    suffix = fields.CharField(
        verbose_name=_('Suffix'),
        max_length=255,
        null=False,
        blank=True,
    )
    rate = fields.DecimalField(
        verbose_name=_('Conversion Rate'),
        max_digits=10,
        decimal_places=4,
        null=False,
        blank=False,
        default=1,
    )
    is_active = fields.BooleanField(
        verbose_name=_('Is Active'),
        null=False,
        blank=False,
        default=True,
        db_index=True,
    )
    records = models.Manager()

    class Meta:
        db_table = 'billing_currency'
        default_related_name = 'currencies'
        verbose_name = _('Currency')
        verbose_name_plural = _('Currencies')

    def __unicode__(self):
        return '%(id)d: %(title)s (%(iso_code)s)' % {
            'id': self.id,
            'iso_code': self.iso_code,
            'title': self.title,
        }
Example #25
0
class DashboardSetting(models.Model):
    myuser    = models.OneToOneField(MYUSER, on_delete=models.CASCADE)
    dark_mode = fields.BooleanField(default=False)

    objects = models.Manager()

    def __str__(self):
        return self.dark_mode
Example #26
0
class Fp17OtherDentalServices(models.EpisodeSubrecord):
    _is_singleton = True
    _title = "FP17 Other Dental Services"

    treatment_on_referral = fields.BooleanField(
        default=False, verbose_name="Treatment on referral")
    free_repair_or_replacement = fields.BooleanField(
        default=False, verbose_name="Free repair or replacement")
    further_treatment_within_2_months = fields.BooleanField(
        default=False, verbose_name="Further treatment within 2 months")
    domicillary_services = fields.BooleanField(
        default=False, verbose_name="Domicillary services")
    sedation_services = fields.BooleanField(default=False,
                                            verbose_name="Sedation services")

    class Meta:
        verbose_name = "Other services"
Example #27
0
class Fp17TreatmentCategory(models.EpisodeSubrecord):
    _is_singleton = True

    TREATMENT_CATEGORIES = enum("Band 1", "Band 2", "Band 3")

    treatment_category = fields.CharField(max_length=255,
                                          blank=True,
                                          null=True,
                                          choices=TREATMENT_CATEGORIES,
                                          verbose_name="Treatment category")
    urgent_treatment = fields.BooleanField(default=False,
                                           verbose_name="Urgent treatment")
    regulation_11_replacement_appliance = fields.BooleanField(
        default=False, verbose_name="Regulation 11 replacement appliance")
    prescription_only = fields.BooleanField(default=False,
                                            verbose_name="Prescription only")
    denture_repairs = fields.BooleanField(default=False,
                                          verbose_name="Denture repairs")
    bridge_repairs = fields.BooleanField(default=False,
                                         verbose_name="Bridge repairs")
    arrest_of_bleeding = fields.BooleanField(default=False,
                                             verbose_name="Arrest of bleeding")
    removal_of_sutures = fields.BooleanField(default=False,
                                             verbose_name="Removal of sutures")

    class Meta:
        verbose_name = "Treatment category"
Example #28
0
class Pregnancy(models.EpisodeSubrecord):
    _is_singleton = True

    PARITY_CHOICES = (
    ('Primiparous', 'Primiparous',),
    ('Multiparous', 'Multiparous',),
    )

    parity = fields.CharField(
        choices=PARITY_CHOICES,
        blank=True, null=True,
        max_length=255,
    )


    low_risk = fields.BooleanField(
        default=False
    )

    platelet_count = fields.CharField(
        null=True,
        max_length=20,
        help_text="Patient's latest Platelet count",
    )

    anticoagulants = fields.BooleanField(
        help_text="Is the patient currently taking anticolagulants, antiplatelet agents, or any other medication that 'thins' blood or affects coagulation?",
        default=False
    )

    hypertension = fields.BooleanField(
        help_text="Does the patient have pregnancy-induced hypertension (PIH)?",
        default=False
    )

    sepsis = fields.BooleanField(
        help_text="Does the patient have signs of maternal sepsis?",
        default=False
        # TODO definition of pyrexia should be explicitly stated (temp, duration, what is 'recent' etc)
    )

    history = fields.TextField(
        null=True,
        help_text="Focused summary of the relevant history. Use this area to let the anaesthetist know about any relevant hazards or special circumstances",
    )
Example #29
0
class Engine(ModelFieldIsDefaultMixin, models.Model):
    """Defines engine settings."""

    DEFAULT_ENGINE = 'engine_mock'
    DRIVER = None

    engine = models.CharField(choices=ENGINES,
                              default=DEFAULT_ENGINE,
                              max_length=100)
    engine_name = models.CharField(max_length=255,
                                   blank=True,
                                   null=True,
                                   unique=True)
    host = models.URLField(blank=True, null=True)
    token = models.CharField(max_length=255, blank=True, null=True)
    lti_parameters = models.TextField(
        default='',
        blank=True,
        help_text=_(
            "LTI parameters to sent to the engine, use comma separated string")
    )
    is_default = fields.BooleanField(
        default=False,
        help_text=_("If checked Engine will be used as the default!"))

    class Meta:
        unique_together = ('host', 'token')

    def __str__(self):
        return "Engine: {}".format(self.engine_name)

    @classmethod
    def create_default(cls):
        return cls.objects.create(engine=cls.DEFAULT_ENGINE,
                                  engine_name='Mock',
                                  is_default=True)

    @property
    def engine_driver(self):
        if not self.DRIVER:
            driver = _load_cls_from_applicable_module(
                'module.engines', self.engine, class_startswith='Engine')
            # NOTE(idegtiarov) Currently, statement coves existent engines modules. Improve in case new engine will be
            # added to the engines package.
            if self.engine.endswith('mock'):
                engine_driver = driver()
            else:
                engine_driver = driver(**{
                    'HOST': self.host,
                    'TOKEN': self.token
                })
            self.DRIVER = engine_driver
        return self.DRIVER

    @property
    def lti_params(self):
        return (param.strip() for param in self.lti_parameters.split(','))
 def get_products(self, obj):
     shop = obj.shop_logistic_unit.shop
     products = Product.objects.filter(
         FK_Shop=shop).annotate(is_checked=Case(
             When(ID__in=obj.products.values('ID'), then=Value(True)),
             default=Value(False),
             output_field=fields.BooleanField()
         )).order_by('-is_checked')
     return ProductSerializer(products, many=True).data