<?php
namespace App\Controller;
use App\Entity\Agencies;
use App\Entity\AgencyDoctors;
use App\Entity\Categories;
use App\Entity\CenterZipcode;
use App\Entity\Centers;
use App\Entity\Cities;
use App\Entity\Degrees;
use App\Entity\DoctorDegrees;
use App\Entity\DoctorPractices;
use App\Entity\Doctors;
use App\Entity\Geocode;
use App\Entity\Hospitals;
use App\Entity\Image;
use App\Entity\Lookup;
use App\Entity\Maps;
use App\Entity\NewsDoctors;
use App\Entity\Practices;
use App\Entity\ServiceDoctors;
use App\Entity\Services;
use App\Entity\Zipcode;
use App\Repository\DoctorPracticesRepository;
use App\Repository\DoctorsRepository;
use App\Repository\ServiceDoctorsRepository;
use Knp\Component\Pager\PaginatorInterface;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Routing\Annotation\Route;
use PhpOffice\PhpSpreadsheet\IOFactory;
use Cocur\Slugify\Slugify;
use Doctrine\ORM\EntityManagerInterface;
use Dom\Entity;
class MedecinController extends AbstractController
{
/**
* @Route("/medecin-ORL-phoniatre/{id}", name="redirect_id_medecin", requirements={"id"="\d+"})
*/
public function redirectIdOnly($id)
{
$doctor = $this->getDoctrine()->getRepository(Doctors::class)->findOneBy(['id' => $id, 'visible' => 1]);
if ($doctor) {
$slug = $this->slugify->slugify($doctor->getFirstName() . '-' . $doctor->getName());
$url = $this->router->generate(
'page_single_medecin_alone',
array('nomMedecin' => $slug, 'idMedecin' => $id)
);
} else {
$url = $this->router->generate(
'liste_medecin'
);
}
return $this->redirect($url, 301);
}
/**
* @Route("/medecin-ORL-phoniatre/page/{page}", name="redirect_page_medecins")
*/
public function redirectPage($page = null)
{
if ($page) {
$url = $this->router->generate(
'liste_medecin'
);
}
return $this->redirect($url, 301);
}
/**
* @Route("/medecin-ORL-phoniatre", name="liste_medecin")
*/
public function renderDefault(): Response
{
$this->setJsonIntoTemplate('list');
$this->setTemplateParameters(array('title_seo' => "Médecins ORL et Phoniatres : Trouvez un médecin ORL près de chez vous"));
$data = $this->JsonProvider->getJson('seo_text_medecins_orl');
$this->setTemplateParameters(array('seo_text' => json_decode($data)));
$this->setInternalLinkage('medecinListe');
return $this->renderTemplate('pages/annuaire_search_ORL.twig');
}
/**
* @Route("/medecin-ORL-phoniatre-{zipcode}-{ville}.html", name="results_medecin_audio_by_city", requirements={"zipcode"="\d{5}"}, defaults={"page" = 1})
* @Route("/medecin-ORL-phoniatre-{zipcode}-{ville}/filtre-resultats/phoniatres-{isPhoniatre}.html", name="results_medecin_audio_by_city_filter_phoniatre", requirements={"zipcode"="\d{5}"}, defaults={"page" = 1})
* @Route("/medecin-ORL-phoniatre-{zipcode}-{ville}/filtre-resultats/exercice-{exercice}.html", name="results_medecin_audio_by_city_filter_exercice", requirements={"zipcode"="\d{5}"}, defaults={"page" = 1})
* @Route("/medecin-ORL-phoniatre-{zipcode}-{ville}/filtre-resultats/{idspecialite}-{specialite}.html", name="results_medecin_audio_by_city_filter_specialite", requirements={"zipcode"="\d{5}"}, defaults={"page" = 1})
* @Route("/medecin-ORL-phoniatre-{departementCode}-{departementTexte}.html", name="results_medecin_by_departement", requirements={"departementCode"="[0-9]{1,2}[0-9A-B]{1}"}, defaults={"page" = 1})
* @Route("/medecin-ORL-phoniatre-{departementCode}-{departementTexte}/filtre-resultats/phoniatres-{isPhoniatre}.html", name="results_medecin_by_departement_filter_phoniatre", requirements={"departementCode"="[0-9]{1,2}[0-9A-B]{1}"}, defaults={"page" = 1})
* @Route("/medecin-ORL-phoniatre-{departementCode}-{departementTexte}/filtre-resultats/exercice-{exercice}.html", name="results_medecin_by_departement_filter_exercice", requirements={"departementCode"="[0-9]{1,2}[0-9A-B]{1}"}, defaults={"page" = 1})
* @Route("/medecin-ORL-phoniatre-{departementCode}-{departementTexte}/filtre-resultats/{idspecialite}-{specialite}.html", name="results_medecin_by_departement_filter_specialite", requirements={"departementCode"="[0-9]{1,2}[0-9A-B]{1}"}, defaults={"page" = 1})
*
*/
public function renderList($zipcode = null, $ville = null, $departementCode = null, $departementTexte = null, $isPhoniatre = null, $exercice = null, $idspecialite = null, $specialite = null, Request $request, PaginatorInterface $paginator): Response
{
$title_seo = "Médecins ORL - Phoniatres";
$doctors_title_seo = $doctors_description_seo = null;
if ($idspecialite) {
$diplomeCheck = $this->getDoctrine()->getRepository(Degrees::class)->findOneBy(array('id' => $idspecialite));
if (!$diplomeCheck) {
if ($zipcode) {
return $this->redirectProvider->redirect301('results_medecin_audio_by_city', array('zipcode' => $zipcode, 'ville' => $ville));
} else if ($departementCode) {
return $this->redirectProvider->redirect301('results_medecin_by_departement', array('departementCode' => $departementCode, 'departementTexte' => $departementTexte));
}
} else if ($this->slugify->slugify($diplomeCheck->getName()) != $specialite) {
$slugCheck = $this->slugify->slugify($diplomeCheck->getName());
if ($zipcode) {
return $this->redirectProvider->redirect301('results_medecin_audio_by_city_filter_specialite', array('zipcode' => $zipcode, 'ville' => $ville, 'idspecialite' => $idspecialite, 'specialite' => $slugCheck));
} else if ($departementCode) {
return $this->redirectProvider->redirect301('results_medecin_by_departement_filter_specialite', array('departementCode' => $departementCode, 'departementTexte' => $departementTexte, 'idspecialite' => $idspecialite, 'specialite' => $slugCheck));
}
}
}
$result = [];
$searchtype = [];
$doctorsID = [];
$localisationId = $lng = $lat = $canonical_url = null;
$doctors = array();
// SI RECHERCHE PAR VILLE
if ($zipcode) {
/********** Description seo ***************/
$description_seo = "ORL à " . $this->dataProvider->wordUpperCaseFirstLetter($ville) . " (" . $zipcode . ") : Trouvez un médecin ORL ou phoniatre proche de chez vous, consultez ses coordonnées et prenez rendez-vous avec l'Annuaire de l'Audition.";
// LOCALISATION
$localisation = $this->getDoctrine()->getRepository(Zipcode::class)->findOneBy(array(
'zipcode' => $zipcode,
'city' => strtoupper($ville)
));
if (!$localisation) {
$localisation = $this->getDoctrine()->getRepository(Zipcode::class)->findOneBy(array(
'zipcode' => $zipcode,
'city' => strtoupper(str_replace('-', ' ', $ville))
));
}
if (!$localisation) {
$localisation = $this->getDoctrine()->getRepository(Zipcode::class)->findByZipCodeAndCityLike($zipcode, $ville);
}
if (!$localisation) {
$localisation = $this->getDoctrine()->getRepository(Zipcode::class)->findOneBy(['zipcode' => $zipcode]);
}
if (!$localisation) {
throw new NotFoundHttpException();
}
if ($ville != $this->slugify->slugify($localisation->getCity())) {
return $this->redirectProvider->redirect301('results_medecin_audio_by_city', array('ville' => $this->slugify->slugify($localisation->getCity()), 'zipcode' => $zipcode));
}
$cities = $localisation->getCities();
if (!$cities) {
$cities = $this->geoProvider->addCities($ville, $zipcode, $localisation);
}
// DEPARTEMENT ET COORDONNEES
if (!empty($localisation->getCities())) {
$departementTexte = $localisation->getCities()->getDeptTxt();
$depcode = $localisation->getCities()->getDeptcode();
$localisationId = $localisation->getCities()->getId();
$lat = $localisation->getCities()->getLat();
$lng = $localisation->getCities()->getLng();
} else {
$dep = $localisation->getDepartment();
$departementTexte = substr($dep, 7);
$depcode = substr($dep, 0, 2);
}
// PREFOOTER
$searchtype['departementCode'] = $depcode;
$searchtype['departementTexte'] = $this->slugify->slugify($departementTexte);
// BREADCRUMB
$this->breadDatas['type'] = 'city';
$this->breadDatas['final'] = $localisation->getCity() . " (" . $zipcode . ")";
$this->breadDatas['final_url'] = $this->router->generate(
'results_medecin_audio_by_city',
array('zipcode' => $zipcode, 'ville' => $this->slugify->slugify($ville))
);
$this->breadDatas['departementTxt'] = $departementTexte;
$this->breadDatas['departementCode'] = $depcode;
$arrondissement = false;
if ($ville == "paris" || $ville == "marseille" || $ville == "lyon") {
$arrondissement = " " . $this->dataProvider->getArrondissement($zipcode);
if ($ville != "paris")
$this->breadDatas['villeArrondissement'] = $ville;
}
$title_seo = "ORL " . $this->dataProvider->wordUpperCaseFirstLetter($localisation->getCity()) . $arrondissement . " (" . $zipcode . ") - Phoniatre : Prenez RDV en ligne";
// TITRE DE RECHERCHE
$search_location = $ville;
// Recherche basée sur le zipcode des adresses des cabinets et des hopitaux
$doctors = $this->getDoctrine()->getRepository(Doctors::class)->findByLocalisation($localisation->getId());
foreach ($doctors as $doctor) {
$doctor->zip = $zipcode;
$doctor->city = $ville;
}
$total_results = count($doctors);
$limit = 30 - $total_results;
if ($total_results < 30) {
$doctors_proximite = [];
// ------- Récupération coordonnées de la ville courante
$lat = $localisation->getCities()->getLat();
$lng = $localisation->getCities()->getLng();
$idLoc = $localisation->getCities()->getId();
$cities_proximite = $this->getDoctrine()->getRepository(Zipcode::class)->findCitiesByProximite($lat, $lng, $idLoc);
foreach ($cities_proximite as $city) {
if ($zip_pro = $this->getDoctrine()->getRepository(Zipcode::class)->find($city[0]->getId())) {
$zip_pro_id = $zip_pro->getId();
if ($total_results < 30) {
$doctors_proximite = $this->getDoctrine()->getRepository(Doctors::class)->findByLocalisation($city[0]->getId());
foreach ($doctors_proximite as $doctor_proximite) {
if (!in_array($doctor_proximite, $doctors) && $total_results < 30) {
$doctor_proximite->zip = $zip_pro->getZipcode();
$doctor_proximite->city = $zip_pro->getCity();
array_push($doctors, $doctor_proximite);
$total_results = count($doctors);
$limit = 30 - $total_results;
}
}
}
}
}
}
$datasFilters = array('ville' => $ville, 'zipcode' => $zipcode);
// Description seo //
if ($localisation) {
$doctors_title_seo = $localisation->getDoctorsTitleSeo();
$doctors_description_seo = html_entity_decode($localisation->getDoctorsDescriptionSeo(), ENT_QUOTES);
}
$canonical_url = $this->router->generate('results_medecin_audio_by_city', array('zipcode' => $zipcode, 'ville' => $this->slugify->slugify($ville)));
$centers_url = $this->router->generate('results_centres_audio_by_city', array('zipcode' => $zipcode, 'ville' => $this->slugify->slugify($ville)));
//$audio_url = $this->router->generate('results_audio_by_city', array('zipcode' => $zipcode, 'ville' => $this->slugify->slugify($ville)));
$ortho_url = $this->router->generate('results_ortho_audio_by_city', array('zipcode' => $zipcode, 'ville' => $this->slugify->slugify($ville)));
//$searchtype['exceptZipCode'] = $zipcode;
$this->setTemplateParameters(array('zipcode' => $zipcode));
$this->setTemplateParameters(array('ville' => $ville));
}
// SI RECHERCHE PAR DEPARTEMENT
elseif ($departementCode) {
$depcode = $departementCode;
/************ Description seo ***************/
$description_seo = "ORL " . $this->dataProvider->wordUpperCaseFirstLetter($departementTexte) . " (" . $departementCode . ") : Trouvez un médecin ORL ou phoniatre proche de chez vous, consultez ses coordonnées et prenez rendez-vous avec l'Annuaire de l'Audition.";
// PREFOOTER
$searchtype['departementCode'] = $departementCode;
$searchtype['departementTexte'] = $this->slugify->slugify($departementTexte);
$localisation = $this->getDoctrine()->getRepository(Cities::class)->findOneBy(array('deptCode' => $departementCode));
$checkDept = $this->slugify->slugify($localisation->getDeptTxt());
if ($checkDept != $departementTexte && ($departementTexte != 'lyon' && $departementTexte != 'paris' && $departementTexte != 'marseille')) {
return $this->redirectProvider->redirect301('results_medecin_by_departement', array('departementCode' => $departementCode, 'departementTexte' => $checkDept));
}
$ville = $localisation->getVille();
$zipcode = $localisation->getZipCode();
// DEPARTEMENT ET COORDONNEES
$localisationId = $localisation->getId();
$lat = $localisation->getLat();
$lng = $localisation->getLng();
// BREADCRUMB
$this->breadDatas['type'] = 'dept';
$this->breadDatas['final'] = $localisation->getDeptTxt() . " (" . $departementCode . ")";
$this->breadDatas['final_url'] = $this->router->generate(
'results_medecin_by_departement',
array('departementCode' => $departementCode, 'departementTexte' => $this->slugify->slugify($departementTexte))
);
$title_seo = "ORL " . $this->dataProvider->wordUpperCaseFirstLetter($localisation->getDeptTxt()) . " (" . $departementCode . ") - Phoniatre : Prenez RDV en ligne";
// TITRE DE RECHERCHE
$search_location = $departementTexte;
// TOUTES LES VILLES DU DEPARTEMENT
if ($departementTexte == 'lyon' || $departementTexte == 'paris' || $departementTexte == 'marseille') {
$citiesInDept = $this->getDoctrine()->getRepository(Zipcode::class)->findBy(['city' => $departementTexte]);
$this->breadDatas['type'] = 'city';
$title_seo = "ORL " . $this->dataProvider->wordUpperCaseFirstLetter($departementTexte) . " (" . $departementCode . ") - Phoniatre : Prenez RDV en ligne";
$this->breadDatas['final'] = $this->dataProvider->wordUpperCaseFirstLetter($departementTexte) . " (" . $departementCode . ")";
// BREADCRUMB SPECIFIQUE
switch ($departementTexte) {
case 'paris':
$this->breadDatas['departementTxt'] = 'Paris';
$this->breadDatas['departementCode'] = 75;
break;
case 'lyon':
$this->breadDatas['departementTxt'] = 'Rhône';
$this->breadDatas['departementCode'] = 69;
break;
case 'marseille':
$this->breadDatas['departementTxt'] = 'Bouches-du-Rhône';
$this->breadDatas['departementCode'] = 13;
break;
}
} else {
$citiesInDept = $this->getDoctrine()->getRepository(Zipcode::class)->findCitiesInDept($departementCode);
}
// TOUS LES DOCTEURS DE TOUTES LES VILLES
foreach ($citiesInDept as $city) {
$doctorsincity = $this->getDoctrine()->getRepository(Doctors::class)->findByLocalisation($city->getId());
foreach ($doctorsincity as $doctorincity) {
if (!in_array($doctorincity, $doctors)) {
$doctorincity->zip = $city->getZipcode();
array_push($doctors, $doctorincity);
}
}
}
$datasFilters = array('departementCode' => $departementCode, 'departementTexte' => $departementTexte);
// Description seo //
//---- On cherche l'objet Map ayant le nom qui commence par depcode %
$maps = $this->getDoctrine()->getRepository(Maps::class)->findOneMapByDepCode($departementCode);
if ($maps && isset($maps[0])) {
$doctors_title_seo = $maps[0]->getDoctorsTitleSeo();
$doctors_description_seo = html_entity_decode($maps[0]->getDoctorsDescriptionSeo(), ENT_QUOTES);
}
$canonical_url = $this->router->generate('results_medecin_by_departement', array('departementCode' => $departementCode, 'departementTexte' => $this->slugify->slugify($departementTexte)));
$centers_url = $this->router->generate('results_centres_audio_by_departement', array('departementCode' => $departementCode, 'departementTexte' => $this->slugify->slugify($departementTexte)));
//$audio_url = $this->router->generate('results_audio_by_departement', array('departementCode' => $departementCode, 'departementTexte' => $this->slugify->slugify($departementTexte)));
$ortho_url = $this->router->generate('results_ortho_by_departement', array('departementCode' => $departementCode, 'departementTexte' => $this->slugify->slugify($departementTexte)));
}
// Récupération des filtres phoniatres
$phoniatre_filters = $this->FiltersProvider->getMedecinPhoniatreFilters($doctors, $datasFilters);
// Récupération des filtres spécialités
$specialite_filters = $this->FiltersProvider->getMedecinSpecialiteFilters($doctors, $datasFilters);
// Récupération des filtres exercices
$exercice_filters = $this->FiltersProvider->getMedecinExerciceFilters($doctors, $datasFilters);
$filtered = false;
$doctors_filtered = array();
// SI filtre par phoniatre
if ($isPhoniatre) {
foreach ($doctors as $doctor) {
if (($doctor->getPhoniatricians() && $isPhoniatre == "oui") || (!$doctor->getPhoniatricians() && $isPhoniatre == "non")) {
$doctors_filtered[] = $doctor;
}
}
$filtered = true;
}
// Si filtre par spécialité
if ($idspecialite) {
foreach ($doctors as $doctor) {
$degree = $this->getDoctrine()->getRepository(DoctorDegrees::class)->findOneBy(['doctor' => $doctor->getId(), 'degree' => $idspecialite]);
if ($degree) {
$doctors_filtered[] = $doctor;
}
}
$filtered = true;
}
// SI filtre par exercice
if ($exercice) {
foreach ($doctors as $doctor) {
if ($exercice == 'liberal') {
$cabinet = $this->getDoctrine()->getRepository(DoctorPractices::class)->findOneBy(['doctorId' => $doctor->getId()]);
if ($cabinet)
$doctors_filtered[] = $doctor;
} else if ($exercice == 'hospitalier') {
$service = $this->getDoctrine()->getRepository(ServiceDoctors::class)->findOneBy(['doctorId' => $doctor->getId()]);
if ($service)
$doctors_filtered[] = $doctor;
}
}
$filtered = true;
}
if ($filtered) {
$result = $this->cardProvider->getDoctorsCards($doctors_filtered);
} else {
$result = $this->cardProvider->getDoctorsCards($doctors);
}
// PAGINATION
$results_paginated = $paginator->paginate(
$result,
$request->query->getInt('page', 1),
30
);
$map = array();
foreach ($results_paginated as $result_paginated) {
if (array_key_exists('hospital', $result_paginated)) {
if ($marker = $this->geoProvider->getHospitalCoords($result_paginated['hospital'], $result_paginated['image'], 'Docteur', $result_paginated['doctor']->getTitle())) {
$map['markers'][] = $marker;
}
} else if (array_key_exists('practice', $result_paginated)) {
if ($marker = $this->geoProvider->getPracticeCoords($result_paginated['practice'], $result_paginated['image'], 'Docteur', $result_paginated['doctor']->getTitle())) {
$map['markers'][] = $marker;
}
}
}
// INJECTION DANS VUE
$this->setTemplateParameters(array(
'searchresult' => array('orl' => $results_paginated),
'filter' => array(
'specialites' => $specialite_filters,
'phoniatre' => $phoniatre_filters,
'exercice' => $exercice_filters,
)
));
//$this->breadDatas['ville'] = $ville;
//$this->breadDatas['zipcode'] = $zipcode;
$this->setBreadcrumb('medecins', 'list');
// PREFOOTER
$searchtype['lng'] = $lng;
$searchtype['lat'] = $lat;
$searchtype['localisationId'] = $localisationId;
$this->setTemplateParameters(array('map' => $map));
$deptForPreFooter = ($departementTexte == "paris" || $ville == "paris" || $departementTexte == "marseille" || $ville == "marseille" || $departementTexte == "lyon" || $ville == "lyon") ? "à " . $departementTexte : "en " . $departementTexte;
$this->setTemplateParameters(array('dept' => $deptForPreFooter));
$this->setTitleSearch();
$this->setPrevNextRel(count($result), $request->query->getInt('page'), $request->getSchemeAndHttpHost() . $request->getPathInfo());
$this->setInternalLinkage('medecinListe', $searchtype);
$this->setTemplateParameters(array('title_seo' => $title_seo));
$this->setTemplateParameters(array('description_seo' => $description_seo));
$this->setTemplateParameters(array('seo_text' => array('title' => $doctors_title_seo, 'text' => $doctors_description_seo)));
$this->setTemplateParameters(array('canonical_url' => $canonical_url));
$this->setTemplateParameters(array(
'centers_url' => $centers_url,
//'audio_url' =>$audio_url,
'ortho_url' => $ortho_url
));
return $this->renderTemplate('pages/annuaire_searchResults_ORL.twig');
}
/**
* @Route("/medecin-ORL-phoniatre/{ville}-{zipcode}/{nomMedecin}-{idMedecin}-practice-{idPractice}.html", name="page_single_medecin_with_practice", requirements={"zipcode"="\d{5}", "nomMedecin"="[a-zA-Z0-9\-_\/]+", "idMedecin"="[0-9]+", "ville"="[a-zA-Z0-9\-_\/]+", "idPractice"="[0-9]+"})
*
* @Route("/medecin-ORL-phoniatre/{ville}-{zipcode}/{nomMedecin}-{idMedecin}-service-{idService}.html", name="page_single_medecin_with_service", requirements={"zipcode"="\d{5}", "nomMedecin"="[a-zA-Z0-9\-_\/]+", "idMedecin"="[0-9]+", "ville"="[a-zA-Z0-9\-_\/]+", "idService"="[0-9]+"})
*
* @Route("/medecin-ORL-phoniatre/{ville}-{zipcode}/{nomMedecin}-{idMedecin}.html", name="page_single_medecin", requirements={"zipcode"="\d{5}", "nomMedecin"="[a-zA-Z0-9\-_\/]+", "idMedecin"="[0-9]+", "ville"="[a-zA-Z0-9\-_\/]+"})
* @Route("/medecin-ORL-phoniatre/{nomMedecin}-{idMedecin}.html", name="page_single_medecin_alone", requirements={"nomMedecin"="[a-zA-Z0-9\-_\/]+", "idMedecin"="[0-9]+"})
*/
public function renderPage($ville = null, $zipcode = null, $nomMedecin = null, $idMedecin = null, $idPractice = null, $idService = null, Request $request): Response
{
$team = [];
$page_provider = [];
$url_practice = $url_service = null;
$doctor = $this->getDoctrine()->getRepository(Doctors::class)->findOneBy(['id' => $idMedecin, 'visible' => 1]);
if (!$doctor) {
if ($zipcode) {
return $this->redirectProvider->redirect301('results_medecin_audio_by_city', array('zipcode' => $zipcode, 'ville' => $ville));
} else {
return $this->redirectProvider->redirect301('liste_medecin');
}
}
$cabinet = $service = null;
$slugMedecin = $this->slugify->slugify($doctor->getFirstName() . '-' . $doctor->getName());
if ($slugMedecin != $nomMedecin) {
if ($idPractice) {
return $this->redirectProvider->redirect301('page_single_medecin_with_practice', array('zipcode' => $zipcode, 'ville' => $ville, 'nomMedecin' => $slugMedecin, 'idMedecin' => $idMedecin, 'idPractice' => $idPractice));
} else if ($idService) {
return $this->redirectProvider->redirect301('page_single_medecin_with_service', array('zipcode' => $zipcode, 'ville' => $ville, 'nomMedecin' => $slugMedecin, 'idMedecin' => $idMedecin, 'idService' => $idService));
} else {
return $this->redirectProvider->redirect301('page_single_medecin_alone', array('nomMedecin' => $slugMedecin, 'idMedecin' => $idMedecin));
}
}
$alone = false;
if (!$idPractice && !$idService) {
$alone = true;
}
if ($idPractice) {
$cabinet = $this->getDoctrine()->getRepository(Practices::class)->find($idPractice);
if (!$cabinet) {
return $this->redirectProvider->redirect301('page_single_medecin_alone', array('nomMedecin' => $slugMedecin, 'idMedecin' => $idMedecin));
}
} else if ($idService) {
$service = $this->getDoctrine()->getRepository(Services::class)->find($idService);
if (!$service) {
return $this->redirectProvider->redirect301('page_single_medecin_alone', array('nomMedecin' => $slugMedecin, 'idMedecin' => $idMedecin));
}
}
/*else {
$cabinet = $this->getDoctrine()->getRepository(Doctors::class)->findPracticeByDoctorID($idMedecin, null, 1);
$cabinet = ($cabinet)? $cabinet[0] : NULL;
if($cabinet) {
$idPractice = $cabinet->getId();
}
}*/
// Les Autres Cabinets & Services //
$buttons = [];
$i = 1;
$idspractices = array();
$practices = $this->getDoctrine()->getRepository(Doctors::class)->findPracticeByDoctorID($idMedecin);
foreach ($practices as $practice) {
$zipcodeCheck = $this->getDoctrine()->getRepository(Zipcode::class)->findOneBy(['id' => $practice->getLocalisation()->getId()]);
if ($zipcodeCheck) {
if ($practice->getLocalisation()->getZipcode()) {
$url = $this->router->generate(
'page_single_medecin_with_practice',
array(
'zipcode' => $practice->getLocalisation()->getZipcode(),
'nomMedecin' => $slugMedecin,
'idMedecin' => $idMedecin,
'ville' => $this->slugify->slugify($practice->getLocalisation()->getCity()),
'idPractice' => $practice->getId(),
)
);
$url_practice = $url;
if ($alone) {
return $this->redirect($url, 301);
}
$idpractice = $practice->getId();
$idspractices[] = $idpractice;
$current = (!$idService && $idpractice == $idPractice) ? true : false;
array_push($buttons, array(
"title" => 'Cabinet ' . $i,
"url" => "/medecin-ORL-phoniatre/" . $this->slugify->slugify($practice->getLocalisation()->getCity()) . "-" . $practice->getLocalisation()->getZipcode() . "/" . $slugMedecin . '-' . $idMedecin . "-practice-" . $idpractice . ".html",
"current" => $current,
));
$i++;
if ($current) {
$doctorPractice = $this->getDoctrine()->getRepository(DoctorPractices::class)->findOneBy(['doctorId' => $idMedecin, 'practice' => $idpractice]);
$this->setTemplateParameters(array('doctolibIframe' => $doctorPractice->getDoctolibIframe() ?? ''));
$phone = (!empty($doctorPractice->getPhone())) ? $doctorPractice->getPhone() : $cabinet->getPhone();
if ($practice->getLocalisation()->getZipcode() && $zipcode != $practice->getLocalisation()->getZipcode()) {
return $this->redirectProvider->redirect301(
'page_single_medecin_with_practice',
array(
'ville' => $this->slugify->slugify($practice->getLocalisation()->getCity()),
'zipcode' => $practice->getLocalisation()->getZipcode(),
'nomMedecin' => $nomMedecin,
'idMedecin' => $idMedecin,
'idPractice' => $idPractice,
)
);
}
// Infos Cabinet
$adresse = $cabinet->getAddress() . " \n";
if ($cabinet->getAdditionalAddress()) {
$adresse .= $cabinet->getAdditionalAddress() . " \n";
}
$adresse .= $cabinet->getLocalisation()->getZipcode() . ' ' . $cabinet->getLocalisation()->getCity() . " \n";
if ($cabinet->getPoBox()) {
$adresse .= $cabinet->getPoBox() . " \n";
}
if ($cabinet->getZipCedex()) {
$adresse .= $cabinet->getZipCedex() . " ";
}
if ($cabinet->getCityCedex()) {
$adresse .= $cabinet->getCityCedex();
}
$page_provider = array(
"coords" => array(
"items" => array(
"tel1" => $phone,
"address" => $cabinet->getAddress() . " \n" . $cabinet->getAdditionalAddress(),
"zip" => $cabinet->getLocalisation()->getZipcode(),
"city" => $cabinet->getLocalisation()->getCity(),
"bp" => $cabinet->getPoBox(),
"zipcedex" => $cabinet->getZipCedex(),
"citycedex" => $cabinet->getCityCedex()
),
"coordTitle" => $practice->getName()
)
);
}
}
}
}
if (($idPractice && !in_array($idPractice, $idspractices))) {
$zipcodeCheckCurrent = $this->getDoctrine()->getRepository(Zipcode::class)->findOneBy(['id' => $idPractice]);
if (!$zipcodeCheckCurrent) {
return $this->redirectProvider->redirect301('page_single_medecin_alone', array('nomMedecin' => $nomMedecin, 'idMedecin' => $idMedecin));
}
}
$services = $this->getDoctrine()->getRepository(Doctors::class)->findServiceByDoctorID($idMedecin);
$idsservices = array();
$j = 1;
foreach ($services as $serv) {
if ($serv->getHospital()->getLocalisation()->getCountry() == "FRANCE" || $serv->getHospital()->getLocalisation()->getCountry() == "") {
$url = $this->router->generate(
'page_single_medecin_with_service',
array(
'zipcode' => $serv->getHospital()->getLocalisation()->getZipcode(),
'nomMedecin' => $slugMedecin,
'idMedecin' => $idMedecin,
'ville' => $this->slugify->slugify($serv->getHospital()->getLocalisation()->getCity()),
'idService' => $serv->getId()
)
);
$url_service = $url;
if ($alone) {
return $this->redirect($url, 301);
}
$idservice = $serv->getId();
$idsservices[] = $idservice;
$current = ($idservice == $idService) ? true : false;
array_push($buttons, array(
"title" => "Service ORL " . $j,
"url" => "/medecin-ORL-phoniatre/" . $this->slugify->slugify($serv->getHospital()->getLocalisation()->getCity()) . "-" . $serv->getHospital()->getLocalisation()->getZipcode() . "/" . $slugMedecin . '-' . $idMedecin . "-service-" . $idservice . ".html",
"current" => $current,
));
$j++;
if ($current) {
if ($zipcode != $serv->getHospital()->getLocalisation()->getZipcode()) {
return $this->redirectProvider->redirect301(
'page_single_medecin_with_service',
array(
'ville' => $this->slugify->slugify($serv->getHospital()->getLocalisation()->getCity()),
'zipcode' => $serv->getHospital()->getLocalisation()->getZipcode(),
'nomMedecin' => $nomMedecin,
'idMedecin' => $idMedecin,
'idService' => $idService
)
);
}
$page_provider = array(
"coords" => array(
"items" => array(
"address" => $serv->getHospital()->getAddress() . " \n" . $serv->getHospital()->getAdditionalAddress(),
"zip" => $serv->getHospital()->getLocalisation()->getZipcode(),
"city" => $serv->getHospital()->getLocalisation()->getCity(),
"bp" => $serv->getHospital()->getPoBox(),
"zipcedex" => $serv->getHospital()->getCedex(),
"citycedex" => $serv->getHospital()->getCityCedex()
),
"coordTitle" => $serv->getHospital()->getCorporateName(),
'subtitleORLService' => $serv->getName(),
'link' => $url = $this->router->generate(
'page_service_hospitalier_avec_service',
array(
'ville' => $ville,
'zipcode' => $zipcode,
'nomhopital' => $this->slugify->slugify($serv->getHospital()->getCorporateName()),
'idhopital' => $serv->getHospital()->getId(),
'nomservice' => $this->slugify->slugify($serv->getName()),
'idservice' => $serv->getId(),
)
)
)
);
$serviceDoctor = $this->getDoctrine()->getRepository(ServiceDoctors::class)->findOneBy([
'service' => $idService,
'doctor' => $idMedecin
]);
$this->setTemplateParameters(array('doctolibIframe' => $serviceDoctor->getDoctolibIframe() ?? ''));
if ($serviceDoctor && $serviceDoctor->getTelSpecifique()) {
$page_provider['coords']['items']['telSpec'] = $serviceDoctor->getTelSpecifique();
$page_provider['coords']['items']['telSpecDesc'] = $serviceDoctor->getTelSpecifiqueDesc();
} else {
// Infos Cabinet
for ($i = 1; $i <= 3; $i++) {
$tel = $serv->{'getTitle' . $i}();
if (!empty($tel))
$tel .= "\n";
$tel .= $serv->{'getDescription' . $i}();
$page_provider['coords']['items']['tel' . $i] = $tel;
}
}
}
}
}
if ($idService && !in_array($idService, $idsservices)) {
return $this->redirectProvider->redirect301('page_single_medecin_alone', array('nomMedecin' => $nomMedecin, 'idMedecin' => $idMedecin));
}
$localisation = $this->getDoctrine()->getRepository(Zipcode::class)->findOneBy(array(
'zipcode' => $zipcode,
'city' => strtoupper($ville)
));
if (!$localisation) {
$localisation = $this->getDoctrine()->getRepository(Zipcode::class)->findOneBy(array(
'zipcode' => $zipcode,
'city' => strtoupper(str_replace('-', ' ', $ville))
));
}
if (!$localisation) {
$localisation = $this->getDoctrine()->getRepository(Zipcode::class)->findByZipCodeAndCityLike($zipcode, $ville);
}
if (!$localisation) {
$localisation = $this->getDoctrine()->getRepository(Zipcode::class)->findOneBy(['zipcode' => $zipcode]);
}
if (!$localisation) {
throw new NotFoundHttpException();
}
if ($localisation && ($zipcode != $localisation->getZipcode() || $ville != $this->slugify->slugify($localisation->getCity()))) {
return $this->redirectProvider->redirect301('page_single_medecin_alone', array('nomMedecin' => $nomMedecin, 'idMedecin' => $idMedecin));
}
//if(!$alone)
//$slugVille = $this->slugify->slugify($localisation->getCity());
// Logo //
$logo = $this->dataProvider->getAvatar('Docteur', $doctor->getTitle());
if ($logoId = $this->getDoctrine()->getRepository(Image::class)->findOneBy(['class' => 'Doctors', 'entityId' => $idMedecin, 'cover' => 1])) {
$file = $this->bo_url . "images/" . $logoId->getId() . "-medium.jpg";
$logo = $file;
}
// Diplômes //
$diplomes = $this->getDoctrine()->getRepository(Doctors::class)->getDoctorDegrees($idMedecin);
$diplomas = [];
foreach ($diplomes as $diplome) {
$diplomas[] = $diplome->getName();
}
if (!empty($doctor->getFreeField())) {
$diplomas[] = $doctor->getFreeField();
}
// Centres à proximités du cabinet //
// On teste s'il y a un cabinet en paramètre, sinon on récupère le premier cabinet dans la requête.
$centre_proximite = [];
if ($cabinet || $service) {
$object = ($cabinet) ? $cabinet : $service;
// Coordonnées de localisation
if ($service) {
$cities = $service->getHospital()->getLocalisation()->getCities();
if (!$cities) {
$cities = $this->geoProvider->addCities($ville, $zipcode, $localisation);
}
$geocode = $this->dataProvider->getGeoCode($service->getHospital());
} else {
$cities = $object->getLocalisation()->getCities();
if (!$cities) {
$cities = $this->geoProvider->addCities($ville, $zipcode, $localisation);
}
$geocode = $this->dataProvider->getGeoCode($object);
}
$lat = $geocode['lat'];
$lng = $geocode['lng'];
$idLoc = $geocode['idLoc'];
$centersCity = $this->getDoctrine()->getRepository(Centers::class)->findBy([
'localisation' => $localisation->getId(),
'advertiser' => 1,
'visible' => 1
]);
shuffle($centersCity);
foreach ($centersCity as $c) {
array_push($centre_proximite, $c);
}
$centersRelated = $this->getDoctrine()->getRepository(CenterZipcode::class)->findBy(['zipcodeId' => $localisation->getId()]);
shuffle($centersRelated);
foreach ($centersRelated as $c) {
$cr = $this->getDoctrine()->getRepository(Centers::class)->findOneBy([
'id' => $c->getCenterId(),
'advertiser' => 1,
'visible' => 1
]);
if ($cr) {
array_push($centre_proximite, $cr);
}
}
if (sizeof($centre_proximite) < 6) {
$limit = 6 - sizeof($centre_proximite);
$proximites = $this->getDoctrine()->getRepository(Centers::class)->findCentersByProximiteCity(array('lat' => $lat, 'lng' => $lng), $localisation->getId(), $limit);
shuffle($proximites);
foreach ($proximites as $proximite) {
$centerPro = $this->getDoctrine()->getRepository(Centers::class)->findOneBy(['id' => $proximite[0]->getId(), 'visible' => 1]);
if ($centerPro && !in_array($centerPro, $centre_proximite)) {
array_push($centre_proximite, $centerPro);
}
}
}
$centre_proximite = $this->cardProvider->getCenterCards($centre_proximite);
// On cherche les autres médecins du même cabinet ou du même service //
$lieuType = null;
$lieuEntity = null;
if ($cabinet) {
$otherDoctors = $this->getDoctrine()->getRepository(Doctors::class)->findByPractice($cabinet->getId(), $idMedecin);
$lieuType = "cabinet";
$lieuEntity = $cabinet;
} elseif ($service) {
$otherDoctors = $this->getDoctrine()->getRepository(Doctors::class)->findByService($service->getId(), $idMedecin);
$lieuType = "service";
$lieuEntity = $service;
}
$team = $this->cardProvider->getOrlCards($otherDoctors, $localisation, $lieuType, $lieuEntity);
}
// Les actualités //
$news = [];
$a = [];
$v = [];
$actualites = $this->getDoctrine()->getRepository(NewsDoctors::class)->findNewsByDoctorID($idMedecin);
if ($actualites) {
$a = $this->cardProvider->getNewsCards($actualites);
}
$videos = $this->getDoctrine()->getRepository(NewsDoctors::class)->findVideosByDoctorID($idMedecin);
if ($videos) {
$v = $this->cardProvider->getVideosCards($videos);
}
$news = array_merge($a, $v);
// Associations //
$agencies = [];
$associations = $this->getDoctrine()->getRepository(AgencyDoctors::class)->findBy(array('doctor' => $idMedecin));
if ($associations) {
$orga = array();
foreach ($associations as $asso) {
$agencie = null;
$agencie = $this->getDoctrine()->getRepository(Agencies::class)->findOneBy(array('id' => $asso->getAgency()->getId()));
if ($agencie) {
$agencie->role1 = $asso->getSpecificity1();
$agencie->role2 = $asso->getSpecificity2();
}
array_push($orga, $agencie);
}
$agencies = $this->cardProvider->getAgencyCards($orga, $zipcode, $ville, true);
}
// ROLES
$servicesDoctors = $this->getDoctrine()->getRepository(ServiceDoctors::class)->findBy(array('doctorId' => $idMedecin));
$rolesDesordre = array();
$roles = [];
foreach ($servicesDoctors as $servicesDoctor) {
$hopital = false;
$lookup = $this->getDoctrine()->getRepository(Lookup::class)->findOneBy(['code' => $servicesDoctor->getStatusGrade(), 'type' => 'StatusGrade']);
$serviceD = $this->getDoctrine()->getRepository(Services::class)->findOneBy(['id' => $servicesDoctor->getService()]);
if ($serviceD) {
$hopital = $this->getDoctrine()->getRepository(Hospitals::class)->findOneBy(['id' => $serviceD->getHospital()]);
}
$cityhospital = "";
if ($hopital && $hopital->getLocalisation()->getCity())
$cityhospital = " de " . $hopital->getLocalisation()->getCity();
if ($lookup && $hopital) {
$nom = $lookup->getName();
if (!empty($servicesDoctor->getSpecialty()))
$nom .= " (" . $servicesDoctor->getSpecialty() . ")";
$nom .= " " . $hopital->getCorporateName() . $cityhospital;
$rolesDesordre[] = array(
'nom' => $nom,
'position' => $lookup->getPosition()
);
}
}
$pos = array_column($rolesDesordre, 'position');
array_multisort($pos, SORT_ASC, $rolesDesordre);
foreach ($rolesDesordre as $r) {
$roles[] = $r['nom'];
}
// Titres organismes
if (isset($orga)) {
foreach ($orga as $agencie) {
$rolePerson = "";
if ($agencie->role1)
$rolePerson = $agencie->role1;
if ($agencie->role2)
$rolePerson .= ", " . $agencie->role2;
if ($agencie->role1 || $agencie->role2)
$rolePerson .= " " . $agencie->getCorporateName();
$roles[] = $rolePerson;
}
}
// Header //
$header = array(
"image" => $logo,
"name" => $doctor->getFirstName(),
"surname" => $doctor->getName(),
"grade" => $doctor->getTitle(),
"job" => $this->dataProvider->getDoctorSpecialities($idMedecin),
"roles" => $roles,
);
$this->setTemplateParameters(array(
"page_orl" => array(
"header" => $header,
"diplomas" => $diplomas,
"centers" => $centre_proximite,
"team" => $team,
"type" => ($service) ? 'service' : 'cabinet',
"actus" => $news,
"associations" => $agencies,
"lieuType" => ($service) ? 'service ORL' : 'cabinet',
),
'search' => array(
'filter' => $buttons,
),
"page_provider" => $page_provider,
));
if (!$alone) {
if (!isset($lat)) {
$lat = $localisation->getCities()->getLat();
$lng = $localisation->getCities()->getLng();
$idLoc = $localisation->getCities()->getId();
}
$searchtype['lat'] = $lat;
$searchtype['lng'] = $lng;
$searchtype['currentCityId'] = $idLoc;
$this->setTemplateParameters(array('city' => $localisation->getCity()));
$map['markers'][] = array(
"lat" => $lat,
"lon" => $lng,
"premium" => true,
"src" => "url(" . $logo . ")"
);
$this->setInternalLinkage('medecinPage', $searchtype);
$dep = $localisation->getDepartment();
$departementTxt = $localisation->getCities()->getDeptTxt();
$departementCode = $localisation->getCities()->getDeptCode();
$this->breadDatas['ville'] = $localisation->getCity();
$this->breadDatas['zipcode'] = $localisation->getZipcode();
$this->breadDatas['departementTxt'] = $departementTxt;
$this->breadDatas['departementCode'] = $departementCode;
$this->setTemplateParameters(array('map' => $map));
}
if ($zipcode && $ville) {
$centers_url = $this->router->generate('results_centres_audio_by_city', array('zipcode' => $zipcode, 'ville' => $this->slugify->slugify($ville)));
//$audio_url = $this->router->generate('results_audio_by_city', array('zipcode' => $zipcode, 'ville' => $this->slugify->slugify($ville)));
$ortho_url = $this->router->generate('results_ortho_audio_by_city', array('zipcode' => $zipcode, 'ville' => $this->slugify->slugify($ville)));
}
/************** Titre seo ***************/
$title_seo = $doctor->getFirstName() . ' ' . $doctor->getName() . ' - Médecin ORL';
if ($ville) {
$title_seo .= ' à ' . $this->dataProvider->wordUpperCaseFirstLetter($localisation->getCity()) . ' (' . $zipcode . ')';
/************** Description seo ***************/
$description_seo = "Prenez rendez-vous avec " . $doctor->getFirstName() . " " . $doctor->getName() . ", médecin ORL à " . $this->dataProvider->wordUpperCaseFirstLetter($localisation->getCity()) . " (" . $zipcode . "). Consultez ses coordonnées et son adresse sur l'Annuaire de l'Audition.";
}
$canonical_url = null;
if ($url_practice) {
$canonical_url = $url_practice;
}
elseif ($url_service) {
$canonical_url = $url_service;
}
else {
$canonical_url = $this->dataProvider->getDoctorLink($idMedecin);
}
$this->setTemplateParameters(array('title_seo' => $title_seo));
$this->setTemplateParameters(array('description_seo' => $description_seo ?? ""));
$this->setTemplateParameters(array('canonical_url' => $canonical_url));
$this->breadDatas['final'] = $doctor->getFirstName() . ' ' . $doctor->getName();
// Breadcrumb
$this->setBreadcrumb('medecins', 'single');
$this->setTemplateParameters(array('dataLayerCenters' => $centre_proximite, 'creative' => 'fiche-pro'));
$this->setTemplateParameters(array(
'centers_url' => $centers_url ?? "",
//'audio_url' =>$audio_url ?? "",
'ortho_url' => $ortho_url ?? ""
));
if ($idPractice) $this->setTemplateParameters(array('idPractice' => $idPractice));
if ($idService) $this->setTemplateParameters(array('idService' => $idService));
if ($idPractice || $idService) {
$id_entity = $idPractice ?? $idService;
$entity = $idPractice ? 'practice' : 'service';
// on cherche le cache des parkings
if (file_exists('overpass/parkings/' . $entity . '/' . $entity . '-' . intval($id_entity) . '.json')) {
$data = json_decode(file_get_contents('overpass/parkings/' . $entity . '/' . $entity . '-' . intval($id_entity) . '.json'));
$parkings = $this->renderView('modules/map/nearby.html.twig', array(
'type' => "parkings",
'parkings' => (array)$data
));
$this->setTemplateParameters(array('parkings' => $parkings));
}
$transport_communs = [];
// on cherche le cache des bus
if (file_exists('overpass/buses/' . $entity . '/' . $entity . '-' . intval($id_entity) . '.json')) {
$data = json_decode(file_get_contents('overpass/buses/' . $entity . '/' . $entity . '-' . intval($id_entity) . '.json'));
if ($data) {
$transport_communs['buses'] = $data;
}
$buses = $this->renderView('modules/map/nearby.html.twig', array(
'type' => "transport",
'subtype' => "buses",
'buses' => (array)$data
));
$this->setTemplateParameters(array('buses' => $buses));
}
// on cherche le cache des métros/trains
if (file_exists('overpass/subways/' . $entity . '/' . $entity . '-' . intval($id_entity) . '.json')) {
$data = json_decode(file_get_contents('overpass/subways/' . $entity . '/' . $entity . '-' . intval($id_entity) . '.json'));
if ($data) {
$transport_communs['subways'] = $data;
}
$subways = $this->renderView('modules/map/nearby.html.twig', array(
'type' => "transport",
'subtype' => "subways",
'subways' => (array)$data
));
$this->setTemplateParameters(array('subways' => $subways));
}
// on cherche le cache des trams.
if (file_exists('overpass/trams/' . $entity . '/' . $entity . '-' . intval($id_entity) . '.json')) {
$data = json_decode(file_get_contents('overpass/trams/' . $entity . '/' . $entity . '-' . intval($id_entity) . '.json'));
if ($data) {
$transport_communs['trams'] = $data;
}
$trams = $this->renderView('modules/map/nearby.html.twig', array(
'type' => "transport",
'subtype' => "trams",
'trams' => (array)$data
));
$this->setTemplateParameters(array('trams' => $trams));
}
}
// FAQ //
$faqs = [];
$nomMedecin = $doctor->getTitle() . ' ' . $doctor->getFirstName() . ' ' . $doctor->getName();
$entity = $cabinet;
if (!$cabinet && $service && $service->getHospital()) $entity = $service->getHospital();
if ($entity) {
$address = $entity->getAddress();
if ($entity->getLocalisation() && $entity->getLocalisation()->getId()) {
$address .= " " . $entity->getLocalisation()->getZipcode() . " " . $entity->getLocalisation()->getCity();
}
$faqs[] = [
"question" => "Quelle est l'adresse du " . $nomMedecin . " ?",
"response" => "L'adresse du " . $nomMedecin . " est " . $address
];
$phone = $entity->getPhone();
if ($phone) {
$faqs[] = [
"question" => "Comment contacter le " . $nomMedecin . " ?",
"response" => "Il est possible de contacter le " . $nomMedecin . " par téléphone au " . $phone . "."
];
}
}
if ($diplomas) {
$suffix = (sizeof($diplomas) > 1) ? "s" : "";
$response_txt = "Le " . $nomMedecin . " possède le" . $suffix . " diplôme" . $suffix . " suivant" . $suffix . " :<ul>";
foreach ($diplomas as $diplome) {
$response_txt .= "<li>" . $diplome . "</li>";
}
$response_txt .= "</ul>";
$faqs[] = [
"question" => "Quelle est la formation et quels sont les diplômes du " . $nomMedecin . " ?",
"response" => $response_txt
];
}
if ((sizeof($idsservices) + sizeof($idspractices) > 1)) {
$suffix = (sizeof($idsservices) + sizeof($idspractices) > 1) ? "s" : "";
$suffixX = (sizeof($idsservices) + sizeof($idspractices) > 1) ? "x" : "";
$response_txt = "";
foreach ($practices as $practice) {
$response_txt .= "<li>" . $practice->getName();
if ($practice->getLocalisation() && $practice->getLocalisation()->getId()) {
$response_txt .= " à " . $practice->getLocalisation()->getCity();
}
$response_txt .= "</li>";
}
foreach ($services as $service) {
$service = $service->getHospital();
$response_txt .= "<li>" . $service->getCorporateName();
if ($service->getLocalisation() && $service->getLocalisation()->getId()) {
$response_txt .= " à " . $service->getLocalisation()->getCity();
}
$response_txt .= "</li>";
}
if ($response_txt) {
$faqs[] = [
"question" => "Où exerce le " . $nomMedecin . " ?",
"response" => "Le " . $nomMedecin . " exerce dans les " . (sizeof($idsservices) + sizeof($idspractices)) . " lieu" . $suffixX . " suivant" . $suffix . " :<ul>" . $response_txt . "</ul>"
];
}
}
$placeType = $cabinet ? "cabinet ORL" : "service ORL";
if ($otherDoctors) {
$suffix = sizeof($otherDoctors) > 1 ? "s" : "";
$suffix_ENT = sizeof($otherDoctors) > 1 ? "nt" : "";
$placeAddress = " " . $entity->getAddress();
if ($entity->getLocalisation() && $entity->getLocalisation()->getId()) {
$placeAddress .= " " . $entity->getLocalisation()->getZipcode() . " " . $entity->getLocalisation()->getCity();
}
$response_txt = "";
foreach ($otherDoctors as $doc) {
$response_txt .= "<li>" . $doc->getTitle() . " " . $doc->getFirstName() . " " . $doc->getName() . "</li>";
}
$faqs[] = [
"question" => "Quels sont les autres médecins ORL du " . $placeType . " " . $placeAddress . " ?",
"response" => sizeof($otherDoctors) . " autre" . $suffix . " médecin" . $suffix . " ORL exerce" . $suffix_ENT . " également dans le " . $placeType . " du " . $nomMedecin . " :<ul>" . $response_txt . "</ul>"
];
}
if ($transport_communs) {
$response_txt = "";
foreach ($transport_communs as $type => $tc) {
$type = $type == 'buses' ? 'Bus - ' : ($type == 'subways' ? 'Métro - ' : 'Tram - ');
foreach ($tc as $value) {
$response_txt .= "<li>" . $type . $value->name . "</li>";
}
}
$faqs[] = [
"question" => "Comment accéder au " . $placeType . " du " . $nomMedecin . " par les transports en commun ?",
"response" => "Le " . $placeType . " du " . $nomMedecin . " est situé à proximité des arrêts suivants :<ul>" . $response_txt . "</ul>"
];
}
$this->setTemplateParameters(array('faqs' => $faqs));
return $this->renderTemplate('pages/annuaire_page_ORL.twig', [
'idMedecin' => $idMedecin,
]);
}
/**
* @Route("/import-doctolib-links", name="import_doctolib_links")
*/
public function importDoctolibLinks(
DoctorPracticesRepository $doctorPracticesRepository,
ServiceDoctorsRepository $serviceDoctorsRepository,
EntityManagerInterface $em,
Request $request
) {
if (!$request->query->get('filename')) {
die('No file exists');
}
$inputFileName = 'imports/' . $request->query->get('filename');
$spreadsheet = IOFactory::load($inputFileName);
$sheetData = $spreadsheet->getActiveSheet()->toArray();
unset($sheetData[0]);
$prefix = "https://partners.doctolib.fr/orl/";
$slugify = new Slugify();
foreach ($sheetData as $row)
{
if (empty($row[0])) break;
$url = $prefix . $slugify->slugify($row[13]) . '/' . $slugify->slugify($row[8]) . '-' . $slugify->slugify($row[9]);
$urlImported = false;
$idCabService = $row[3];
// Check practices.
/** @var [] DoctorPractices */
$doctorPractices = $doctorPracticesRepository->findBy(['doctorId' => $row[0]]);
if (count($doctorPractices)) {
foreach ($doctorPractices as $doctorPractice) {
/**
* @var Practices $practice
*/
$practice = $doctorPractice->getPractice();
$idCabService = $row[3];
if ($idCabService == $practice->getId()) {
$doctorPractice->setDoctolibIframe($url);
$em->persist($doctorPractice);
$em->flush();
$urlImported = true;
break;
}
}
}
// Check services.
if (!$urlImported) {
$services = $serviceDoctorsRepository->findBy(['doctorId' => $row[0]]);
if (count($services)) {
foreach ($services as $serviceDoctor) {
if ($idCabService == $serviceDoctor->getService()->getId()) {
$serviceDoctor->setDoctolibIframe($url);
$em->persist($serviceDoctor);
$em->flush();
$urlImported = true;
break;
}
}
}
}
if (!$urlImported) {
echo $row[0] . ' - ' . $url . '<br>';
}
}
die('Import done');
}
/**
* @Route("/get-all-orls-having-doctolib-iframe", name="get_all_orls_having_doctolib_iframe")
*/
public function getAllOrlsHavingDoctolibIframe(
DoctorPracticesRepository $doctorPracticesRepository,
ServiceDoctorsRepository $serviceDoctorsRepository
) {
$siteUrl = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
$urls = '';
// Practices.
$doctorPractices = $doctorPracticesRepository->findAllHavingDoctolibIframe();
foreach ($doctorPractices as $doctorPractice) {
$practice = $doctorPractice->getPractice();
if ($practice->getLocalisation()->getCountry() != 'FRANCE') {
continue;
}
$doctor = $doctorPractice->getDoctor();
if (!$doctor || !$practice) continue;
$slugMedecin = $this->slugify->slugify($doctor->getFirstName() . '-' . $doctor->getName());
$urls .= $siteUrl . $this->router->generate(
'page_single_medecin_with_practice',
array(
'zipcode' => $practice->getLocalisation()->getZipcode(),
'nomMedecin' => $slugMedecin,
'idMedecin' => $doctor->getId(),
'ville' => $this->slugify->slugify($practice->getLocalisation()->getCity()),
'idPractice' => $practice->getId(),
)
) . '<br>';
}
// Services.
$servicesDoctors = $serviceDoctorsRepository->findAllHavingDoctolibIframe();
foreach ($servicesDoctors as $serviceDoctor) {
$service = $serviceDoctor->getService();
if ($service->getHospital()->getLocalisation()->getCountry() !== 'FRANCE') {
continue;
}
$doctor = $serviceDoctor->getDoctor();
if (!$doctor || !$practice) continue;
$slugMedecin = $this->slugify->slugify($doctor->getFirstName() . '-' . $doctor->getName());
$urls .= $siteUrl . $this->router->generate(
'page_single_medecin_with_service',
array(
'zipcode' => $service->getHospital()->getLocalisation()->getZipcode(),
'nomMedecin' => $slugMedecin,
'idMedecin' => $doctor->getId(),
'ville' => $this->slugify->slugify($service->getHospital()->getLocalisation()->getCity()),
'idService' => $service->getId()
)
) . '<br>';
}
die($urls);
}
}