Skip to content

Commit

Permalink
add pattern field for system model
Browse files Browse the repository at this point in the history
  • Loading branch information
saladgg committed Sep 2, 2021
1 parent ed1273f commit b620cd3
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions fahari/common/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class Meta:
class SystemForm(BaseModelForm):
field_order = (
"name",
"pattern",
"description",
"active",
)
Expand Down
18 changes: 18 additions & 0 deletions fahari/common/migrations/0019_system_pattern.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.6 on 2021-09-02 12:45

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('common', '0018_alter_facility_keph_level'),
]

operations = [
migrations.AddField(
model_name='system',
name='pattern',
field=models.CharField(choices=[('NONE', 'Add stock'), ('RESTROSPECTIVE_DATA_ENTRY', 'Retrospective data entry'), ('POINT_OF_CARE', 'Point of care'), ('HYBRID', 'Hybrid')], default='NONE', max_length=150),
),
]
18 changes: 18 additions & 0 deletions fahari/common/migrations/0020_alter_system_pattern.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.6 on 2021-09-02 12:49

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('common', '0019_system_pattern'),
]

operations = [
migrations.AlterField(
model_name='system',
name='pattern',
field=models.CharField(choices=[('NONE', 'None'), ('RESTROSPECTIVE_DATA_ENTRY', 'Retrospective data entry'), ('POINT_OF_CARE', 'Point of care'), ('HYBRID', 'Hybrid')], default='NONE', max_length=150),
),
]
15 changes: 15 additions & 0 deletions fahari/common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,21 @@ class System(AbstractBase):
"""List of systems used in the public sector e.g Kenya EMR."""

name = models.CharField(max_length=128, null=False, blank=False, unique=True)

NONE = "NONE"
RESTROSPECTIVE_DATA_ENTRY = "RESTROSPECTIVE_DATA_ENTRY"
POINT_OF_CARE = "POINT_OF_CARE"
HYBRID = "HYBRID"

PATTERN_IDS = [
(NONE, "None"),
(RESTROSPECTIVE_DATA_ENTRY, "Retrospective data entry"),
(POINT_OF_CARE, "Point of care"),
(HYBRID, "Hybrid"),
]

pattern = models.CharField(max_length=150, choices=PATTERN_IDS, default=NONE)

description = models.TextField()

def get_absolute_url(self):
Expand Down
2 changes: 2 additions & 0 deletions fahari/common/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ class SystemFormTest(LoggedInMixin, TestCase):
def test_create(self):
data = {
"name": fake.name()[:127],
"pattern": "NONE",
"description": fake.text(),
"organisation": self.global_organisation.pk,
}
Expand All @@ -429,6 +430,7 @@ def test_update(self):
data = {
"pk": system.pk,
"name": fake.name()[:127],
"pattern": "NONE",
"description": fake.text(),
"organisation": self.global_organisation.pk,
}
Expand Down

0 comments on commit b620cd3

Please sign in to comment.