Skip to content

Commit

Permalink
Removed inconsistent Migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
vigneshhari committed May 13, 2021
1 parent 872b08a commit c3e9dc1
Showing 1 changed file with 30 additions and 29 deletions.
59 changes: 30 additions & 29 deletions care/facility/migrations/0220_populate_investigations.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,35 +148,36 @@ def none_or_float(val):


def populate_investigations(apps, *args):
PatientInvestigation = apps.get_model("facility", "patientinvestigation")
PatientInvestigationGroup = apps.get_model("facility", "patientinvestigationgroup")
investigation_group_data = investigation_groups.split("\n")[1:]
investigation_group_dict = {}
for investigation_group in investigation_group_data:
current_investigation_group = investigation_group.split("\t")
current_obj = PatientInvestigationGroup.objects.filter(name=current_investigation_group[1]).first()
if not current_obj:
current_obj = PatientInvestigationGroup(name=current_investigation_group[1])
current_obj.save()
investigation_group_dict[current_investigation_group[0]] = current_obj
investigation_data = investigations.split("\n")[1:]
for investigation in investigation_data:
current_investigation = investigation.split("\t")
data = {
"name": current_investigation[0],
"unit": current_investigation[1],
"ideal_value": current_investigation[2],
"min_value": none_or_float(current_investigation[3]),
"max_value": none_or_float(current_investigation[4]),
"investigation_type": current_investigation[5],
"choices": current_investigation[6],
}
current_obj = PatientInvestigation.objects.filter(**data).first()
if not current_obj:
current_obj = PatientInvestigation(**data)
current_obj.save()
current_obj.groups.add(investigation_group_dict[current_investigation[7]])
current_obj.save()
# PatientInvestigation = apps.get_model("facility", "patientinvestigation")
# PatientInvestigationGroup = apps.get_model("facility", "patientinvestigationgroup")
# investigation_group_data = investigation_groups.split("\n")[1:]
# investigation_group_dict = {}
# for investigation_group in investigation_group_data:
# current_investigation_group = investigation_group.split("\t")
# current_obj = PatientInvestigationGroup.objects.filter(name=current_investigation_group[1]).first()
# if not current_obj:
# current_obj = PatientInvestigationGroup(name=current_investigation_group[1])
# current_obj.save()
# investigation_group_dict[current_investigation_group[0]] = current_obj
# investigation_data = investigations.split("\n")[1:]
# for investigation in investigation_data:
# current_investigation = investigation.split("\t")
# data = {
# "name": current_investigation[0],
# "unit": current_investigation[1],
# "ideal_value": current_investigation[2],
# "min_value": none_or_float(current_investigation[3]),
# "max_value": none_or_float(current_investigation[4]),
# "investigation_type": current_investigation[5],
# "choices": current_investigation[6],
# }
# current_obj = PatientInvestigation.objects.filter(**data).first()
# if not current_obj:
# current_obj = PatientInvestigation(**data)
# current_obj.save()
# current_obj.groups.add(investigation_group_dict[current_investigation[7]])
# current_obj.save()
pass # This has been deprecated since the investigation data has been changed and is no longer consistent


def reverse_populate_investigations(apps, *args):
Expand Down

0 comments on commit c3e9dc1

Please sign in to comment.