def get_source(config: SVCMConfig, inventory: Inventory) -> Callable[([Any], Any)]:
    host = resolve_one(config.source.id, inventory)
    if ('dhis2' not in host.type):
        log.error("Only 'dhis2' source type is currently supported")
        sys.exit((- 1))
    log.info(f"Creating source from '{host.key}' with base url '{host.baseUrl}'")

    def fn():
        filters = []
        if config.source.lastUpdated:
            filters.append(f'lastUpdated:ge:{config.source.lastUpdated}')
        option_sets_filter = list(map((lambda x: f'id:eq:{x}'), config.source.filters.optionSets))
        option_sets_filter.extend(filters)
        option_sets = BaseHttpRequest(host).get('api/optionSets', params={'fields': 'id,code,name,version,translations,options[id,code,name,translations]', 'rootJunction': 'OR', 'filter': option_sets_filter, 'paging': False})
        categories_filter = list(map((lambda x: f'id:eq:{x}'), config.source.filters.categories))
        categories_filter.extend(filters)
        categories = BaseHttpRequest(host).get('api/categories', params={'fields': 'id,code,name,translations,categoryOptions::rename(options)[id,code,name,translations]', 'rootJunction': 'OR', 'filter': categories_filter, 'paging': False})
        data = {'optionSets': option_sets.get('optionSets', []), 'categories': categories.get('categories', [])}
        return (host, data)
    return fn
def get_source(config: SVCMConfig, inventory: Inventory) -> Callable[([Any], Any)]:
    host = resolve_one(config.source.id, inventory)
    if ('dhis2' not in host.type):
        log.error("Only 'dhis2' source type is currently supported")
        sys.exit((- 1))
    log.info(f"Creating source from '{host.key}' with base url '{host.baseUrl}'")

    def fn():
        filters = []
        if config.source.lastUpdated:
            filters.append(f'lastUpdated:ge:{config.source.lastUpdated}')
        option_sets_filter = list(map((lambda x: f'id:eq:{x}'), config.source.filters.optionSets))
        option_sets_filter.extend(filters)
        option_sets = BaseHttpRequest(host).get('api/optionSets', params={'fields': 'id,code,name,version,translations,options[id,code,name,translations]', 'rootJunction': 'OR', 'filter': option_sets_filter, 'paging': False})
        categories_filter = list(map((lambda x: f'id:eq:{x}'), config.source.filters.categories))
        categories_filter.extend(filters)
        categories = BaseHttpRequest(host).get('api/categories', params={'fields': 'id,code,name,translations,categoryOptions::rename(options)[id,code,name,translations]', 'rootJunction': 'OR', 'filter': categories_filter, 'paging': False})
        data = {'optionSets': option_sets.get('optionSets', []), 'categories': categories.get('categories', [])}
        return (host, data)
    return fn