code: def active_services(doc):
      
      if doc.get('state') != 'deactivated':
          for service_id, service in doc.get('services', {}).items():
              if service.get('state') != 'deactivated':
                  service_type = service.get('service_type')
                  org = doc['_id']
                  service['id'] = service_id
                  service['organisation_id'] = org
  
                  yield service_id, service
                  yield [service_type, org], service
                  yield [service_type, None], service
                  yield [None, org], service
                  yield [None, None], service
docs: View for getting active services