Beispiel #1
0
 def test_enrolled1(self):
     """Assert enrolled is False if members but none consented."""
     SurveyFactory()
     plot = PlotFactory(community=self.mapper().map_area,
                        household_count=3,
                        status='residential_habitable')
     for household in Household.objects.filter(plot=plot):
         household_log = HouseholdLog.objects.get(
             household_structure__household=household)
         household_log_entry = HouseholdLogEntryFactory(
             household_log=household_log)
     household_structure = household_log.household_structure
     RepresentativeEligibilityFactory(
         household_structure=household_structure)
     HouseholdMemberFactory(household_structure=household_structure,
                            age_in_years=10)
     HouseholdMemberFactory(household_structure=household_structure,
                            age_in_years=74)
     HouseholdMemberFactory(household_structure=household_structure,
                            age_in_years=25)
     HouseholdMemberFactory(household_structure=household_structure,
                            age_in_years=50)
     household_structure = HouseholdStructure.objects.get(
         pk=household_structure.pk)
     self.assertFalse(household_structure.enrolled)
Beispiel #2
0
 def test_eligible_members3(self):
     """Assert eligible_members set from True but stays True if an eligible member 
     is added then removed but others exist."""
     SurveyFactory()
     plot = PlotFactory(community=self.mapper().map_area,
                        household_count=3,
                        status='residential_habitable')
     for household in Household.objects.filter(plot=plot):
         household_log = HouseholdLog.objects.get(
             household_structure__household=household)
         household_log_entry = HouseholdLogEntryFactory(
             household_log=household_log)
     household_structure = household_log.household_structure
     RepresentativeEligibilityFactory(
         household_structure=household_structure)
     HouseholdMemberFactory(household_structure=household_structure,
                            age_in_years=10)
     HouseholdMemberFactory(household_structure=household_structure,
                            age_in_years=74)
     HouseholdMemberFactory(household_structure=household_structure,
                            age_in_years=50)
     household_member = HouseholdMemberFactory(
         household_structure=household_structure, age_in_years=25)
     household_structure = HouseholdStructure.objects.get(
         pk=household_structure.pk)
     household_member.age_in_years = 10
     household_member.save()
     self.assertTrue(household_structure.eligible_members)
Beispiel #3
0
 def test_eligible_subject4(self):
     """Assert 'eligible' and 'is' flags  if passes enrollment checklist for BHS and household is enrolled."""
     # eligible member
     household_member = HouseholdMemberFactory(
         household_structure=self.household_structure,
         gender='M',
         age_in_years=25,
         study_resident='Yes',
         initials='EE')
     # who is an eligible subject
     EnrollmentChecklistFactory(household_member=household_member,
                                gender='M',
                                dob=date.today() - relativedelta(years=25),
                                initials=household_member.initials,
                                part_time_resident='Yes')
     # who is consented
     SubjectConsentFactory(
         household_member=household_member,
         gender='M',
         dob=date.today() - relativedelta(years=25),
         first_name='ERIKFIRST',
         last_name='ERIKLAST',
         initials=household_member.initials,
     )
     self.assertTrue(household_member.eligible_member)
     self.assertTrue(household_member.eligible_subject)
     self.assertFalse(household_member.eligible_htc)
     self.assertTrue(household_member.is_consented)
     self.assertFalse(household_member.is_htc_only)
Beispiel #4
0
 def setUp(self):
     StudySpecificFactory()
     StudySiteFactory()
     self.survey = SurveyFactory()
     self.plot = PlotFactory(community='test_community2', household_count=1, status='occupied')
     self.household_structure = HouseholdStructure.objects.get(household__plot=self.plot)
     self.household_member = HouseholdMemberFactory(household_structure=self.household_structure)
    def test_eligible_bhs(self):
        """Assert for eligible for BHS, household enrolled."""
        #self.startup()
        self.enroll_household()
        household_member = HouseholdMemberFactory(first_name='ERIK', initials='EXW', age_in_years=64, study_resident='Yes', household_structure=self.household_structure)
        household_member.member_status = BHS_SCREEN
        household_member.save()
        pk = household_member.pk
        household_member = HouseholdMember.objects.get(pk=pk)
        EnrollmentChecklistFactory(
            household_member=household_member,
            gender='M',
            dob=date.today() - relativedelta(years=64),
            guardian='No',
            initials=household_member.initials,
            part_time_resident='Yes')
        pk = household_member.pk
        household_member = HouseholdMember.objects.get(pk=pk)
        options = [BHS, BHS_ELIGIBLE, DECEASED, REFUSED]
        options.append(household_member.member_status)
        options = list(set(options))
        options.sort()
        member_status_choices = [(item, item) for item in options]
        x = household_member.member_status_choices
