示例#1
0
class SexualBehaviourRuleGroup(RuleGroup):

    partners = ScheduledDataRule(
        logic=Logic(
            predicate=('last_year_partners', 'gte', 1),
            consequence='new',
            alternative='not_required'),
        target_model=['monthsrecentpartner', 'monthssecondpartner', 'monthsthirdpartner'])

    last_year_partners = ScheduledDataRule(
        logic=Logic(
            predicate=('last_year_partners', 'gte', 2),
            consequence='new',
            alternative='not_required'),
        target_model=['monthssecondpartner'])

    more_partners = ScheduledDataRule(
        logic=Logic(
            predicate=('last_year_partners', 'gte', 3),
            consequence='new',
            alternative='not_required'),
        target_model=['monthsthirdpartner'])

    ever_sex = ScheduledDataRule(
        logic=Logic(
            predicate=evaluate_ever_had_sex_for_female,
            consequence='new',
            alternative='not_required'),
        target_model=['reproductivehealth', 'pregnancy', 'nonpregnancy'])

    class Meta:
        app_label = 'bcpp_subject'
        source_fk = (SubjectVisit, 'subject_visit')
        source_model = SexualBehaviour
示例#2
0
class MedicalDiagnosesRuleGroup(RuleGroup):
    """"Allows the heartattack, cancer, tb forms to be made available whether or not the participant
    has a record. see redmine 314."""
    heart_attack_record = ScheduledDataRule(
        logic=Logic(
            predicate=('heart_attack_record', 'equals', 'Yes'),
            consequence='new',
            alternative='not_required'),
        target_model=['heartattack'])

    cancer_record = ScheduledDataRule(
        logic=Logic(
            predicate=('cancer_record', 'equals', 'Yes'),
            consequence='new',
            alternative='not_required'),
        target_model=['cancer'])

    tb_record_tubercolosis = ScheduledDataRule(
        logic=Logic(
            predicate=('tb_record', 'equals', 'Yes'),
            consequence='new',
            alternative='not_required'),
        target_model=['tubercolosis'])

    class Meta:
        app_label = 'bcpp_subject'
        source_fk = (SubjectVisit, 'subject_visit')
        source_model = MedicalDiagnoses
示例#3
0
class ReviewPositiveRuleGroup(RuleGroup):

    recorded_hiv_result = ScheduledDataRule(
        logic=Logic(
            predicate=func_todays_hiv_result_required,
            consequence='not_required',
            alternative='new'),
        target_model=['hivcareadherence', 'hivmedicalcare', 'positiveparticipant'])

    recorded_hivresult = ScheduledDataRule(
        logic=Logic(
            predicate=('recorded_hiv_result', 'equals', 'NEG'),
            consequence='new',
            alternative='not_required'),
        target_model=['stigma', 'stigmaopinion'])

    require_todays_hiv_result = ScheduledDataRule(
        logic=Logic(
            predicate=func_show_microtube,
            consequence='new',
            alternative='not_required'),
        target_model=['hivresult'])

    class Meta:
        app_label = 'bcpp_subject'
        source_fk = (SubjectVisit, 'subject_visit')
        source_model = HivTestReview
示例#4
0
class BaseRequisitionRuleGroup(RuleGroup):
    """Ensures an RBD requisition if HIV result is POS."""
    rbd_for_pos = RequisitionRule(
        logic=Logic(
            predicate=func_rbd,
            consequence='new',
            alternative='not_required'),
        target_model=[('bcpp_lab', 'subjectrequisition')],
        target_requisition_panels=['Research Blood Draw'], )

    vl_for_pos = RequisitionRule(
        logic=Logic(
            predicate=func_vl,
            consequence='new',
            alternative='not_required'),
        target_model=[('bcpp_lab', 'subjectrequisition')],
        target_requisition_panels=['Viral Load'], )

    """Ensures a Microtube is not required for POS."""
    microtube_for_neg = RequisitionRule(
        logic=Logic(
            predicate=func_show_microtube,
            consequence='new',
            alternative='not_required'),
        target_model=[('bcpp_lab', 'subjectrequisition')],
        target_requisition_panels=['Microtube'], )

    pima_for_art_naive = ScheduledDataRule(
        logic=Logic(
            predicate=func_require_pima,
            consequence='new',
            alternative='not_required'),
        target_model=['pima'])

