Exemple #1
0
    def test_patient_today(self):
        from assigned_procedures.models import AssignedProcedures
        from procedures.models import Procedure

        tPatient = self.create_patient()
        tPatient.save()

        actualResult = tPatient.patient_status()

        self.assertEqual("Referred", actualResult)

        tProcedure = Procedure.objects.create(procedure_name="leeches")
        tProcedure.save()
        tProcedure2 = Procedure.objects.create(procedure_name="Bloodwork")
        tProcedure2.save()
        tProcedure3 = Procedure.objects.create(procedure_name="TAVR")
        tProcedure3.save()

        ap1 = AssignedProcedures.assign_procedure_to_patient(
            1, tPatient, tProcedure)
        self.assertFalse(tPatient.has_incomplete_procedure_today())
        ap1.scheduled = True
        ap1.save()
        ap2 = AssignedProcedures.assign_procedure_to_patient(
            2, tPatient, tProcedure2)
        ap3 = AssignedProcedures.assign_procedure_to_patient(
            3, tPatient, tProcedure3)

        expected_list = [tProcedure]
        final_procedures_list = tPatient.procedures_for_today()
        self.assertListEqual(expected_list, final_procedures_list)
        self.assertTrue(tPatient.has_incomplete_procedure_today())
Exemple #2
0
 def test_check_goal_status(self):
     testAssign, testPatient, testProcedure = self.test_create_assignedProcedure(
     )
     result = AssignedProcedures.check_goal_status(testPatient,
                                                   testProcedure)
     self.assertEqual(result, "not scheduled")
     tAssignment = AssignedProcedures.assign_procedure_to_patient(
         step=2,
         patientToLink=testPatient,
         procedureToLink=testProcedure,
         proc_est=2,
         return_visit=True)
     resultz = AssignedProcedures.check_goal_status(testPatient,
                                                    testProcedure, 2)
     self.assertEqual(resultz, "in progress (on time)")
     AssignedProcedures.toggle_completed(testPatient, testProcedure, 2)
     tAssignment = AssignedProcedures.assign_procedure_to_patient(
         step=3,
         patientToLink=testPatient,
         procedureToLink=testProcedure,
         proc_est=2,
         return_visit=True)
     resultz = AssignedProcedures.check_goal_status(testPatient,
                                                    testProcedure, 2)
     self.assertEqual(resultz, "completed (on time)")
Exemple #3
0
    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)
Exemple #4
0
    def test_calculate_behind_procedure_prec(self):
        tpatient, tprocedure, tassignedProc = self.test_create_test_inputs()

        self.assertEqual(Analytics.calculate_behind_procedure_prec(), 0)

        tprocedure2 = Procedure.objects.create(procedure_name="TAVR Old", est_days_to_complete=-2)

        AssignedProcedures.assign_procedure_to_patient(2, tpatient, tprocedure2)

        self.assertEqual(Analytics.calculate_behind_procedure_prec(), 50)
        self.assertEqual(Analytics.behind_procedure_perc, 50)
Exemple #5
0
 def test_remove_assigned_procedure(self):
     testAssign, testPatient, testProcedure = self.test_create_assignedProcedure(
     )
     tProcedure = Procedure.objects.create(procedure_name="TAVR")
     AssignedProcedures.assign_procedure_to_patient(2, testPatient,
                                                    tProcedure)
     AssignedProcedures.remove_assigned_procedure(testPatient,
                                                  testProcedure, 1)
     toCheck = AssignedProcedures.get_all_procedures(testPatient)
     correct = [(tProcedure, 2)]
     self.assertEqual(toCheck, correct)
Exemple #6
0
 def test_get_all_procedures(self):
     # one linked procedure case
     testAssign, testPatient, testProcedure = self.test_create_assignedProcedure(
     )
     quiriedProcedure = AssignedProcedures.get_all_procedures(testPatient)
     self.assertEqual(quiriedProcedure[0], (testProcedure, 1))
     # two linked procedures case
     tProcedure = Procedure.objects.create(procedure_name="bloodwork")
     AssignedProcedures.assign_procedure_to_patient(2, testPatient,
                                                    tProcedure)
     quiriedProcedure = AssignedProcedures.get_all_procedures(testPatient)
     self.assertEqual(quiriedProcedure, [(testProcedure, 1),
                                         (tProcedure, 2)])
