def setUp(self):
        edc_base_startup()
        try:
            site_lab_profiles.register(TestLabProfile())
        except AlreadyRegisteredLabProfile:
            pass

        self.configuration = TestAppConfiguration()
        self.configuration.prepare()
        consent_type = ConsentType.objects.first()
        consent_type.app_label = 'edc_testing'
        consent_type.model_name = 'testconsentwithmixin'
        consent_type.save()

        TestVisitSchedule().build()

        self.study_site = '40'
        self.identity = '111111111'
        self.visit_definition = VisitDefinition.objects.get(code='1000')
        subject_identifier = '999-100000-1'
        self.registered_subject = RegisteredSubjectFactory(
            subject_identifier=subject_identifier)
        self.test_consent = TestConsentWithMixinFactory(
            registered_subject=self.registered_subject,
            gender=MALE,
            dob=date.today() - relativedelta(years=35),
            study_site=self.study_site,
            identity=self.identity,
            confirm_identity=self.identity,
            subject_identifier='999-100000-1')
        self.appointment_count = VisitDefinition.objects.all().count()
        self.appointment = Appointment.objects.get(
            registered_subject=self.registered_subject,
            visit_definition=self.visit_definition)
Example #2
0
    def setUp(self):
        try:
            site_lab_profiles.register(MaternalProfile())
            site_lab_profiles.register(InfantProfile())
        except AlreadyRegisteredLabProfile:
            pass
        AppConfiguration(lab_profiles=site_lab_profiles).prepare()
        AntenatalEnrollmentVisitSchedule().build()
        PostnatalEnrollmentVisitSchedule().build()
        site_rule_groups.autodiscover()
        InfantBirthVisitSchedule().build()

        self.maternal_eligibility = MaternalEligibilityFactory()
        self.maternal_consent = MaternalConsentFactory(
            registered_subject=self.maternal_eligibility.registered_subject)
        self.registered_subject = self.maternal_consent.registered_subject

        PostnatalEnrollmentFactory(
            registered_subject=self.registered_subject,
            current_hiv_status=POS,
            evidence_hiv_status=YES)
        self.appointment = Appointment.objects.get(registered_subject=self.registered_subject,
                                                   visit_definition__code='1000M')
        self.maternal_visit = MaternalVisitFactory(appointment=self.appointment)
        self.appointment = Appointment.objects.get(
            registered_subject=self.registered_subject, visit_definition__code='2000M')
        maternal_visit = MaternalVisitFactory(appointment=self.appointment)
        self.maternal_labour_del = MaternalLabourDelFactory(maternal_visit=maternal_visit)

        self.registered_subject_infant = RegisteredSubject.objects.get(
            subject_type=INFANT, relative_identifier=self.registered_subject.subject_identifier)
    def setUp(self):

        try:
            site_lab_profiles.register(TestLabProfile())
        except AlreadyRegisteredLabProfile:
            pass
        TestAppConfiguration().prepare()
        TestVisitSchedule().build()

        class TestRuleGroupConsent(RuleGroup):
            test_rule = RequisitionRule(
                logic=Logic(
                    predicate=(('may_store_samples', 'equals', NO)),
                    consequence='not_required',
                    alternative='new'),
                target_model=['testrequisition'],
                target_requisition_panels=['research blood draw'])

            class Meta:
                app_label = 'testing'
                source_fk = (RegisteredSubject, 'registered_subject')
                source_model = TestConsentWithMixin
        site_rule_groups.register(TestRuleGroupConsent)

        class TestRuleGroupSched(RuleGroup):
            test_rule = RequisitionRule(
                logic=Logic(
                    predicate=(('f1', 'equals', NO)),
                    consequence='not_required',
                    alternative='new'),
                target_model=['testrequisition'],
                target_requisition_panels=['microtube', 'viral load'])

            class Meta:
                app_label = 'testing'
                source_fk = (TestVisit, 'test_visit')
                source_model = TestScheduledModel1

        self.study_site = '40'
        site_rule_groups.register(TestRuleGroupSched)
        self.test_rule_group_sched_cls = TestRuleGroupSched
        self.test_visit_factory = TestVisitFactory
        self.visit_definition = VisitDefinition.objects.get(code='1000')
        self.test_consent = TestConsentWithMixinFactory(
            gender='M', study_site=self.study_site, may_store_samples=YES)
        self.registered_subject = RegisteredSubject.objects.get(
            subject_identifier=self.test_consent.subject_identifier)
        self.appointment = Appointment.objects.get(
            registered_subject=self.registered_subject)
from edc_lab.lab_profile.classes import site_lab_profiles

from edc_lab.lab_profile.classes import LabProfile

from .models import (Aliquot, AliquotType, Receive, MaternalRequisition, InfantRequisition,
                     AliquotProfile, AliquotProfileItem, Panel)


