-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
converted investigation and investigation group data into JSON (#1912)
* converted investigation and investigation group data into JSON * created json files for investigations and investigation_groups * updated investigations.json * fixed json data,command and migrations * fixing migrations * fixing lint issue * update migrations * update migrations --------- Co-authored-by: Aakash Singh <[email protected]>
- Loading branch information
1 parent
6ed4494
commit a5171a8
Showing
5 changed files
with
1,971 additions
and
175 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Generated by Django 4.2.10 on 2024-03-30 09:46 | ||
|
||
from django.db import migrations, models | ||
from django.db.models import F, Window | ||
from django.db.models.functions import RowNumber | ||
|
||
|
||
def fix_duplicate_investigation_names(apps, schema_editor): | ||
PatientInvestigation = apps.get_model("facility", "PatientInvestigation") | ||
|
||
window = Window( | ||
expression=RowNumber(), | ||
partition_by=[F("name")], | ||
order_by=F("id").asc(), | ||
) | ||
|
||
investigations = PatientInvestigation.objects.annotate(row_number=window).filter( | ||
row_number__gt=1 | ||
) | ||
|
||
for investigation in investigations: | ||
investigation.name = f"{investigation.name}_{investigation.row_number - 1}" | ||
|
||
PatientInvestigation.objects.bulk_update(investigations, ["name"], batch_size=2000) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("facility", "0433_alter_hospitaldoctors_area"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(fix_duplicate_investigation_names), | ||
migrations.AlterField( | ||
model_name="patientinvestigation", | ||
name="name", | ||
field=models.CharField(max_length=500, unique=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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[ | ||
{ | ||
"id": "1", | ||
"name": "Haematology" | ||
}, | ||
{ | ||
"id": "2", | ||
"name": "Biochemistry test" | ||
}, | ||
{ | ||
"id": "3", | ||
"name": "Urine Test" | ||
}, | ||
{ | ||
"id": "4", | ||
"name": "CBC" | ||
}, | ||
{ | ||
"id": "5", | ||
"name": "Differential white blood cell count" | ||
}, | ||
{ | ||
"id": "6", | ||
"name": "Liver Function Test" | ||
}, | ||
{ | ||
"id": "7", | ||
"name": "Kidney Function test" | ||
} | ||
] |
Oops, something went wrong.