#         print x
#         print member_status_choices
        self.assertEqual(x, member_status_choices)
Beispiel #6
0
 def enroll_household(self):
     household_member = HouseholdMemberFactory(
         first_name='ERIK',
         initials='EW',
         age_in_years=18,
         study_resident='Yes',
         household_structure=self.source_household_structure)
     enrollment_checklist = EnrollmentChecklistFactory(
         household_member=household_member,
         gender='M',
         dob=date.today() - relativedelta(years=18),
         guardian='No',
         initials=household_member.initials,
         part_time_resident='Yes')
     from bhp066.apps.bcpp_subject.tests.factories import SubjectConsentFactory
     self.subject_consent = SubjectConsentFactory(
         household_member=enrollment_checklist.household_member,
         first_name="ERIK",
         last_name='WERIK',
         gender='M',
         dob=date.today() - relativedelta(years=18),
         initials=household_member.initials,
         study_site=self.study_site,
     )
     self.assertEqual(self.subject_consent.household_member.member_status,
                      BHS)
     self.assertTrue(
         self.subject_consent.household_member.household_structure.enrolled)
     return household_member
Beispiel #7
0
    def test_eligible_subject3(self):
        """Assert 'eligible' and 'is' flags  if fails enrollment checklist for BHS and household is enrolled.

        Fails eligibility but is eligible for HTC by age."""
        # eligible member
        household_member = HouseholdMemberFactory(
            household_structure=self.household_structure,
            gender='M',
            age_in_years=25,
            study_resident='Yes',
            initials='EE')
        # who is an eligible subject
        EnrollmentChecklistFactory(household_member=household_member,
                                   gender='M',
                                   dob=date.today() - relativedelta(years=25),
                                   initials=household_member.initials,
                                   part_time_resident='Yes')
        # who is consented
        SubjectConsentFactory(
            household_member=household_member,
            gender='M',
            dob=date.today() - relativedelta(years=25),
            first_name='ERIKFIRST',
            last_name='ERIKLAST',
            initials=household_member.initials,
        )
        # the household is now enrolled
        self.assertTrue(
            household_member.household_structure.household.enrolled)
        # an ineligible member
        household_member = HouseholdMemberFactory(
            household_structure=self.household_structure,
            gender='M',
            age_in_years=65,
            study_resident='No')
        # who fails eligibility ...should not be able get to this via the interface
        EnrollmentChecklistFactory(household_member=household_member,
                                   gender='M',
                                   dob=date.today() - relativedelta(years=65),
                                   initials=household_member.initials,
                                   part_time_resident='No')
        # should only be eligible_htc
        self.assertFalse(household_member.eligible_member)
        self.assertFalse(household_member.eligible_subject)
        self.assertTrue(household_member.eligible_htc)
        self.assertFalse(household_member.is_consented)
        self.assertFalse(household_member.is_htc_only)
 def create_members(self, count):
     for i in range(0, count - 1):
         rs = next(self.registered_subject)
         HouseholdMemberFactory(
             household_structure=self.household_structure,
             registered_subject=rs,
             internal_identifier=rs.registration_identifier,
         )
 def test_not_eligible_member(self):
     """Assert for not eligible for BHS and HTC (household not enrolled)."""
     #self.startup()
     household_member = HouseholdMemberFactory(first_name='ERIK', initials='EW', age_in_years=64, study_resident='No', household_structure=self.household_structure)
     options = [NOT_ELIGIBLE]
     options.append(household_member.member_status)
     options = list(set(options))
     options.sort()
     member_status_choices = [(item, item) for item in options]
     self.assertEqual(household_member.member_status_choices, member_status_choices)
 def test_new_eligible_member(self):
     #self.startup()
     household_member = HouseholdMemberFactory(first_name='ERIK', initials='EW', age_in_years=64, study_resident='Yes', household_structure=self.household_structure)
     options = [ABSENT, BHS_SCREEN, REFUSED, UNDECIDED, DECEASED]
     options.append(household_member.member_status)
     options = list(set(options))
     options.sort()
     member_status_choices = [(item, item) for item in options]
     x = household_member.member_status_choices
     self.assertEqual(x, member_status_choices)
