From b909ce64dc0e06c70594d17f2a51718bfc70d413 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Thu, 12 Sep 2024 13:21:26 +0530 Subject: [PATCH 1/6] Adds fields for Community Nurses log update --- care/facility/api/serializers/daily_round.py | 19 +++ ...te_dailyround_bladder_drainage_and_more.py | 147 ++++++++++++++++++ care/facility/models/daily_round.py | 122 +++++++++++++-- 3 files changed, 275 insertions(+), 13 deletions(-) create mode 100644 care/facility/migrations/0455_dailyround_appetite_dailyround_bladder_drainage_and_more.py diff --git a/care/facility/api/serializers/daily_round.py b/care/facility/api/serializers/daily_round.py index 46fea14d05..c7cdbc3a40 100644 --- a/care/facility/api/serializers/daily_round.py +++ b/care/facility/api/serializers/daily_round.py @@ -40,6 +40,25 @@ class DailyRoundSerializer(serializers.ModelSerializer): rounds_type = ChoiceField(choices=DailyRound.RoundsTypeChoice, required=True) + # Community Nurse's Log + + bowel_difficulty = ChoiceField( + choices=DailyRound.BowelDifficultyChoice, required=False + ) + bladder_drainage = ChoiceField( + choices=DailyRound.BladderDrainageChoice, required=False + ) + bladder_issue = ChoiceField(choices=DailyRound.BladderIssueChoice, required=False) + urination_frequency = ChoiceField( + choices=DailyRound.UrinationFrequencyChoice, required=False + ) + sleep = ChoiceField(choices=DailyRound.SleepChoice, required=False) + nutrition_route = ChoiceField( + choices=DailyRound.NutritionRouteChoice, required=False + ) + oral_issue = ChoiceField(choices=DailyRound.OralIssueChoice, required=False) + appetite = ChoiceField(choices=DailyRound.AppetiteChoice, required=False) + # Critical Care Components consciousness_level = ChoiceField( diff --git a/care/facility/migrations/0455_dailyround_appetite_dailyround_bladder_drainage_and_more.py b/care/facility/migrations/0455_dailyround_appetite_dailyround_bladder_drainage_and_more.py new file mode 100644 index 0000000000..2ba039f104 --- /dev/null +++ b/care/facility/migrations/0455_dailyround_appetite_dailyround_bladder_drainage_and_more.py @@ -0,0 +1,147 @@ +# Generated by Django 4.2.10 on 2024-09-12 05:59 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("facility", "0454_remove_historicalpatientregistration_abha_number_and_more"), + ] + + operations = [ + migrations.AddField( + model_name="dailyround", + name="appetite", + field=models.SmallIntegerField( + blank=True, + choices=[ + (1, "INCREASED"), + (2, "SATISFACTORY"), + (3, "REDUCED"), + (4, "NO_TASTE_FOR_FOOD"), + (5, "CANNOT_BE_ASSESSED"), + ], + default=None, + null=True, + ), + ), + migrations.AddField( + model_name="dailyround", + name="bladder_drainage", + field=models.SmallIntegerField( + blank=True, + choices=[ + (1, "NORMAL"), + (2, "CONDOM_CATHETER"), + (3, "DIAPER"), + (4, "INTERMITTENT_CATHETER"), + (5, "CONTINUOUS_INDWELLING_CATHETER"), + (6, "CONTINUOUS_SUPRAPUBIC_CATHETER"), + (7, "UROSTOMY"), + ], + default=None, + null=True, + ), + ), + migrations.AddField( + model_name="dailyround", + name="bladder_issue", + field=models.SmallIntegerField( + blank=True, + choices=[ + (1, "NORMAL"), + (2, "CONDOM_CATHETER"), + (3, "DIAPER"), + (4, "INTERMITTENT_CATHETER"), + (5, "CONTINUOUS_INDWELLING_CATHETER"), + (6, "CONTINUOUS_SUPRAPUBIC_CATHETER"), + (7, "UROSTOMY"), + ], + default=None, + null=True, + ), + ), + migrations.AddField( + model_name="dailyround", + name="bowel_difficulty", + field=models.SmallIntegerField( + blank=True, + choices=[(0, "NO_DIFFICULTY"), (1, "CONSTIPATION"), (2, "DIARRHOEA")], + default=None, + null=True, + ), + ), + migrations.AddField( + model_name="dailyround", + name="is_experiencing_dysuria", + field=models.BooleanField(blank=True, default=None, null=True), + ), + migrations.AddField( + model_name="dailyround", + name="nutrition_route", + field=models.SmallIntegerField( + blank=True, + choices=[ + (1, "ORAL"), + (2, "RYLES_TUBE"), + (3, "GASTROSTOMY_OR_JEJUNOSTOMY"), + (4, "PEG"), + (5, "PARENTERAL_TUBING_FLUID"), + (6, "PARENTERAL_TUBING_TPN"), + ], + default=None, + null=True, + ), + ), + migrations.AddField( + model_name="dailyround", + name="oral_issue", + field=models.SmallIntegerField( + blank=True, + choices=[(0, "NO_ISSUE"), (1, "DYSPHAGIA"), (2, "ODYNOPHAGIA")], + default=None, + null=True, + ), + ), + migrations.AddField( + model_name="dailyround", + name="sleep", + field=models.SmallIntegerField( + blank=True, + choices=[ + (1, "EXCESSIVE"), + (2, "SATISFACTORY"), + (3, "UNSATISFACTORY"), + (4, "NO_SLEEP"), + ], + default=None, + null=True, + ), + ), + migrations.AddField( + model_name="dailyround", + name="urination_frequency", + field=models.SmallIntegerField( + blank=True, + choices=[(1, "NORMAL"), (2, "DECREASED"), (3, "INCREASED")], + default=None, + null=True, + ), + ), + migrations.AlterField( + model_name="dailyround", + name="rounds_type", + field=models.IntegerField( + choices=[ + (0, "NORMAL"), + (30, "COMMUNITY_NURSES_LOG"), + (50, "DOCTORS_LOG"), + (100, "VENTILATOR"), + (200, "ICU"), + (300, "AUTOMATED"), + (400, "TELEMEDICINE"), + ], + default=0, + ), + ), + ] diff --git a/care/facility/models/daily_round.py b/care/facility/models/daily_round.py index 078709d9c9..cb6ed93b4b 100644 --- a/care/facility/models/daily_round.py +++ b/care/facility/models/daily_round.py @@ -28,16 +28,21 @@ from care.utils.models.validators import JSONFieldSchemaValidator +def enum_choices(enum: enum.Enum): + return [(e.value, e.name) for e in enum] + + class DailyRound(PatientBaseModel): class RoundsType(enum.Enum): NORMAL = 0 + COMMUNITY_NURSES_LOG = 30 DOCTORS_LOG = 50 VENTILATOR = 100 ICU = 200 AUTOMATED = 300 TELEMEDICINE = 400 - RoundsTypeChoice = [(e.value, e.name) for e in RoundsType] + RoundsTypeChoice = enum_choices(RoundsType) RoundsTypeDict = covert_choice_dict(RoundsTypeChoice) class ConsciousnessType(enum.Enum): @@ -49,7 +54,74 @@ class ConsciousnessType(enum.Enum): AGITATED_OR_CONFUSED = 25 ONSET_OF_AGITATION_AND_CONFUSION = 30 - ConsciousnessChoice = [(e.value, e.name) for e in ConsciousnessType] + ConsciousnessChoice = enum_choices(ConsciousnessType) + + class BowelDifficultyType(enum.Enum): + NO_DIFFICULTY = 0 + CONSTIPATION = 1 + DIARRHOEA = 2 + + BowelDifficultyChoice = enum_choices(BowelDifficultyType) + + class BladderDrainageType(enum.Enum): + NORMAL = 1 + CONDOM_CATHETER = 2 + DIAPER = 3 + INTERMITTENT_CATHETER = 4 + CONTINUOUS_INDWELLING_CATHETER = 5 + CONTINUOUS_SUPRAPUBIC_CATHETER = 6 + UROSTOMY = 7 + + BladderDrainageChoice = enum_choices(BladderDrainageType) + + class BladderIssueType(enum.Enum): + NO_ISSUES = 0 + INCONTINENCE = 1 + RETENTION = 2 + HESITANCY = 3 + + BladderIssueChoice = enum_choices(BladderDrainageType) + + class UrinationFrequencyType(enum.Enum): + NORMAL = 1 + DECREASED = 2 + INCREASED = 3 + + UrinationFrequencyChoice = enum_choices(UrinationFrequencyType) + + class SleepType(enum.Enum): + EXCESSIVE = 1 + SATISFACTORY = 2 + UNSATISFACTORY = 3 + NO_SLEEP = 4 + + SleepChoice = enum_choices(SleepType) + + class NutritionRouteType(enum.Enum): + ORAL = 1 + RYLES_TUBE = 2 + GASTROSTOMY_OR_JEJUNOSTOMY = 3 + PEG = 4 + PARENTERAL_TUBING_FLUID = 5 + PARENTERAL_TUBING_TPN = 6 + + NutritionRouteChoice = enum_choices(NutritionRouteType) + + class OralIssueType(enum.Enum): + NO_ISSUE = 0 + DYSPHAGIA = 1 + ODYNOPHAGIA = 2 + + OralIssueChoice = enum_choices(OralIssueType) + + class AppetiteType(enum.Enum): + INCREASED = 1 + SATISFACTORY = 2 + REDUCED = 3 + NO_TASTE_FOR_FOOD = 4 + CANNOT_BE_ASSESSED = 5 + + AppetiteChoice = enum_choices(AppetiteType) class PupilReactionType(enum.Enum): UNKNOWN = 0 @@ -58,7 +130,7 @@ class PupilReactionType(enum.Enum): FIXED = 15 CANNOT_BE_ASSESSED = 20 - PupilReactionChoice = [(e.value, e.name) for e in PupilReactionType] + PupilReactionChoice = enum_choices(PupilReactionType) class LimbResponseType(enum.Enum): UNKNOWN = 0 @@ -69,14 +141,14 @@ class LimbResponseType(enum.Enum): EXTENSION = 25 NONE = 30 - LimbResponseChoice = [(e.value, e.name) for e in LimbResponseType] + LimbResponseChoice = enum_choices(LimbResponseType) class RythmnType(enum.Enum): UNKNOWN = 0 REGULAR = 5 IRREGULAR = 10 - RythmnChoice = [(e.value, e.name) for e in RythmnType] + RythmnChoice = enum_choices(RythmnType) class VentilatorInterfaceType(enum.Enum): UNKNOWN = 0 @@ -84,7 +156,7 @@ class VentilatorInterfaceType(enum.Enum): NON_INVASIVE = 10 OXYGEN_SUPPORT = 15 - VentilatorInterfaceChoice = [(e.value, e.name) for e in VentilatorInterfaceType] + VentilatorInterfaceChoice = enum_choices(VentilatorInterfaceType) class VentilatorModeType(enum.Enum): UNKNOWN = 0 @@ -98,7 +170,7 @@ class VentilatorModeType(enum.Enum): ASV = 45 PSV = 50 - VentilatorModeChoice = [(e.value, e.name) for e in VentilatorModeType] + VentilatorModeChoice = enum_choices(VentilatorModeType) class VentilatorOxygenModalityType(enum.Enum): UNKNOWN = 0 @@ -107,9 +179,7 @@ class VentilatorOxygenModalityType(enum.Enum): NON_REBREATHING_MASK = 15 HIGH_FLOW_NASAL_CANNULA = 20 - VentilatorOxygenModalityChoice = [ - (e.value, e.name) for e in VentilatorOxygenModalityType - ] + VentilatorOxygenModalityChoice = enum_choices(VentilatorOxygenModalityType) class InsulinIntakeFrequencyType(enum.Enum): UNKNOWN = 0 @@ -117,9 +187,7 @@ class InsulinIntakeFrequencyType(enum.Enum): BD = 10 TD = 15 - InsulinIntakeFrequencyChoice = [ - (e.value, e.name) for e in InsulinIntakeFrequencyType - ] + InsulinIntakeFrequencyChoice = enum_choices(InsulinIntakeFrequencyType) consultation = models.ForeignKey( PatientConsultation, @@ -175,6 +243,34 @@ class InsulinIntakeFrequencyType(enum.Enum): ) is_parsed_by_ocr = models.BooleanField(default=False) + # Community Nurse's Log Attributes + + bowel_difficulty = models.SmallIntegerField( + choices=BowelDifficultyChoice, default=None, null=True, blank=True + ) + bladder_drainage = models.SmallIntegerField( + choices=BladderDrainageChoice, default=None, null=True, blank=True + ) + bladder_issue = models.SmallIntegerField( + choices=BladderIssueChoice, default=None, null=True, blank=True + ) + is_experiencing_dysuria = models.BooleanField(default=None, null=True, blank=True) + urination_frequency = models.SmallIntegerField( + choices=UrinationFrequencyChoice, default=None, null=True, blank=True + ) + sleep = models.SmallIntegerField( + choices=SleepChoice, default=None, null=True, blank=True + ) + nutrition_route = models.SmallIntegerField( + choices=NutritionRouteChoice, default=None, null=True, blank=True + ) + oral_issue = models.SmallIntegerField( + choices=OralIssueChoice, default=None, null=True, blank=True + ) + appetite = models.SmallIntegerField( + choices=AppetiteChoice, default=None, null=True, blank=True + ) + # Critical Care Attributes consciousness_level = models.IntegerField( From fa0388278bc200e40bd94e9e6d98e7c7b74769a6 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Fri, 13 Sep 2024 13:03:58 +0530 Subject: [PATCH 2/6] add event types and fixes bladder issue choices --- .../management/commands/load_event_types.py | 20 +++++++++++++++++++ ...e_dailyround_bladder_drainage_and_more.py} | 15 ++++++-------- care/facility/models/daily_round.py | 2 +- 3 files changed, 27 insertions(+), 10 deletions(-) rename care/facility/migrations/{0455_dailyround_appetite_dailyround_bladder_drainage_and_more.py => 0456_dailyround_appetite_dailyround_bladder_drainage_and_more.py} (90%) diff --git a/care/facility/management/commands/load_event_types.py b/care/facility/management/commands/load_event_types.py index fc9c231372..a3bab152e1 100644 --- a/care/facility/management/commands/load_event_types.py +++ b/care/facility/management/commands/load_event_types.py @@ -217,6 +217,26 @@ class Command(BaseCommand): ), }, {"name": "NURSING", "fields": ("nursing",)}, + { + "name": "ROUTINE", + "children": ( + {"name": "SLEEP", "fields": ("sleep",)}, + {"name": "BOWEL_DIFFICULTY", "fields": ("bowel_difficulty",)}, + { + "name": "BLADDER", + "fields": ( + "bladder_drainage", + "bladder_issue", + "experiences_dysuria", + "urination_frequency", + ), + }, + { + "name": "NUTRITION", + "fields": ("nutrition_route", "oral_issue", "appetite"), + }, + ), + }, ), }, { diff --git a/care/facility/migrations/0455_dailyround_appetite_dailyround_bladder_drainage_and_more.py b/care/facility/migrations/0456_dailyround_appetite_dailyround_bladder_drainage_and_more.py similarity index 90% rename from care/facility/migrations/0455_dailyround_appetite_dailyround_bladder_drainage_and_more.py rename to care/facility/migrations/0456_dailyround_appetite_dailyround_bladder_drainage_and_more.py index 2ba039f104..0aed3df161 100644 --- a/care/facility/migrations/0455_dailyround_appetite_dailyround_bladder_drainage_and_more.py +++ b/care/facility/migrations/0456_dailyround_appetite_dailyround_bladder_drainage_and_more.py @@ -1,11 +1,11 @@ -# Generated by Django 4.2.10 on 2024-09-12 05:59 +# Generated by Django 4.2.10 on 2024-09-13 07:06 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ("facility", "0454_remove_historicalpatientregistration_abha_number_and_more"), + ("facility", "0455_remove_facility_old_features"), ] operations = [ @@ -49,13 +49,10 @@ class Migration(migrations.Migration): field=models.SmallIntegerField( blank=True, choices=[ - (1, "NORMAL"), - (2, "CONDOM_CATHETER"), - (3, "DIAPER"), - (4, "INTERMITTENT_CATHETER"), - (5, "CONTINUOUS_INDWELLING_CATHETER"), - (6, "CONTINUOUS_SUPRAPUBIC_CATHETER"), - (7, "UROSTOMY"), + (0, "NO_ISSUES"), + (1, "INCONTINENCE"), + (2, "RETENTION"), + (3, "HESITANCY"), ], default=None, null=True, diff --git a/care/facility/models/daily_round.py b/care/facility/models/daily_round.py index cb6ed93b4b..4a31940338 100644 --- a/care/facility/models/daily_round.py +++ b/care/facility/models/daily_round.py @@ -80,7 +80,7 @@ class BladderIssueType(enum.Enum): RETENTION = 2 HESITANCY = 3 - BladderIssueChoice = enum_choices(BladderDrainageType) + BladderIssueChoice = enum_choices(BladderIssueType) class UrinationFrequencyType(enum.Enum): NORMAL = 1 From ff3c875e1be3273bdb7a45e913143ce0112fdf04 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Fri, 13 Sep 2024 13:14:02 +0530 Subject: [PATCH 3/6] Add tests --- .../tests/test_patient_daily_rounds_api.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/care/facility/tests/test_patient_daily_rounds_api.py b/care/facility/tests/test_patient_daily_rounds_api.py index 5145e4827e..48d8cc5a41 100644 --- a/care/facility/tests/test_patient_daily_rounds_api.py +++ b/care/facility/tests/test_patient_daily_rounds_api.py @@ -126,3 +126,21 @@ def test_doctors_log_update(self): data={**self.log_update, "rounds_type": "DOCTORS_LOG"}, ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) + + def test_community_nurses_log_update(self): + response = self.client.post( + f"/api/v1/consultation/{self.consultation_with_bed.external_id}/daily_rounds/", + data={ + **self.log_update, + "rounds_type": "COMMUNITY_NURSES_LOG", + "bowel_difficulty": "NO_DIFFICULTY", + "bladder_drainage": "CONDOM_CATHETER", + "bladder_issue": "NO_ISSUES", + "urination_frequency": "DECREASED", + "sleep": "SATISFACTORY", + "nutrition_route": "ORAL", + "oral_issue": "NO_ISSUE", + "appetite": "INCREASED", + }, + ) + self.assertEqual(response.status_code, status.HTTP_201_CREATED) From 887661b4a1c35c7406fe5a751ea4fea96054c612 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Tue, 17 Sep 2024 16:09:59 +0530 Subject: [PATCH 4/6] switch to integer choices --- care/facility/models/daily_round.py | 86 ++++++++++++++--------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/care/facility/models/daily_round.py b/care/facility/models/daily_round.py index 4a31940338..cf52a29070 100644 --- a/care/facility/models/daily_round.py +++ b/care/facility/models/daily_round.py @@ -56,70 +56,70 @@ class ConsciousnessType(enum.Enum): ConsciousnessChoice = enum_choices(ConsciousnessType) - class BowelDifficultyType(enum.Enum): - NO_DIFFICULTY = 0 - CONSTIPATION = 1 - DIARRHOEA = 2 + class BowelDifficultyType(models.IntegerChoices): + NO_DIFFICULTY = 0, "NO_DIFFICULTY" + CONSTIPATION = 1, "CONSTIPATION" + DIARRHOEA = 2, "DIARRHOEA" BowelDifficultyChoice = enum_choices(BowelDifficultyType) - class BladderDrainageType(enum.Enum): - NORMAL = 1 - CONDOM_CATHETER = 2 - DIAPER = 3 - INTERMITTENT_CATHETER = 4 - CONTINUOUS_INDWELLING_CATHETER = 5 - CONTINUOUS_SUPRAPUBIC_CATHETER = 6 - UROSTOMY = 7 + class BladderDrainageType(models.IntegerChoices): + NORMAL = 1, "NORMAL" + CONDOM_CATHETER = 2, "CONDOM_CATHETER" + DIAPER = 3, "DIAPER" + INTERMITTENT_CATHETER = 4, "INTERMITTENT_CATHETER" + CONTINUOUS_INDWELLING_CATHETER = 5, "CONTINUOUS_INDWELLING_CATHETER" + CONTINUOUS_SUPRAPUBIC_CATHETER = 6, "CONTINUOUS_SUPRAPUBIC_CATHETER" + UROSTOMY = 7, "UROSTOMY" BladderDrainageChoice = enum_choices(BladderDrainageType) - class BladderIssueType(enum.Enum): - NO_ISSUES = 0 - INCONTINENCE = 1 - RETENTION = 2 - HESITANCY = 3 + class BladderIssueType(models.IntegerChoices): + NO_ISSUES = 0, "NO_ISSUES" + INCONTINENCE = 1, "INCONTINENCE" + RETENTION = 2, "RETENTION" + HESITANCY = 3, "HESITANCY" BladderIssueChoice = enum_choices(BladderIssueType) - class UrinationFrequencyType(enum.Enum): - NORMAL = 1 - DECREASED = 2 - INCREASED = 3 + class UrinationFrequencyType(models.IntegerChoices): + NORMAL = 1, "NORMAL" + DECREASED = 2, "DECREASED" + INCREASED = 3, "INCREASED" UrinationFrequencyChoice = enum_choices(UrinationFrequencyType) - class SleepType(enum.Enum): - EXCESSIVE = 1 - SATISFACTORY = 2 - UNSATISFACTORY = 3 - NO_SLEEP = 4 + class SleepType(models.IntegerChoices): + EXCESSIVE = 1, "EXCESSIVE" + SATISFACTORY = 2, "SATISFACTORY" + UNSATISFACTORY = 3, "UNSATISFACTORY" + NO_SLEEP = 4, "NO_SLEEP" SleepChoice = enum_choices(SleepType) - class NutritionRouteType(enum.Enum): - ORAL = 1 - RYLES_TUBE = 2 - GASTROSTOMY_OR_JEJUNOSTOMY = 3 - PEG = 4 - PARENTERAL_TUBING_FLUID = 5 - PARENTERAL_TUBING_TPN = 6 + class NutritionRouteType(models.IntegerChoices): + ORAL = 1, "ORAL" + RYLES_TUBE = 2, "RYLES_TUBE" + GASTROSTOMY_OR_JEJUNOSTOMY = 3, "GASTROSTOMY_OR_JEJUNOSTOMY" + PEG = 4, "PEG" + PARENTERAL_TUBING_FLUID = 5, "PARENTERAL_TUBING_FLUID" + PARENTERAL_TUBING_TPN = 6, "PARENTERAL_TUBING_TPN" NutritionRouteChoice = enum_choices(NutritionRouteType) - class OralIssueType(enum.Enum): - NO_ISSUE = 0 - DYSPHAGIA = 1 - ODYNOPHAGIA = 2 + class OralIssueType(models.IntegerChoices): + NO_ISSUE = 0, "NO_ISSUE" + DYSPHAGIA = 1, "DYSPHAGIA" + ODYNOPHAGIA = 2, "ODYNOPHAGIA" OralIssueChoice = enum_choices(OralIssueType) - class AppetiteType(enum.Enum): - INCREASED = 1 - SATISFACTORY = 2 - REDUCED = 3 - NO_TASTE_FOR_FOOD = 4 - CANNOT_BE_ASSESSED = 5 + class AppetiteType(models.IntegerChoices): + INCREASED = 1, "INCREASED" + SATISFACTORY = 2, "SATISFACTORY" + REDUCED = 3, "REDUCED" + NO_TASTE_FOR_FOOD = 4, "NO_TASTE_FOR_FOOD" + CANNOT_BE_ASSESSED = 5, "CANNOT_BE_ASSESSED" AppetiteChoice = enum_choices(AppetiteType) From b232b060e66755a9e84b357482aefb922cb6d510 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Tue, 17 Sep 2024 18:21:31 +0530 Subject: [PATCH 5/6] switch to using `.choices` instead of manually generating choices --- care/facility/api/serializers/daily_round.py | 18 +++--- care/facility/models/daily_round.py | 58 +++++++------------- 2 files changed, 31 insertions(+), 45 deletions(-) diff --git a/care/facility/api/serializers/daily_round.py b/care/facility/api/serializers/daily_round.py index 00e188d410..6a098a7f63 100644 --- a/care/facility/api/serializers/daily_round.py +++ b/care/facility/api/serializers/daily_round.py @@ -44,21 +44,23 @@ class DailyRoundSerializer(serializers.ModelSerializer): # Community Nurse's Log bowel_difficulty = ChoiceField( - choices=DailyRound.BowelDifficultyChoice, required=False + choices=DailyRound.BowelDifficultyType.choices, required=False ) bladder_drainage = ChoiceField( - choices=DailyRound.BladderDrainageChoice, required=False + choices=DailyRound.BladderDrainageType.choices, required=False + ) + bladder_issue = ChoiceField( + choices=DailyRound.BladderIssueType.choices, required=False ) - bladder_issue = ChoiceField(choices=DailyRound.BladderIssueChoice, required=False) urination_frequency = ChoiceField( - choices=DailyRound.UrinationFrequencyChoice, required=False + choices=DailyRound.UrinationFrequencyType.choices, required=False ) - sleep = ChoiceField(choices=DailyRound.SleepChoice, required=False) + sleep = ChoiceField(choices=DailyRound.SleepType.choices, required=False) nutrition_route = ChoiceField( - choices=DailyRound.NutritionRouteChoice, required=False + choices=DailyRound.NutritionRouteType.choices, required=False ) - oral_issue = ChoiceField(choices=DailyRound.OralIssueChoice, required=False) - appetite = ChoiceField(choices=DailyRound.AppetiteChoice, required=False) + oral_issue = ChoiceField(choices=DailyRound.OralIssueType.choices, required=False) + appetite = ChoiceField(choices=DailyRound.AppetiteType.choices, required=False) # Critical Care Components diff --git a/care/facility/models/daily_round.py b/care/facility/models/daily_round.py index cf52a29070..d3f49f6cdb 100644 --- a/care/facility/models/daily_round.py +++ b/care/facility/models/daily_round.py @@ -28,10 +28,6 @@ from care.utils.models.validators import JSONFieldSchemaValidator -def enum_choices(enum: enum.Enum): - return [(e.value, e.name) for e in enum] - - class DailyRound(PatientBaseModel): class RoundsType(enum.Enum): NORMAL = 0 @@ -42,7 +38,7 @@ class RoundsType(enum.Enum): AUTOMATED = 300 TELEMEDICINE = 400 - RoundsTypeChoice = enum_choices(RoundsType) + RoundsTypeChoice = [(e.value, e.name) for e in RoundsType] RoundsTypeDict = covert_choice_dict(RoundsTypeChoice) class ConsciousnessType(enum.Enum): @@ -54,15 +50,13 @@ class ConsciousnessType(enum.Enum): AGITATED_OR_CONFUSED = 25 ONSET_OF_AGITATION_AND_CONFUSION = 30 - ConsciousnessChoice = enum_choices(ConsciousnessType) + ConsciousnessChoice = [(e.value, e.name) for e in ConsciousnessType] class BowelDifficultyType(models.IntegerChoices): NO_DIFFICULTY = 0, "NO_DIFFICULTY" CONSTIPATION = 1, "CONSTIPATION" DIARRHOEA = 2, "DIARRHOEA" - BowelDifficultyChoice = enum_choices(BowelDifficultyType) - class BladderDrainageType(models.IntegerChoices): NORMAL = 1, "NORMAL" CONDOM_CATHETER = 2, "CONDOM_CATHETER" @@ -72,31 +66,23 @@ class BladderDrainageType(models.IntegerChoices): CONTINUOUS_SUPRAPUBIC_CATHETER = 6, "CONTINUOUS_SUPRAPUBIC_CATHETER" UROSTOMY = 7, "UROSTOMY" - BladderDrainageChoice = enum_choices(BladderDrainageType) - class BladderIssueType(models.IntegerChoices): NO_ISSUES = 0, "NO_ISSUES" INCONTINENCE = 1, "INCONTINENCE" RETENTION = 2, "RETENTION" HESITANCY = 3, "HESITANCY" - BladderIssueChoice = enum_choices(BladderIssueType) - class UrinationFrequencyType(models.IntegerChoices): NORMAL = 1, "NORMAL" DECREASED = 2, "DECREASED" INCREASED = 3, "INCREASED" - UrinationFrequencyChoice = enum_choices(UrinationFrequencyType) - class SleepType(models.IntegerChoices): EXCESSIVE = 1, "EXCESSIVE" SATISFACTORY = 2, "SATISFACTORY" UNSATISFACTORY = 3, "UNSATISFACTORY" NO_SLEEP = 4, "NO_SLEEP" - SleepChoice = enum_choices(SleepType) - class NutritionRouteType(models.IntegerChoices): ORAL = 1, "ORAL" RYLES_TUBE = 2, "RYLES_TUBE" @@ -105,15 +91,11 @@ class NutritionRouteType(models.IntegerChoices): PARENTERAL_TUBING_FLUID = 5, "PARENTERAL_TUBING_FLUID" PARENTERAL_TUBING_TPN = 6, "PARENTERAL_TUBING_TPN" - NutritionRouteChoice = enum_choices(NutritionRouteType) - class OralIssueType(models.IntegerChoices): NO_ISSUE = 0, "NO_ISSUE" DYSPHAGIA = 1, "DYSPHAGIA" ODYNOPHAGIA = 2, "ODYNOPHAGIA" - OralIssueChoice = enum_choices(OralIssueType) - class AppetiteType(models.IntegerChoices): INCREASED = 1, "INCREASED" SATISFACTORY = 2, "SATISFACTORY" @@ -121,8 +103,6 @@ class AppetiteType(models.IntegerChoices): NO_TASTE_FOR_FOOD = 4, "NO_TASTE_FOR_FOOD" CANNOT_BE_ASSESSED = 5, "CANNOT_BE_ASSESSED" - AppetiteChoice = enum_choices(AppetiteType) - class PupilReactionType(enum.Enum): UNKNOWN = 0 BRISK = 5 @@ -130,7 +110,7 @@ class PupilReactionType(enum.Enum): FIXED = 15 CANNOT_BE_ASSESSED = 20 - PupilReactionChoice = enum_choices(PupilReactionType) + PupilReactionChoice = [(e.value, e.name) for e in PupilReactionType] class LimbResponseType(enum.Enum): UNKNOWN = 0 @@ -141,14 +121,14 @@ class LimbResponseType(enum.Enum): EXTENSION = 25 NONE = 30 - LimbResponseChoice = enum_choices(LimbResponseType) + LimbResponseChoice = [(e.value, e.name) for e in LimbResponseType] class RythmnType(enum.Enum): UNKNOWN = 0 REGULAR = 5 IRREGULAR = 10 - RythmnChoice = enum_choices(RythmnType) + RythmnChoice = [(e.value, e.name) for e in RythmnType] class VentilatorInterfaceType(enum.Enum): UNKNOWN = 0 @@ -156,7 +136,7 @@ class VentilatorInterfaceType(enum.Enum): NON_INVASIVE = 10 OXYGEN_SUPPORT = 15 - VentilatorInterfaceChoice = enum_choices(VentilatorInterfaceType) + VentilatorInterfaceChoice = [(e.value, e.name) for e in VentilatorInterfaceType] class VentilatorModeType(enum.Enum): UNKNOWN = 0 @@ -170,7 +150,7 @@ class VentilatorModeType(enum.Enum): ASV = 45 PSV = 50 - VentilatorModeChoice = enum_choices(VentilatorModeType) + VentilatorModeChoice = [(e.value, e.name) for e in VentilatorModeType] class VentilatorOxygenModalityType(enum.Enum): UNKNOWN = 0 @@ -179,7 +159,9 @@ class VentilatorOxygenModalityType(enum.Enum): NON_REBREATHING_MASK = 15 HIGH_FLOW_NASAL_CANNULA = 20 - VentilatorOxygenModalityChoice = enum_choices(VentilatorOxygenModalityType) + VentilatorOxygenModalityChoice = [ + (e.value, e.name) for e in VentilatorOxygenModalityType + ] class InsulinIntakeFrequencyType(enum.Enum): UNKNOWN = 0 @@ -187,7 +169,9 @@ class InsulinIntakeFrequencyType(enum.Enum): BD = 10 TD = 15 - InsulinIntakeFrequencyChoice = enum_choices(InsulinIntakeFrequencyType) + InsulinIntakeFrequencyChoice = [ + (e.value, e.name) for e in InsulinIntakeFrequencyType + ] consultation = models.ForeignKey( PatientConsultation, @@ -246,29 +230,29 @@ class InsulinIntakeFrequencyType(enum.Enum): # Community Nurse's Log Attributes bowel_difficulty = models.SmallIntegerField( - choices=BowelDifficultyChoice, default=None, null=True, blank=True + choices=BowelDifficultyType.choices, default=None, null=True, blank=True ) bladder_drainage = models.SmallIntegerField( - choices=BladderDrainageChoice, default=None, null=True, blank=True + choices=BladderDrainageType.choices, default=None, null=True, blank=True ) bladder_issue = models.SmallIntegerField( - choices=BladderIssueChoice, default=None, null=True, blank=True + choices=BladderIssueType.choices, default=None, null=True, blank=True ) is_experiencing_dysuria = models.BooleanField(default=None, null=True, blank=True) urination_frequency = models.SmallIntegerField( - choices=UrinationFrequencyChoice, default=None, null=True, blank=True + choices=UrinationFrequencyType.choices, default=None, null=True, blank=True ) sleep = models.SmallIntegerField( - choices=SleepChoice, default=None, null=True, blank=True + choices=SleepType.choices, default=None, null=True, blank=True ) nutrition_route = models.SmallIntegerField( - choices=NutritionRouteChoice, default=None, null=True, blank=True + choices=NutritionRouteType.choices, default=None, null=True, blank=True ) oral_issue = models.SmallIntegerField( - choices=OralIssueChoice, default=None, null=True, blank=True + choices=OralIssueType.choices, default=None, null=True, blank=True ) appetite = models.SmallIntegerField( - choices=AppetiteChoice, default=None, null=True, blank=True + choices=AppetiteType.choices, default=None, null=True, blank=True ) # Critical Care Attributes From 5f2f45d7f93491b6637d35f5dc149d7d825d9028 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Tue, 17 Sep 2024 22:07:28 +0530 Subject: [PATCH 6/6] update event types and field name --- care/facility/api/serializers/daily_round.py | 2 +- care/facility/management/commands/load_event_types.py | 8 ++++---- ...round_appetite_dailyround_bladder_drainage_and_more.py | 2 +- care/facility/models/daily_round.py | 2 +- care/facility/tests/test_patient_daily_rounds_api.py | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/care/facility/api/serializers/daily_round.py b/care/facility/api/serializers/daily_round.py index 6a098a7f63..4f2f61c32b 100644 --- a/care/facility/api/serializers/daily_round.py +++ b/care/facility/api/serializers/daily_round.py @@ -43,7 +43,7 @@ class DailyRoundSerializer(serializers.ModelSerializer): # Community Nurse's Log - bowel_difficulty = ChoiceField( + bowel_issue = ChoiceField( choices=DailyRound.BowelDifficultyType.choices, required=False ) bladder_drainage = ChoiceField( diff --git a/care/facility/management/commands/load_event_types.py b/care/facility/management/commands/load_event_types.py index a3bab152e1..c6a92064f5 100644 --- a/care/facility/management/commands/load_event_types.py +++ b/care/facility/management/commands/load_event_types.py @@ -220,10 +220,10 @@ class Command(BaseCommand): { "name": "ROUTINE", "children": ( - {"name": "SLEEP", "fields": ("sleep",)}, - {"name": "BOWEL_DIFFICULTY", "fields": ("bowel_difficulty",)}, + {"name": "SLEEP_ROUTINE", "fields": ("sleep",)}, + {"name": "BOWEL_ROUTINE", "fields": ("bowel_issue",)}, { - "name": "BLADDER", + "name": "BLADDER_ROUTINE", "fields": ( "bladder_drainage", "bladder_issue", @@ -232,7 +232,7 @@ class Command(BaseCommand): ), }, { - "name": "NUTRITION", + "name": "NUTRITION_ROUTINE", "fields": ("nutrition_route", "oral_issue", "appetite"), }, ), diff --git a/care/facility/migrations/0456_dailyround_appetite_dailyround_bladder_drainage_and_more.py b/care/facility/migrations/0456_dailyround_appetite_dailyround_bladder_drainage_and_more.py index 0aed3df161..71cb7bd793 100644 --- a/care/facility/migrations/0456_dailyround_appetite_dailyround_bladder_drainage_and_more.py +++ b/care/facility/migrations/0456_dailyround_appetite_dailyround_bladder_drainage_and_more.py @@ -60,7 +60,7 @@ class Migration(migrations.Migration): ), migrations.AddField( model_name="dailyround", - name="bowel_difficulty", + name="bowel_issue", field=models.SmallIntegerField( blank=True, choices=[(0, "NO_DIFFICULTY"), (1, "CONSTIPATION"), (2, "DIARRHOEA")], diff --git a/care/facility/models/daily_round.py b/care/facility/models/daily_round.py index d3f49f6cdb..58a288ed91 100644 --- a/care/facility/models/daily_round.py +++ b/care/facility/models/daily_round.py @@ -229,7 +229,7 @@ class InsulinIntakeFrequencyType(enum.Enum): # Community Nurse's Log Attributes - bowel_difficulty = models.SmallIntegerField( + bowel_issue = models.SmallIntegerField( choices=BowelDifficultyType.choices, default=None, null=True, blank=True ) bladder_drainage = models.SmallIntegerField( diff --git a/care/facility/tests/test_patient_daily_rounds_api.py b/care/facility/tests/test_patient_daily_rounds_api.py index d8ace426f4..1ea519c3eb 100644 --- a/care/facility/tests/test_patient_daily_rounds_api.py +++ b/care/facility/tests/test_patient_daily_rounds_api.py @@ -135,7 +135,7 @@ def test_community_nurses_log_update(self): data={ **self.log_update, "rounds_type": "COMMUNITY_NURSES_LOG", - "bowel_difficulty": "NO_DIFFICULTY", + "bowel_issue": "NO_DIFFICULTY", "bladder_drainage": "CONDOM_CATHETER", "bladder_issue": "NO_ISSUES", "urination_frequency": "DECREASED",