#     pimavl_for_art_naive = ScheduledDataRule(
#         logic=Logic(
#             predicate=func_art_naive,
#             consequence='new',
#             alternative='not_required'),
#         target_model=['pimavl'])

    hic = ScheduledDataRule(
        logic=Logic(
            predicate=func_show_hic_enrollment,
            consequence='new',
            alternative='not_required'),
        target_model=['hicenrollment'])

    class Meta:
        abstract = True
示例#5
0
class CessationRuleGroup(RuleGroup):

    feeding_survey = ScheduledDataRule(
        logic=Logic(predicate=func_feeding_survey,
                    consequence='new',
                    alternative='none'),
        target_model=['PostNatalInfantFeedingSurvey'])

    offstudy = ScheduledDataRule(logic=Logic(predicate=func_offstudy,
                                             consequence='new',
                                             alternative='none'),
                                 target_model=['MaternalOffStudy'])

    class Meta:
        app_label = 'mpepu_maternal'
        source_fk = None
        source_model = RegisteredSubject
示例#6
0
class MaternalArvPregRuleGroup(RuleGroup):

    took_arv = ScheduledDataRule(logic=Logic(predicate=('took_arv', 'equals',
                                                        'Yes'),
                                             consequence='new',
                                             alternative='not_required'),
                                 target_model=['maternalarvpreghistory'])

    start_pp = ScheduledDataRule(logic=Logic(predicate=('start_pp', 'equals',
                                                        'Yes'),
                                             consequence='new',
                                             alternative='not_required'),
                                 target_model=['maternalarvpphistory'])

    class Meta:
        app_label = 'mpepu_maternal'
        source_fk = (MaternalVisit, 'maternal_visit')
        source_model = MaternalArvPreg
示例#7
0
class InfantFuRuleGroup(RuleGroup):

    diarrhea_illness = ScheduledDataRule(logic=Logic(
        predicate=('diarrhea_illness', 'equals', 'No'),
        consequence='not_required',
        alternative='new'),
                                         target_model=['Infantfud'])

    has_dx = ScheduledDataRule(logic=Logic(predicate=('has_dx', 'equals',
                                                      'No'),
                                           consequence='not_required',
                                           alternative='new'),
                               target_model=['Infantfudx'])

    class Meta:
        app_label = 'mpepu_infant'
        source_fk = (InfantVisit, 'infant_visit')
        source_model = InfantFu
示例#8
0
class GenderRuleGroup(RuleGroup):

    female = ScheduledDataRule(logic=Logic(predicate=('gender', 'equals', 'f'),
                                           consequence='not_required',
                                           alternative='new'),
                               target_model=[
                                   'htccircumcision', 'malefollowup',
                                   'circumcisionappointment'
                               ])

    male = ScheduledDataRule(logic=Logic(predicate=('gender', 'equals', 'm'),
                                         consequence='not_required',
                                         alternative='new'),
                             target_model=['pregnantfollowup'])

    class Meta:
        app_label = 'bcpp_htc_subject'
        filter_model = (HtcSubjectVisit, 'htc_subject_visit')
        source_model = RegisteredSubject
示例#9
0
class CircumcisionRuleGroup(RuleGroup):

    circumcised = ScheduledDataRule(
        logic=Logic(
            predicate=('circumcised', 'equals', 'Yes'),
            consequence='new',
            alternative='not_required'),
        target_model=['circumcised'])

    uncircumcised = ScheduledDataRule(
        logic=Logic(
            predicate=('circumcised', 'equals', 'No'),
            consequence='new',
            alternative='not_required'),
        target_model=['uncircumcised'])

    class Meta:
        app_label = 'bcpp_subject'
        source_fk = (SubjectVisit, 'subject_visit')
        source_model = Circumcision