Beispiel #11
0
    def setUp(self):
        site_mappers.autodiscover()
        try:
            site_lab_profiles.register(BcppSubjectProfile())
        except AlreadyRegisteredLabProfile:
            pass
        self.app_config = BcppAppConfiguration()
        self.app_config.prepare()
        site_lab_tracker.autodiscover()
        BcppSubjectVisitSchedule().build()
        site_rule_groups.autodiscover()
        self.mapper = site_mappers.get_current_mapper()
#         self.app_config.prep_survey_for_tests()

        self.community = 'test_community'
        plot = PlotFactory(community=self.community, household_count=1, status='residential_habitable')

        survey = Survey.objects.all().order_by('datetime_start')[0]

        self.study_site = StudySite.objects.get(site_code='01')

        self.household_structure = HouseholdStructure.objects.get(household__plot=plot, survey=survey)
        RepresentativeEligibilityFactory(household_structure=self.household_structure)

        self.male_dob = date.today() - relativedelta(years=25)
        self.male_age_in_years = 25
        self.male_first_name = 'ERIK'
        self.male_initials = "EW"

        self.household_member_male_T0 = HouseholdMemberFactory(
            household_structure=self.household_structure, gender='M',
            age_in_years=self.male_age_in_years, first_name=self.male_first_name,
            initials=self.male_initials
        )

        EnrollmentChecklistFactory(
            household_member=self.household_member_male_T0,
            gender='M',
            citizen='Yes',
            dob=self.male_dob,
            guardian='No',
            initials=self.household_member_male_T0.initials,
            part_time_resident='Yes'
        )

        self.subject_consent_male = SubjectConsentFactory(household_member=self.household_member_male_T0, study_site=self.study_site, gender='M', dob=self.male_dob, first_name=self.male_first_name, initials=self.male_initials)

        self.registered_subject_male = RegisteredSubject.objects.get(subject_identifier=self.subject_consent_male.subject_identifier)

        self.appointment_male_T0 = Appointment.objects.get(registered_subject=self.registered_subject_male, visit_definition__code='T0')

        self.subject_visit_male_T0 = SubjectVisitFactory(appointment=self.appointment_male_T0, household_member=self.household_member_male_T0)
        SubjectLocatorFactory(registered_subject=self.subject_visit_male_T0.appointment.registered_subject, subject_visit=self.subject_visit_male_T0)
        self.household_member_T1 = None
        self.update_call_list_class = UpdateCallList()
 def test5(self):
     """Assert subject identifier is None if not consented"""
     household_member = HouseholdMemberFactory(
         inability_to_participate=NOT_APPLICABLE,
         first_name='ERIK',
         initials='EW',
         age_in_years=64,
         study_resident='Yes',
         household_structure=self.household_structure)
     subject = Subject(household_member)
     self.assertisNone(subject.subject_identifier)
 def test1(self):
     """Assert handles a member not consented"""
     household_member = HouseholdMemberFactory(
         inability_to_participate=NOT_APPLICABLE,
         first_name='ERIK',
         initials='EW',
         age_in_years=64,
         study_resident='Yes',
         household_structure=self.household_structure)
     subject = Subject(household_member)
     self.assertEquals(subject.age_in_years, 64)