Exemple #7
0
    def test_flag_update(self):
        from assigned_procedures.models import AssignedProcedures
        from procedures.models import Procedure

        tProcedure = Procedure.objects.create(procedure_name="leeches")
        tProcedure.save()
        tProcedure2 = Procedure.objects.create(procedure_name="Bloodwork")
        tProcedure2.save()
        tProcedure3 = Procedure.objects.create(procedure_name="TAVR")
        tProcedure3.save()
        tPatient = self.create_patient()
        tPatient.save()

        AssignedProcedures.assign_procedure_to_patient(1, tPatient, tProcedure)
        AssignedProcedures.assign_procedure_to_patient(2, tPatient,
                                                       tProcedure2)
        AssignedProcedures.assign_procedure_to_patient(3, tPatient,
                                                       tProcedure3)

        self.assertEqual(tPatient.flag_update(), (None, False))
        tProcedure = Procedure.objects.create(procedure_name="mmmhm popy")
        tProcedure.save()
        AssignedProcedures.assign_procedure_to_patient(4, tPatient, tProcedure,
                                                       -10)
        self.assertEqual(tPatient.flag_update(), (tProcedure, True))
Exemple #8
0
 def test_create_assignedProcedureReturnVisit(self):
     tPatient = Patients.objects.create(first_name="Kyle",
                                        last_name="Dorce",
                                        bday=datetime(1996, 10, 24))
     tProcedure = Procedure.objects.create(procedure_name="leeches")
     tAssignment = AssignedProcedures.assign_procedure_to_patient(
         1, tPatient, tProcedure, True)
     return tAssignment, tPatient, tProcedure
Exemple #9
0
    def test_return_all_behind_procedures(self):
        tpatient, tprocedure, tassignedProc = self.test_create_test_inputs()
        self.assertEqual(Analytics.return_all_behind_procedures(), [])

        tprocedure2 = Procedure.objects.create(procedure_name="TAVR Old", est_days_to_complete=-2)

        solution = AssignedProcedures.assign_procedure_to_patient(2, tpatient, tprocedure2)

        self.assertEqual(Analytics.return_all_behind_procedures(), [solution])
Exemple #10
0
    def test_patient_status(self):
        from assigned_procedures.models import AssignedProcedures
        from procedures.models import Procedure

        tPatient = self.create_patient()
        tPatient.save()

        actualResult = tPatient.patient_status()

        self.assertEqual("Referred", actualResult)

        tProcedure = Procedure.objects.create(procedure_name="leeches")
        tProcedure.save()
        tProcedure2 = Procedure.objects.create(procedure_name="Bloodwork")
        tProcedure2.save()
        tProcedure3 = Procedure.objects.create(procedure_name="TAVR")
        tProcedure3.save()

        ap1 = AssignedProcedures.assign_procedure_to_patient(
            1, tPatient, tProcedure)
        ap2 = AssignedProcedures.assign_procedure_to_patient(
            2, tPatient, tProcedure2)
        ap3 = AssignedProcedures.assign_procedure_to_patient(
            3, tPatient, tProcedure3)

        actualResult = tPatient.patient_status()

        self.assertEqual("In-Progress", actualResult)

        ap1.completed = True
        ap1.save()
        ap2.completed = True
        ap2.save()

        actualResult = tPatient.patient_status()

        self.assertEqual("Ready", actualResult)

        ap3.completed = True
        ap3.save()

        actualResult = tPatient.patient_status()

        self.assertEqual("Done", actualResult)
Exemple #11
0
    def test_has_missed_appointment(self):
        tPatient = Patients.objects.create(first_name="Kyle", last_name="Moo", bday="2000-01-01", referring_physician="Mr magoo",
                                date_of_referral="2019-12-22")
        tProcedure = Procedure.objects.create(procedure_name="leaches")
        tProcedure2 = Procedure.objects.create(procedure_name="bloodwork")

        tAssignedProc = AssignedProcedures.assign_procedure_to_patient(1,tPatient,tProcedure)
        tAssignedProc.date_scheduled = datetime(2019,3,22)
        tAssignedProc.scheduled = True
        AssignedProcedures.toggle_completed(tPatient,tProcedure)

        tAssignedProc2 = AssignedProcedures.assign_procedure_to_patient(2,tPatient,tProcedure2)
        tAssignedProc2.date_scheduled = datetime(2019,2,22)
        tAssignedProc2.scheduled = True
        AssignedProcedures.toggle_completed(tPatient,tProcedure2)
        tAssignedProc.save()
        tAssignedProc2.save()

        self.assertEqual(True,tPatient.has_missed_appointment())