示例#10
0
class ReproductiveRuleGroup(RuleGroup):

    currently_pregnant = ScheduledDataRule(
        logic=Logic(
            predicate=(('currently_pregnant', 'equals', 'Yes'), ('menopause', 'equals', 'No', 'and')),
            consequence='new',
            alternative='not_required'),
        target_model=['pregnancy'])

    non_pregnant = ScheduledDataRule(
        logic=Logic(
            predicate=(('currently_pregnant', 'equals', 'No'), ('menopause', 'equals', 'No', 'and')),
            consequence='new',
            alternative='not_required'),
        target_model=['nonpregnancy'])

    class Meta:
        app_label = 'bcpp_subject'
        source_fk = (SubjectVisit, 'subject_visit')
        source_model = ReproductiveHealth
示例#11
0
class ResourceUtilizationRuleGroup(RuleGroup):

    out_patient = ScheduledDataRule(
        logic=Logic(
            predicate=(('out_patient', 'equals', 'no'), ('out_patient', 'equals', 'Refuse', 'or')),
            consequence='not_required',
            alternative='new'),
        target_model=['outpatientcare'])

    hospitalized = ScheduledDataRule(
        logic=Logic(
            predicate=('hospitalized', 'equals', 0),
            consequence='not_required',
            alternative='new'),
        target_model=['hospitaladmission'])

    class Meta:
        app_label = 'bcpp_subject'
        source_fk = (SubjectVisit, 'subject_visit')
        source_model = ResourceUtilization
示例#12
0
class HivCareAdherenceRuleGroup(RuleGroup):

    medical_care = ScheduledDataRule(
        logic=Logic(
            predicate=('medical_care', 'equals', 'Yes'),
            consequence='new',
            alternative='not_required'),
        target_model=['hivmedicalcare'])

    pima_for_art_naive = ScheduledDataRule(
        logic=Logic(
            predicate=func_require_pima,
            consequence='new',
            alternative='not_required'),
        target_model=['pima'])

#     pimavl_for_art_naive = ScheduledDataRule(
#         logic=Logic(
#             predicate=func_art_naive,
#             consequence='new',
#             alternative='not_required'),
#         target_model=['pimavl'])

    require_todays_hiv_result = ScheduledDataRule(
        logic=Logic(
            predicate=func_show_microtube,
            consequence='new',
            alternative='not_required'),
        target_model=['hivresult'])

    hiv_linkage_to_care_art_naive = ScheduledDataRule(
        logic=Logic(
            predicate=func_art_naive_at_annual_or_defaulter,
            consequence='new',
            alternative='not_required'),
        target_model=['hivlinkagetocare'])

    class Meta:
        app_label = 'bcpp_subject'
        source_fk = (SubjectVisit, 'subject_visit')
        source_model = HivCareAdherence
示例#13
0
class FeedingChoiceRuleGroup(RuleGroup):

    first_time_feeding = ScheduledDataRule(
        logic=Logic(predicate=('first_time_feeding', 'equals', 'No'),
                    consequence='new',
                    alternative='not_required'),
        target_model=[
            'feedingchoicesectionone', 'feedingchoicesectiontwo',
            'feedingchoicesectionthree'
        ])

    first_time_feeding_yes = ScheduledDataRule(
        logic=Logic(predicate=('first_time_feeding', 'equals', 'Yes'),
                    consequence='new',
                    alternative='none'),
        target_model=['feedingchoicesectiontwo', 'feedingchoicesectionthree'])

    class Meta:
        app_label = 'mpepu_maternal'
        source_fk = (MaternalVisit, 'maternal_visit')
        source_model = FeedingChoice
示例#14
0
class HivResultRuleGroup(RuleGroup):

    todays_result = ScheduledDataRule(
        logic=Logic(predicate=('todays_result', 'equals', 'NEG'),
                    consequence='not_required',
                    alternative='new'),
        target_model=['Cd4test', 'positivefollowup'])

    class Meta:
        app_label = 'bcpp_htc_subject'
        filter_model = (HtcSubjectVisit, 'htc_subject_visit')
        source_model = HtcHivResult
示例#15
0
class HivTestingHistoryRuleGroup(RuleGroup):

    hiv_record = ScheduledDataRule(logic=Logic(predicate=('hiv_record',
                                                          'equals', 'Yes'),
                                               consequence='new',
                                               alternative='not_required'),
                                   target_model=['lasthivrecord'])

    class Meta:
        app_label = 'bcpp_htc_subject'
        filter_model = (HtcSubjectVisit, 'htc_subject_visit')
        source_model = HtcHivTestingHistory
