Skip to content

Commit

Permalink
some more minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
iamsdas committed Mar 12, 2022
1 parent 613eff3 commit c9b5f5c
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 11 deletions.
35 changes: 35 additions & 0 deletions arike/facilities/migrations/0010_auto_20220312_1912.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Generated by Django 3.2.12 on 2022-03-12 13:42

import datetime
from django.db import migrations, models
from django.utils.timezone import utc


class Migration(migrations.Migration):

dependencies = [
('facilities', '0009_auto_20220304_2237'),
]

operations = [
migrations.AlterField(
model_name='facility',
name='created_at',
field=models.DateTimeField(default=datetime.datetime(2022, 3, 12, 13, 42, 45, 775102, tzinfo=utc)),
),
migrations.AlterField(
model_name='localbody',
name='created_at',
field=models.DateTimeField(default=datetime.datetime(2022, 3, 12, 13, 42, 45, 774451, tzinfo=utc)),
),
migrations.AlterField(
model_name='state',
name='created_at',
field=models.DateTimeField(default=datetime.datetime(2022, 3, 12, 13, 42, 45, 773814, tzinfo=utc)),
),
migrations.AlterField(
model_name='ward',
name='created_at',
field=models.DateTimeField(default=datetime.datetime(2022, 3, 12, 13, 42, 45, 774777, tzinfo=utc)),
),
]
1 change: 0 additions & 1 deletion arike/patients/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class Meta:
"education",
"occupation",
"remarks",
"patient",
]


Expand Down
40 changes: 40 additions & 0 deletions arike/patients/migrations/0016_auto_20220312_1912.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generated by Django 3.2.12 on 2022-03-12 13:42

import datetime
from django.db import migrations, models
from django.utils.timezone import utc


class Migration(migrations.Migration):

dependencies = [
('patients', '0015_auto_20220304_2237'),
]

operations = [
migrations.AlterField(
model_name='disease',
name='created_at',
field=models.DateTimeField(default=datetime.datetime(2022, 3, 12, 13, 42, 45, 778296, tzinfo=utc)),
),
migrations.AlterField(
model_name='familymember',
name='created_at',
field=models.DateTimeField(default=datetime.datetime(2022, 3, 12, 13, 42, 45, 777857, tzinfo=utc)),
),
migrations.AlterField(
model_name='patient',
name='created_at',
field=models.DateTimeField(default=datetime.datetime(2022, 3, 12, 13, 42, 45, 777382, tzinfo=utc)),
),
migrations.AlterField(
model_name='patientdisease',
name='created_at',
field=models.DateTimeField(default=datetime.datetime(2022, 3, 12, 13, 42, 45, 778569, tzinfo=utc)),
),
migrations.AlterField(
model_name='treatment',
name='created_at',
field=models.DateTimeField(default=datetime.datetime(2022, 3, 12, 13, 42, 45, 778881, tzinfo=utc)),
),
]
4 changes: 3 additions & 1 deletion arike/patients/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
path("<pk>/delete/", view=PatientDeleteView.as_view(), name="delete"),
path("<pk>/family/", view=FamilyListVeiw.as_view(), name="family"),
path("<pk>/family/add/", view=MemberCreateView.as_view(), name="family_add"),
path("<pk>/family/<id>/", view=MemberUpdateView.as_view(), name="family_update"),
path(
"<pk>/family/<id>/update", view=MemberUpdateView.as_view(), name="family_update"
),
path("<pk>/family/del/<id>/", view=MemberDeleteView.as_view(), name="family_del"),
path("<pk>/disease/", view=DiseaseListVeiw.as_view(), name="disease"),
path("<pk>/disease/add/", view=DiseaseCreateView.as_view(), name="disease_add"),
Expand Down
17 changes: 10 additions & 7 deletions arike/patients/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
)
from arike.patients.models import FamilyMember, Patient, PatientDisease, Treatment
from arike.facilities.models import Ward
from arike.visits.models import TreatmentNote, VisitDetails, VisitSchedule
from arike.visits.models import TreatmentNote, VisitDetails
from arike.users.models import UserRoles


