-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2401 from ohcnetwork/staging
Production release v24.35.0
- Loading branch information
Showing
18 changed files
with
354 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
care/facility/migrations/0448_rename_features_facility_old_features.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Generated by Django 4.2.10 on 2024-06-03 06:24 | ||
|
||
import django.contrib.postgres.fields | ||
from django.db import migrations, models | ||
|
||
|
||
def convert_features_to_array(apps, schema_editor): | ||
Facility = apps.get_model("facility", "Facility") | ||
|
||
facilities_to_update = Facility.objects.filter(old_features__isnull=False) | ||
|
||
updated_facilities = [] | ||
|
||
for facility in facilities_to_update: | ||
try: | ||
facility.features = list(facility.old_features) | ||
updated_facilities.append(facility) | ||
except ValueError: | ||
print(f"facility '{facility.name}' has invalid facility features") | ||
|
||
if updated_facilities: | ||
Facility.objects.bulk_update(updated_facilities, ["features"]) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("facility", "0447_patientconsultationevent_taken_at"), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameField( | ||
model_name="facility", | ||
old_name="features", | ||
new_name="old_features", | ||
), | ||
migrations.AddField( | ||
model_name="facility", | ||
name="features", | ||
field=django.contrib.postgres.fields.ArrayField( | ||
base_field=models.SmallIntegerField( | ||
choices=[ | ||
(1, "CT Scan Facility"), | ||
(2, "Maternity Care"), | ||
(3, "X-Ray Facility"), | ||
(4, "Neonatal Care"), | ||
(5, "Operation Theater"), | ||
(6, "Blood Bank"), | ||
] | ||
), | ||
blank=True, | ||
null=True, | ||
size=None, | ||
), | ||
), | ||
migrations.RunPython(convert_features_to_array), | ||
] |
80 changes: 80 additions & 0 deletions
80
care/facility/migrations/0448_rename_ventilator_fi02_dailyround_ventilator_fio2.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# Generated by Django 4.2.10 on 2024-08-13 10:36 | ||
|
||
from django.core.paginator import Paginator | ||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
def forward_rename_dailyround_events(apps, schema_editor): | ||
EventType = apps.get_model("facility", "EventType") | ||
PatientConsultationEvent = apps.get_model( | ||
"facility", "PatientConsultationEvent" | ||
) | ||
|
||
event_type = EventType.objects.filter(name="RESPIRATORY_SUPPORT") | ||
if not event_type.exists(): | ||
return | ||
event_type_id = event_type.first().id | ||
|
||
paginator = Paginator( | ||
PatientConsultationEvent.objects.filter( | ||
object_model="DailyRound", | ||
event_type_id=event_type_id, | ||
value__has_key="ventilator_fi02", | ||
).order_by("id"), | ||
1000, | ||
) | ||
|
||
for page_number in paginator.page_range: | ||
bulk = [] | ||
for instance in paginator.page(page_number).object_list: | ||
instance.value["ventilator_fio2"] = instance.value.pop( | ||
"ventilator_fi02" | ||
) | ||
bulk.append(instance) | ||
PatientConsultationEvent.objects.bulk_update(bulk, ["value"]) | ||
|
||
def reverse_rename_dailyround_events(apps, schema_editor): | ||
EventType = apps.get_model("facility", "EventType") | ||
PatientConsultationEvent = apps.get_model( | ||
"facility", "PatientConsultationEvent" | ||
) | ||
|
||
event_type = EventType.objects.filter(name="RESPIRATORY_SUPPORT") | ||
if not event_type.exists(): | ||
return | ||
event_type_id = event_type.first().id | ||
|
||
paginator = Paginator( | ||
PatientConsultationEvent.objects.filter( | ||
object_model="DailyRound", | ||
event_type_id=event_type_id, | ||
value__has_key="ventilator_fio2", | ||
).order_by("id"), | ||
1000, | ||
) | ||
|
||
for page_number in paginator.page_range: | ||
bulk = [] | ||
for instance in paginator.page(page_number).object_list: | ||
instance.value["ventilator_fi02"] = instance.value.pop( | ||
"ventilator_fio2" | ||
) | ||
bulk.append(instance) | ||
PatientConsultationEvent.objects.bulk_update(bulk, ["value"]) | ||
|
||
dependencies = [ | ||
("facility", "0447_patientconsultationevent_taken_at"), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameField( | ||
model_name="dailyround", | ||
old_name="ventilator_fi02", | ||
new_name="ventilator_fio2", | ||
), | ||
migrations.RunPython( | ||
forward_rename_dailyround_events, | ||
reverse_code=reverse_rename_dailyround_events, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Generated by Django 4.2.10 on 2024-08-22 08:13 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("facility", "0448_rename_features_facility_old_features"), | ||
("facility", "0448_rename_ventilator_fi02_dailyround_ventilator_fio2"), | ||
] | ||
|
||
operations = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.