示例#16
0
class InfantStudyDrugRuleGroup(RuleGroup):

    on_placebo_status = ScheduledDataRule(logic=Logic(
        predicate=('on_placebo_status', 'equals', 'No'),
        consequence='not_required',
        alternative='new'),
                                          target_model=['infantctxplaceboadh'])

    class Meta:
        app_label = 'mpepu_infant'
        source_fk = (InfantVisit, 'infant_visit')
        source_model = InfantStudyDrug
示例#17
0
class ViralLoadTrackingRuleGroup(RuleGroup):

    is_drawn = ScheduledDataRule(logic=Logic(predicate=('is_drawn', 'equals',
                                                        'Yes'),
                                             consequence='new',
                                             alternative='not_required'),
                                 target_model=['clinicvlresult'])

    class Meta:
        app_label = 'bcpp_clinic'
        source_fk = (ClinicVisit, 'clinic_visit')
        source_model = ViralLoadTracking
示例#18
0
class InfantBirthDataRuleGroup(RuleGroup):

    congenital_anomalities = ScheduledDataRule(
        logic=Logic(predicate=('congenital_anomalities', 'equals', 'Yes'),
                    consequence='new',
                    alternative='not_required'),
        target_model=['infantcongenitalanomalies'])

    class Meta:
        app_label = 'mpepu_infant'
        source_fk = (InfantVisit, 'infant_visit')
        source_model = InfantBirthData
示例#19
0
class InfantArvProphRuleGroup(RuleGroup):

    prophylatic_nvp = ScheduledDataRule(logic=Logic(
        predicate=('prophylatic_nvp', 'equals', 'No'),
        consequence='not_required',
        alternative='new'),
                                        target_model=['infantnvpadherence'])

    class Meta:
        app_label = 'mpepu_infant'
        source_fk = (InfantVisit, 'infant_visit')
        source_model = InfantArvProph
示例#20
0
class RequisitionRuleGroup1(BaseRequisitionRuleGroup):

    """Ensures an ELISA blood draw requisition if HIV result is IND."""
    elisa_for_ind = RequisitionRule(
        logic=Logic(
            predicate=func_hiv_indeterminate_today,
            consequence='new',
            alternative='not_required'),
        target_model=[('bcpp_lab', 'subjectrequisition')],
        target_requisition_panels=['ELISA', ], )

    """Ensures a venous blood draw requisition is required if insufficient
    volume in the capillary (microtube)."""
    venous_for_vol = RequisitionRule(
        logic=Logic(
            predicate=(('insufficient_vol', 'equals', 'Yes'), ('blood_draw_type', 'equals', 'venous', 'or'),),
            consequence='new',
            alternative='not_required'),
        target_model=[('bcpp_lab', 'subjectrequisition')],
        target_requisition_panels=['Venous (HIV)'], )

    serve_sti_form = ScheduledDataRule(
        logic=Logic(
            predicate=func_hiv_positive_today,
            consequence='new',
            alternative='not_required'),
        target_model=['sti'])

    elisa_result = ScheduledDataRule(
        logic=Logic(
            predicate=func_hiv_indeterminate_today,
            consequence='new',
            alternative='not_required'),
        target_model=['elisahivresult'])

    class Meta:
        app_label = 'bcpp_subject'
        source_fk = (SubjectVisit, 'subject_visit')
        source_model = HivResult
示例#21
0
class MasaRuleGroup(RuleGroup):

    is_drawn = ScheduledDataRule(logic=Logic(predicate=(('registration_type',
                                                         'equals',
                                                         'masa_vl_scheduled')),
                                             consequence='new',
                                             alternative='not_required'),
                                 target_model=['viralloadtracking'])

    class Meta:
        app_label = 'bcpp_clinic'
        source_fk = (ClinicVisit, 'clinic_visit')
        source_model = Questionnaire
示例#22
0
class StoolSamplingRuleGroup(RuleGroup):

    no_sample_taken = RequisitionRule(
        logic=Logic(predicate=('sample_obtained', 'equals', 'No'),
                    consequence='not_required',
                    alternative='new'),
        target_model=[('mpepu_lab', 'infantrequisition')],
        target_requisition_panels=['Stool storage'],
    )

    class Meta:
        app_label = 'mpepu_infant'
        source_fk = (InfantVisit, 'infant_visit')
        source_model = InfantStoolCollection
