def form_workflow_frames(self, if_prefix, module, form):
        """
        post_form_workflow = 'module':
          * Add stack frame and a command with value = "module command"

        post_form_workflow = 'previous_screen':
          * Add stack frame and a command with value = "module command"
          * Find longest list of common datums between form entries for the module and add datums
            to the stack frame for each.
          * Add a command to the frame with value = "form command"
          * Add datums to the frame for any remaining datums for that form.
          * Remove any autoselect items from the end of the stack frame.
          * Finally remove the last item from the stack frame.
        """
        from corehq.apps.app_manager.models import (
            WORKFLOW_PREVIOUS, WORKFLOW_MODULE, WORKFLOW_ROOT, WORKFLOW_FORM, WORKFLOW_PARENT_MODULE
        )

        def frame_children_for_module(module_, include_user_selections=True):
            frame_children = []
            if module_.root_module:
                frame_children.extend(frame_children_for_module(module_.root_module))

            if include_user_selections:
                this_module_children = self.helper.get_frame_children(module_.get_form(0), module_only=True)
                for child in this_module_children:
                    if child not in frame_children:
                        frame_children.append(child)
            else:
                module_command = id_strings.menu_id(module_)
                if module_command != id_strings.ROOT:
                    frame_children.append(CommandId(module_command))

            return frame_children

        stack_frames = []
        if form.post_form_workflow == WORKFLOW_ROOT:
            stack_frames.append(StackFrameMeta(if_prefix, None, [], allow_empty_frame=True))
        elif form.post_form_workflow == WORKFLOW_MODULE:
            frame_children = frame_children_for_module(module, include_user_selections=False)
            stack_frames.append(StackFrameMeta(if_prefix, None, frame_children))
        elif form.post_form_workflow == WORKFLOW_PARENT_MODULE:
            root_module = module.root_module
            frame_children = frame_children_for_module(root_module)
            stack_frames.append(StackFrameMeta(if_prefix, None, frame_children))
        elif form.post_form_workflow == WORKFLOW_PREVIOUS:
            frame_children = self.helper.get_frame_children(form)

            # since we want to go the 'previous' screen we need to drop the last
            # datum
            last = frame_children.pop()
            while isinstance(last, WorkflowDatumMeta) and not last.requires_selection:
                # keep removing last element until we hit a command
                # or a non-autoselect datum
                last = frame_children.pop()

            stack_frames.append(StackFrameMeta(if_prefix, None, frame_children))
        elif form.post_form_workflow == WORKFLOW_FORM:
            source_form_datums = self.helper.get_form_datums(form)
            for link in form.form_links:
                target_form = self.helper.app.get_form(link.form_id)
                target_module = target_form.get_module()

                target_frame_children = self.helper.get_frame_children(target_form)
                if link.datums:
                    frame_children = EndOfFormNavigationWorkflow.get_datums_matched_to_manual_values(
                        target_frame_children, link.datums
                    )
                else:
                    frame_children = EndOfFormNavigationWorkflow.get_datums_matched_to_source(
                        target_frame_children, source_form_datums
                    )

                if target_module in module.get_child_modules():
                    parent_frame_children = self.helper.get_frame_children(module.get_form(0), module_only=True)

                    # exclude frame children from the child module if they are already
                    # supplied by the parent module
                    parent_ids = {parent.id for parent in parent_frame_children}
                    frame_children = parent_frame_children + [
                        child for child in frame_children
                        if child.id not in parent_ids
                    ]

                stack_frames.append(StackFrameMeta(if_prefix, link.xpath, frame_children))

        return stack_frames
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/app_manager/suite_xml/post_process/workflow.py/EndOfFormNavigationWorkflow.form_workflow_frames/original