(self, form, case)
Adds the necessary hidden properties, fixture references, and calculations to
        get the global next visit date for schedule modules
Adds the necessary hidden properties, fixture references, and calculations to
        get the global next visit date for schedule modules
Adds the necessary hidden properties fixture references and calculations to get the global next visit date for schedule modules
def _schedule_global_next_visit_date(self, form, case):
        """
        Adds the necessary hidden properties, fixture references, and calculations to
        get the global next visit date for schedule modules
        """
        forms = [f for f in form.get_phase().get_forms()
                 if getattr(f, 'schedule') and f.schedule.enabled]
        forms_due = []
        for form in forms:
            form_xpath = QualifiedScheduleFormXPath(form, form.get_phase(), form.get_module(), case)
            name = "next_{}".format(form.schedule_form_id)
            forms_due.append("/data/{}".format(name))

            self.add_instance(
                form_xpath.fixture_id,
                'jr://fixture/{}'.format(form_xpath.fixture_id)
            )

            if form.get_phase().id == 1:
                self.add_bind(
                    nodeset='/data/{}'.format(name),
                    calculate=form_xpath.first_visit_phase_set
                )
            else:
                self.add_bind(
                    nodeset='/data/{}'.format(name),
                    calculate=form_xpath.xpath_phase_set
                )

            self.data_node.append(_make_elem(name))

        self.add_bind(
            nodeset='/data/{}'.format(SCHEDULE_GLOBAL_NEXT_VISIT_DATE),
            calculate='date(min({}))'.format(','.join(forms_due))
        )
        self.data_node.append(_make_elem(SCHEDULE_GLOBAL_NEXT_VISIT_DATE))

        self.add_bind(
            nodeset='/data/{}'.format(SCHEDULE_NEXT_DUE),
            calculate=QualifiedScheduleFormXPath.next_visit_date(forms, case)
        )
        self.data_node.append(_make_elem(SCHEDULE_NEXT_DUE))
def _schedule_global_next_visit_date ( self , form , case ) : forms = [ f for f in form . get_phase ( ) . get_forms ( ) if getattr ( f , 'schedule' ) and f . schedule . enabled ] forms_due = [ ] for form in forms : form_xpath = QualifiedScheduleFormXPath ( form , form . get_phase ( ) , form . get_module ( ) , case ) name = "next_{}" . format ( form . schedule_form_id ) forms_due . append ( "/data/{}" . format ( name ) ) self . add_instance ( form_xpath . fixture_id , 'jr://fixture/{}' . format ( form_xpath . fixture_id ) ) if form . get_phase ( ) . id == 1 : self . add_bind ( nodeset = '/data/{}' . format ( name ) , calculate = form_xpath . first_visit_phase_set ) else : self . add_bind ( nodeset = '/data/{}' . format ( name ) , calculate = form_xpath . xpath_phase_set ) self . data_node . append ( _make_elem ( name ) ) self . add_bind ( nodeset = '/data/{}' . format ( SCHEDULE_GLOBAL_NEXT_VISIT_DATE ) , calculate = 'date(min({}))' . format ( ',' . join ( forms_due ) ) ) self . data_node . append ( _make_elem ( SCHEDULE_GLOBAL_NEXT_VISIT_DATE ) ) self . add_bind ( nodeset = '/data/{}' . format ( SCHEDULE_NEXT_DUE ) , calculate = QualifiedScheduleFormXPath . next_visit_date ( forms , case ) ) self . data_node . append ( _make_elem ( SCHEDULE_NEXT_DUE ) )