Skip to content

Commit

Permalink
Added migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
aeswibon committed Jul 7, 2022
1 parent 5fabd9f commit 085a69f
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions care/facility/migrations/0302_auto_20220707_1737.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Generated by Django 2.2.11 on 2022-07-07 12:07

from django.db import migrations, models

def populate_data(apps, schema_editor):
# Models
PatientConsultation = apps.get_model('facility', 'PatientConsultation')

# objects
patient_cons = PatientConsultation.objects.all()

# populate the data
for patient in patient_cons:
# find the data
ongoing_medication = patient.patient__ongoning_medication
present_health = patient.patient__present_health

# assign the data
if ongoing_medication is not None:
patient.ongoing_medication = ongoing_medication

if present_health is not None:
patient.present_health = present_health

# save the data
patient.save()


class Migration(migrations.Migration):

dependencies = [
('facility', '0301_auto_20220707_1724'),
]

operations = [
migrations.AddField(
model_name='patientconsultation',
name='ongoing_medication',
field=models.TextField(blank=True, default='', verbose_name='Already pescribed medication if any'),
),
migrations.AddField(
model_name='patientconsultation',
name='present_health',
field=models.TextField(blank=True, default='', verbose_name="Patient's Current Health Details"),
),
migrations.RunPython(populate_data, migrations.RunPython.noop),
migrations.RemoveField(
model_name='historicalpatientregistration',
name='ongoing_medication',
),
migrations.RemoveField(
model_name='historicalpatientregistration',
name='present_health',
),
migrations.RemoveField(
model_name='patientregistration',
name='ongoing_medication',
),
migrations.RemoveField(
model_name='patientregistration',
name='present_health',
),
]

0 comments on commit 085a69f

Please sign in to comment.