Get all appointments for an episode

@param int|Episode $episode Episode Id or object
@return array appointmentId => appointment object
12687
public function getAppointmentsForEpisode($episode)
    {
        $select = $this->_getAppointmentSelect();

        if ($episode instanceof EpisodeOfCare) {
            $episodeId = $episode->getId();
        } else {
            $episodeId = $episode;
        }
        $select->where('gap_id_episode = ?', $episodeId);

        // \MUtil_Echo::track($select->__toString());
        $rows = $this->db->fetchAll($select);

        if (! $rows) {
            return array();
        }

        $results = array();
        foreach ($rows as $row) {
            $results[$row['gap_id_appointment']] = $this->getAppointment($row);
        }
        return $results;
    }
1006702
public function getAppointment($appointmentData)
    {
        if (! $appointmentData) {
            throw new \Gems_Exception_Coding('Provide at least the apppointment id when requesting an appointment.');
        }

        if (is_array($appointmentData)) {
             if (!isset($appointmentData['gap_id_appointment'])) {
                 throw new \Gems_Exception_Coding(
                         '$appointmentData array should atleast have a key "gap_id_appointment" containing the requested appointment id'
                         );
             }
            $appointmentId = $appointmentData['gap_id_appointment'];
        } else {
            $appointmentId = $appointmentData;
        }
        // \MUtil_Echo::track($appointmentId, $appointmentData);

        if (! isset($this->_appointments[$appointmentId])) {
            $this->_appointments[$appointmentId] = $this->_loadClass('appointment', true, array($appointmentData));
        } elseif (is_array($appointmentData)) {
            // Make sure the new values are set in the object
            $this->_appointments[$appointmentId]->refresh($appointmentData);
        }

        return $this->_appointments[$appointmentId];
    }
245862
private function getReviewEpisode($top_area)
    {
        $episode = $top_area->find('div div', 1)->plaintext;
        $episode = str_replace(['episodes seen', 'chapters read'], '', $episode);

        return trim($episode);
    }
814160
public function getShedule(string $day = 'all'): array
    {
        $parts = ['/'];
        if ($day !== 'all') {
            $parts[] = sprintf('div[contains(@class, "js-seasonal-anime-list-key-%s")]', $day);
        }
        $parts[] = 'div[contains(@class, "seasonal-anime")]';
        $query = implode('/', $parts);

        return $this->crawler->filterXPath($query)->each(
            function (Crawler $c) {
                return (new AnimeCardParser($c))->getModel();
            }
        );
    }
673479
public function get(int $row, int $column)
    {
        $this->assertIndexesAreValid($row, $column);
        return $this->cells[$row][$column];
    }
893876
def delete_episode(db, aid, episode):
    """"""
    db.cursor().execute(
        'DELETE FROM episode WHERE aid=:aid AND type=:type AND number=:number',
        {
            'aid': aid,
            'type': episode.type,
            'number': episode.number,
        })
619098
public function getShowInfo($id)
    {
        $showInfo = array();

        $crawler = $this->request('GET', $this->baseUrl . '/title/' . $id . '/');
        $showInfo['title'] = $crawler->filterXPath('//h1/span[@itemprop="name"]')->text();

        $nextEpisode = $crawler->filterXPath('//div[@class="next-episode"]/div');
        if (count($nextEpisode) && preg_match('/S(?P<season>[0-9]+), Ep(?P<episode>[0-9]+)/', $nextEpisode->text(), $match)) {
            $showInfo['latestSeason'] = $match['season'];
            $showInfo['latestEpisode'] = $match['episode'];
        } else {
            $showInfo['latestSeason'] = $crawler->filterXPath('//div[@id="titleTVSeries"]//h4[text()="Season:"]/../span[1]/a[1]')->text();
            $today = time(0, 0, 0);
            do {
                $seasonEpisodes = $this->getSeasonEpisodes($id, $showInfo['latestSeason']);
                $currentEpisodes = array_filter($seasonEpisodes, function($episode) use ($today) {
                    return strtotime($episode['airdate']) < $today;
                });
                if ($currentEpisodes) {
                    $showInfo['latestEpisode'] = max(array_keys($currentEpisodes));
                    break;
                } elseif ($showInfo['latestSeason'] > 1) {
                    $showInfo['latestSeason']--;
                } else {
                    $showInfo['latestEpisode'] = 1;
                }
            } while ($showInfo['latestSeason'] >= 1);
        }

        return $showInfo;
    }
