<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def active_service_location(doc):
 """View for getting active service by location"""

    if doc.get('state') != 'deactivated':
        for service_id, service in doc.get('services', {}).items():
            if service.get('state') != 'deactivated':
                service['id'] = service_id
                service['organisation_id'] = doc['_id']

                location = service.get('location', None)
                if location:
                    yield location, service