Skip to content

Commit

Permalink
ref: appointment model changes
Browse files Browse the repository at this point in the history
- remove appointment uuid
- remove appointment status
- remove start time and end time
- add appointment id
  • Loading branch information
Muchogoc committed Apr 6, 2022
1 parent e0cf52e commit 5f09dc4
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 21 deletions.
38 changes: 38 additions & 0 deletions mycarehub/appointments/migrations/0005_auto_20220402_1226.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Generated by Django 3.2.12 on 2022-04-02 09:26

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('appointments', '0004_appointment_has_rescheduled_appointment'),
]

operations = [
migrations.RemoveField(
model_name='appointment',
name='appointment_type',
),
migrations.RemoveField(
model_name='appointment',
name='appointment_uuid',
),
migrations.RemoveField(
model_name='appointment',
name='end_time',
),
migrations.RemoveField(
model_name='appointment',
name='start_time',
),
migrations.RemoveField(
model_name='appointment',
name='status',
),
migrations.AddField(
model_name='appointment',
name='appointment_id',
field=models.CharField(blank=True, editable=False, help_text='Identifier that is shared between KenyaEMR and MyCareHub', max_length=128, null=True),
),
]
22 changes: 22 additions & 0 deletions mycarehub/appointments/migrations/0006_auto_20220404_1111.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 3.2.12 on 2022-04-04 08:11

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('appointments', '0005_auto_20220402_1226'),
]

operations = [
migrations.RemoveField(
model_name='appointment',
name='appointment_id',
),
migrations.AddField(
model_name='appointment',
name='external_id',
field=models.CharField(blank=True, editable=False, help_text='Identifier that is shared between KenyaEMR and MyCareHub', max_length=128, null=True, unique=True),
),
]
22 changes: 4 additions & 18 deletions mycarehub/appointments/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
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 @@ -16,25 +15,14 @@ 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 = "IN_CONSULTATION", _("IN_CONSULTATION")
WALKIN = "WALKIN", _("WALK IN")
CANCELLED = "CANCELLED", _("CANCELLED")
NEEDSRESCHEDULE = "NEEDS_RESCHEDULE", _("NEEDS_RESCHEDULE")

appointment_uuid = models.UUIDField(
external_id = models.CharField(
max_length=128,
editable=False,
null=True,
blank=True,
unique=True,
help_text=_("Identifier that is shared between KenyaEMR and MyCareHub"),
)
appointment_type = 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 @@ -48,9 +36,7 @@ class AppointmentStatus(TextChoices):
blank=True,
)
date = models.DateField(null=True, blank=True)
start_time = models.TimeField(null=True, blank=True)
end_time = models.TimeField(null=True, blank=True)
has_rescheduled_appointment = models.BooleanField(default=False)

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

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

0 comments on commit 5f09dc4

Please sign in to comment.