Beispiel #14
0
 def test_enrolled2(self):
     """Assert enrolled is True if eligible member consents."""
     SurveyFactory()
     plot = PlotFactory(community=self.mapper().map_area,
                        household_count=3,
                        status='residential_habitable')
     for household in Household.objects.filter(plot=plot):
         household_log = HouseholdLog.objects.get(
             household_structure__household=household)
         household_log_entry = HouseholdLogEntryFactory(
             household_log=household_log)
     household_structure = household_log.household_structure
     RepresentativeEligibilityFactory(
         household_structure=household_structure)
     HouseholdMemberFactory(household_structure=household_structure,
                            age_in_years=10)
     HouseholdMemberFactory(household_structure=household_structure,
                            age_in_years=74)
     household_member = HouseholdMemberFactory(
         household_structure=household_structure,
         age_in_years=25,
         initials='NN')
     HouseholdMemberFactory(household_structure=household_structure,
                            age_in_years=50)
     household_structure = HouseholdStructure.objects.get(
         pk=household_structure.pk)
     dob = date.today() - relativedelta(years=25)
     enrollment_checklist = EnrollmentChecklistFactory(
         household_member=household_member,
         report_datetime=household_member.created,
         dob=dob,
         initials='NN')
     self.assertFalse(household_structure.enrolled)
     self.assertTrue(enrollment_checklist.is_eligible)
     household_member = HouseholdMember.objects.get(pk=household_member.pk)
     SubjectConsentFactory(household_member=household_member,
                           dob=dob,
                           initials='NN')
     household_structure = HouseholdStructure.objects.get(
         pk=household_structure.pk)
     self.assertTrue(household_structure.enrolled)
Beispiel #15
0
    def setUp(self):
        try:
            site_lab_profiles.register(BcppSubjectProfile())
        except AlreadyRegisteredLabProfile:
            pass
        BcppAppConfiguration()
        site_lab_tracker.autodiscover()
        BcppSubjectVisitSchedule().build()
        self.survey1 = Survey.objects.get(survey_name='BCPP Year 1')  # see app_configuration
        site_mappers.autodiscover()
        mapper = site_mappers.get(site_mappers.get_as_list()[0])
        self.community = mapper().get_map_area()
        gps_degrees_s, gps_minutes_s, gps_degrees_e, gps_minutes_e = mapper().test_location
        self.plot = PlotFactory(community=self.community,
                                gps_degrees_s=gps_degrees_s,
                                gps_minutes_s=gps_minutes_s,
                                gps_degrees_e=gps_degrees_e,
                                gps_minutes_e=gps_minutes_e,
                                household_count=2,
                                status='residential_habitable')
        self.household1 = Household.objects.filter(plot=self.plot).order_by('created')[0]
        self.household_structure1 = HouseholdStructure.objects.get(household=self.household1, survey=self.survey1)
        self.household2 = Household.objects.filter(plot=self.plot).order_by('created')[1]
        self.household_member1 = HouseholdMemberFactory(household_structure=self.household_structure1,
                                                        age_in_years=26,
                                                        present_today='Yes',
                                                        member_status='RESEARCH')
        self.household_member2 = HouseholdMemberFactory(household_structure=self.household_structure1, age_in_years=36, present_today='Yes')
        self.household_member3 = HouseholdMemberFactory(household_structure=self.household_structure1, age_in_years=12, present_today='Yes')
        self.household_member4 = HouseholdMemberFactory(household_structure=self.household_structure1, age_in_years=99, present_today='Yes')
        self.dashboard_type = 'household'
        self.dashboard_model = 'household'
        self.dashboard_id = self.household1.pk

        self.household_member1.eligible_subject = True

        self.subject_consent = SubjectConsentFactory(
            household_member=self.household_member1,
            first_name=self.household_member1.first_name,
            initials=self.household_member1.initials,
            registered_subject=self.household_member1.registered_subject)
