Skip to content

Commit

Permalink
feat: add basic client models (#15)
Browse files Browse the repository at this point in the history
This lays down the groundwork for invite APIs
  • Loading branch information
ngurenyaga committed Nov 9, 2021
1 parent f2f5a76 commit 686bbf0
Show file tree
Hide file tree
Showing 16 changed files with 879 additions and 8 deletions.
3 changes: 2 additions & 1 deletion config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pathlib import Path

import environ
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from google.cloud import secretmanager

ROOT_DIR = Path(__file__).resolve(strict=True).parent.parent.parent
Expand Down Expand Up @@ -102,6 +102,7 @@
"mycarehub.users.apps.UsersConfig",
"mycarehub.common.apps.CommonConfig",
"mycarehub.content.apps.ContentConfig",
"mycarehub.clients.apps.ClientsConfig",
]
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS

Expand Down
3 changes: 0 additions & 3 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
r"^favicon\.ico$",
RedirectView.as_view(url=settings.STATIC_URL + "favicon.ico", permanent=True),
),
<<<<<<< HEAD
path(
"graphql", csrf_exempt(DRFAuthenticatedGraphQLView.as_view(graphiql=True)), name="graphql"
),
Expand All @@ -47,7 +46,6 @@
# For anything not caught by a more specific rule above, hand over to
# Wagtail's serving mechanism
re_path(r"content", include(wagtail_urls)),
=======
path("graphql", csrf_exempt(GraphQLView.as_view(graphiql=True)), name="graphql"),
# content management
path("admin/", include(wagtailadmin_urls)),
Expand All @@ -57,7 +55,6 @@
# Wagtail's serving mechanism
# from wagtail.core import urls as wagtail_urls
# re_path(r"", include(wagtail_urls)),
>>>>>>> 596fcae (feat: add graphene and wagtail dependencies (#5))
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
if settings.DEBUG:
# Static file serving when using Gunicorn + Uvicorn for local web socket development
Expand Down
Empty file added mycarehub/clients/__init__.py
Empty file.
42 changes: 42 additions & 0 deletions mycarehub/clients/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from django.contrib import admin

from mycarehub.common.admin import BaseAdmin

from .models import (
Client,
ClientFacility,
Identifier,
RelatedPerson,
SecurityQuestion,
SecurityQuestionResponse,
)


@admin.register(Identifier)
class IdentifierAdmin(BaseAdmin):
pass


@admin.register(SecurityQuestion)
class SecurityQuestionAdmin(BaseAdmin):
pass


@admin.register(SecurityQuestionResponse)
class SecurityQuestionResponseAdmin(BaseAdmin):
pass


@admin.register(RelatedPerson)
class RelatedPersonAdmin(BaseAdmin):
pass


@admin.register(Client)
class ClientAdmin(BaseAdmin):
pass


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


class ClientsConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "mycarehub.clients"
192 changes: 192 additions & 0 deletions mycarehub/clients/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
# Generated by Django 3.2.9 on 2021-11-08 17:23

from django.conf import settings
import django.contrib.postgres.fields
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import mycarehub.common.models.base_models
import uuid


class Migration(migrations.Migration):

initial = True

dependencies = [
('common', '0003_auto_20211108_2023'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='Client',
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)),
('client_type', models.CharField(choices=[('PMTCT', 'PMTCT'), ('OTZ', 'OTZ'), ('OTZ_PLUS', 'OTZ Plus'), ('HVL', 'HVL'), ('OVC', 'OVC'), ('DREAMS', 'DREAMS'), ('HIGH_RISK', 'High Risk Clients'), ('SPOUSES', 'SPOUSES'), ('YOUTH', 'Youth')], max_length=64)),
('enrollment_date', models.DateTimeField(auto_now_add=True)),
('fhir_patient_id', models.TextField(blank=True, null=True, unique=True)),
('emr_health_record_id', models.TextField(blank=True, null=True, unique=True)),
('treatment_buddy', models.TextField(blank=True)),
('counselled', models.BooleanField(default=False)),
('languages', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(blank=True, choices=[('en', 'English'), ('sw', 'Swahili')], max_length=150, null=True), blank=True, null=True, size=None)),
('addresses', models.ManyToManyField(related_name='client_addresses', to='common.Address')),
('chv', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='client_chvs', to=settings.AUTH_USER_MODEL)),
('contacts', models.ManyToManyField(related_name='client_contacts', to='common.Contact')),
('current_facility', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='common.facility')),
],
options={
'ordering': ('-updated', '-created'),
'abstract': False,
},
managers=[
('objects', mycarehub.common.models.base_models.AbstractBaseManager()),
],
),
migrations.CreateModel(
name='SecurityQuestion',
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)),
('stem', models.TextField()),
('description', models.TextField()),
('sequence', models.IntegerField(default=0)),
('response_type', models.CharField(choices=[('TEXT', 'Text Response'), ('DATE', 'Date Response'), ('NUMBER', 'Number Response'), ('BOOLEAN', 'Boolean Response')], max_length=32)),
('organisation', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='clients_securityquestion_related', to='common.organisation')),
],
options={
'ordering': ('-updated', '-created'),
'abstract': False,
},
managers=[
('objects', mycarehub.common.models.base_models.AbstractBaseManager()),
],
),
migrations.CreateModel(
name='RelatedPerson',
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)),
('first_name', models.TextField()),
('last_name', models.TextField()),
('other_name', models.TextField()),
('date_of_birth', models.DateField(blank=True, null=True)),
('gender', models.CharField(choices=[('MALE', 'Male'), ('FEMALE', 'Female')], max_length=16)),
('relationship_type', models.CharField(choices=[('SPOUSE', 'Spouse'), ('NEXT_OF_KIN', 'Next of kin'), ('CHILD', 'Child'), ('PARENT', 'Parent'), ('SIBLING', 'Sibling'), ('NEIGHBOUR', 'Neighbour'), ('OTHER', 'Other')], max_length=64)),
('addresses', models.ManyToManyField(related_name='related_person_addresses', to='common.Address')),
('contacts', models.ManyToManyField(related_name='related_person_contacts', to='common.Contact')),
('organisation', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='clients_relatedperson_related', to='common.organisation')),
],
options={
'ordering': ('-updated', '-created'),
'abstract': False,
},
managers=[
('objects', mycarehub.common.models.base_models.AbstractBaseManager()),
],
),
migrations.CreateModel(
name='Identifier',
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)),
('identifier_type', models.CharField(choices=[('CCC', 'Comprehensive Care Clinic Number'), ('NATIONAL_ID', 'National ID Document'), ('BIRTH_CERTIFICATE', 'Birth Certificate'), ('PASSPORT', 'Passport'), ('UNIQUE', 'Unique Identifier')], max_length=64)),
('identifier_value', models.TextField()),
('identifier_use', models.CharField(choices=[('OFFICIAL', 'Official Identifier'), ('TEMPORARY', 'Temporary Identifier'), ('OLD', 'Old (retired) Identifier')], max_length=64)),
('description', models.TextField()),
('valid_from', models.DateTimeField(auto_now_add=True)),
('valid_to', models.DateTimeField(blank=True, null=True)),
('is_primary_identifier', models.BooleanField(default=False)),
('organisation', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='clients_identifier_related', to='common.organisation')),
],
options={
'ordering': ('-updated', '-created'),
'abstract': False,
},
managers=[
('objects', mycarehub.common.models.base_models.AbstractBaseManager()),
],
),
migrations.CreateModel(
name='ClientFacility',
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)),
('assigned', models.DateTimeField()),
('transferred_out', models.DateTimeField(blank=True, null=True)),
('client', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='clients.client')),
('facility', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='common.facility')),
('organisation', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='clients_clientfacility_related', to='common.organisation')),
],
options={
'ordering': ('-updated', '-created'),
'abstract': False,
},
managers=[
('objects', mycarehub.common.models.base_models.AbstractBaseManager()),
],
),
migrations.AddField(
model_name='client',
name='identifiers',
field=models.ManyToManyField(related_name='client_identifiers', to='clients.Identifier'),
),
migrations.AddField(
model_name='client',
name='organisation',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='clients_client_related', to='common.organisation'),
),
migrations.AddField(
model_name='client',
name='related_persons',
field=models.ManyToManyField(related_name='client_related_persons', to='clients.RelatedPerson'),
),
migrations.AddField(
model_name='client',
name='user',
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL),
),
migrations.CreateModel(
name='SecurityQuestionResponse',
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)),
('timestamp', models.DateTimeField(auto_now_add=True)),
('response', models.TextField()),
('organisation', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='clients_securityquestionresponse_related', to='common.organisation')),
('question', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='clients.securityquestion')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
],
options={
'unique_together': {('user', 'question')},
},
managers=[
('objects', mycarehub.common.models.base_models.AbstractBaseManager()),
],
),
]
Empty file.
Loading

0 comments on commit 686bbf0

Please sign in to comment.