class BaseTshiloDikotlaProfile(LabProfile):
    aliquot_model = Aliquot
    aliquot_type_model = AliquotType
    profile_model = AliquotProfile
    profile_item_model = AliquotProfileItem
    receive_model = Receive
    panel_model = Panel


class MaternalProfile(BaseTshiloDikotlaProfile):
    requisition_model = MaternalRequisition
    name = MaternalRequisition._meta.object_name
site_lab_profiles.register(MaternalProfile)


class InfantProfile(BaseTshiloDikotlaProfile):
    requisition_model = InfantRequisition
    name = InfantRequisition._meta.object_name
site_lab_profiles.register(InfantProfile)
    def setUp(self):

        try:
            site_lab_profiles.register(TestLabProfile())
        except AlreadyRegisteredLabProfile:
            pass
        TestAppConfiguration().prepare()
        TestVisitSchedule().build()

        # a test rule group where the source model is RegisteredSubject
        # the rules in this rule group will be only evaluated when the visit instance
        # is created or saved. Note source_fk is None.
        class TestRuleGroupRs(RuleGroup):
            test_rule = CrfRule(
                logic=Logic(
                    predicate=(('gender', 'equals', 'M')),
                    consequence='not_required',
                    alternative='new'),
                target_model=['testscheduledmodel1'])

            class Meta:
                app_label = 'testing'
                source_fk = None
                source_model = RegisteredSubject
        site_rule_groups.register(TestRuleGroupRs)

        # a test rule group where the source model is a scheduled model.
        # a scheduled model has a FK to the visit instance (source_fk).
        # the rules in this rule group will be evaluated when the source instance
        # is created or saved.
        class TestRuleGroupSched(RuleGroup):
            test_rule = CrfRule(
                logic=Logic(
                    predicate=(('f1', 'equals', NO)),
                    consequence='not_required',
                    alternative='new'),
                target_model=['testscheduledmodel2'])

            class Meta:
                app_label = 'testing'
                source_fk = (TestVisit, 'test_visit')
                source_model = TestScheduledModel1
        site_rule_groups.register(TestRuleGroupSched)

        # a test rule group where the source model is a consent or membership model.
        # these models have a FK to registered subject (source_fk).
        # the rules in this rule group will only evaluated when the visit instance
        # is created or saved.
        class TestRuleGroupConsent(RuleGroup):
            test_rule = CrfRule(
                logic=Logic(
                    predicate=(('may_store_samples', 'equals', NO)),
                    consequence='not_required',
                    alternative='new'),
                target_model=['testscheduledmodel3'])

            class Meta:
                app_label = 'testing'
                source_fk = (RegisteredSubject, 'registered_subject')
                source_model = TestConsentWithMixin
        site_rule_groups.register(TestRuleGroupConsent)

        class TestRuleGroupConsentFunc(RuleGroup):
            test_rule = CrfRule(
                logic=Logic(
                    predicate=func_condition_true,
                    consequence='not_required',
                    alternative='new'),
                target_model=['testscheduledmodel3'])

            class Meta:
                app_label = 'testing'
                source_fk = (RegisteredSubject, 'registered_subject')
                source_model = TestConsentWithMixin
        self.test_rule_group_rs_cls = TestRuleGroupRs
        self.test_rule_group_sched_cls = TestRuleGroupSched
        self.test_rule_group_consent_cls = TestRuleGroupConsent
        self.test_rule_group_consent_func_cls = TestRuleGroupConsentFunc

        self.visit_definition = VisitDefinition.objects.get(code='1000')

        self.test_consent = TestConsentWithMixinFactory(
            gender='M',
            study_site='40',
            may_store_samples=NO)

        self.registered_subject = RegisteredSubject.objects.get(subject_identifier=self.test_consent.subject_identifier)
        self.appointment = Appointment.objects.get(registered_subject=self.registered_subject)
from edc_lab.lab_profile.classes import LabProfile

from .models import (Aliquot, AliquotType, Receive, MaternalRequisition,
                     InfantRequisition, AliquotProfile, AliquotProfileItem,
                     Panel)


class BaseMicrobiomeProfile(LabProfile):
    aliquot_model = Aliquot
    aliquot_type_model = AliquotType
    profile_model = AliquotProfile
    profile_item_model = AliquotProfileItem
    receive_model = Receive
    panel_model = Panel


class MaternalProfile(BaseMicrobiomeProfile):
    requisition_model = MaternalRequisition
    name = MaternalRequisition._meta.object_name


site_lab_profiles.register(MaternalProfile)


class InfantProfile(BaseMicrobiomeProfile):
    requisition_model = InfantRequisition
    name = InfantRequisition._meta.object_name


site_lab_profiles.register(InfantProfile)