Exemple #12
0
 def test_get_all_active(self):
     # one linked procedure case
     testAssign, testPatient, testProcedure = self.test_create_assignedProcedure(
     )
     # two linked procedures case
     tProcedure = Procedure.objects.create(procedure_name="bloodwork")
     assigned = AssignedProcedures.assign_procedure_to_patient(
         2, testPatient, tProcedure)
     assigned.completed = True
     assigned.save()
     quiriedProcedure = AssignedProcedures.get_all_active_procedures()
     self.assertTrue(assigned not in quiriedProcedure)
Exemple #13
0
 def test_get_average_completed(self):
     testAssign, testPatient, testProcedure = self.test_create_assignedProcedure(
     )
     # test 1 procedure 0 time
     tProcedure = Procedure.objects.create(procedure_name="bloodwork")
     assigned = AssignedProcedures.assign_procedure_to_patient(
         2, testPatient, tProcedure)
     spoof_time = assigned.created_at
     assigned.completed = True
     assigned.date_completed = spoof_time
     assigned.save()
     time = AssignedProcedures.average_completion_time(tProcedure.id)
     self.assertEqual(time, "0")
     # test 2 procedures 1 time
     assigned = AssignedProcedures.assign_procedure_to_patient(
         3, testPatient, tProcedure)
     spoof_time = assigned.created_at
     assigned.completed = True
     assigned.date_completed = spoof_time + timedelta(days=2)
     assigned.save()
     time = AssignedProcedures.average_completion_time(tProcedure.id)
     self.assertEqual(time, "1")
Exemple #14
0
    def test_get_update_page(self):
        procedure = AssignedProcedures.assign_procedure_to_patient(1, self.test_patient, self.test_object_one)
        request = self.factory.get('/assigned/procedure/?id=' + str(procedure.id))
        self.middleware.process_request(request)

        request.session.save()
        request.user = self.user

        setattr(request, 'session', 'session')
        messages = FallbackStorage(request)
        setattr(request, '_messages', messages)

        response = update(request)
        self.assertEqual(response.status_code, 200)
Exemple #15
0
 def test_create_assignedProcedure(self,
                                   first_name="Kyle",
                                   last_name="Dorce",
                                   bday=datetime(1996, 10, 24),
                                   referring_physician='Dr. Who',
                                   date_of_referral=datetime(2019, 1, 1)):
     tPatient = Patients.objects.create(
         first_name=first_name,
         last_name=last_name,
         bday=bday,
         referring_physician=referring_physician,
         date_of_referral=date_of_referral)
     tPatient.save()
     tProcedure = Procedure.objects.create(procedure_name="leeches")
     tAssignment = AssignedProcedures.assign_procedure_to_patient(
         1, tPatient, tProcedure)
     return tAssignment, tPatient, tProcedure
Exemple #16
0
    def test_post_update_page(self):
        procedure = AssignedProcedures.assign_procedure_to_patient(1, self.test_patient, self.test_object_one)
        request = self.factory.post('/assigned/procedure/?id=' + str(procedure.id), {'completion_goal': '2019-05-07', 'assigned_date': '2019-04-30', 'scheduled_date': '2019-04-30', 'scheduled': 'True', 'completed_date': '2019-04-30', 'notes': ''})

        self.middleware.process_request(request)

        request.session.save()
        request.user = self.user

        setattr(request, 'session', 'session')
        messages = FallbackStorage(request)
        setattr(request, '_messages', messages)

        response = update(request)

        updated_procedure = AssignedProcedures.objects.get(scheduled=True)
        self.assertIsNotNone(updated_procedure)
Exemple #17
0
    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])
Exemple #18
0
    def test_create_test_inputs(self):
        tpatient = Patients.objects.create(first_name="test", last_name="testlast", bday=datetime(2010, 2, 3))
        tprocedure = Procedure.objects.create(procedure_name="TAVR", est_days_to_complete=12)
        tassignedProc = AssignedProcedures.assign_procedure_to_patient(1, tpatient, tprocedure)

        return tpatient, tprocedure, tassignedProc