Skip to content

Commit

Permalink
Improve terminology: ~recordable~ measurable
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad committed Sep 6, 2024
1 parent 293bce2 commit f9f432e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Migration(migrations.Migration):
2. Fills name with "Unknown" for I/O balance field items for ones with
empty string.
3. Update blood pressure column to `None` for empty objects (`{}`).
4. Backfill systolic_not_recordable and diastolic_not_recordable attributes.
4. Backfill systolic_not_measurable and diastolic_not_measurable attributes.
"""

dependencies = [
Expand Down Expand Up @@ -90,7 +90,7 @@ def reverse_set_empty_bp_to_null(apps, schema_editor):
DailyRound = apps.get_model("facility", "DailyRound")
DailyRound.objects.filter(bp=None).update(bp={})

def backfill_blood_pressure_recordable(apps, schema_editor):
def backfill_blood_pressure_not_measurable(apps, schema_editor):
DailyRound = apps.get_model("facility", "DailyRound")

paginator = Paginator(
Expand All @@ -101,8 +101,8 @@ def backfill_blood_pressure_recordable(apps, schema_editor):
bulk = []
for instance in paginator.page(page_number).object_list:
bp = instance.bp
bp["systolic_not_recordable"] = bp.get("systolic") is None
bp["diastolic_not_recordable"] = bp.get("diastolic") is None
bp["systolic_not_measurable"] = bp.get("systolic") is None
bp["diastolic_not_measurable"] = bp.get("diastolic") is None
bulk.append(instance)
DailyRound.objects.bulk_update(bulk, ["bp"])

Expand All @@ -129,7 +129,7 @@ def backfill_blood_pressure_recordable(apps, schema_editor):
},
"if": {
"properties": {
"systolic_not_recordable": {"const": False}
"systolic_not_measurable": {"const": False}
}
},
"then": {
Expand All @@ -147,7 +147,7 @@ def backfill_blood_pressure_recordable(apps, schema_editor):
},
"if": {
"properties": {
"diastolic_not_recordable": {"const": False}
"diastolic_not_measurable": {"const": False}
}
},
"then": {
Expand All @@ -169,13 +169,13 @@ def backfill_blood_pressure_recordable(apps, schema_editor):
},
"properties": {
"diastolic": {},
"diastolic_not_recordable": {"type": "boolean"},
"diastolic_not_measurable": {"type": "boolean"},
"systolic": {},
"systolic_not_recordable": {"type": "boolean"},
"systolic_not_measurable": {"type": "boolean"},
},
"required": [
"systolic_not_recordable",
"diastolic_not_recordable",
"systolic_not_measurable",
"diastolic_not_measurable",
],
"type": "object",
}
Expand All @@ -188,7 +188,7 @@ def backfill_blood_pressure_recordable(apps, schema_editor):
reverse_code=reverse_set_empty_bp_to_null,
),
migrations.RunPython(
backfill_blood_pressure_recordable,
backfill_blood_pressure_not_measurable,
reverse_code=migrations.RunPython.noop,
),
migrations.AlterField(
Expand Down
10 changes: 5 additions & 5 deletions care/facility/models/json_schema/daily_round.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
"properties": {
"systolic": {},
"diastolic": {},
"systolic_not_recordable": {"type": "boolean"},
"diastolic_not_recordable": {"type": "boolean"},
"systolic_not_measurable": {"type": "boolean"},
"diastolic_not_measurable": {"type": "boolean"},
},
"required": ["systolic_not_recordable", "diastolic_not_recordable"],
"required": ["systolic_not_measurable", "diastolic_not_measurable"],
"allOf": [
{
"if": {
"properties": {"systolic_not_recordable": {"const": False}},
"properties": {"systolic_not_measurable": {"const": False}},
},
"then": {
"properties": {"systolic": {"$ref": "#/definitions/blood-pressure"}},
Expand All @@ -26,7 +26,7 @@
},
{
"if": {
"properties": {"diastolic_not_recordable": {"const": False}},
"properties": {"diastolic_not_measurable": {"const": False}},
},
"then": {
"properties": {"diastolic": {"$ref": "#/definitions/blood-pressure"}},
Expand Down
36 changes: 18 additions & 18 deletions care/facility/tests/test_patient_daily_rounds_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def test_create_log_update_blood_pressure_empty(self):
response = self.create_log_update(bp={})
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

def test_create_log_update_blood_pressure_without_recordable_fields(self):
def test_create_log_update_blood_pressure_without_measurable_fields(self):
response = self.create_log_update(
bp={
"systolic": 90,
Expand All @@ -131,58 +131,58 @@ def test_create_log_update_blood_pressure_without_recordable_fields(self):
)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

def test_create_log_update_blood_pressure_not_recordable(self):
def test_create_log_update_blood_pressure_not_measurable(self):
response = self.create_log_update(
bp={
"systolic_not_recordable": True,
"diastolic_not_recordable": True,
"systolic_not_measurable": True,
"diastolic_not_measurable": True,
}
)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)

def test_create_log_update_blood_pressure_not_recordable_with_value(self):
def test_create_log_update_blood_pressure_not_measurable_with_value(self):
response = self.create_log_update(
bp={
"systolic_not_recordable": True,
"systolic_not_measurable": True,
"systolic": 60,
"diastolic_not_recordable": True,
"diastolic_not_measurable": True,
}
)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

def test_create_log_update_blood_pressure_recordable_without_value(self):
response = self.create_log_update(
bp={
"systolic_not_recordable": False,
"diastolic_not_recordable": True,
"systolic_not_measurable": False,
"diastolic_not_measurable": True,
}
)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

def test_create_log_update_blood_pressure_partially_recordable(self):
response = self.create_log_update(
bp={
"systolic_not_recordable": False,
"systolic_not_measurable": False,
"systolic": 60,
"diastolic_not_recordable": True,
"diastolic_not_measurable": True,
}
)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)

def test_create_log_update_with_out_of_range_blood_pressure(self):
response = self.create_log_update(
bp={
"systolic_not_recordable": False,
"systolic_not_measurable": False,
"systolic": 1000,
"diastolic_not_recordable": True,
"diastolic_not_measurable": True,
}
)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

def test_create_log_update_with_missing_systolic_blood_pressure(self):
response = self.create_log_update(
bp={
"diastolic_not_recordable": False,
"diastolic_not_measurable": False,
"diastolic": 100,
}
)
Expand All @@ -191,9 +191,9 @@ def test_create_log_update_with_missing_systolic_blood_pressure(self):
def test_create_log_update_with_systolic_below_diastolic_blood_pressure(self):
response = self.create_log_update(
bp={
"systolic_not_recordable": False,
"systolic_not_measurable": False,
"systolic": 60,
"diastolic_not_recordable": False,
"diastolic_not_measurable": False,
"diastolic": 90,
},
)
Expand All @@ -202,9 +202,9 @@ def test_create_log_update_with_systolic_below_diastolic_blood_pressure(self):
def test_create_log_update_with_valid_blood_pressure(self):
response = self.create_log_update(
bp={
"systolic_not_recordable": False,
"systolic_not_measurable": False,
"systolic": 90,
"diastolic_not_recordable": False,
"diastolic_not_measurable": False,
"diastolic": 60,
},
)
Expand Down

0 comments on commit f9f432e

Please sign in to comment.