Exemplo n.º 1
0
class EpiduralInsertion(models.EpisodeSubrecord):
    _is_singleton = True

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

    #needs to be the current user
    performed_by = fields.TextField(
        null=True,
        blank=True,

    )

    #pick from list of anaesthetist users
    supervised_by = fields.TextField(
        null=True,
        blank=True,

    )

    procedure = ForeignKeyOrFreeText(
        ProcedureType,
        help_text="Free text clinical record of the intervention"
    )


    # TODO should ideally be SNOMEDized
    indication = ForeignKeyOrFreeText(
        Indication,
        help_text="Description of the indication",
    )
Exemplo n.º 2
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
Exemplo n.º 3
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)
Exemplo n.º 4
0
class Code(models.Model):
    org_text = fields.TextField()
    md_text = fields.TextField()
    c_time = fields.DateTimeField(auto_now_add=True)
    u_time = fields.DateTimeField(auto_now=True)

    class Meta:
        ordering = ('-c_time', )
Exemplo n.º 5
0
class SocCode(models.models.Model):
    soc90 = fields.CharField(max_length=200)
    soc2000 = fields.CharField(max_length=200)
    title = fields.CharField(max_length=255)
    short_desc = fields.TextField()
    entry = fields.TextField()
    tasks = fields.TextField()
    related = fields.TextField()
Exemplo n.º 6
0
class OccupationalHistory(models.PatientSubrecord):
    _title = "Occupational History"
    job_name = fields.CharField(max_length=250, blank=True, null=True)
    job_tasks = fields.TextField(blank=True, null=True)
    employer_output = fields.CharField(
        max_length=250, blank=True,
        null=True)  # change label to be what did you make
    start_year = fields.CharField(max_length=4, blank=True, null=True)
    end_year = fields.CharField(max_length=4, blank=True, null=True)
    address = fields.TextField(blank=True, null=True)
Exemplo n.º 7
0
class OccupationalHistory(models.PatientSubrecord):
    _title = "Occupational History"
    job_name = fields.CharField(max_length=250, blank=True, null=True)
    soc_job = models.ForeignKeyOrFreeText(SocJob, verbose_name="Job name")
    job_tasks = fields.TextField(blank=True, null=True)
    employer_output = fields.CharField(
        max_length=250, blank=True,
        null=True)  # change label to be what did you make
    start_year = fields.CharField(max_length=4, blank=True, null=True)
    end_year = fields.CharField(max_length=4, blank=True, null=True)
    address = fields.TextField(blank=True, null=True)
