def test_get_first_incomplete_phase(self): testAssign, testPatient, testProcedure = self.test_create_assignedProcedure( ) testProcedure2 = Procedure.objects.create(procedure_name="Procedure 2") testProcedure3 = Procedure.objects.create(procedure_name="Procedure 3") assigned2 = AssignedProcedures.assign_procedure_to_patient( 2, testPatient, testProcedure2) assigned3 = AssignedProcedures.assign_procedure_to_patient( 3, testPatient, testProcedure3) first_incomplete_phase = AssignedProcedures.get_first_incomplete_phase( testPatient) self.assertEqual(first_incomplete_phase, 1) AssignedProcedures.set_complete(testPatient, testProcedure, 1) first_incomplete_phase = AssignedProcedures.get_first_incomplete_phase( testPatient) self.assertEqual(first_incomplete_phase, 2) AssignedProcedures.set_complete(testPatient, testProcedure2, 2) first_incomplete_phase = AssignedProcedures.get_first_incomplete_phase( testPatient) self.assertEqual(first_incomplete_phase, 3)
def get_patient_next_procedures(self): from assigned_procedures.models import AssignedProcedures first_incomplete_phase = AssignedProcedures.get_first_incomplete_phase( self) next_procedure_list = [] final_procedures = AssignedProcedures.objects.filter( patient=self, phaseNumber=first_incomplete_phase, completed=False) for incomplete_procedure in final_procedures: next_procedure_list.append(incomplete_procedure.procedure.all()[0]) return next_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"