Beispiel #16
0
 def test_new_member4(self):
     """Assert 15 is not an eligible member."""
     household_member = HouseholdMemberFactory(
         household_structure=self.household_structure,
         gender='M',
         age_in_years=15,
         present_today='No',  # on day of survey
         study_resident='Yes')
     self.assertFalse(household_member.eligible_member)
     self.assertFalse(household_member.eligible_subject)
     self.assertFalse(household_member.eligible_htc)
     self.assertFalse(household_member.is_consented)
     self.assertFalse(household_member.is_htc_only)
 def test_eligible_member_bhs_and_htc(self):
     """Assert for not eligible for BHS but eligible for HTC (household enrolled)."""
     #self.startup()
     household_member = self.enroll_household()
     household_member = HouseholdMemberFactory(first_name='ERIK', initials='EXW', age_in_years=78, study_resident='Yes', household_structure=household_member.household_structure)
     self.assertEqual(household_member.member_status, HTC_ELIGIBLE)
     options = [HTC_ELIGIBLE, BHS_SCREEN]
     options.append(household_member.member_status)
     options = list(set(options))
     options.sort()
     member_status_choices = [(item, item) for item in options]
     x = household_member.member_status_choices
     self.assertEqual(x, member_status_choices)
Beispiel #18
0
 def test_add_members_aged_in_and_out(self):
     """Assert members ageing in and out are correctly set to eligible/not eligible."""
     self.enroll_household()
     age_in = HouseholdMemberFactory(
         household_structure=self.source_household_structure,
         age_in_years=15,
         study_resident='Yes',
         inability_to_participate=NOT_APPLICABLE)
     age_out = HouseholdMemberFactory(
         household_structure=self.source_household_structure,
         age_in_years=64,
         study_resident='Yes',
         inability_to_participate=NOT_APPLICABLE)
     HouseholdStructure.objects.add_household_members_from_survey(
         self.household, self.survey1, self.survey2)
     age_out = HouseholdMember.objects.get(
         internal_identifier=age_out.internal_identifier,
         household_structure=self.target_household_structure)
     self.assertFalse(age_out.eligible_member)
     age_in = HouseholdMember.objects.get(
         internal_identifier=age_in.internal_identifier,
         household_structure=self.target_household_structure)
     self.assertTrue(age_in.eligible_member)
    def test_eligible_htc_only(self):
        """Assert for not eligible for BHS but eligible for HTC (household enrolled). No need to ever screen for BHS as not eligible member(by age or residency)."""
        #self.startup()
        household_member = self.enroll_household()
        household_member = HouseholdMemberFactory(first_name='ERIK', initials='EXW', age_in_years=64, study_resident='No', household_structure=household_member.household_structure)
        self.assertEqual(household_member.member_status, HTC_ELIGIBLE)
        options = [BHS_SCREEN]
        options.append(household_member.member_status)
        options = list(set(options))
        options.sort()
        member_status_choices = [(item, item) for item in options]
#         pprint.pprint(member_status_choices)
#         pprint.pprint(household_member.member_status_choices)
        self.assertEqual(household_member.member_status_choices, member_status_choices)
Beispiel #20
0
 def test_enrollment_checklist_deleted_on_fail(self):
     household_member = HouseholdMemberFactory(
         household_structure=self.household_structure,
         gender='M',
         age_in_years=50,
         present_today='No',  # on day of survey
         study_resident='No')
     EnrollmentChecklistFactory(household_member=household_member,
                                gender='M',
                                dob=date.today() - relativedelta(years=50),
                                initials=household_member.initials,
                                part_time_resident='No')
     self.assertEqual(
         EnrollmentChecklist.objects.filter(
             household_member=household_member).count(), 0)
 def test4(self):
     """Assert handles a member not consented and offered but did not accept HTC"""
     household_member = HouseholdMemberFactory(
         inability_to_participate=NOT_APPLICABLE,
         first_name='ERIK',
         initials='EW',
         age_in_years=64,
         study_resident='Yes',
         household_structure=self.household_structure)
     subject_htc = SubjectHtcFactory(household_member=household_member,
                                     offered=YES,
                                     accepted=NO)
     subject = Subject(household_member)
     self.assertEqual(subject.subject_htc, subject_htc)
     self.assertisNone(subject.subject_identifier)
