Esempio n. 1
0
class Game(models.Model):
    guid = fields.UUIDField(primary_key=True)

    n_cells = fields.PositiveIntegerField()
    cell_area = fields.FloatField()

    temperature = fields.FloatField(blank=True, null=True)
    months_elapsed = fields.PositiveIntegerField(blank=True, null=True)

    arrays = models.FileField(blank=True, null=True, upload_to=arrays_upload_location)
Esempio n. 2
0
class TicketInfo(Model):
    registration = ForeignKey(Registration, on_delete=PROTECT)
    fee = ForeignKey(Fee, on_delete=PROTECT)
    quantity = fields.PositiveIntegerField(default=0)

    def __str__(self):
        return str(self.quantity)
Esempio n. 3
0
class User(AbstractUser):
    """
    - extended the User model of django to reuse existing user model with few modifications.
    - Phone Number is PositiveBigInt (Positive Integer is not enough) with validation of accepting 10 digits.
    - Pincode is PositiveInt with validation of accept only 6 digits.
    - other feilds are optional only username is required as we are using DjangoUserModel.
    - Added REQUIRED_FIELDS to define required feilds.
    """

    phone_validator = [
        MinValueValidator(7000000000, message='Invalid Phone Number'),
        MaxValueValidator(9999999999, message='Invalid Phone Number')
    ]

    pincode_validator = [
        MinValueValidator(100000, message='Invalid Pincode'),
        MaxValueValidator(999999, message='Invalid Pincode')
    ]

    full_name_validator = [
        RegexValidator('^[a-zA-Z]+ [a-zA-Z]+$', 'Invalid Full Name')
    ]

    USER_TYPE_CHOICES = ((1, "Admin"), (2, "Author"))

    full_name = fields.CharField(max_length=128,
                                 validators=full_name_validator)
    phone = fields.PositiveBigIntegerField(unique=True,
                                           validators=phone_validator)
    pincode = fields.PositiveIntegerField(validators=pincode_validator)
    user_type = fields.PositiveIntegerField(choices=USER_TYPE_CHOICES,
                                            default=USER_TYPE_CHOICES[0][0])
    address = fields.CharField(max_length=128, default='')
    city = fields.CharField(max_length=32, default='')
    state = fields.CharField(max_length=32, default='')
    country = fields.CharField(max_length=32, default='')

    REQUIRED_FIELDS = ['full_name', 'email', 'phone', 'pincode']
    '''
        - Email Must be unique to be used for login.
    '''
    class Meta(object):
        unique_together = ('email', )

    def __str__(self):
        return self.full_name
Esempio n. 4
0
class Progress(models.EpisodeSubrecord):
    _is_singleton = True

    cervical_dilation = fields.PositiveIntegerField(
        null=True,
        help_text="Cervical dilatation as at last examination",
    )

    synto_infusion = fields.BooleanField(
        default=False,
        help_text="Syntocinon infusion?",
    )
class EpiduralInsertion(models.EpisodeSubrecord):

    insertion_date_time = fields.DateTimeField(
        null=True,
        # default=timezone.now,  (causes an Opal APIerror if uncommented)
        help_text=
        "Date and time of the epidural insertion or epidural insertion attempt",
    )

    # TODO should ideally allow SNOMED codes to be embedded in the text
    insertion_record = fields.TextField(
        null=True,
        max_length=255,
        help_text="Free text clinical record of the intervention",
    )

    # TODO should ideally be SNOMEDized
    indication = fields.CharField(
        null=True,
        max_length=255,
        help_text="Description of the intervention",
    )

    number_of_attempts = fields.PositiveIntegerField(
        default=1,
        help_text="The number of discrete epidural insertion attempts",
    )

    # TODO should ideally be SNOMEDized
    # TODO consider a default value? "no immediate complications"
    complications = fields.CharField(
        blank=True,
        null=True,
        max_length=255,
        help_text="Complications caused by the epidural insertion",
    )

    # TODO should ideally be SNOMEDized
    # TODO any other options @TimCKnowles?
    OUTCOME_CHOICES = (
        ("SUCCESS", "Successful epidural insertion and effective analgesia"),
        ("INEFFECTIVE", "Successful insertion of epidural catheter"),
        ("DURAL PUNCTURE", "Epidural insertion caused dural puncture"),
        ("FAILURE", "Failed epidural insertion"),
    )
    outcome = fields.CharField(
        choices=OUTCOME_CHOICES,
        blank=True,
        null=True,
        help_text="Outcome of the epidural insertion attempt",
        max_length=255,
    )
Esempio n. 6
0
class NeuraxialDrugs(models.EpisodeSubrecord):
    _is_singleton = True

    spinal_opiate = ForeignKeyOrFreeText(
        SpinalOpiate,
    )

    spinal_opiate_dose = fields.PositiveIntegerField(
        null=True,
        blank=True,
    )

    local_anaesthetic_spinal = ForeignKeyOrFreeText(
        SpinalLocal,
    )

    spinal_local_anaesthetic_volume = fields.PositiveIntegerField(
        null=True,
        blank=True,
    )

    epidural_opiate = ForeignKeyOrFreeText(
        EpiduralOpiate,
    )

    epidural_opiate_dose = fields.PositiveIntegerField(
        null=True,
        blank=True,
    )

    local_anaesthetic_epidural = ForeignKeyOrFreeText(
        EpiduralLocal,
    )

    epidural_local_anaesthetic_volume = fields.PositiveIntegerField(
        null=True,
        blank=True,
    )
