def setUp(self): import_holidays() self.options = {'consent_datetime': get_utcnow(), 'version': '1'} self.maternal_dataset_options = { 'mom_enrolldate': get_utcnow(), 'mom_hivstatus': 'HIV-infected', 'study_maternal_identifier': '12345', 'protocol': 'Tshilo Dikotla' } self.child_dataset_options = { 'infant_hiv_exposed': 'Exposed', 'infant_enrolldate': get_utcnow(), 'study_maternal_identifier': '12345', 'study_child_identifier': '1234', 'infant_sex': MALE } self.child_assent_options = { 'gender': MALE, 'first_name': 'TEST ONE', 'last_name': 'TEST', 'initials': 'TOT', 'identity': '123425678', 'identity_type': 'birth_cert', 'confirm_identity': '123425678', 'preg_testing': YES, 'citizen': YES }
def __init__(self, maternal_identifier=None, requesting_model=None, birth_order=None, live_infants=None, template=None, first_name=None, initials=None, last_name=None, registration_status=None, registration_datetime=None, subject_type=None): self._first_name = first_name self._identifier = None self._infant_suffix = None # check maternal identifier try: rs = RegisteredSubject.objects.get( subject_identifier=maternal_identifier) except ObjectDoesNotExist: raise InfantIdentifierError( f'Failed to create infant identifier. Invalid maternal ' f'identifier. Got {maternal_identifier}') self.last_name = last_name or rs.last_name self.maternal_identifier = maternal_identifier self.birth_order = birth_order self.initials = initials self.live_infants = live_infants self.registration_datetime = registration_datetime or get_utcnow() self.registration_status = registration_status or 'DELIVERED' self.requesting_model = requesting_model self.subject_type = subject_type or self.subject_type self.template = template or self.template self.identifier
def setUp(self): import_holidays() self.panel_one = Panel.objects.create(name='one') register_to_site_reference_configs() site_visit_schedules._registry = {} site_visit_schedules.loaded = False site_visit_schedules.register(visit_schedule) site_reference_configs.register_from_visit_schedule( visit_models={ 'edc_appointment.appointment': 'edc_metadata.subjectvisit'}) self.subject_identifier = '1111111' subject_consent = SubjectConsent.objects.create( subject_identifier=self.subject_identifier, consent_datetime=get_utcnow()) _, self.schedule = site_visit_schedules.get_by_onschedule_model( 'edc_metadata.onschedule') self.schedule.put_on_schedule( subject_identifier=self.subject_identifier, onschedule_datetime=subject_consent.consent_datetime) self.appointment = Appointment.objects.get( subject_identifier=self.subject_identifier, visit_code=self.schedule.visits.first.code) self.subject_visit = SubjectVisit.objects.create( appointment=self.appointment, subject_identifier=self.subject_identifier, reason=SCHEDULED)
def add_visit(self, model_label=None, visit_code=None, reason=None, subject_identifier=None): """Adds (or gets) and returns a visit for give model and code. """ reason = reason or SCHEDULED model = django_apps.get_model(*model_label.split('.')) try: appointment = self.appointment_model_cls.objects.get( subject_identifier=subject_identifier, visit_code=visit_code) if appointment.appt_datetime > get_utcnow(): raise VisitTestHelperFutureDate( f'For testing, create visits without future dates. ' f'Got {appointment.visit_code}, {appointment.appt_datetime}') try: visit = self.get_visit( visit_code=visit_code, model_label=model_label, subject_identifier=subject_identifier) except model.DoesNotExist: # create visit for the first time visit = mommy.make_recipe( model_label, appointment=appointment, report_datetime=appointment.appt_datetime, reason=reason) except ObjectDoesNotExist as e: raise VisitTestHelperError( f'{e} {model_label}, {visit_code}. Did you complete the enrollment form?') return visit
def setUp(self): import_holidays() self.options = {'consent_datetime': get_utcnow(), 'version': '2'} screening_preg = mommy.make_recipe( 'flourish_caregiver.screeningpregwomen', ) self.preg_subject_consent = mommy.make_recipe( 'flourish_caregiver.subjectconsent', screening_identifier=screening_preg.screening_identifier, breastfeed_intent=YES, **self.options) self.preg_caregiver_child_consent_obj = mommy.make_recipe( 'flourish_caregiver.caregiverchildconsent', subject_consent=self.preg_subject_consent, gender=None, first_name=None, last_name=None, identity=None, confirm_identity=None, study_child_identifier=None, child_dob=None, version='2') self.preg_subject_identifier = self.preg_subject_consent.subject_identifier
def setUp(self): import_holidays() register_to_site_reference_configs() for name in ['one', 'two', 'three', 'four', 'five', 'six']: Panel.objects.create(name=name) site_visit_schedules._registry = {} site_visit_schedules.loaded = False site_visit_schedules.register(visit_schedule) site_reference_configs.register_from_visit_schedule( visit_models={ 'edc_appointment.appointment': 'edc_metadata.subjectvisit'}) self.subject_identifier = '1111111' self.assertEqual(CrfMetadata.objects.all().count(), 0) self.assertEqual(RequisitionMetadata.objects.all().count(), 0) subject_consent = SubjectConsent.objects.create( subject_identifier=self.subject_identifier, consent_datetime=get_utcnow()) _, self.schedule = site_visit_schedules.get_by_onschedule_model( 'edc_metadata.onschedule') self.schedule.put_on_schedule( subject_identifier=self.subject_identifier, onschedule_datetime=subject_consent.consent_datetime) self.appointment = Appointment.objects.get( subject_identifier=self.subject_identifier, visit_code=self.schedule.visits.first.code) self.subject_visit = SubjectVisit.objects.create( appointment=self.appointment, subject_identifier=self.subject_identifier, reason=SCHEDULED)
def setUp(self): import_holidays() self.panel_one = Panel.objects.create(name='one') self.panel_seven = Panel.objects.create(name='seven') self.panel_blah = Panel.objects.create(name='blah') register_to_site_reference_configs() site_visit_schedules._registry = {} site_visit_schedules.loaded = False site_visit_schedules.register(visit_schedule) site_reference_configs.register_from_visit_schedule( visit_models={ 'edc_appointment.appointment': 'edc_metadata.subjectvisit'}) self.subject_identifier = '1111111' self.assertEqual(CrfMetadata.objects.all().count(), 0) self.assertEqual(RequisitionMetadata.objects.all().count(), 0) subject_consent = SubjectConsent.objects.create( subject_identifier=self.subject_identifier, consent_datetime=get_utcnow()) _, self.schedule = site_visit_schedules.get_by_onschedule_model( 'edc_metadata.onschedule') self.schedule.put_on_schedule( subject_identifier=self.subject_identifier, onschedule_datetime=subject_consent.consent_datetime) self.appointment = Appointment.objects.get( subject_identifier=self.subject_identifier, visit_code=self.schedule.visits.first.code)
def validate_not_future_appt_datetime(self): appt_datetime = self.cleaned_data.get('appt_datetime') if appt_datetime and appt_datetime != NEW_APPT: rappt_datetime = Arrow.fromdatetime( appt_datetime, appt_datetime.tzinfo) if rappt_datetime.to('UTC').date() > get_utcnow().date(): raise forms.ValidationError({ 'appt_datetime': 'Cannot be a future date.'})
def test_visit_sequence_enforcer_without_first_visit_in_sequence(self): appointments = Appointment.objects.all().order_by('timepoint_datetime') SubjectVisit.visit_sequence_cls = DisabledVisitSequence visit = SubjectVisit.objects.create( appointment=appointments[1], report_datetime=get_utcnow() - relativedelta(months=10), reason=SCHEDULED) visit_sequence = VisitSequence(appointment=visit.appointment) self.assertRaises(VisitSequenceError, visit_sequence.enforce_sequence)
def test_add_subject_visits(self): self.helper.consent_and_put_on_schedule() schedule_name = 'schedule1' for visit in visit_schedule1.schedules.get(schedule_name).visits.values(): with self.subTest(visit=visit): # get parent appointment appointment = Appointment.objects.get( subject_identifier=self.subject_identifier, visit_code=visit.code) appointment.appt_status = IN_PROGRESS_APPT appointment.save() subject_visit = SubjectVisit.objects.create( appointment=appointment, report_datetime=get_utcnow()) appointment = Appointment.objects.get( subject_identifier=self.subject_identifier, visit_code=visit.code, visit_code_sequence=0) self.assertTrue(appointment.visit, subject_visit) self.assertEqual(0, appointment.visit.visit_code_sequence) self.assertEqual(1, appointment.next_visit_code_sequence) appointment.appt_status = INCOMPLETE_APPT appointment.save() creator = UnscheduledAppointmentCreator( subject_identifier=self.subject_identifier, visit_schedule_name=visit_schedule1.name, schedule_name=schedule_name, visit_code=visit.code, facility=appointment.facility) new_appointment = creator.appointment self.assertEqual(new_appointment.appt_status, IN_PROGRESS_APPT) subject_visit = SubjectVisit.objects.create( appointment=new_appointment, report_datetime=get_utcnow()) self.assertEqual(1, new_appointment.visit_code_sequence) self.assertEqual(1, subject_visit.visit_code_sequence) new_appointment.appt_status = INCOMPLETE_APPT new_appointment.save() self.assertEqual(new_appointment.appt_status, INCOMPLETE_APPT)
def test_visit_sequence_enforcer_on_first_visit_in_sequence(self): appointments = Appointment.objects.all().order_by('timepoint_datetime') SubjectVisit.visit_sequence_cls = DisabledVisitSequence visit = SubjectVisit.objects.create( appointment=appointments[0], report_datetime=get_utcnow() - relativedelta(months=10), reason=SCHEDULED) visit_sequence = VisitSequence(appointment=visit.appointment) try: visit_sequence.enforce_sequence() except VisitSequenceError as e: self.fail(f'VisitSequenceError unexpectedly raised. Got \'{e}\'')
def test_resave(self): """Asserts returns the correct instances for the schedule. """ visit_schedule, schedule = site_visit_schedules.get_by_onschedule_model( 'edc_visit_schedule.onscheduletwo') subject_schedule = SubjectSchedule( visit_schedule=visit_schedule, schedule=schedule) subject_schedule.put_on_schedule( subject_identifier=self.subject_identifier, onschedule_datetime=get_utcnow()) subject_schedule.resave(subject_identifier=self.subject_identifier)
def setUp(self): import_holidays() self.options = {'consent_datetime': get_utcnow(), 'version': '1'} self.maternal_dataset_options = { 'delivdt': get_utcnow() - relativedelta(years=1, months=7), 'mom_enrolldate': get_utcnow(), 'mom_hivstatus': 'HIV-infected', 'study_maternal_identifier': '12345', 'protocol': 'Tshilo Dikotla' } self.child_dataset_options = { 'infant_hiv_exposed': 'Exposed', 'infant_enrolldate': get_utcnow(), 'study_maternal_identifier': '12345', 'study_child_identifier': '1234' } self.child_birth_options = { 'report_datetime': get_utcnow(), 'first_name': 'TR', 'initials': 'TT', 'dob': get_utcnow() - relativedelta(years=1, months=7), 'gender': MALE }
def test_on_offschedule(self): OnSchedule.objects.create( subject_identifier='1234', onschedule_datetime=datetime(2017, 12, 1, 0, 0, 0, 0, pytz.utc)) history_obj = SubjectScheduleHistory.objects.get( subject_identifier='1234') self.assertEqual(history_obj.schedule_status, ON_SCHEDULE) OffSchedule.objects.create( subject_identifier='1234', offschedule_datetime=get_utcnow()) history_obj = SubjectScheduleHistory.objects.get( subject_identifier='1234') self.assertEqual(history_obj.schedule_status, OFF_SCHEDULE)
def test_requires_previous_visit_thru_model(self): """Asserts requires previous visit to exist on create. """ appointments = Appointment.objects.all().order_by('timepoint_datetime') SubjectVisit.objects.create( appointment=appointments[0], report_datetime=get_utcnow() - relativedelta(months=10), reason=SCHEDULED) self.assertRaises( PreviousVisitError, SubjectVisit.objects.create, appointment=appointments[2], report_datetime=get_utcnow() - relativedelta(months=8), reason=SCHEDULED) SubjectVisit.objects.create( appointment=appointments[1], report_datetime=get_utcnow() - relativedelta(months=10), reason=SCHEDULED) self.assertRaises( PreviousVisitError, SubjectVisit.objects.create, appointment=appointments[3], report_datetime=get_utcnow() - relativedelta(months=8), reason=SCHEDULED)
def test_put_on_schedule(self): _, schedule = site_visit_schedules.get_by_onschedule_model( 'edc_visit_schedule.onschedule') self.assertRaises( ObjectDoesNotExist, OnSchedule.objects.get, subject_identifier=self.subject_identifier) schedule.put_on_schedule( subject_identifier=self.subject_identifier, onschedule_datetime=get_utcnow()) try: OnSchedule.objects.get(subject_identifier=self.subject_identifier) except ObjectDoesNotExist: self.fail('ObjectDoesNotExist unexpectedly raised')
def test_history(self): OnSchedule.objects.create( subject_identifier='1234', onschedule_datetime=datetime(2017, 12, 1, 0, 0, 0, 0, pytz.utc)) OffSchedule.objects.create( subject_identifier='1234', offschedule_datetime=get_utcnow()) obj = SubjectScheduleHistory.objects.get( subject_identifier='1234') self.assertEqual( obj.natural_key(), (obj.subject_identifier, obj.visit_schedule_name, obj.schedule_name)) self.assertEqual( SubjectScheduleHistory.objects.get_by_natural_key( obj.subject_identifier, obj.visit_schedule_name, obj.schedule_name), obj)
def onschedules(self, subject_identifier=None, report_datetime=None): """Returns a list of onschedule model instances for this subject where the schedule_status would be ON_SCHEDULE relative to the report_datetime. """ onschedules = [] report_datetime = report_datetime or get_utcnow() qs = self.filter( Q(subject_identifier=subject_identifier), Q(onschedule_datetime__lte=report_datetime), (Q(offschedule_datetime__gte=report_datetime) | Q(offschedule_datetime__isnull=True))) for obj in qs: onschedule_model_cls = django_apps.get_model(obj.onschedule_model) onschedules.append(onschedule_model_cls.objects.get( subject_identifier=subject_identifier)) return onschedules
def test_onschedules_manager(self): """Assert can enter a CRF. """ onschedule = OnSchedule.objects.create( subject_identifier='1234', onschedule_datetime=datetime(2017, 12, 1, 0, 0, 0, 0, pytz.utc)) history = SubjectScheduleHistory.objects.onschedules( subject_identifier='1234') self.assertEqual([onschedule], [obj for obj in history]) onschedules = SubjectScheduleHistory.objects.onschedules( subject_identifier='1234', report_datetime=get_utcnow()) self.assertEqual([onschedule], [obj for obj in onschedules]) onschedules = SubjectScheduleHistory.objects.onschedules( subject_identifier='1234', report_datetime=datetime(2017, 11, 30, 0, 0, 0, 0, pytz.utc)) self.assertEqual(0, len(onschedules)) # add offschedule OffSchedule.objects.create( subject_identifier='1234', offschedule_datetime=datetime(2017, 12, 15, 0, 0, 0, 0, pytz.utc)) onschedules = SubjectScheduleHistory.objects.onschedules( subject_identifier='1234', report_datetime=datetime(2017, 11, 30, 0, 0, 0, 0, pytz.utc)) self.assertEqual(0, len(onschedules)) onschedules = SubjectScheduleHistory.objects.onschedules( subject_identifier='1234', report_datetime=datetime(2017, 12, 1, 0, 0, 0, 0, pytz.utc)) self.assertEqual([onschedule], [obj for obj in onschedules]) onschedules = SubjectScheduleHistory.objects.onschedules( subject_identifier='1234', report_datetime=datetime(2017, 12, 2, 0, 0, 0, 0, pytz.utc)) self.assertEqual([onschedule], [obj for obj in onschedules]) onschedules = SubjectScheduleHistory.objects.onschedules( subject_identifier='1234', report_datetime=datetime(2018, 1, 1, 0, 0, 0, 0, pytz.utc)) self.assertEqual(0, len(onschedules))
def test_unscheduled_allowed_but_raises_on_appt_status(self): self.helper.consent_and_put_on_schedule() schedule_name = 'schedule1' visit = visit_schedule1.schedules.get(schedule_name).visits.first appointment = Appointment.objects.get( subject_identifier=self.subject_identifier, visit_code=visit.code) # subject_visit not created so expect exception because of # the missing subject_visit for appt_status in [NEW_APPT, IN_PROGRESS_APPT, CANCELLED_APPT]: with self.subTest(appt_status=appt_status): appointment.appt_status = appt_status appointment.save() self.assertEqual(appointment.appt_status, appt_status) self.assertRaises( InvalidParentAppointmentMissingVisitError, UnscheduledAppointmentCreator, subject_identifier=self.subject_identifier, visit_schedule_name=visit_schedule1.name, schedule_name=schedule_name, visit_code=visit.code) # add a subject_visit and expect exception to be raises because # of appt_status subject_visit = SubjectVisit.objects.create( appointment=appointment, report_datetime=get_utcnow()) appointment = Appointment.objects.get( subject_identifier=self.subject_identifier, visit_code=visit.code) self.assertEqual(appointment.visit, subject_visit) for appt_status in [NEW_APPT, IN_PROGRESS_APPT, CANCELLED_APPT]: with self.subTest(appt_status=appt_status): appointment.appt_status = appt_status appointment.save() self.assertEqual(appointment.appt_status, appt_status) self.assertRaises( InvalidParentAppointmentStatusError, UnscheduledAppointmentCreator, subject_identifier=self.subject_identifier, visit_schedule_name=visit_schedule1.name, schedule_name=schedule_name, visit_code=visit.code)
def test_multpile_consents(self): """Asserts does not raise if more than one consent for this subject """ subject_identifier = 'ABCDEF' SubjectConsent.objects.create( subject_identifier=subject_identifier, version='1') SubjectConsent.objects.create( subject_identifier=subject_identifier, version='2') visit_schedule, schedule = site_visit_schedules.get_by_onschedule_model( 'edc_visit_schedule.onscheduletwo') subject_schedule = SubjectSchedule( visit_schedule=visit_schedule, schedule=schedule) try: subject_schedule.put_on_schedule( subject_identifier=subject_identifier, onschedule_datetime=get_utcnow()) except SubjectScheduleError: self.fail('SubjectScheduleError unexpectedly raised.')
def test_onschedule_updates_history(self): """Asserts returns the correct instances for the schedule. """ for onschedule_model, schedule_name in [ ('edc_visit_schedule.onscheduletwo', 'schedule_two'), ('edc_visit_schedule.onschedulefour', 'schedule_four')]: with self.subTest(onschedule_model=onschedule_model, schedule_name=schedule_name): visit_schedule, schedule = site_visit_schedules.get_by_onschedule_model( onschedule_model) subject_schedule = SubjectSchedule( visit_schedule=visit_schedule, schedule=schedule) subject_schedule.put_on_schedule( subject_identifier=self.subject_identifier, onschedule_datetime=get_utcnow()) try: SubjectScheduleHistory.objects.get( subject_identifier=self.subject_identifier, schedule_name=schedule_name) except ObjectDoesNotExist: self.fail('ObjectDoesNotExist unexpectedly raised')
def setUp(self): import_holidays() self.subject_identifier = '12345678' self.study_maternal_identifier = '89721' self.options = {'consent_datetime': get_utcnow(), 'version': '1'} self.subject_screening = mommy.make_recipe( 'flourish_caregiver.screeningpriorbhpparticipants') self.eligible_options = { 'screening_identifier': self.subject_screening.screening_identifier, 'consent_datetime': get_utcnow, 'remain_in_study': YES, 'hiv_testing': YES, 'breastfeed_intent': YES, 'consent_reviewed': YES, 'study_questions': YES, 'assessment_score': YES, 'consent_signature': YES, 'consent_copy': YES }
def test_get_previous_model_instance(self): """Assert model can determine the previous. """ self.helper.consent_and_put_on_schedule() for index, appointment in enumerate(Appointment.objects.all().order_by( 'visit_code')): SubjectVisit.objects.create( appointment=appointment, report_datetime=get_utcnow() - relativedelta(months=10 - index), reason=SCHEDULED) subject_visits = SubjectVisit.objects.all().order_by( 'appointment__timepoint_datetime') self.assertEqual(subject_visits.count(), 4) subject_visit = subject_visits[0] self.assertIsNone(subject_visit.previous_visit) subject_visit = subject_visits[1] self.assertEqual(subject_visit.previous_visit.pk, subject_visits[0].pk) subject_visit = subject_visits[2] self.assertEqual(subject_visit.previous_visit.pk, subject_visits[1].pk) subject_visit = subject_visits[3] self.assertEqual(subject_visit.previous_visit.pk, subject_visits[2].pk)
def test_dev_screening_36_months(self): maternal_dataset_obj = mommy.make_recipe( 'flourish_caregiver.maternaldataset', delivdt=get_utcnow() - relativedelta(years=3, months=0), **self.maternal_dataset_options) child_dataset = mommy.make_recipe('flourish_child.childdataset', dob=get_utcnow() - relativedelta(years=3, months=0), **self.child_dataset_options) mommy.make_recipe( 'flourish_caregiver.screeningpriorbhpparticipants', screening_identifier=maternal_dataset_obj.screening_identifier, ) subject_consent = mommy.make_recipe( 'flourish_caregiver.subjectconsent', screening_identifier=maternal_dataset_obj.screening_identifier, breastfeed_intent=YES, biological_caregiver=YES, **self.options) caregiver_child_consent = mommy.make_recipe( 'flourish_caregiver.caregiverchildconsent', subject_consent=subject_consent, study_child_identifier=child_dataset.study_child_identifier, child_dob=maternal_dataset_obj.delivdt.date(), ) mommy.make_recipe( 'flourish_caregiver.caregiverpreviouslyenrolled', subject_identifier=subject_consent.subject_identifier) self.assertEqual( ChildDummySubjectConsent.objects.filter( identity=caregiver_child_consent.identity).count(), 1) dummy_consent = ChildDummySubjectConsent.objects.get( subject_identifier=caregiver_child_consent.subject_identifier) mommy.make_recipe( 'flourish_child.childvisit', appointment=Appointment.objects.get( visit_code='2000', subject_identifier=caregiver_child_consent.subject_identifier), report_datetime=get_utcnow(), reason=SCHEDULED) self.assertEqual( OnScheduleChildCohortAQuarterly.objects.filter( subject_identifier=dummy_consent.subject_identifier, schedule_name='child_a_quart_schedule1').count(), 1) mommy.make_recipe( 'flourish_child.childvisit', appointment=Appointment.objects.get( visit_code='2001', subject_identifier=caregiver_child_consent.subject_identifier), report_datetime=get_utcnow(), reason=SCHEDULED) self.assertEqual( CrfMetadata.objects.get( model='flourish_child.infantdevscreening36months', subject_identifier=caregiver_child_consent.subject_identifier, visit_code='2001').entry_status, REQUIRED) visit = ChildVisit.objects.get(visit_code='2001') mommy.make_recipe( 'flourish_child.infantdevscreening36months', child_visit=visit, ) mommy.make_recipe( 'flourish_child.childvisit', appointment=Appointment.objects.get( visit_code='2002', subject_identifier=caregiver_child_consent.subject_identifier), report_datetime=get_utcnow(), reason=SCHEDULED) self.assertEqual( CrfMetadata.objects.get( model='flourish_child.infantdevscreening36months', subject_identifier=caregiver_child_consent.subject_identifier, visit_code='2002').entry_status, NOT_REQUIRED)
def test_viral_load_required(self): screening_preg = mommy.make_recipe( 'flourish_caregiver.screeningpregwomen', ) subject_consent = mommy.make_recipe( 'flourish_caregiver.subjectconsent', screening_identifier=screening_preg.screening_identifier, breastfeed_intent=YES, **self.options) mommy.make_recipe('flourish_caregiver.caregiverchildconsent', subject_consent=subject_consent, gender=None, first_name=None, last_name=None, identity=None, confirm_identity=None, study_child_identifier=None, child_dob=None, version='2') mommy.make_recipe( 'flourish_caregiver.antenatalenrollment', subject_identifier=subject_consent.subject_identifier, ) mommy.make_recipe( 'flourish_caregiver.maternaldelivery', subject_identifier=subject_consent.subject_identifier) self.assertEqual( OnScheduleCohortABirth.objects.filter( subject_identifier=subject_consent.subject_identifier, schedule_name='a_birth1_schedule1').count(), 1) mommy.make_recipe( 'flourish_caregiver.maternalvisit', appointment=Appointment.objects.get( subject_identifier=subject_consent.subject_identifier, visit_code='2000D'), report_datetime=get_utcnow(), reason=SCHEDULED) self.assertEqual( RequisitionMetadata.objects.get( panel_name='viral_load', subject_identifier=subject_consent.subject_identifier, visit_code='2000D').entry_status, REQUIRED) self.assertEqual( OnScheduleCohortAQuarterly.objects.filter( subject_identifier=subject_consent.subject_identifier, schedule_name='a_quarterly1_schedule1').count(), 1) mommy.make_recipe( 'flourish_caregiver.maternalvisit', appointment=Appointment.objects.get( subject_identifier=subject_consent.subject_identifier, visit_code='2001M'), report_datetime=get_utcnow(), reason=SCHEDULED) self.assertEqual( RequisitionMetadata.objects.get( panel_name='viral_load', subject_identifier=subject_consent.subject_identifier, visit_code='2001M').entry_status, NOT_REQUIRED)
def get_difference(birth_date=None): difference = relativedelta.relativedelta( get_utcnow().date(), birth_date) return difference.years