Skip to content

Commit

Permalink
Fix:Migration of new facility types (#1936)
Browse files Browse the repository at this point in the history
* changed some facility types and also made custom migration for old data

* update migrations

---------

Co-authored-by: Aakash Singh <[email protected]>
  • Loading branch information
SinghYuvraj0506 and sainak authored Mar 4, 2024
1 parent 284c639 commit 93c8604
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
30 changes: 30 additions & 0 deletions care/facility/migrations/0416_update_facility_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Generated by Django 4.2.10 on 2024-03-02 05:39

from django.db import migrations


def update_facility_types(apps, schema_editor):
Facility = apps.get_model("facility", "Facility")
facilities_to_update = {
801: 800, # 24x7 Public Health Centres to Primary Health Centres
820: 800, # Urban Primary Health Center to Primary Health Centres
831: 830, # Taluk Headquarters Hospitals to Taluk Hospitals
850: 860, # General hospitals to District Hospitals
900: 910, # Co-operative hospitals to Autonomous healthcare facility
950: 870, # Corona Testing Labs to Govt. Labs
1000: 3, # Corona Care Centre to Other
8: 870, # Govt Hospital to Govt Medical College Hospitals
}

for old_id, new_id in facilities_to_update.items():
Facility.objects.filter(facility_type=old_id).update(facility_type=new_id)


class Migration(migrations.Migration):
dependencies = [
("facility", "0415_alter_patientmetainfo_head_of_household_and_more"),
]

operations = [
migrations.RunPython(update_facility_types, migrations.RunPython.noop),
]
17 changes: 9 additions & 8 deletions care/facility/models/facility.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,27 @@
(5, "Hotel"),
(6, "Lodge"),
(7, "TeleMedicine"),
(8, "Govt Hospital"),
(9, "Labs"),
# (8, "Govt Hospital"), # Change from "Govt Hospital" to "Govt Medical College Hospitals"
(9, "Govt Labs"),
(10, "Private Labs"),
# Use 8xx for Govt owned hospitals and health centres
(800, "Primary Health Centres"),
(801, "24x7 Public Health Centres"),
# (801, "24x7 Public Health Centres"), # Change from "24x7 Public Health Centres" to "Primary Health Centres"
(802, "Family Health Centres"),
(803, "Community Health Centres"),
(820, "Urban Primary Health Center"),
# (820, "Urban Primary Health Center"), # Change from "Urban Primary Health Center" to "Primary Health Centres"
(830, "Taluk Hospitals"),
(831, "Taluk Headquarters Hospitals"),
# (831, "Taluk Headquarters Hospitals"), # Change from "Taluk Headquarters Hospitals" to "Taluk Hospitals"
(840, "Women and Child Health Centres"),
(850, "General hospitals"), # TODO: same as 8, need to merge
# (850, "General hospitals"), # Change from "General hospitals" to "District Hospitals"
(860, "District Hospitals"),
(870, "Govt Medical College Hospitals"),
(900, "Co-operative hospitals"),
(910, "Autonomous healthcare facility"),
# Use 9xx for Labs
(950, "Corona Testing Labs"),
# (950, "Corona Testing Labs"), # Change from "Corona Testing Labs" to "Govt Labs"
# Use 10xx for Corona Care Center
(1000, "Corona Care Centre"),
# (1000, "Corona Care Centre"), # Change from "Corona Care Centre" to "Other"
(1010, "COVID-19 Domiciliary Care Center"),
# Use 11xx for First Line Treatment Centre
(1100, "First Line Treatment Centre"),
Expand Down

0 comments on commit 93c8604

Please sign in to comment.