Skip to content

Commit

Permalink
chore: add appointment status choices and shared appointment identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
Muchogoc committed Mar 11, 2022
1 parent 8198624 commit f7354d1
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 6 deletions.
38 changes: 38 additions & 0 deletions mycarehub/appointments/migrations/0002_auto_20220311_1137.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Generated by Django 3.2.12 on 2022-03-11 08:37

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('appointments', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='appointment',
name='appointment_uuid',
field=models.UUIDField(blank=True, editable=False, help_text='Identifier that is shared between KenyaEMR and MyCareHub', null=True),
),
migrations.AlterField(
model_name='appointment',
name='date',
field=models.DateField(blank=True, null=True),
),
migrations.AlterField(
model_name='appointment',
name='end_time',
field=models.TimeField(blank=True, null=True),
),
migrations.AlterField(
model_name='appointment',
name='start_time',
field=models.TimeField(blank=True, null=True),
),
migrations.AlterField(
model_name='appointment',
name='status',
field=models.CharField(choices=[('SCHEDULED', 'Scheduled'), ('RESCHEDULED', 'Rescheduled'), ('WAITING', 'Waiting'), ('MISSED', 'Missed'), ('COMPLETED', 'Completed'), ('INCONSULTATION', 'In Consultation'), ('WALKIN', 'Walk In'), ('CANCELLED', 'Cancelled'), ('NEEDSRESCHEDULE', 'Needs Reschedule')], max_length=36),
),
]
26 changes: 22 additions & 4 deletions mycarehub/appointments/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.db import models
from django.db.models.enums import TextChoices
from django.utils.translation import gettext_lazy as _

from mycarehub.clients.models import Client
Expand All @@ -15,8 +16,25 @@ class Appointment(AbstractBase):
It is referenced from the Open MRS appointment data model
"""

class AppointmentStatus(TextChoices):
SCHEDULED = "SCHEDULED", _("Scheduled")
RESCHEDULED = "RESCHEDULED", _("Rescheduled")
WAITING = "WAITING", _("Waiting")
MISSED = "MISSED", _("Missed")
COMPLETED = "COMPLETED", _("Completed")
INCONSULTATION = "INCONSULTATION", _("In Consultation")
WALKIN = "WALKIN", _("Walk In")
CANCELLED = "CANCELLED", _("Cancelled")
NEEDSRESCHEDULE = "NEEDSRESCHEDULE", _("Needs Reschedule")

appointment_uuid = models.UUIDField(
editable=False,
null=True,
blank=True,
help_text=_("Identifier that is shared between KenyaEMR and MyCareHub"),
)
appointment_type = models.CharField(max_length=36)
status = models.CharField(max_length=36)
status = models.CharField(max_length=36, choices=AppointmentStatus.choices)
reason = models.TextField(max_length=1024, null=True, blank=True)
client = models.ForeignKey(Client, on_delete=models.PROTECT)
staff = models.ForeignKey(Staff, on_delete=models.PROTECT, null=True, blank=True)
Expand All @@ -28,9 +46,9 @@ class Appointment(AbstractBase):
null=True,
blank=True,
)
date = models.DateField()
start_time = models.TimeField()
end_time = models.TimeField()
date = models.DateField(null=True, blank=True)
start_time = models.TimeField(null=True, blank=True)
end_time = models.TimeField(null=True, blank=True)

def __str__(self) -> str:
return f"{self.client} - {self.appointment_type} - {self.status}"
4 changes: 2 additions & 2 deletions mycarehub/appointments/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def test_appointments_str(user):
appointment = baker.make(
Appointment,
appointment_type="consultation",
status="completed",
status="COMPLETED",
client=client,
)

assert str(appointment) == f"{client} - consultation - completed"
assert str(appointment) == f"{client} - consultation - COMPLETED"

0 comments on commit f7354d1

Please sign in to comment.