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

Painscale changed from 0 - 5 to 0 - 10 #1967

Merged
merged 16 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
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
36 changes: 36 additions & 0 deletions care/facility/migrations/0420_auto_20240312_2318.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Generated by Django 4.2.10 on 2024-03-12 17:48

from math import ceil

from django.db import migrations


def double_pain_scale(apps, schema_editor):
DailyRound = apps.get_model("facility", "DailyRound")
records_to_update = []
for daily_round in DailyRound.objects.filter(pain_scale_enhanced__isnull=False):
if daily_round.pain_scale_enhanced.get("scale"):
daily_round.pain_scale_enhanced["scale"] *= 2
records_to_update.append(daily_round)
DailyRound.objects.bulk_update(records_to_update, ["pain_scale_enhanced"])


def halve_pain_scale(apps, schema_editor):
DailyRound = apps.get_model("facility", "DailyRound")
records_to_update = []
for daily_round in DailyRound.objects.filter(pain_scale_enhanced__isnull=False):
if scale := daily_round.pain_scale_enhanced.get("scale"):
scale = ceil(scale / 2)
daily_round.pain_scale_enhanced["scale"] = scale
records_to_update.append(daily_round)
rithviknishad marked this conversation as resolved.
Show resolved Hide resolved
rithviknishad marked this conversation as resolved.
Show resolved Hide resolved
DailyRound.objects.bulk_update(records_to_update, ["pain_scale_enhanced"])


class Migration(migrations.Migration):
dependencies = [
("facility", "0419_alter_patientconsultation_patient_no"),
]

operations = [
migrations.RunPython(double_pain_scale, reverse_code=halve_pain_scale),
]
2 changes: 1 addition & 1 deletion care/facility/models/json_schema/daily_round.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
"type": "object",
"properties": {
"region": {"type": "string"},
"scale": {"type": "number", "minimum": 1, "maximum": 5},
"scale": {"type": "number", "minimum": 1, "maximum": 10},
"description": {"type": "string"},
},
"additionalProperties": False,
Expand Down
Loading