62957
private function calculateInterval($episode)
    {
        $max_image = floor(65500/$this->sprite_height);
        $calculated_interval = ceil($episode->getDuration()/$max_image);
        if ($calculated_interval > $this->sprite_interval) {
            $this->sprite_interval = $calculated_interval;
        }
    }
589982
protected function getAddressesForPrincipal($principal)
    {
        $CUAS = '{'.self::NS_CALDAV.'}calendar-user-address-set';

        $properties = $this->server->getProperties(
            $principal,
            [$CUAS]
        );

        // If we can't find this information, we'll stop processing
        if (!isset($properties[$CUAS])) {
            return [];
        }

        $addresses = $properties[$CUAS]->getHrefs();

        return $addresses;
    }
329441
public function getAppointmentFieldValue(\Gems_Agenda_Appointment $appointment, $field)
    {
        switch ($field) {
            case 'gap_id_organization':
                return $appointment->getOrganizationId();

            case 'gap_source':
                return $appointment->getSource();

            case 'gap_id_attended_by':
                return $appointment->getAttendedById();

            case 'gap_id_referred_by':
                return $appointment->getReferredById();

            case 'gap_id_activity':
                return $appointment->getActivityId();

            case 'gap_id_procedure':
                return $appointment->getProcedureId();

            case 'gap_id_location':
                return $appointment->getLocationId();

            case 'gap_subject':
                return $appointment->getSubject();
        }
    }
251760
public function paginationEpisodesAction(Request $request, $series)
    {
        $em = $this->getDoctrine()->getManager();
        $dql = "SELECT e FROM ".$this->container->getParameter('oktolab_media.episode_class')." e WHERE e.series = :series ORDER By e.firstranAt DESC";
        $query = $em->createQuery($dql);
        $query->setParameter('series', $series->getId());

        $page = $request->query->get('page', 1);
        $results = $request->query->get('results', 20);

        $paginator  = $this->get('knp_paginator');
        $pagination = $paginator->paginate(
            $query,
            $page/*page number*/,
            $results
        );
        $pagination->setUsedRoute('media_episode_paginator', ['series' => $series]);
        $pagination->setParam('series', $series->getId());

        return ['pagination' => $pagination];
    }
918137
public function matchAppointment(\Gems_Agenda_Appointment $appointment)
    {
        if (! $this->_data['gaf_filter_text1']) {
            return ! $appointment->getSubject();
        }

        $regex = '/' . str_replace(array('%', '_'), array('.*', '.{1,1}'),$this->_data['gaf_filter_text1']) . '/i';

        return (boolean) preg_match($regex, $appointment->getSubject());
    }
264245
public function addEpisode(\Oktolab\MediaBundle\Entity\Episode $episodes)
    {
        $this->episodes[] = $episodes;
        return $this;
    }
755185
public function editAction(Request $request, $episode)
    {
        $entity = $episode;

        $editForm = $this->createEditForm($entity);
        $deleteForm = $this->createDeleteForm($id);

        return [
            'entity' => $entity,
            'form' => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        ];
    }
477710
public function matchEpisode(EpisodeOfCare $episode)
    {
        foreach ($this->_subFilters as $filterObject) {
            if ($filterObject instanceof AppointmentFilterInterface) {
                if ($filterObject->matchEpisode($episode)) {
                    return true;
                }
            }
        }
        return false;
    }
1078540
public function get($episodeId): Episode
    {
        $json = $this->client->performApiCallWithJsonResponse('get', '/episodes/' . (int) $episodeId);
        return ResponseHandler::create($json, ResponseHandler::METHOD_EPISODE)->handle();
    }
776156
public function getEpisodesByShowID($ID){

		$url = self::APIURL.'/shows/'.$ID.'/episodes';

		$episodes = $this->getFile($url);

		$allEpisodes = [];
		foreach($episodes as $episode){
			$ep = new Episode($episode);
			$allEpisodes[] = $ep;
		}

		return $allEpisodes;
	}