def get_latest_maternal_hiv_status(self, visit=None):
        maternal_subject_id = visit.subject_identifier[:-3]
        maternal_visit = self.maternal_visit_model_cls.objects.filter(
            subject_identifier=maternal_subject_id)

        if maternal_visit:
            latest_visit = maternal_visit.latest('report_datetime')
            maternal_status_helper = MaternalStatusHelper(
                maternal_visit=latest_visit)
        else:
            maternal_status_helper = MaternalStatusHelper(
                subject_identifier=maternal_subject_id)
        return maternal_status_helper
示例#2
0
 def func_hiv_positive(self, visit=None, **kwargs):
     """
     Get HIV Status from the rapid test results
     """
     maternal_status_helper = MaternalStatusHelper(
         maternal_visit=visit, subject_identifier=visit.subject_identifier)
     return maternal_status_helper.hiv_status == POS
示例#3
0
    def maternal_hiv_status(self):
        """Returns mother's current hiv status.
        """
        maternal_visit_cls = django_apps.get_model(
            'flourish_caregiver.maternalvisit')
        subject_identifier = self.kwargs.get('subject_identifier')
        latest_visit = maternal_visit_cls.objects.filter(
            subject_identifier=subject_identifier[:-3], ).order_by(
                '-report_datetime').first()

        if latest_visit:
            maternal_status_helper = MaternalStatusHelper(
                maternal_visit=latest_visit)
        else:
            maternal_status_helper = MaternalStatusHelper(
                subject_identifier=self.kwargs.get('subject_identifier')[:-3])
        return maternal_status_helper.hiv_status
    def hiv_status(self):
        """Returns mother's current hiv status.
        """
        maternal_visit_cls = django_apps.get_model(
            MaternalVisitModelWrapper.model)
        subject_identifier = self.kwargs.get('subject_identifier')
        latest_visit = maternal_visit_cls.objects.filter(
            subject_identifier=subject_identifier, ).order_by(
            '-report_datetime').first()

        if latest_visit:
            maternal_status_helper = MaternalStatusHelper(
                maternal_visit=latest_visit)
        else:
            maternal_status_helper = MaternalStatusHelper(
                subject_identifier=self.kwargs.get('subject_identifier'))
        return maternal_status_helper.hiv_status
 def func_hiv_exposed(self, visit=None, **kwargs):
     """
     Get the pregnancy status of the mother, is positive it means
     the child was exposed to HIV
     """
     child_subject_identifier = visit.subject_identifier
     caregiver_subject_identifier = child_subject_identifier[0:16]
     maternal_status_helper = MaternalStatusHelper(
         subject_identifier=caregiver_subject_identifier)
     return maternal_status_helper.hiv_status == POS
 def maternal_status_helper(self):
     cleaned_data = self.cleaned_data
     latest_visit = self.maternal_visit_cls.objects.filter(
         subject_identifier=cleaned_data.get(
             'subject_identifier')).order_by('-created').first()
     if latest_visit:
         return MaternalStatusHelper(latest_visit)
     else:
         raise ValidationError(
             'Please complete previous visits before filling in '
             'Maternal Labour Delivery Form.')
示例#7
0
    def func_pregnant_hiv(self,
                          visit=None,
                          maternal_status_helper=None,
                          **kwargs):
        """Returns true if a newly enrolled participant is pregnant and living with HIV.
        """
        maternal_status_helper = maternal_status_helper or MaternalStatusHelper(
            maternal_visit=visit)

        return (self.enrolled_pregnant(visit=visit)
                and maternal_status_helper.hiv_status == POS)
示例#8
0
    def child_gt10_eligible(self, visit, maternal_status_helper, id_post_fix):

        maternal_status_helper = maternal_status_helper or MaternalStatusHelper(
            maternal_visit=visit)

        gt_10, child_subject_identifier = self.child_gt10(visit)

        if child_subject_identifier:
            child_exists = child_subject_identifier[-3:] in id_post_fix

            return maternal_status_helper.hiv_status == POS and gt_10 and child_exists
        return False
示例#9
0
    def func_bio_mother_hiv(self,
                            visit=None,
                            maternal_status_helper=None,
                            **kwargs):
        """Returns true if participant is non-pregnant biological mother living with HIV.
        """
        maternal_status_helper = maternal_status_helper or MaternalStatusHelper(
            maternal_visit=visit)

        return (self.func_bio_mother(visit=visit)
                and not self.currently_pregnant(visit=visit)
                and maternal_status_helper.hiv_status == POS)
示例#10
0
    def func_bio_mothers_hiv_cohort_a(self,
                                      visit=None,
                                      maternal_status_helper=None,
                                      **kwargs):
        """Returns true if participant is biological mother living with HIV.
        """

        maternal_status_helper = maternal_status_helper or MaternalStatusHelper(
            maternal_visit=visit)

        cohort_a = visit.schedule_name[:2] == 'a_'

        return cohort_a and self.func_bio_mother_hiv(visit=visit)
示例#11
0
    def func_show_hiv_test_form(self,
                                visit=None,
                                maternal_status_helper=None,
                                **kwargs):
        subject_identifier = visit.subject_identifier
        result_date = None

        maternal_status_helper = maternal_status_helper or MaternalStatusHelper(
            visit)

        if maternal_status_helper.hiv_status != POS:
            if self.currently_pregnant(
                    visit=visit) and visit.visit_code == '1000M':
                return True
            elif (maternal_status_helper.hiv_status == NEG
                  and not self.currently_pregnant(visit=visit)
                  and visit.visit_code == '2000M'):
                return True
            else:
                prev_rapid_test = Reference.objects.filter(
                    model=f'{self.app_label}.hivrapidtestcounseling',
                    report_datetime__lt=visit.report_datetime,
                    identifier=subject_identifier).order_by(
                        '-report_datetime').last()

                if prev_rapid_test:
                    result_date = self.exists(
                        reference_name=
                        f'{self.app_label}.hivrapidtestcounseling',
                        subject_identifier=visit.subject_identifier,
                        report_datetime=prev_rapid_test.report_datetime,
                        field_name='result_date')

                    if result_date and isinstance(result_date[0], date):
                        return (visit.report_datetime.date() -
                                result_date[0]).days > 90
        return False
示例#12
0
 def maternal_status_helper(self):
     cleaned_data = self.cleaned_data
     visit_obj = cleaned_data.get('maternal_visit')
     if visit_obj:
         return MaternalStatusHelper(visit_obj)
示例#13
0
 def maternal_status_helper(self):
     cleaned_data = self.cleaned_data
     status_helper = MaternalStatusHelper(
         cleaned_data.get('maternal_visit'))
     return status_helper