Esempio n. 7
0
class Registration(Model):
    camp = ForeignKey(Camp, on_delete=CASCADE)
    clan = ForeignKey(Clan, on_delete=PROTECT)
    telephone = fields.CharField(max_length=100)
    contact_name = fields.CharField(max_length=100)
    email = fields.EmailField(max_length=100)
    comment = fields.TextField(max_length=1000, null=True, blank=True)
    paid = fields.DecimalField(decimal_places=2, max_digits=6, default=0)
    rules_accepted = fields.BooleanField(default=False,
                                         validators=[validate_true])
    present_participants = fields.PositiveIntegerField(null=True)

    def get_price(self):
        price = 0
        for info in self.ticketinfo_set.all():
            price += info.quantity * info.fee.price
        return price

    def get_quantity(self):
        quantity = 0
        for info in self.ticketinfo_set.all():
            quantity += info.quantity
        return quantity

    def get_quantities(self):
        quantities = list()
        for fee in self.camp.fee_set.all().order_by('pk'):
            value = 0
            for info in self.ticketinfo_set.all():
                if info.fee == fee:
                    value = info.quantity
            quantities.append(value)
        return quantities

    def get_ticket_count(self):
        tickets = list()
        for info in self.ticketinfo_set.all():
            tickets.extend(info.ticket_set.all())
        return len(tickets)

    def get_registrated_participant_count(self):
        count = 0
        for info in self.ticketinfo_set.all():
            for ticket in info.ticket_set.all():
                if ticket.registrated:
                    count += 1
        return count

    def __str__(self):
        return "Registration from {}".format(self.clan.name)
Esempio n. 8
0
class EpiduralRequest(models.EpisodeSubrecord):
    _is_singleton = True

    # 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)",
    )

    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",)
Esempio n. 9
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",
    )
Esempio n. 10
0
class Image(_Model):
    from django.contrib.contenttypes.fields import GenericForeignKey as _GenericForeign
    from django.contrib.contenttypes.models import ContentType as _Type
    from django.db.models.fields.files import ImageField as _image
    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

    content_type = _related.ForeignKey(_Type,
                                       on_delete=_deletion.CASCADE,
                                       verbose_name="Модель")
    object_id = _field.PositiveIntegerField(verbose_name="Ключ")
    content_object = _GenericForeign()

    def computed_folder(self, file_name):
        import uuid
        from app.base.helpers import snake
        extension = file_name.split('.')[-1]

        return "%s/%d/%s" % (snake(self.content_type.model_class().__name__),
                             self.object_id, "%s.%s" %
                             (uuid.uuid4(), extension))

    image = _image("Изображение", null=True, upload_to=computed_folder)

    # Can be empty...
    description = _field.CharField(verbose_name="Описание",
                                   null=True,
                                   blank=True,
                                   max_length=512)

    def __str__(self):
        return "Изображение для %s [№ %d]" % (self.content_type,
                                              self.object_id)

    class Meta:
        verbose_name = "Изображение"
        verbose_name_plural = "Изображения"
Esempio n. 11
0
 def rel_db_type(self, connection):
     return fields.PositiveIntegerField().db_type(connection=connection)
Esempio n. 12
0
class Technique(models.EpisodeSubrecord):
    _is_singleton = True

    POSITION_CHOICES = (
        ('Sitting', 'Sitting',),
        ('Lateral', 'Lateral',),
    )
    LEVEL_CHOICES = (
        ('L2/3', 'L2/3',),
        ('L3/4', 'L3/4',),
        ('L4/5', 'L4/5',),
        ('Other', 'Other',),
    )

    APPROACH_CHOICES = (
        ('Midline', 'Midline',),
        ('Paramedian', 'Paramedian',),
    )

    TUOHY_NEEDLE_CHOICES = (
        ('16G', '16G',),
        ('18G', '18G',),
    )

    SPINAL_NEEDLE_CHOICES = (
        ('26G', '26G',),
        ('27G', '27G',),
    )

    LOR_CHOICES = (
        ('Saline', 'Saline',),
        ('Air', 'Air',),
    )

    CATHETER_IN_EPIDURAL_SPACE_CHOICES = (
        ('2 cm', '2 cm',),
        ('3 cm', '3 cm',),
        ('4 cm', '4 cm',),
        ('5 cm', '5 cm',),
        ('6 cm', '6 cm',),
    )

    LIDOCAINE_CHOICES = (
        ('1 %', '1 %',),
        ('2 %', '2 %',),
    )

    patient_position  = fields.CharField(
        choices=POSITION_CHOICES,
        blank=True, null=True,
        max_length=255,
    )

    level  = fields.CharField(
        choices=LEVEL_CHOICES,
        blank=True, null=True,
        max_length=255,
    )

    approach  = fields.CharField(
        choices=APPROACH_CHOICES,
        blank=True, null=True,
        max_length=255,
    )

    lidocaine  = fields.CharField(
        choices=LIDOCAINE_CHOICES,
        blank=True, null=True,
        max_length=255,
    )

    lidocaine_volume = fields.PositiveIntegerField(
        default=3,
    )

    tuohy_needle_choices = fields.CharField(
        choices=TUOHY_NEEDLE_CHOICES,
        blank=True, null=True,
        max_length=255,
    )

    spinal_needle_choices = fields.CharField(
        choices=SPINAL_NEEDLE_CHOICES,
        blank=True, null=True,
        max_length=255,
    )

    loss_of_resistance = fields.CharField(
        choices=LOR_CHOICES,
        blank=True, null=True,
        max_length=255,
    )

    depth_of_epidural_space = fields.PositiveIntegerField(
        default=3,

    )

    catheter_length_in_epidural_space = fields.CharField(
        choices=CATHETER_IN_EPIDURAL_SPACE_CHOICES,
        blank=True, null=True,
        max_length=255,
        default=3,
    )