Beispiel #22
0
 def test_gender_match(self):
     """Assert raises ValidationError if household_member age <> enrollment age."""
     household_member = HouseholdMemberFactory(
         household_structure=self.household_structure,
         gender='M',
         age_in_years=25,
         study_resident='Yes',
         initials='EE')
     self.assertRaisesRegexp(ValidationError,
                             'Gender does not match',
                             EnrollmentChecklistFactory,
                             household_member=household_member,
                             gender='F',
                             dob=date.today() - relativedelta(years=25),
                             initials="EE",
                             part_time_resident='Yes')
Beispiel #23
0
 def test_eligible_subject1(self):
     """Assert 'eligible' and 'is' flags  if passes enrollment checklist for BHS."""
     household_member = HouseholdMemberFactory(
         household_structure=self.household_structure,
         gender='M',
         age_in_years=50,
         present_today='No',  # on day of survey
         study_resident='Yes')
     EnrollmentChecklistFactory(household_member=household_member,
                                gender='M',
                                dob=date.today() - relativedelta(years=50),
                                initials=household_member.initials)
     self.assertTrue(household_member.eligible_member)
     self.assertTrue(household_member.eligible_subject)
     self.assertFalse(household_member.eligible_htc)
     self.assertFalse(household_member.is_consented)
     self.assertFalse(household_member.is_htc_only)
Beispiel #24
0
 def test_eligible_members1(self):
     """Assert eligible_members set to True if an eligible member is added."""
     SurveyFactory()
     plot = PlotFactory(community=self.mapper().map_area,
                        household_count=3,
                        status='residential_habitable')
     for household in Household.objects.filter(plot=plot):
         household_log = HouseholdLog.objects.get(
             household_structure__household=household)
         household_log_entry = HouseholdLogEntryFactory(
             household_log=household_log)
     household_structure = household_log.household_structure
     RepresentativeEligibilityFactory(
         household_structure=household_structure)
     HouseholdMemberFactory(household_structure=household_structure)
     household_structure = HouseholdStructure.objects.get(
         pk=household_structure.pk)
     self.assertTrue(household_structure.eligible_members)
Beispiel #25
0
 def test_enumerated_members2(self):
     """Assert enumerated_members is True if a household_member is added, others stay False."""
     SurveyFactory()
     plot = PlotFactory(community=self.mapper().map_area,
                        household_count=3,
                        status='residential_habitable')
     for household in Household.objects.filter(plot=plot):
         household_log = HouseholdLog.objects.get(
             household_structure__household=household)
     household_structure = household_log.household_structure
     RepresentativeEligibilityFactory(
         household_structure=household_structure)
     HouseholdMemberFactory(household_structure=household_structure)
     household_structure = HouseholdStructure.objects.get(
         pk=household_structure.pk)
     self.assertTrue(household_structure.enumerated)
     for household_structure in HouseholdStructure.objects.filter(
             household=household).exclude(pk=household_structure.pk):
         self.assertFalse(household_structure.enumerated)
    def test_refused_bhs_and_consent_later(self):
        """Assert for refused BHS, household not enrolled and BHS_SCREEN still available as option."""
        #self.startup()
        household_member = HouseholdMemberFactory(first_name='ERIK', initials='EXW', age_in_years=64, study_resident='Yes', household_structure=self.household_structure)
        household_member.member_status = REFUSED
        household_member.save(update_fields=['member_status'])
        self.assertEqual(household_member.member_status, REFUSED)
        subject_refusal = SubjectRefusalFactory(household_member=household_member)
        self.assertEqual(subject_refusal.household_member.member_status, REFUSED)
        self.assertTrue(subject_refusal.household_member.refused)
        options = [BHS_SCREEN, DECEASED]
        options.append(household_member.member_status)
        options = list(set(options))
        options.sort()
#         print options
        member_status_choices = [(item, item) for item in options]
        x = household_member.member_status_choices
