(self)
return mkeventslist(self.data)
Transform Subject.data into the structure that CdiscOdmExportWriter expects
Transform Subject.data into the structure that CdiscOdmExportWriter expects
Transform Subject . data into the structure that CdiscOdmExportWriter expects
def get_export_data(self):
        """
        Transform Subject.data into the structure that CdiscOdmExportWriter expects
        """
        mkitemlist = lambda d: [dict(v, item_oid=k) for k, v in d.items()]  # `dict()` updates v with item_oid

        def mkitemgrouplist(itemgroupdict):
            itemgrouplist = []
            for oid, item_groups in itemgroupdict.items():
                for i, item_group in enumerate(item_groups):
                    itemgrouplist.append({
                        'item_group_oid': oid,
                        'repeat_key': i + 1,
                        'items': mkitemlist(item_group.items)
                    })
            return itemgrouplist

        mkformslist = lambda d: [{'form_oid': k, 'item_groups': mkitemgrouplist(v)} for k, v in d.items()]

        def mkeventslist(eventsdict):
            eventslist = []
            for oid, study_events in eventsdict.items():
                for i, study_event in enumerate(study_events):
                    eventslist.append({
                        'study_event_oid': oid,
                        'repeat_key': i + 1,
                        'start_short': study_event.start_short,
                        'start_long': study_event.start_long,
                        'end_short': study_event.end_short,
                        'end_long': study_event.end_long,
                        'forms': mkformslist(study_event.forms)
                    })
            return eventslist

        return mkeventslist(self.data)
def get_export_data ( self ) : mkitemlist = lambda d : [ dict ( v , item_oid = k ) for k , v in d . items ( ) ] # `dict()` updates v with item_oid def mkitemgrouplist ( itemgroupdict ) : itemgrouplist = [ ] for oid , item_groups in itemgroupdict . items ( ) : for i , item_group in enumerate ( item_groups ) : itemgrouplist . append ( { 'item_group_oid' : oid , 'repeat_key' : i + 1 , 'items' : mkitemlist ( item_group . items ) } ) return itemgrouplist mkformslist = lambda d : [ { 'form_oid' : k , 'item_groups' : mkitemgrouplist ( v ) } for k , v in d . items ( ) ] def mkeventslist ( eventsdict ) : eventslist = [ ] for oid , study_events in eventsdict . items ( ) : for i , study_event in enumerate ( study_events ) : eventslist . append ( { 'study_event_oid' : oid , 'repeat_key' : i + 1 , 'start_short' : study_event . start_short , 'start_long' : study_event . start_long , 'end_short' : study_event . end_short , 'end_long' : study_event . end_long , 'forms' : mkformslist ( study_event . forms ) } ) return eventslist return mkeventslist ( self . data )