@@ -28,36 +28,21 @@ def in_status(self, *statuses):
2828
2929 def remaining (self ):
3030 return self .in_status (
31- AppointmentStatus .CONFIRMED ,
32- AppointmentStatus .CHECKED_IN ,
33- AppointmentStatus .STARTED ,
34- AppointmentStatus .IDENTITY_CONFIRMED ,
35- AppointmentStatus .MEDICAL_INFORMATION_REVIEWED ,
36- AppointmentStatus .IMAGES_TAKEN ,
31+ * AppointmentStatus .YET_TO_BEGIN_STATUSES ,
32+ * AppointmentStatus .IN_PROGRESS_STATUSES ,
3733 )
3834
3935 def checked_in (self ):
4036 return self .in_status (AppointmentStatus .CHECKED_IN )
4137
4238 def in_progress (self ):
43- return self .in_status (
44- AppointmentStatus .STARTED ,
45- AppointmentStatus .IDENTITY_CONFIRMED ,
46- AppointmentStatus .MEDICAL_INFORMATION_REVIEWED ,
47- AppointmentStatus .IMAGES_TAKEN ,
48- )
39+ return self .in_status (* AppointmentStatus .IN_PROGRESS_STATUSES )
4940
5041 def for_participant (self , participant_id ):
5142 return self .filter (screening_episode__participant_id = participant_id )
5243
5344 def complete (self ):
54- return self .in_status (
55- AppointmentStatus .CANCELLED ,
56- AppointmentStatus .DID_NOT_ATTEND ,
57- AppointmentStatus .SCREENED ,
58- AppointmentStatus .PARTIALLY_SCREENED ,
59- AppointmentStatus .ATTENDED_NOT_SCREENED ,
60- )
45+ return self .in_status (* AppointmentStatus .FINAL_STATUSES )
6146
6247 def upcoming (self ):
6348 return self .filter (clinic_slot__starts_at__date__gte = date .today ())
@@ -175,6 +160,27 @@ class AppointmentStatus(models.Model):
175160 PARTIALLY_SCREENED : "Partially screened" ,
176161 ATTENDED_NOT_SCREENED : "Attended not screened" ,
177162 }
163+
164+ YET_TO_BEGIN_STATUSES = [
165+ CONFIRMED ,
166+ CHECKED_IN ,
167+ ]
168+
169+ IN_PROGRESS_STATUSES = [
170+ STARTED ,
171+ IDENTITY_CONFIRMED ,
172+ MEDICAL_INFORMATION_REVIEWED ,
173+ IMAGES_TAKEN ,
174+ ]
175+
176+ FINAL_STATUSES = [
177+ CANCELLED ,
178+ DID_NOT_ATTEND ,
179+ SCREENED ,
180+ PARTIALLY_SCREENED ,
181+ ATTENDED_NOT_SCREENED ,
182+ ]
183+
178184 name = models .CharField (choices = STATUS_CHOICES , max_length = 50 , default = CONFIRMED )
179185
180186 id = models .UUIDField (default = uuid .uuid4 , editable = False , primary_key = True )
@@ -198,25 +204,14 @@ def active(self):
198204 """
199205 return self .is_in_progress () or self .is_yet_to_begin ()
200206
201- def is_final_status (self ):
202- return self .name in [
203- self .CANCELLED ,
204- self .DID_NOT_ATTEND ,
205- self .SCREENED ,
206- self .PARTIALLY_SCREENED ,
207- self .ATTENDED_NOT_SCREENED ,
208- ]
207+ def is_yet_to_begin (self ):
208+ return self .name in self .YET_TO_BEGIN_STATUSES
209209
210210 def is_in_progress (self ):
211- return self .name in [
212- self .STARTED ,
213- self .IDENTITY_CONFIRMED ,
214- self .MEDICAL_INFORMATION_REVIEWED ,
215- self .IMAGES_TAKEN ,
216- ]
211+ return self .name in self .IN_PROGRESS_STATUSES
217212
218- def is_yet_to_begin (self ):
219- return self .name in [ self .CONFIRMED , self . CHECKED_IN ]
213+ def is_final_status (self ):
214+ return self .name in self .FINAL_STATUSES
220215
221216 def __str__ (self ):
222217 return self .name
0 commit comments