-
Notifications
You must be signed in to change notification settings - Fork 331
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/lock-asset-and-privacy
- Loading branch information
Showing
29 changed files
with
1,504 additions
and
89 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
33 changes: 33 additions & 0 deletions
33
care/facility/migrations/0415_alter_patientmetainfo_head_of_household_and_more.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,33 @@ | ||
# Generated by Django 4.2.10 on 2024-02-20 13:26 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("facility", "0414_remove_bed_old_name"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="patientmetainfo", | ||
name="head_of_household", | ||
field=models.BooleanField(blank=True, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name="patientmetainfo", | ||
name="occupation", | ||
field=models.IntegerField( | ||
blank=True, | ||
choices=[ | ||
(1, "STUDENT"), | ||
(2, "BUSINESSMAN"), | ||
(3, "HEALTH_CARE_WORKER"), | ||
(4, "HEALTH_CARE_LAB_WORKER"), | ||
(5, "ANIMAL_HANDLER"), | ||
(6, "OTHERS"), | ||
], | ||
null=True, | ||
), | ||
), | ||
] |
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,42 @@ | ||
# Generated by Django 4.2.10 on 2024-02-26 20:00 | ||
|
||
from django.db import migrations | ||
from django.db.models import Count, F, Value, Window | ||
from django.db.models.functions import RowNumber | ||
|
||
|
||
def fix_duplicate_patient_numbers(apps, schema_editor): | ||
PatientConsultation = apps.get_model("facility", "PatientConsultation") | ||
|
||
PatientConsultation.objects.filter(patient_no__regex=r"^\s*$").update( | ||
patient_no=None | ||
) | ||
|
||
window = Window( | ||
expression=RowNumber(), | ||
partition_by=[F("patient_no"), F("facility")], | ||
order_by=F("id").asc(), | ||
) | ||
|
||
consultations = PatientConsultation.objects.annotate(row_number=window).filter( | ||
row_number__gt=1, patient_no__isnull=False | ||
) | ||
|
||
for consultation in consultations: | ||
consultation.patient_no = ( | ||
f"{consultation.patient_no}_{consultation.row_number - 1}" | ||
) | ||
|
||
PatientConsultation.objects.bulk_update( | ||
consultations, ["patient_no"], batch_size=2000 | ||
) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("facility", "0414_remove_bed_old_name"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(fix_duplicate_patient_numbers, migrations.RunPython.noop), | ||
] |
20 changes: 20 additions & 0 deletions
20
care/facility/migrations/0416_patientconsultation_unique_patient_no_within_facility.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,20 @@ | ||
# Generated by Django 4.2.10 on 2024-02-26 20:08 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("facility", "0415_auto_20240227_0130"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddConstraint( | ||
model_name="patientconsultation", | ||
constraint=models.UniqueConstraint( | ||
condition=models.Q(("patient_no__isnull", False)), | ||
fields=("patient_no", "facility"), | ||
name="unique_patient_no_within_facility", | ||
), | ||
), | ||
] |
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,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), | ||
] |
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-03-05 12:35 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("facility", "0416_patientconsultation_unique_patient_no_within_facility"), | ||
("facility", "0416_update_facility_types"), | ||
] | ||
|
||
operations = [] |
Oops, something went wrong.