def patient_final_procedures(self): from assigned_procedures.models import AssignedProcedures final_phase_for_patient = AssignedProcedures.get_final_phase_number( self) final_procedure_list = [] final_procedures = AssignedProcedures.objects.filter( patient=self, phaseNumber=final_phase_for_patient) for single_procedure in final_procedures: final_procedure_list.append(single_procedure.procedure.all()[0]) return final_procedure_list
def patient_status(self): from assigned_procedures.models import AssignedProcedures # If the patient doesn't have any procedures assigned, then they've only been referred # If the patient has procedures, but the first_incomplete_phase is not the final phase, then they aren't ready for the final procedure(s) # Only procedures left for the patient are the final ones # Patient has procedures that are all completed first_incomplete_phase = AssignedProcedures.get_first_incomplete_phase( self) final_phase_for_patient = AssignedProcedures.get_final_phase_number( self) if not AssignedProcedures.objects.filter(patient=self): return "Referred" elif first_incomplete_phase < final_phase_for_patient: return "In-Progress" elif first_incomplete_phase == final_phase_for_patient: return "Ready" else: return "Done"