-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |