Exemplo n.º 1
0
    def func_show_infant_nvp_dispensing(self,
                                        visit=None,
                                        maternal_status_helper=None,
                                        **kwargs):
        maternal_rando = Reference.objects.filter(
            model='td_maternal.maternalrando',
            report_datetime__lt=visit.report_datetime,
            identifier=visit.appointment.subject_identifier[:-3]).order_by(
                '-report_datetime').last()

        if maternal_rando:
            nvp_refsets = LongitudinalRefset(
                name='td_maternal.maternalrando',
                visit_model='td_maternal.maternalvisit',
                reference_model_cls=django_apps.get_model(
                    site_reference_configs.get_reference_model(
                        'td_maternal.maternalvisit')),
                subject_identifier=visit.appointment.subject_identifier[:-3],
                report_datetime=maternal_rando.report_datetime,
            )

            value = nvp_refsets.fieldset(field_name='rx').all().values

            return (self.get_latest_maternal_hiv_status(
                visit, maternal_status_helper)
                    and value[0].strip('\n') == 'NVP')
        return False
Exemplo n.º 2
0
    def is_keyed(self, crf=None):
        """Returns True if CRF is keyed determined by
        querying the reference model.

        See also edc_reference.
        """
        reference_model = site_reference_configs.get_reference_model(
            name=crf.model)
        self.reference_model_cls = django_apps.get_model(reference_model)
        return self.reference_model_cls.objects.filter_crf_for_visit(
            name=crf.model,
            visit=self.visit).exists()
Exemplo n.º 3
0
    def is_keyed(self, requisition=None):
        """Returns True if requisition is keyed determined by
        getting the reference model instance for this
        requisition+panel_name .

        See also edc_reference.
        """
        name = f'{requisition.model}.{requisition.panel.name}'
        reference_model = site_reference_configs.get_reference_model(
            name=name)
        self.reference_model_cls = django_apps.get_model(reference_model)
        return self.reference_model_cls.objects.get_requisition_for_visit(
            name=name, visit=self.visit)
Exemplo n.º 4
0
 def __init__(self, subject_identifier=None, report_datetime=None,
              baseline=None, visit_model=None):
     if visit_model:
         self.visit_model = visit_model
     self.values = {}
     self.baseline = baseline
     self.subject_identifier = subject_identifier
     self.report_datetime = report_datetime
     self.reference_model_cls = django_apps.get_model(
         site_reference_configs.get_reference_model(name=self.visit_model))
     self.longitudinal_refset = LongitudinalRefset(
         name=self.model,
         subject_identifier=self.subject_identifier,
         visit_model=self.visit_model,
         reference_model_cls=self.reference_model_cls,
         **self.options).order_by('report_datetime')
Exemplo n.º 5
0
    def __init__(self,
                 subject_identifier=None,
                 report_datetime=None,
                 baseline=None,
                 visit_model=None):
        if visit_model:
            self.visit_model = visit_model
        self.baseline = baseline
        self.reference_model_cls = django_apps.get_model(
            site_reference_configs.get_reference_model(name=self.visit_model))
        self.report_datetime = report_datetime
        self.subject_identifier = subject_identifier
        self.values = {}
        opts = dict(subject_identifier=subject_identifier,
                    report_datetime=report_datetime,
                    baseline=baseline,
                    visit_model=self.visit_model)

        values_classes = [
            self.elisa_result_cls, self.hiv_care_adherence_cls,
            self.hiv_result_cls, self.hiv_test_review_cls,
            self.hiv_testing_history_cls, self.hiv_result_documentation_cls
        ]

        for values_cls in values_classes:
            values_obj = values_cls(**opts)
            for field, value in values_obj:
                if field in values_obj.attrs:
                    self.values.update({field: value})

        for attr in [
                'arv_evidence', 'elisa_hiv_result', 'elisa_hiv_result_date',
                'ever_taken_arv', 'has_tested', 'on_arv', 'other_record',
                'recorded_hiv_result', 'recorded_hiv_result_date',
                'result_recorded', 'result_recorded_document',
                'self_reported_result', 'today_hiv_result',
                'today_hiv_result_date'
        ]:
            if attr not in self.values:
                raise ModelDataError(
                    f'Attribute missing from values. Got {attr}')
Exemplo n.º 6
0
 def reference_model_cls(self):
     reference_model = site_reference_configs.get_reference_model(
         name=self.model)
     return django_apps.get_model(reference_model)
Exemplo n.º 7
0
 def reference_model_cls(self):
     name = f"{self.model}.{self.target_panel.name}"
     reference_model = site_reference_configs.get_reference_model(name=name)
     return django_apps.get_model(reference_model)
 def reference_model_cls(self):
     name = f'{self.model}.{self.target_panel.name}'
     reference_model = site_reference_configs.get_reference_model(
         name=name)
     return django_apps.get_model(reference_model)
 def reference_model_cls(self):
     reference_model = site_reference_configs.get_reference_model(
         name=self.model)
     return django_apps.get_model(reference_model)
 def __init__(self):
     if not site_reference_configs.loaded:
         site_reference_configs.autodiscover()
     self.reference_model_cls = django_apps.get_model(
         site_reference_configs.get_reference_model(self.visit_model))
Exemplo n.º 11
0
 def reference_model_cls(self) -> Type[Model]:
     """Returns an the model cls edc_reference.reference by default"""
     reference_model = site_reference_configs.get_reference_model(
         name=self.crf.model)
     return django_apps.get_model(reference_model)
Exemplo n.º 12
0
 def reference_model_cls(self) -> Type[Model]:
     reference_model = site_reference_configs.get_reference_model(
         name=self.panel_name)
     return django_apps.get_model(reference_model)