class MedicalDiagnosesRuleGroup(CrfRuleGroup):
    """Allows the heartattack, cancer, tb forms to be made available
    whether or not the participant has a record. see redmine 314.
    """
    heart_attack_record = CrfRule(
        predicate=P('heart_attack_record', 'eq', YES),
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.heartattack'])

    cancer_record = CrfRule(
        predicate=P('cancer_record', 'eq', YES),
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.cancer'])

    tb_record_tuberculosis = CrfRule(
        predicate=P('tb_record', 'eq', YES),
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.tuberculosis'])

    class Meta:
        app_label = app_label
        source_model = f'{app_label}.medicaldiagnoses'
class ReviewPositiveRuleGroup(CrfRuleGroup):

    recorded_hiv_result = CrfRule(
        predicate=pc.func_requires_todays_hiv_result,
        consequence=NOT_REQUIRED,
        alternative=REQUIRED,
        target_models=[f'{app_label}.hivcareadherence',
                       f'{app_label}.hivmedicalcare',
                       f'{app_label}.positiveparticipant'])

    recorded_hivresult = CrfRule(
        predicate=P('recorded_hiv_result', 'eq', NEG),
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.stigma', f'{app_label}.stigmaopinion'])

    require_todays_hiv_result = CrfRule(
        predicate=pc.func_requires_todays_hiv_result,
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.hivresult'])

    class Meta:
        app_label = app_label
        source_model = f'{app_label}.hivtestreview'
class SexualBehaviourRuleGroup(CrfRuleGroup):

    partners = CrfRule(
        predicate=pc.func_requires_recent_partner,
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.recentpartner'])

    last_year_partners = CrfRule(
        predicate=pc.func_requires_second_partner_forms,
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.secondpartner'])

    more_partners = CrfRule(
        predicate=pc.func_requires_third_partner_forms,
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.thirdpartner'])

    ever_sex = CrfRule(
        predicate=PF(
            'ever_sex', 'gender',
            func=lambda x, y: True if x == YES and y == FEMALE else False),
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.reproductivehealth',
                       f'{app_label}.pregnancy',
                       f'{app_label}.nonpregnancy'])

    class Meta:
        app_label = app_label
        source_model = f'{app_label}.sexualbehaviour'
Example #4
0
class ChildSocioDemographicRuleGroup(CrfRuleGroup):

    attend_school = CrfRule(predicate=P('attend_school', 'eq', YES),
                            consequence=REQUIRED,
                            alternative=NOT_REQUIRED,
                            target_models=[f'{app_label}.academicperformance'])

    working_status = CrfRule(predicate=P('working', 'eq', YES),
                             consequence=REQUIRED,
                             alternative=NOT_REQUIRED,
                             target_models=[f'{app_label}.childworkingstatus'])

    class Meta:
        app_label = app_label
        source_model = f'{app_label}.childsociodemographic'
class BaseCrfRuleGroup(CrfRuleGroup):

    pima_cd4 = CrfRule(
        predicate=pc.func_requires_pima_cd4,
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.pimacd4'])

    hic_enrollment = CrfRule(
        predicate=pc.func_requires_hic_enrollment,
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.hicenrollment'])

    class Meta:
        abstract = True
class CrfRuleGroup1(BaseCrfRuleGroup):

    serve_sti_form = CrfRule(
        predicate=pc.func_hiv_positive,
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.hivrelatedillness'])

    elisa_result = CrfRule(
        predicate=P('hiv_result', 'eq', IND),
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.elisahivresult'])

    class Meta:
        app_label = app_label
        source_model = f'{app_label}.hivresult'
class CircumcisionRuleGroup(CrfRuleGroup):

    circumcised = CrfRule(
        predicate=P('circumcised', 'eq', YES),
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.circumcised'])

    uncircumcised = CrfRule(
        predicate=P('circumcised', 'eq', NO),
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.uncircumcised'])

    class Meta:
        app_label = app_label
        source_model = f'{app_label}.circumcision'
class ResourceUtilizationRuleGroup(CrfRuleGroup):

    out_patient = CrfRule(
        predicate=P('out_patient', 'eq', YES),
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.outpatientcare'])

    hospitalized = CrfRule(
        predicate=P('hospitalized', 'eq', 0),
        consequence=NOT_REQUIRED,
        alternative=REQUIRED,
        target_models=[f'{app_label}.hospitaladmission'])

    class Meta:
        app_label = app_label
        source_model = f'{app_label}.resourceutilization'
class MaternalSrhServicesRuleGroup(CrfRuleGroup):
    srh_services = CrfRule(predicate=pc.func_show_srh_services_utilization,
                           consequence=REQUIRED,
                           alternative=NOT_REQUIRED,
                           target_models=[(f'{app_label}.maternalsrh')])

    class Meta:
        app_label = app_label
        source_model = f'{app_label}.maternalvisit'
Example #10
0
class InfantBirthArvRuleGroup(CrfRuleGroup):
    birth_arv = CrfRule(predicate=pc.func_infant_heu,
                        consequence=REQUIRED,
                        alternative=NOT_REQUIRED,
                        target_models=[(f'{app_label}.infantbirtharv')])

    class Meta:
        app_label = app_label
        source_model = f'{app_label}.infantvisit'
class InfantArvProphRuleGroup(CrfRuleGroup):
    arv_proph = CrfRule(predicate=pc.func_show_infant_arv_proph,
                        consequence=REQUIRED,
                        alternative=NOT_REQUIRED,
                        target_models=[(f'{app_label}.infantarvproph')])

    class Meta:
        app_label = app_label
        source_model = f'{app_label}.infantvisit'
Example #12
0
class InfantFuDxRuleGroup(CrfRuleGroup):
    has_dx_yes = CrfRule(predicate=P('has_dx', 'eq', YES),
                         consequence=REQUIRED,
                         alternative=NOT_REQUIRED,
                         target_models=[(f'{app_label}.infantfudx')])

    class Meta:
        app_label = app_label
        source_model = f'{app_label}.infantfu'
class KaraboOffstudyRuleGroup(CrfRuleGroup):

    show_offstudy = CrfRule(predicate=pc.show_karabo_offstudy,
                            consequence=REQUIRED,
                            alternative=NOT_REQUIRED,
                            target_models=[(f'{app_label}.karabooffstudy')])

    class Meta:
        app_label = app_label
        source_model = f'{app_label}.karabotuberculosishistory'
Example #14
0
class InfantNvpDispensingRuleGroup(CrfRuleGroup):
    infant_nvp_dispensing = CrfRule(
        predicate=pc.func_show_infant_nvp_dispensing,
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[(f'{app_label}.infantnvpdispensing')])

    class Meta:
        app_label = app_label
        source_model = f'{app_label}.infantvisit'
class RapidTestResultGroup(CrfRuleGroup):
    rapid_test_result = CrfRule(
        predicate=pc.func_show_rapid_test_form,
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[(f'{app_label}.rapidtestresult')])

    class Meta:
        app_label = app_label
        source_model = f'{app_label}.maternalvisit'
class InfantBirthDataRuleGroup(CrfRuleGroup):
    solid_foods = CrfRule(
        predicate=P('congenital_anomalities', 'eq', YES),
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[(f'{app_label}.infantcongenitalanomalies')])

    class Meta:
        app_label = app_label
        source_model = f'{app_label}.infantbirthdata'
Example #17
0
class ViralLoadTrackingCrfRuleGroup(CrfRuleGroup):

    is_drawn = CrfRule(predicate=P('is_drawn', 'eq', YES),
                       consequence=REQUIRED,
                       alternative=NOT_REQUIRED,
                       target_models=[f'{app_label}.vlresult'])

    class Meta:
        source_model = f'{app_label}.viralloadtracking'
        app_label = app_label
class EducationQuestionnaireRuleGroup(CrfRuleGroup):

    work_status = CrfRule(
        predicate=P('work_status', 'eq', YES),
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.communityquestionnaire'])

    class Meta:
        app_label = 'trainee_subject'
        source_model = f'{app_label}.educationquestionnaire'
Example #19
0
class InfantNvpAdjustmentRuleGroup(CrfRuleGroup):
    nvp_adjustment = CrfRule(predicate=pc.func_show_nvp_adjustment_2010,
                             consequence=REQUIRED,
                             alternative=NOT_REQUIRED,
                             target_models=[
                                 (f'{app_label}.infantnvpadjustment')
                             ])

    class Meta:
        app_label = app_label
        source_model = f'{app_label}.infantvisit'
Example #20
0
class GAD7AnxietyScreeningRuleGroup(CrfRuleGroup):

    gad_anxiety_referral = CrfRule(
        predicate=P('anxiety_score', 'gte', 10),
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.caregivergadreferral'])

    class Meta:
        app_label = app_label
        source_model = f'{app_label}.caregivergadanxietyscreening'
Example #21
0
class MaternalUltrasoundInitialRuleGroup(CrfRuleGroup):

    maternal_ultrasound = CrfRule(
        predicate=pc.func_show_ultrasound_form,
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.maternalultrasoundinitial'])

    class Meta:
        app_label = app_label
        source_model = f'{app_label}.maternalvisit'
class QuestionnaireCrfRuleGroup(CrfRuleGroup):

    viralloadtracking = CrfRule(
        predicate=P('registration_type', 'eq', MASA_VL_SCHEDULED),
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.viralloadtracking'])

    class Meta:
        source_model = f'{app_label}.questionnaire'
        app_label = app_label
class HivTestingHistoryRuleGroup(CrfRuleGroup):

    has_record = CrfRule(
        predicate=pc.func_requires_hivtestreview,
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.hivtestreview'])

    has_tested = CrfRule(
        predicate=P('has_tested', 'eq', YES),
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.hivtested'])

    hiv_untested = CrfRule(
        predicate=pc.func_requires_hivuntested,
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.hivuntested'])

    other_record = CrfRule(
        predicate=PF(
            'has_tested', 'other_record',
            func=lambda x, y: True if x == YES and y == YES else False),
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.hivresultdocumentation'])

    require_todays_hiv_result = CrfRule(
        predicate=pc.func_requires_todays_hiv_result,
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.hivresult'])

    verbal_hiv_result_hiv_care_baseline = CrfRule(
        predicate=P('verbal_hiv_result', 'eq', POS),
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.hivcareadherence',
                       f'{app_label}.positiveparticipant',
                       f'{app_label}.hivmedicalcare',
                       f'{app_label}.hivhealthcarecosts'])

    verbal_response = CrfRule(
        predicate=P('verbal_hiv_result', 'eq', NEG),
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.stigma',
                       f'{app_label}.stigmaopinion'])

    def method_result(self):
        return True

    class Meta:
        app_label = app_label
        source_model = f'{app_label}.hivtestinghistory'
Example #24
0
class FollowupRuleGroup(CrfRuleGroup):

    death_report = CrfRule(
        predicate=P("alive", "eq", NO),
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=["deathreport"],
    )

    class Meta:
        app_label = "mapitio_subject"
        source_model = "followup"
Example #25
0
class MedicalExpensesCrfRuleGroup(CrfRuleGroup):

    medical_expenses = CrfRule(
        predicate=P("care_before_hospital", "eq", YES),
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f"{app_label}.medicalexpensestwo"],
    )

    class Meta:
        app_label = app_label
        source_model = f"{app_label}.medicalexpenses"
Example #26
0
class CongenitalAnomaliesRuleGroup(CrfRuleGroup):

    congenital_anomalies = CrfRule(
        predicate=P('congenital_anomalities', 'eq', YES),
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.infantcongenitalanomalies']
    )

    class Meta:
        app_label = app_label
        source_model = f'{app_label}.birthdata'
Example #27
0
class InfantFuPhysicalRuleGroup(CrfRuleGroup):
    physical_assessment_yes = CrfRule(predicate=P('physical_assessment', 'eq',
                                                  YES),
                                      consequence=REQUIRED,
                                      alternative=NOT_REQUIRED,
                                      target_models=[
                                          (f'{app_label}.infantfuphysical')
                                      ])

    class Meta:
        app_label = app_label
        source_model = f'{app_label}.infantfu'
class KaraboTbRuleGroup(CrfRuleGroup):

    require_tb_form = CrfRule(predicate=pc.func_show_karabo_tb_form,
                              consequence=REQUIRED,
                              alternative=NOT_REQUIRED,
                              target_models=[
                                  (f'{app_label}.karabotuberculosishistory')
                              ])

    class Meta:
        app_label = app_label
        source_model = f'{app_label}.infantvisit'
class ReproductiveRuleGroup(CrfRuleGroup):

    currently_pregnant = CrfRule(
        predicate=PF(
            'currently_pregnant', 'menopause',
            func=lambda x, y: True if x == YES or x == NOT_SURE and y == NO else False),
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.pregnancy'])

    non_pregnant = CrfRule(
        predicate=PF(
            'currently_pregnant', 'menopause',
            func=lambda x, y: True if x == NO and y == NO else False),
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.nonpregnancy'])

    class Meta:
        app_label = app_label
        source_model = f'{app_label}.reproductivehealth'
class CrfRuleGroup2(BaseCrfRuleGroup):

    serve_hiv_care_adherence = CrfRule(
        predicate=P('verbal_hiv_result', 'eq', POS),
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.hivcareadherence',
                       f'{app_label}.hivmedicalcare'])

    class Meta:
        app_label = app_label
        source_model = f'{app_label}.hivtestinghistory'