Exemplo n.º 8
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."""
Exemplo n.º 9
0
class ApiSitemapVersion(object):
    class Meta:
        get_latest_by = 'id'
    
    version             = fields.TextField()
    depreciation_date   = fields.DateField(blank=True, null=True)
    content             = JSONField(default="{}")
Exemplo n.º 10
0
class EmergencyDepartmentTriage(models.EpisodeSubrecord):
    _is_singleton = True
    reason = fields.TextField(blank=True,
                              null=True,
                              verbose_name="Reason For Attendance")
    mts_score = ForeignKeyOrFreeText(ManchesterTriageScore,
                                     verbose_name="Manchester Triage Score")
Exemplo n.º 11
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", )}
Exemplo n.º 12
0
class Blog(models.Model):
    title = fields.CharField(max_length=100)
    date = fields.DateField()
    content = fields.TextField(default='no content for this entry')

# to show in the admin console the object from database with the title instead of object 1, object 2, ...
    def __str__(self):
        return self.title
Exemplo n.º 13
0
class PerformerNumber(djangomodels.Model):
    user = djangomodels.ForeignKey(models.User, on_delete=djangomodels.CASCADE)
    number = fields.TextField()

    @property
    def dpb_pin(self):
        print("This needs to not be hardcoded")
        return 100000
Exemplo n.º 14
0
class Mood(models.Model):
    date = fields.DateField()
    title = fields.CharField(max_length=50)
    image = models.ImageField()
    description = fields.TextField()

    def __str__(self):
        return str(self.date)
Exemplo n.º 15
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)
class Migration(migrations.Migration):

    dependencies = [
        ('post', '0026_auto_20200414_2220'),
    ]

    operations = [
        migrations.AlterField(
            model_name='post',
            name='excerpt_text',
            field=fields.TextField(),
        ),
        migrations.AlterField(
            model_name='post',
            name='text',
            field=fields.TextField(),
        ),
    ]
Exemplo n.º 17
0
class Task(models.Model):
    text = f.TextField(null=False)
    date_add = f.DateTimeField(auto_now_add=True)
    date_complete = f.DateTimeField(blank=True, null=True)

    # user = models.ForeignKey(User ,on_delete=models.CASCADE)

    def __str__(self):
        return f' Задача №{self.id}  {self.text} '
Exemplo n.º 18
0
class Choice(models.Model):
    name = fields.CharField(max_length=200)
    key = fields.CharField(max_length=200, unique=True)
    description = fields.TextField(default='', blank=True)
    collection = models.ForeignKey(Collection, on_delete=models.CASCADE)
    image_url = fields.URLField(blank=True, null=True)

    def __str__(self):
        return self.name
Exemplo n.º 19
0
class WinPathResult(models.EpisodeSubrecord):
    _read_only = True
    _sort = 'profile_code'

    lab_number = fields.CharField(max_length=200, blank=True, null=True)
    visible_in_list = fields.BooleanField(default=False)
    profile_code = fields.CharField(max_length=200, blank=True, null=True)
    profile_description = fields.CharField(max_length=200,
                                           blank=True,
                                           null=True)
    request_datetime = fields.DateTimeField(blank=True, null=True)
    observation_datetime = fields.DateTimeField(blank=True, null=True)
    last_edited = fields.DateTimeField(blank=True, null=True)
    result_status = fields.CharField(max_length=200, blank=True, null=True)
    observations = fields.TextField(blank=True, null=True)

    @classmethod
    def create_or_update_from_gloss(klass, identifier, data):
        lab_number = data['lab_number']
        print 'lab number', lab_number
        print 'identifier', identifier

        # First, check if we have this lab number...
        if klass.objects.filter(lab_number=lab_number).count() > 0:
            result = klass.objects.get(lab_number=lab_number)
            episode = result.episode
            patient = episode.patient
        else:
            patient = models.Patient.objects.first()
            #            patient = models.Patient.objects.all()[1]
            if patient.episode_set.count() == 0:
                episode = patient.create_episode()
                episode.active = True
                episode.save()
            else:
                episode = patient.episode_set.first()
            result = klass(episode=episode, lab_number=lab_number)

        def date_from_key(prop):
            return make_aware(
                datetime.datetime.strptime(data[prop], '%Y/%m/%d %H:%M'))

        result.profile_code = data['profile_code']
        result.profile_description = data['profile_description']
        result.request_datetime = date_from_key('request_datetime')
        result.observation_datetime = date_from_key('observation_datetime')
        result.last_edited = date_from_key('last_edited')
        result.result_status = data.get('result_status', None)
        result.observations = data['observations']
        result.save()

        return

    def to_dict(self, user):
        d = super(WinPathResult, self).to_dict(user)
        d['observations'] = json.loads(self.observations)
        return d
Exemplo n.º 20
0
class Notification(Model):
    time = fields.DateTimeField(blank=True, null=True)
    message = fields.TextField(blank=True, null=True)
    readed = fields.BooleanField(default=False)
    kind = fields.CharField(max_length=50, blank=True,
                            null=True)  # Expected: hazard, assignment
    user = models.ForeignKey(User, blank=True, null=True)

    def mark_as_read(self):
        self.readed = True
        self.save()
class Migration(migrations.Migration):
    dependencies = [
        ('post', '0017_auto_20200220_1914'),
    ]

    operations = [
        migrations.AlterField(
            model_name='post',
            name='description',
            field=fields.TextField(),
        ),
    ]
Exemplo n.º 22
0
class Event(models.Model):

    title = fields.CharField(max_length=100, verbose_name=_('Title and venue'))
    description = fields.TextField(blank=True,
                                   verbose_name=_('Long description'))
    date = fields.DateTimeField(verbose_name=_('Date of the event'))
    tickets_info = fields.URLField(blank=True,
                                   verbose_name=_('Link to buy tickets'))

    class Meta:
        verbose_name = 'event'
        verbose_name_plural = 'events'
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,
    )
Exemplo n.º 24
0
class Task(ModelBase):
    STATUS_LIST = [('DONE', 'DONE'), ('NOTDONE', 'NOTDONE'),
                   ('DELETED', 'DELETED')]

    owner = models.ForeignKey(User)
    name = fields.CharField(max_length=127)
    status = fields.CharField(max_length=127,
                              choices=STATUS_LIST,
                              default=STATUS_LIST[1][0])
    description = fields.TextField(null=True, blank=True)

    def __unicode__(self):
        return self.name
Exemplo n.º 25
0
class FileContent(models.Model):
    id = fields.AutoField(primary_key=True)

    create_time = fields.DateTimeField(default=timezone.now)
    file = models.ForeignKey(SomeFile,
                             on_delete=models.CASCADE,
                             blank=True,
                             null=True)

    content = fields.TextField(blank=True, default="")

    def append_string(self, string: str):
        self.content += ('\n' + string.strip())
        self.save()
Exemplo n.º 26
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)
Exemplo n.º 27
0
class Task(models.Model):
    class Meta:
        verbose_name = _('task')
        verbose_name_plural = _('tasks')

    text = f.TextField(_('text'), help_text=_('what to do'))
    date_added = f.DateTimeField(auto_now_add=True)
    date_completed = f.DateTimeField(blank=True, null=True)
    user = models.ForeignKey(User, on_delete=models.CASCADE)

    def get_absolute_url(self):
        return reverse('task-show', kwargs=dict(task_id=self.id))

    def __str__(self):
        return self.text
Exemplo n.º 28
0
class EpiduralFollowUp(models.EpisodeSubrecord):
    _is_singleton = True
    time_of_follow_up = fields.DateTimeField(
        blank=True, null=True
    )
    performed_by = fields.TextField(
        null=True,
        blank=True,

    )
    headache = fields.BooleanField(default=False)
    has_not_mobilised = fields.BooleanField(default=False)
    weakness = fields.BooleanField(default=False)
    sensory_disturbance = fields.BooleanField(default=False)
    back_pain = fields.BooleanField(default=False)
    has_not_passed_urine = fields.BooleanField(default=False)
    itu_admission = fields.BooleanField(default=False)
    general_anaesthesia = fields.BooleanField(default=False)
    home_before_follow_up = fields.BooleanField(default=False)
    post_natal_appointment_required = fields.BooleanField(default=False)
    other = fields.TextField(
        null=True,

    )
Exemplo n.º 29
0
class Note(models.Model):
    text = f.TextField()
    time_added = f.DateTimeField(auto_now_add=True)
    is_private = f.BooleanField()
    user = models.ForeignKey(auth.models.User, on_delete=models.CASCADE)

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.id = None

    def __str__(self):
        return self.text

    def get_absolute_url(self):
        return reverse('note-show', kwargs=dict(note_id=self.id))
Exemplo n.º 30
0
class Violation(_Model):
    employee = _related.ForeignKey(
        'holding.Employee',
        on_delete=_deletion.SET_NULL,
        null=True,
        blank=False,  # For admin panel?
        related_name="violations",
    )

    when = _field.DateTimeField("Когда")

    title = _field.CharField(
        verbose_name="Название нарушения",
        null=False,
        blank=False,
        max_length=128,
    )

    description = _field.TextField(
        verbose_name="Описание нарушения",
        null=True,
        blank=True,
    )

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

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

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

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

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

    def __str__(self):
        return self.title

    class Meta:
        verbose_name = "Нарушение"
        verbose_name_plural = "Нарушения"