示例#23
0
class ViralLoadTrackingRequisitionRuleGroup(RuleGroup):

    initiation = RequisitionRule(
        logic=Logic(predicate=('is_drawn', 'equals', 'No'),
                    consequence='new',
                    alternative='not_required'),
        target_model=[('bcpp_lab', 'clinicrequisition')],
        target_requisition_panels=['Clinic Viral Load'],
    )

    class Meta:
        app_label = 'bcpp_clinic'
        source_fk = (ClinicVisit, 'clinic_visit')
        source_model = ViralLoadTracking
示例#24
0
class MaternalArvPostRuleGroup(RuleGroup):

    haart = ScheduledDataRule(logic=Logic(predicate=(('haart_last_visit',
                                                      'equals', 'No'),
                                                     ('arv_status', 'equals',
                                                      'never started', 'or')),
                                          consequence='not_required',
                                          alternative='new'),
                              target_model=['maternalarvpostadh'])

    class Meta:
        app_label = 'mpepu_maternal'
        source_fk = (MaternalVisit, 'maternal_visit')
        source_model = MaternalArvPost
示例#25
0
class FeedingChoiceRuleGroup(RuleGroup):

    maternal_feeding_choice = RequisitionRule(
        logic=Logic(predicate=('maternal_feeding_choice', 'equals', 'FF'),
                    consequence='not_required',
                    alternative='new'),
        target_model=[('mpepu_lab', 'infantrequisition')],
        target_requisition_panels=['DNA PCR'],
    )

    class Meta:
        app_label = 'mpepu_infant'
        source_fk = (InfantVisit, 'infant_visit')
        source_model = InfantEligibility
示例#26
0
class InitiationRequisitionRuleGroup(RuleGroup):

    initiation = RequisitionRule(
        logic=Logic(predicate=(('registration_type', 'equals', 'initiation'),
                               ('registration_type', 'equals', 'OTHER', 'or')),
                    consequence='new',
                    alternative='not_required'),
        target_model=[('bcpp_lab', 'clinicrequisition')],
        target_requisition_panels=['Clinic Viral Load'],
    )

    class Meta:
        app_label = 'bcpp_clinic'
        source_fk = (ClinicVisit, 'clinic_visit')
        source_model = Questionnaire
示例#27
0
class MaternalEnrollRuleGroup(RuleGroup):

    prev_pregnancies = ScheduledDataRule(logic=Logic(
        predicate=('prev_pregnancies', 'equals', 0),
        consequence='not_required',
        alternative='new'),
                                         target_model=['maternalenrollob'])

    prior_health_haart = ScheduledDataRule(logic=Logic(
        predicate=('prior_health_haart', 'equals', 'Yes'),
        consequence='new',
        alternative='not_required'),
                                           target_model=['maternalenrollarv'])

    prev_pregnancy_arv = ScheduledDataRule(logic=Logic(
        predicate=('prev_pregnancy_arv', 'equals', 'Yes'),
        consequence='new',
        alternative='not_required'),
                                           target_model=['maternalenrollclin'])

    class Meta:
        app_label = 'mpepu_maternal'
        source_fk = (MaternalVisit, 'maternal_visit')
        source_model = MaternalEnroll
示例#28
0
class HivTestingConsentRuleGroup(RuleGroup):

    todays_result = ScheduledDataRule(logic=Logic(predicate=('testing_today',
                                                             'equals', 'No'),
                                                  consequence='not_required',
                                                  alternative='new'),
                                      target_model=[
                                          'Cd4test', 'positivefollowup',
                                          'pregnantfollowup', 'malefollowup',
                                          'circumcisionappointment'
                                      ])

    class Meta:
        app_label = 'bcpp_htc_subject'
        filter_model = (HtcSubjectVisit, 'htc_subject_visit')
        source_model = HivTestingConsent