Expand Down Expand Up @@ -70,12 +70,17 @@ class GenericFamilyMemberFormView(NurseAuthMixin):
slug_url_kwarg = "id"

def get_queryset(self):
patient_pk = self.kwargs["pk"]
return FamilyMember.objects.filter(patient__pk=patient_pk, deleted=False)
return FamilyMember.objects.all()

def get_success_url(self):
return reverse_lazy("patients:family", kwargs={"pk": self.kwargs["pk"]})

def form_valid(self, form):
self.object = form.save(commit=False)
self.object.patient = Patient.objects.get(pk=self.kwargs["pk"])
self.object.save()
return HttpResponseRedirect(self.get_success_url())


class MemberCreateView(GenericFamilyMemberFormView, CreateView):
pass
Expand All @@ -96,8 +101,7 @@ class GenericDiseaseFormView(NurseAuthMixin):
slug_url_kwarg = "id"

def get_queryset(self):
patient_pk = self.kwargs["pk"]
return PatientDisease.objects.filter(patient__pk=patient_pk)
return PatientDisease.objects.all()

def get_success_url(self):
return reverse_lazy("patients:disease", kwargs={"pk": self.kwargs["pk"]})
Expand Down Expand Up @@ -128,8 +132,7 @@ class GenericTreatmentFormView(NurseAuthMixin):
slug_url_kwarg = "id"

def get_queryset(self):
patient_pk = self.kwargs["pk"]
return Treatment.objects.filter(patient__pk=patient_pk)
return Treatment.objects.all()

def get_success_url(self):
return reverse_lazy("patients:treatments", kwargs={"pk": self.kwargs["pk"]})
Expand Down
24 changes: 24 additions & 0 deletions arike/users/migrations/0015_auto_20220312_1912.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 3.2.12 on 2022-03-12 13:42

import datetime
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('users', '0014_alter_user_email_preff_time'),
]

operations = [
migrations.AlterField(
model_name='user',
name='email_last_sent',
field=models.DateField(default=datetime.date(2022, 3, 12)),
),
migrations.AlterField(
model_name='user',
name='email_preff_time',
field=models.TimeField(default=datetime.time(13, 42, 45, 775599)),
),
]
30 changes: 30 additions & 0 deletions arike/visits/migrations/0007_auto_20220312_1912.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Generated by Django 3.2.12 on 2022-03-12 13:42

import datetime
from django.db import migrations, models
from django.utils.timezone import utc


class Migration(migrations.Migration):

dependencies = [
('visits', '0006_auto_20220304_2237'),
]

operations = [
migrations.AlterField(
model_name='treatmentnote',
name='created_at',
field=models.DateTimeField(default=datetime.datetime(2022, 3, 12, 13, 42, 45, 780550, tzinfo=utc)),
),
migrations.AlterField(
model_name='visitdetails',
name='created_at',
field=models.DateTimeField(default=datetime.datetime(2022, 3, 12, 13, 42, 45, 780052, tzinfo=utc)),
),
migrations.AlterField(
model_name='visitschedule',
name='created_at',
field=models.DateTimeField(default=datetime.datetime(2022, 3, 12, 13, 42, 45, 779619, tzinfo=utc)),
),
]
6 changes: 4 additions & 2 deletions arike/visits/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class TreatmentsListVeiw(NurseAuthMixin, ListView):
def get_queryset(self):
schedule = VisitSchedule.objects.get(pk=self.kwargs["pk"])
patient = schedule.patient
treatments = Treatment.objects.filter(patient=patient)
treatments = Treatment.objects.filter(patient=patient, deleted=False)
return treatments

def get_context_data(self, **kwargs):
Expand All @@ -106,7 +106,9 @@ class GenericTreatmenNotetFormView(NurseAuthMixin):

def get_queryset(self):
schedule = VisitSchedule.objects.get(pk=self.kwargs["pk"])
return TreatmentNote.objects.filter(treatment__patient=schedule.patient)
return TreatmentNote.objects.filter(
treatment__patient=schedule.patient, deleted=False
)

def get_success_url(self):
return reverse_lazy("visits:treatments", kwargs={"pk": self.kwargs["pk"]})
Expand Down

0 comments on commit c9b5f5c

Please sign in to comment.