def homepage(request): if request.method == 'GET': return render( request, 'homepage.html', { 'title': 'Home', 'patients': Patients.objects.all(), 'alert_patients': AssignedProcedures.update_and_return_all_patient_goal_flags() })
def test_update_all_patient_goal_flags(self): result = AssignedProcedures.update_and_return_all_patient_goal_flags() self.assertEqual(result, []) tPatient3 = Patients.objects.create(first_name="Woof", last_name="Daddy", bday=datetime(1996, 10, 24)) tPatient3.toggle_flag() tPatient3.save() self.assertEqual( AssignedProcedures.update_and_return_all_patient_goal_flags(), [tPatient3]) tPatient = Patients.objects.create(first_name="Kyle", last_name="Dorcey", bday=datetime(1996, 10, 24)) tPatient.save() tPatient2 = Patients.objects.create(first_name="Mr", last_name="Magoo", bday=datetime(1996, 10, 24)) tPatient2.save() testProcedure = Procedure.objects.create(procedure_name="Leaches") testProcedure.save() testProcedure2 = Procedure.objects.create(procedure_name="moo") testProcedure2.save() AssignedProcedures.assign_procedure_to_patient(1, tPatient, testProcedure) AssignedProcedures.assign_procedure_to_patient(2, tPatient, testProcedure2, -10) AssignedProcedures.assign_procedure_to_patient(1, tPatient2, testProcedure) AssignedProcedures.assign_procedure_to_patient(2, tPatient2, testProcedure2, -10) result = AssignedProcedures.update_and_return_all_patient_goal_flags() self.assertEqual(result, [tPatient3, tPatient, tPatient2])
def calculate_behind_procedure_prec(): totalProc = 0 for indivAssignedProc in AssignedProcedures.get_all_active_procedures( ): totalProc += 1 behindProc = 0 for flaggedPatients in AssignedProcedures.update_and_return_all_patient_goal_flags( ): if flaggedPatients.behind_flag is True: behindProc += 1 if totalProc is 0: percentBehind = 0 else: percentBehind = (behindProc / totalProc) * 100 Analytics.behind_procedure_perc = percentBehind return round(percentBehind, 1)