1313)
1414from arike .patients .models import FamilyMember , Patient , PatientDisease , Treatment
1515from arike .facilities .models import Ward
16- from arike .visits .models import TreatmentNote , VisitDetails , VisitSchedule
16+ from arike .visits .models import TreatmentNote , VisitDetails
1717from arike .users .models import UserRoles
1818
1919
@@ -70,12 +70,17 @@ class GenericFamilyMemberFormView(NurseAuthMixin):
7070 slug_url_kwarg = "id"
7171
7272 def get_queryset (self ):
73- patient_pk = self .kwargs ["pk" ]
74- return FamilyMember .objects .filter (patient__pk = patient_pk , deleted = False )
73+ return FamilyMember .objects .all ()
7574
7675 def get_success_url (self ):
7776 return reverse_lazy ("patients:family" , kwargs = {"pk" : self .kwargs ["pk" ]})
7877
78+ def form_valid (self , form ):
79+ self .object = form .save (commit = False )
80+ self .object .patient = Patient .objects .get (pk = self .kwargs ["pk" ])
81+ self .object .save ()
82+ return HttpResponseRedirect (self .get_success_url ())
83+
7984
8085class MemberCreateView (GenericFamilyMemberFormView , CreateView ):
8186 pass
@@ -96,8 +101,7 @@ class GenericDiseaseFormView(NurseAuthMixin):
96101 slug_url_kwarg = "id"
97102
98103 def get_queryset (self ):
99- patient_pk = self .kwargs ["pk" ]
100- return PatientDisease .objects .filter (patient__pk = patient_pk )
104+ return PatientDisease .objects .all ()
101105
102106 def get_success_url (self ):
103107 return reverse_lazy ("patients:disease" , kwargs = {"pk" : self .kwargs ["pk" ]})
@@ -128,8 +132,7 @@ class GenericTreatmentFormView(NurseAuthMixin):
128132 slug_url_kwarg = "id"
129133
130134 def get_queryset (self ):
131- patient_pk = self .kwargs ["pk" ]
132- return Treatment .objects .filter (patient__pk = patient_pk )
135+ return Treatment .objects .all ()
133136
134137 def get_success_url (self ):
135138 return reverse_lazy ("patients:treatments" , kwargs = {"pk" : self .kwargs ["pk" ]})
0 commit comments