Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add management command to load skills #1707

Merged
merged 3 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions care/facility/management/commands/load_dummy_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
management.call_command("load_data", "kerala")
management.call_command("load_medicines_data")
management.call_command("seed_data")
management.call_command("load_skill_data")

Check warning on line 29 in care/facility/management/commands/load_dummy_data.py

View check run for this annotation

Codecov / codecov/patch

care/facility/management/commands/load_dummy_data.py#L29

Added line #L29 was not covered by tests
management.call_command("loaddata", self.BASE_URL + "facility.json")
management.call_command("loaddata", self.BASE_URL + "cypress_users.json")
management.call_command("loaddata", self.BASE_URL + "facility_users.json")
Expand Down
59 changes: 59 additions & 0 deletions care/users/management/commands/load_skill_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
from django.core.management import BaseCommand

Check warning on line 1 in care/users/management/commands/load_skill_data.py

View check run for this annotation

Codecov / codecov/patch

care/users/management/commands/load_skill_data.py#L1

Added line #L1 was not covered by tests

from care.users.models import Skill

Check warning on line 3 in care/users/management/commands/load_skill_data.py

View check run for this annotation

Codecov / codecov/patch

care/users/management/commands/load_skill_data.py#L3

Added line #L3 was not covered by tests


class Command(BaseCommand):

Check warning on line 6 in care/users/management/commands/load_skill_data.py

View check run for this annotation

Codecov / codecov/patch

care/users/management/commands/load_skill_data.py#L6

Added line #L6 was not covered by tests
"""
Command to load default skills
"""

help = "Seed Data for Skills"

Check warning on line 11 in care/users/management/commands/load_skill_data.py

View check run for this annotation

Codecov / codecov/patch

care/users/management/commands/load_skill_data.py#L11

Added line #L11 was not covered by tests

def handle(self, *args, **options):
self.stdout.write("Seeding Skills Data... ", ending="")

Check warning on line 14 in care/users/management/commands/load_skill_data.py

View check run for this annotation

Codecov / codecov/patch

care/users/management/commands/load_skill_data.py#L13-L14

Added lines #L13 - L14 were not covered by tests

skills = [

Check warning on line 16 in care/users/management/commands/load_skill_data.py

View check run for this annotation

Codecov / codecov/patch

care/users/management/commands/load_skill_data.py#L16

Added line #L16 was not covered by tests
"Anesthetists",
"Cardiac Surgeon",
"Cardiologist",
"Dermatologist",
"Diabetologist",
"Emergency Medicine Physcian",
"Endocrinologist",
"Family Physcian",
"Gastroenterologist",
"General Medicine",
"General Surgeon",
"Hematologist",
"Intensivists",
"Medical Officer",
"Nephrologist",
"Neuro Surgeon",
"Neurologist",
"obstetrician and Gynecologists",
"Oncologist",
"Oncology Surgeon",
"Opthalmologists",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see a lot of plural words, can we switch to singular form?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"orthopaedic Surgeon",
"Orthopaedician",
"Otolaryngologist ( ENT )",
"Palliative care Physcian",
"Pathologists",
"Pediatrician",
"Physcian",
"Plastic Surgeon",
"Psychiatrists",
"Pulmonologists",
"Radio technician",
"Radiologist",
"Rheumatologist",
"Thoraco-Vascular Surgeon",
"Urologist",
]

Skill.objects.bulk_create(
[Skill(name=skill) for skill in skills], ignore_conflicts=True
)

self.stdout.write(self.style.SUCCESS("OK"))

Check warning on line 59 in care/users/management/commands/load_skill_data.py

View check run for this annotation

Codecov / codecov/patch

care/users/management/commands/load_skill_data.py#L59

Added line #L59 was not covered by tests
4 changes: 4 additions & 0 deletions docs/django-commands/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ All Django commands must be executed by invoking :code:`python manage.py`, so fo
| | | |
| | | Example Invocation: :code:`python manage.py seed_data` |
+---------------------+---------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| load_skill_data | None | This command loads default skills |
| | | |
| | | Example Invocation: :code:`python manage.py load_skill_data` |
+---------------------+---------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| summarize | None | The summary jobs are run by Celery every 10 mins, but we can force Django to summarize the current data and update the summary table with this command |
| | | |
| | | Example Invocation: :code:`python manage.py summarize` |
Expand Down
Loading