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 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'
예제 #3
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 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 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'
예제 #7
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'
예제 #8
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 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'
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'
예제 #11
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'
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
예제 #13
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"
예제 #14
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 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'
예제 #16
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"
class EducationCrfRuleGroup(CrfRuleGroup):

    head_of_household = CrfRule(
        predicate=P("household_head", "eq", NO),
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f"{app_label}.educationhoh"],
    )

    class Meta:
        app_label = app_label
        source_model = f"{app_label}.education"
예제 #18
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'
예제 #19
0
class MaternalAntenatalEnrollmentRuleGroup(CrfRuleGroup):

    maternal_ultrasound_neg = CrfRule(
        predicate=P('number_of_gestations', 'eq', '1'),
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_models=[f'{app_label}.maternalobstericalhistory',
                       f'{app_label}.maternalmedicalhistory',
                       f'{app_label}.maternaldemographics',
                       f'{app_label}.maternalclinicalmeasurementsone'])

    class Meta:
        app_label = app_label
        source_model = f'{app_label}.maternalultrasoundinitial'
class OutPatientCareRuleGroup(CrfRuleGroup):
    """Allows the ceaopd forms to be made available
    whether or not the participant has govt_health_care.
    """

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

    class Meta:
        app_label = app_label
        source_model = f'{app_label}.outpatientcare'
class RequisitionRuleGroup1(BaseRequisitionRuleGroup):

    """Ensures an ELISA blood draw requisition if HIV result is IND.
    """
    elisa_for_ind = RequisitionRule(
        predicate=P('hiv_result', 'eq', IND),
        consequence=REQUIRED,
        alternative=NOT_REQUIRED,
        target_panels=[elisa_panel])

    class Meta:
        app_label = app_label
        source_model = f'{app_label}.hivresult'
        requisition_model = f'{app_label}.subjectrequisition'
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 HivCareAdherenceRuleGroup(CrfRuleGroup):

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

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

    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}.hivcareadherence'