#         print x
        self.assertEqual(x, member_status_choices)
 def test2(self):
     """Assert handles a member consented"""
     household_member = HouseholdMemberFactory(
         inability_to_participate=NOT_APPLICABLE,
         first_name='ERIK',
         initials='EW',
         age_in_years=64,
         study_resident='Yes',
         household_structure=self.household_structure)
     self.enrollment_checklist(household_member)
     #        household_member.member_status = BHS_ELIGIBLE
     subject_consent = SubjectConsentFactory(
         household_member=household_member,
         initials=household_member.initials,
         last_name='WWW',
         dob=date.today() - relativedelta(years=64),
         identity='123456789',
         identity_type='OMANG')
     subject = Subject(household_member)
     self.assertEqual(subject.subject_consent, subject_consent)
 def enroll_household(self, household_member=None):
     if not household_member:
         household_member = HouseholdMemberFactory(
             first_name='ERIK',
             initials='EW',
             age_in_years=18,
             present_today='Yes',
             study_resident='Yes',
             household_structure=self.household_structure,
             inability_to_participate=NOT_APPLICABLE)
     self.assertEquals(household_member.member_status, BHS_SCREEN)
     enrollment_checklist = EnrollmentChecklistFactory(
         household_member=household_member,
         report_datetime=datetime.today(),
         gender='M',
         dob=date.today() - relativedelta(years=18),
         guardian='No',
         initials=household_member.initials,
         part_time_resident='Yes')
     household_member = HouseholdMember.objects.get(
         pk=enrollment_checklist.household_member.pk)
     self.assertEquals(household_member.member_status, BHS_ELIGIBLE)
     from bhp066.apps.bcpp_subject.tests.factories import SubjectConsentFactory
     subject_consent = SubjectConsentFactory(
         household_member=household_member,
         registered_subject=household_member.registered_subject,
         first_name=household_member.first_name,
         last_name='WERIK',
         gender=household_member.gender,
         dob=date.today() - relativedelta(years=18),
         initials=household_member.initials,
         study_site=self.study_site,
     )
     household_member = HouseholdMember.objects.get(
         pk=subject_consent.household_member.pk)
     self.household_structure = household_member.household_structure
     self.assertEquals(household_member.member_status, BHS)
     self.assertTrue(self.household_structure.enrolled)
     self.assertTrue(self.household_structure.household.enrolled)
     self.assertTrue(self.household_structure.household.plot.bhs)
     return household_member
    def test_eligible_bhs_and_htc_and_refused_bhs(self):
        """Assert for eligible for BHS, household is enrolled, and eligible for HTC since has refused BHS."""
        #self.startup()
        household_member = self.enroll_household()
        household_member = HouseholdMemberFactory(first_name='ERIK', initials='EXW', age_in_years=64, study_resident='Yes', household_structure=household_member.household_structure)

        household_member.member_status = REFUSED
        household_member.save(update_fields=['member_status'])

        self.assertEqual(household_member.member_status, REFUSED)
        subject_refusal = SubjectRefusalFactory(household_member=household_member)
        self.assertEqual(subject_refusal.household_member.member_status, HTC_ELIGIBLE)
        self.assertTrue(subject_refusal.household_member.refused)
        self.assertTrue(subject_refusal.household_member.eligible_htc)
        options = [BHS_SCREEN, HTC_ELIGIBLE]
        options.append(subject_refusal.household_member.member_status)
        options = list(set(options))
        options.sort()
        member_status_choices = [(item, item) for item in options]
        x = subject_refusal.household_member.member_status_choices
        self.assertEqual(x, member_status_choices)
Beispiel #30
0
    def test_eligible_subject2(self):
        """Assert 'eligible' and 'is' flags  if fails enrollment checklist for BHS but household not enrolled.

        Fails eligibility but is eligible for HTC by age."""
        household_member = HouseholdMemberFactory(
            household_structure=self.household_structure,
            gender='M',
            age_in_years=50,
            present_today='No',  # on day of survey
            study_resident='No')
        # should not be able get to this via the interface
        EnrollmentChecklistFactory(household_member=household_member,
                                   gender='M',
                                   dob=date.today() - relativedelta(years=50),
                                   initials=household_member.initials,
                                   part_time_resident='No')
        self.assertFalse(household_member.eligible_member)
        self.assertFalse(household_member.eligible_subject)
        self.assertFalse(household_member.eligible_htc)
        self.assertFalse(household_member.is_consented)
        self.assertFalse(household_member.is_htc_only)