示例#29
0
class HivTestingHistoryRuleGroup(RuleGroup):

    has_record = ScheduledDataRule(
        logic=Logic(
            predicate=('has_record', 'equals', 'Yes'),
            consequence='new',
            alternative='not_required'),
        target_model=['hivtestreview'])

    has_tested = ScheduledDataRule(
        logic=Logic(
            predicate=('has_tested', 'equals', 'Yes'),
            consequence='new',
            alternative='not_required'),
        target_model=['hivtested'])

    hiv_untested = ScheduledDataRule(
        logic=Logic(
            predicate=func_hiv_untested,
            consequence='new',
            alternative='not_required'),
        target_model=['hivuntested'])

    other_record = ScheduledDataRule(
        logic=Logic(
            predicate=('other_record', 'equals', 'Yes'),
            consequence='new',
            alternative='not_required'),
        target_model=['hivresultdocumentation'])

    require_todays_hiv_result = ScheduledDataRule(
        logic=Logic(
            predicate=func_show_microtube,
            consequence='new',
            alternative='not_required'),
        target_model=['hivresult'])

    verbal_hiv_result_hiv_care_baseline = ScheduledDataRule(
        logic=Logic(
            predicate=('verbal_hiv_result', 'equals', 'POS'),
            consequence='new',
            alternative='not_required'),
        target_model=['hivcareadherence', 'positiveparticipant', 'hivmedicalcare', 'hivhealthcarecosts'])

    verbal_response = ScheduledDataRule(
        logic=Logic(
            predicate=('verbal_hiv_result', 'equals', 'NEG'),
            consequence='new',
            alternative='not_required'),
        target_model=['stigma', 'stigmaopinion'])

    other_response = ScheduledDataRule(
        logic=Logic(
            predicate=func_no_verbal_hiv_result,
            consequence='not_required',
            alternative='none'),
        target_model=['hivcareadherence', 'hivmedicalcare', 'positiveparticipant', 'stigma', 'stigmaopinion'])

    def method_result(self):
        return True

    class Meta:
        app_label = 'bcpp_subject'
        source_fk = (SubjectVisit, 'subject_visit')
        source_model = HivTestingHistory
示例#30
0
class RegisteredSubjectRuleGroup(RuleGroup):

    gender_circumsion = ScheduledDataRule(
        logic=Logic(
            predicate=func_should_not_show_circumsition,
            consequence='not_required',
            alternative='new'),
        target_model=['circumcision', 'circumcised', 'uncircumcised'])

    gender_menopause = ScheduledDataRule(
        logic=Logic(
            predicate=is_gender_male,
            consequence='not_required',
            alternative='new'),
        target_model=['reproductivehealth', 'pregnancy', 'nonpregnancy'])

    known_pos_in_y1 = ScheduledDataRule(
        logic=Logic(
            predicate=func_known_pos_in_prev_year,
            consequence='not_required',
            alternative='new'),
        target_model=['hivtestreview', 'hivtested', 'hivtestinghistory', 'hivresultdocumentation', 'hivresult', 'hivuntested'])

    pima_art_naive_enrollment_req_ahs = ScheduledDataRule(
        logic=Logic(
            predicate=func_require_pima,
            consequence='new',
            alternative='not_required'),
        target_model=['pima'])

    hiv_linkage_to_care = ScheduledDataRule(
        logic=Logic(
            predicate=func_hiv_neg_linkage_to_care,
            consequence='not_required',
            alternative='new'),
        target_model=['hivlinkagetocare'])

    require_microtube = RequisitionRule(
        logic=Logic(
            predicate=func_show_microtube,
            consequence='new',
            alternative='not_required'),
        target_model=[('bcpp_lab', 'subjectrequisition')],
        target_requisition_panels=['Microtube'])

    vl_for_pos = RequisitionRule(
        logic=Logic(
            predicate=func_vl,
            consequence='new',
            alternative='not_required'),
        target_model=[('bcpp_lab', 'subjectrequisition')],
        target_requisition_panels=['Viral Load'], )

    rbd_for_pos = RequisitionRule(
        logic=Logic(
            predicate=func_rbd,
            consequence='new',
            alternative='not_required'),
        target_model=[('bcpp_lab', 'subjectrequisition')],
        target_requisition_panels=['Research Blood Draw'], )

    class Meta:
        app_label = 'bcpp_subject'
        source_fk = None
        source_model = RegisteredSubject