示例#1
0
文件: tests.py 项目: Kyle-Levy/SPP400
 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)])
示例#2
0
文件: tests.py 项目: Kyle-Levy/SPP400
 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)
示例#3
0
文件: tests.py 项目: Kyle-Levy/SPP400
    def test_add_roadmap_to_patient(self):
        tPatient = Patients.objects.create(first_name="Lyle",
                                           last_name="Magoo",
                                           bday=datetime(1996, 10, 24))
        tPatient.save()
        tRoadmap, tProcedure, tProcedure2 = self.test_create_roadmap()

        AssignedProcedures.add_roadmap_to_patient(tRoadmap, tPatient)
        toCheck = AssignedProcedures.get_all_procedures(tPatient)
        solution = [(tProcedure, 1), (tProcedure2, 2)]
        self.assertEqual(toCheck, solution)
示例#4
0
    def test_post_add_procedure_valid(self):
        add_request = self.factory.post('profile/procedures/add_procedure/?id=' + str(self.test_patient.id), {
            'procedure': [self.test_object_one.id, self.test_object_two.id, self.test_object_three.id], 'phase': 1})
        self.middleware.process_request(add_request)
        add_request.user = self.user

        response = add_procedure(add_request)
        self.assertEqual(response.status_code, 302)

        expected_list = [(self.test_object_one, 1), (self.test_object_two, 1), (self.test_object_three, 1)]

        self.assertListEqual(expected_list, AssignedProcedures.get_all_procedures(self.test_patient))
示例#5
0
    def test_post_add_roadmap_valid(self):

        post_request = self.factory.post('/patients/profile/procedures/add_roadmap/?id=' + str(self.test_patient.id),
                                         {'roadmap': [str(self.test_roadmap.id)]})
        self.middleware.process_request(post_request)
        post_request.user = self.user
        response = add_roadmap(post_request)
        self.assertEqual(response.status_code, 302)

        expected_list = [(self.test_object_one, 1), (self.test_object_two, 1), (self.test_object_three, 1)]

        self.assertListEqual(expected_list, AssignedProcedures.get_all_procedures(self.test_patient))

        return post_request
示例#6
0
    def test_post_remove_no_procedures(self):
        self.test_post_add_procedure_valid()
        remove_request = self.factory.post('/patients/profile/procedures/remove/?id=' + str(self.test_patient.id), {
            'selection[]': []
        })
        self.middleware.process_request(remove_request)
        remove_request.user = self.user
        self.middleware.process_request(remove_request)
        response = remove_pairs_from_patient(remove_request)

        self.assertEqual(response.status_code, 302)

        expected_list = [(self.test_object_one, 1), (self.test_object_two, 1), (self.test_object_three, 1)]

        self.assertListEqual(expected_list, AssignedProcedures.get_all_procedures(self.test_patient))
示例#7
0
    def test_post_add_procedure_invalid_patient_id(self):
        add_request = self.factory.post('profile/procedures/add_procedure/?id=' + str(99999), {
            'procedure': [self.test_object_one.id, self.test_object_two.id, self.test_object_three.id], 'phase': 1})
        self.middleware.process_request(add_request)
        add_request.user = self.user

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

        response = add_procedure(add_request)
        self.assertEqual(response.status_code, 302)

        expected_list = []

        self.assertListEqual(expected_list, AssignedProcedures.get_all_procedures(self.test_patient))
示例#8
0
    def test_post_add_roadmap_invalid_roadmap(self):

        post_request = self.factory.post('/patients/profile/procedures/add_roadmap/?id=' + str(self.test_patient.id), {'roadmap': [str(99999)]})
        self.middleware.process_request(post_request)
        post_request.user = self.user

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

        response = add_roadmap(post_request)
        self.assertEqual(response.status_code, 302)

        expected_list = []

        self.assertListEqual(expected_list, AssignedProcedures.get_all_procedures(self.test_patient))
示例#9
0
    def flag_update(self):
        import assigned_procedures
        from assigned_procedures.models import AssignedProcedures

        assignedProcs = AssignedProcedures.get_all_procedures(self)
        for procedureToCheck in assignedProcs:
            result = AssignedProcedures.check_goal_status(
                self, procedureToCheck[0], 1)
            if result == "in progress (behind)":
                self.behind_flag = True
                self.save()
                return procedureToCheck[0], True

        self.behind_flag = False
        self.save()
        return None, False
示例#10
0
    def test_post_remove_procedures_invalid_patient(self):
        self.test_post_add_procedure_valid()
        remove_request = self.factory.post('/patients/profile/procedures/remove/?id=' + str(99999), {
            'selection[]': ['1,1', '3,1']
        })
        self.middleware.process_request(remove_request)
        remove_request.user = self.user
        self.middleware.process_request(remove_request)

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

        response = remove_pairs_from_patient(remove_request)

        self.assertEqual(response.status_code, 302)

        expected_list = [(self.test_object_one, 1), (self.test_object_two, 1), (self.test_object_three, 1)]

        self.assertListEqual(expected_list, AssignedProcedures.get_all_procedures(self.test_patient))