Skip to content

Commit

Permalink
feat: appointment model (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
Muchogoc committed Mar 10, 2022
1 parent b6fde2f commit 8198624
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
"mycarehub.authority.apps.AuthorityConfig",
"mycarehub.communities.apps.CommunityConfig",
"mycarehub.screeningtools.apps.ScreeningtoolsConfig",
"mycarehub.appointments.apps.AppointmentsConfig",
]
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS

Expand Down
Empty file.
10 changes: 10 additions & 0 deletions mycarehub/appointments/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.contrib import admin

from mycarehub.common.admin import BaseAdmin

from .models import Appointment


@admin.register(Appointment)
class AppointmentAdmin(BaseAdmin):
pass
5 changes: 5 additions & 0 deletions mycarehub/appointments/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class AppointmentsConfig(AppConfig):
name = "mycarehub.appointments"
51 changes: 51 additions & 0 deletions mycarehub/appointments/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Generated by Django 3.2.12 on 2022-03-10 07:36

from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import mycarehub.common.models.base_models
import mycarehub.utils.general_utils
import uuid


class Migration(migrations.Migration):

initial = True

dependencies = [
('clients', '0027_alter_servicerequest_request_type'),
('common', '0016_auto_20220215_1721'),
('staff', '0003_auto_20220215_1157'),
]

operations = [
migrations.CreateModel(
name='Appointment',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('active', models.BooleanField(default=True)),
('created', models.DateTimeField(default=django.utils.timezone.now)),
('created_by', models.UUIDField(blank=True, null=True)),
('updated', models.DateTimeField(default=django.utils.timezone.now)),
('updated_by', models.UUIDField(blank=True, null=True)),
('deleted_at', models.DateTimeField(blank=True, null=True)),
('appointment_type', models.CharField(max_length=36)),
('status', models.CharField(max_length=36)),
('reason', models.TextField(blank=True, max_length=1024, null=True)),
('provider', models.CharField(blank=True, help_text='Name of individual conducting the appointment for when the staff is not in our system', max_length=36, null=True)),
('date', models.DateField()),
('start_time', models.TimeField()),
('end_time', models.TimeField()),
('client', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='clients.client')),
('organisation', models.ForeignKey(default=mycarehub.utils.general_utils.default_organisation, on_delete=django.db.models.deletion.PROTECT, related_name='appointments_appointment_related', to='common.organisation')),
('staff', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='staff.staff')),
],
options={
'ordering': ('-updated', '-created'),
'abstract': False,
},
managers=[
('objects', mycarehub.common.models.base_models.AbstractBaseManager()),
],
),
]
Empty file.
36 changes: 36 additions & 0 deletions mycarehub/appointments/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from django.db import models
from django.utils.translation import gettext_lazy as _

from mycarehub.clients.models import Client
from mycarehub.common.models import AbstractBase
from mycarehub.staff.models import Staff


class Appointment(AbstractBase):
"""
Appointment stores information of a scheduled day and time
for an client to be evaluated or treated by a physician
or other licensed health care professional.
It is referenced from the Open MRS appointment data model
"""

appointment_type = models.CharField(max_length=36)
status = models.CharField(max_length=36)
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)
provider = models.CharField(
max_length=36,
help_text=_(
"Name of individual conducting the appointment for when the staff is not in our system"
),
null=True,
blank=True,
)
date = models.DateField()
start_time = models.TimeField()
end_time = models.TimeField()

def __str__(self) -> str:
return f"{self.client} - {self.appointment_type} - {self.status}"
Empty file.
19 changes: 19 additions & 0 deletions mycarehub/appointments/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import pytest
from model_bakery import baker

from mycarehub.appointments.models import Appointment
from mycarehub.clients.models import Client

pytestmark = pytest.mark.django_db


def test_appointments_str(user):
client = baker.make(Client, user=user)
appointment = baker.make(
Appointment,
appointment_type="consultation",
status="completed",
client=client,
)

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

0 comments on commit 8198624

Please sign in to comment.