<?php
namespace App\Controller;
use Exception;//A voir
use Symfony\Bundle\FrameworkBundle\Controller\Controller;//A voir
use Symfony\Component\HttpFoundation\JsonResponse;//A voir
use App\Entity\Contenu;
use App\Entity\InformationHopital;
use App\Entity\InformationHopitalReferenceHopital;
use App\Entity\Personnalisation;
use App\Entity\PersonnalisationReferenceHopital;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;//A voir
use Symfony\Contracts\Translation\TranslatorInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use App\Repository\ATBGRepository;
use App\Repository\AbbreviationLangueRepository;
use App\Repository\AbbreviationRepository;
use App\Repository\ActualiteRepository;
use App\Repository\AntibiotiqueRepository;
use App\Repository\CasCliniquesCategorieRepository;
use App\Repository\CasCliniquesQuestionRepository;
use App\Repository\CasCliniquesReponseRepository;
use App\Repository\CasCliniquesReponseUtilisateurRepository;
use App\Repository\CelluleRepository;
use App\Repository\CelluleTitreCompletRepository;
use App\Repository\CoAntibiotiqueCalculRepository;
use App\Repository\ContenuRepository;
use App\Repository\EtablissementRepository;
use App\Repository\FamilleAntibiotiqueRepository;
use App\Repository\FavorisRepository;
use App\Repository\InformationHopitalRepository;
use App\Repository\InformationReferenceRepository;
use App\Repository\InformationRepository;
use App\Repository\IntervenantSessioneppRepository;
use App\Repository\LangueRepository;
use App\Repository\MicroorganismeRepository;
use App\Repository\NoteRepository;
use App\Repository\ParametreRepository;
use App\Repository\PaysRepository;
use App\Repository\PersonnalisationRepository;
use App\Repository\PersonnalisationSpectreRepository;
use App\Repository\QualiteRepository;
use App\Repository\ReferenceHopitalRepository;
use App\Repository\ReferenceRepository;
use App\Repository\SessioneppRepository;
use App\Repository\SessioneppUrlRepository;
use App\Repository\SpecialiteRepository;
use App\Repository\SpectreRepository;
use App\Repository\TicketPatientRepository;
use App\Repository\TypeInformationRepository;
use App\Repository\UtilisateurRepository;
use App\Repository\VersionRepository;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use App\Service\EppService;
use App\Service\ContentHandler;
use App\Controller\ReferencesController;
class SituationsCliniquesController extends ATBGController
{
public function __construct(
private AbbreviationLangueRepository $abbreviationLangueRepo,
private AbbreviationRepository $abbreviationRepo,
private ActualiteRepository $actualiteRepo,
private AntibiotiqueRepository $antibiotiqueRepo,
private CasCliniquesCategorieRepository $casCliniquesCategorieRepo,
private CasCliniquesQuestionRepository $casCliniquesQuestionRepo,
private CasCliniquesReponseRepository $casCliniquesReponseRepo,
private CasCliniquesReponseUtilisateurRepository $casCliniquesReponseUtilisateurRepo,
private CelluleRepository $celluleRepo,
private CelluleTitreCompletRepository $celluleTitreCompletRepo,
private CoAntibiotiqueCalculRepository $coAntibiotiqueCalculRepo,
private ContenuRepository $contenuRepo,
private EtablissementRepository $etablissementRepo,
private FamilleAntibiotiqueRepository $familleAntibiotiqueRepository,
private FavorisRepository $favorisRepo,
private InformationHopitalRepository $informationHopitalRepo,
private InformationReferenceRepository $informationReferenceRepo,
private InformationRepository $informationRepo,
private IntervenantSessioneppRepository $intervenantSessioneppRepo,
private LangueRepository $langueRepo,
private MicroorganismeRepository $microorganismeRepo,
private NoteRepository $noteRepo,
private ParametreRepository $parametreRepo,
private PaysRepository $paysRepo,
private PersonnalisationRepository $personnalisationRepo,
private PersonnalisationSpectreRepository $personnalisationSpectreRepo,
private QualiteRepository $qualiteRepo,
private ReferenceHopitalRepository $referenceHopitalRepo,
private ReferenceRepository $referenceRepo,
private SessioneppRepository $sessioneppRepo,
private SessioneppUrlRepository $sessioneppUrlRepo,
private SpecialiteRepository $specialiteRepo,
private SpectreRepository $spectreRepo,
private TicketPatientRepository $ticketPatientRepo,
private TypeInformationRepository $typeInformationRepo,
private UtilisateurRepository $utilisateurRepo,
private VersionRepository $versionRepo,
private TranslatorInterface $translator,
private ContentHandler $gestionBalises,
private ReferencesController $referenceService,
private EppService $eppService,
){}
/**
* Require ROLE_AUTHENTICATED only for this action
*
* @IsGranted("ROLE_AUTHENTICATED")
*/
public function redirectSituationsCliniques($path, Request $request) : RedirectResponse
{
switch ($this->getTypeCategorieCellule($request)) {
case $this->getParameter('categorie_situations_cliniques'):
return $this->redirect($this->get('router')->generate('situations_cliniques_home') . '#/' . $path);
break;
case $this->getParameter('categorie_prophylaxie'):
return $this->redirect($this->get('router')->generate('prophylaxie_home') . '#/' . $path);
break;
case $this->getParameter('categorie_informations_pratiques'):
return $this->redirect($this->get('router')->generate('informations_pratiques_home') . '#/' . $path);
break;
case $this->getParameter('categorie_elements_de_gravite'):
return $this->redirect($this->get('router')->generate('elements_de_gravite_home') . '#/' . $path);
break;
case $this->getParameter('categorie_spectres'):
return $this->redirect($this->get('router')->generate('spectres_home') . '#/' . $path);
break;
case $this->getParameter('categorie_therapeutique'):
return $this->redirect($this->get('router')->generate('therapeutique_home') . '#/' . $path);
break;
case $this->getParameter('categorie_prevention_vaccins'):
return $this->redirect($this->get('router')->generate('prevention_vaccins_home') . '#/' . $path);
break;
case $this->getParameter('categorie_outils_prescriptions'):
return $this->redirect($this->get('router')->generate('outils_prescriptions_home') . '#/' . $path);
break;
}
}
/**
* Require ROLE_AUTHENTICATED only for this action
*
* @IsGranted("ROLE_AUTHENTICATED")
*/
public function index(Request $request)
{
$returned = parent::suppression_parametres_get($request);
if ($returned != null)
{
return $returned;
}
$type_contenu = $this->getTypeCategorieCellule($request);
return $this->render('SituationsCliniques/index.html.twig', array('type_contenu' => $type_contenu));
}
private function getTypeCategorieCellule(Request $request)
{
$routeName = $request->get('_route');
$idCategorie = 0;
switch ($routeName)
{
case 'therapeutique_home':
case 'therapeutique_home_redirect':
case 'therapeutique_sommaire_block':
$idCategorie = $this->getParameter('categorie_therapeutique');
break;
case 'situations_cliniques_node_block':
case 'situations_cliniques_home':
case 'situations_cliniques_home_redirect':
case 'situations_cliniques_sommaire_block':
$idCategorie = $this->getParameter('categorie_situations_cliniques');
break;
case 'prophylaxie_node_block':
case 'prophylaxie_home':
case 'prophylaxie_home_redirect':
case 'prophylaxie_sommaire_block':
$idCategorie = $this->getParameter('categorie_prophylaxie');
break;
case 'prevention_vaccins_node_block':
case 'prevention_vaccins_home':
case 'prevention_vaccins_home_redirect':
case 'prevention_vaccins_sommaire_block':
$idCategorie = $this->getParameter('categorie_prevention_vaccins');
break;
case 'outils_prescriptions_node_block':
case 'outils_prescriptions_home':
case 'outils_prescriptions_home_redirect':
case 'outils_prescriptions_sommaire_block':
$idCategorie = $this->getParameter('categorie_outils_prescriptions');
break;
case 'informations_pratiques_node_block':
case 'informations_pratiques_home':
case 'informations_pratiques_home_redirect':
case 'informations_pratiques_sommaire_block':
$idCategorie = $this->getParameter('categorie_informations_pratiques');
break;
case 'elements_de_gravite_node_block':
case 'elements_de_gravite_home':
case 'elements_de_gravite_home_redirect':
case 'elements_de_gravite_sommaire_block':
$idCategorie = $this->getParameter('categorie_elements_de_gravite');
break;
default:
# code...
break;
}
return $idCategorie;
}
/**
* Require ROLE_AUTHENTICATED only for this action
*
* @IsGranted("ROLE_AUTHENTICATED")
*/
public function detailsInformation($informationId, $type, Request $request)
{
if ($request->isXmlHttpRequest())
{
$em = $this->getDoctrine()->getManager();
if ($type == 'info')
$information = $this->informationRepo->findInformationWithId($informationId);
else
$information = $this->informationHopitalRepo->find($informationId);
$session = $request->getSession();
if ($type == 'info')
$informationsReferences = $this->informationReferenceRepo->findInformationReferenceFromInformation($information);
else
$informationsReferences = $information->getReferencesHopital();
$references = array();
foreach ($informationsReferences as $infoRef)
{
if ($type == 'info')
$references[] = $infoRef->getReference();
else
$references[] = $infoRef->getReferenceHopital();
}
$personnalisation = null;
if ($type == 'info')
{
$personnalisation = $this->personnalisationRepo->findOneBy(array('clientIdAdada' => $session->get('client_id_adada'),'Information' => $information));
if ($personnalisation != null)
{
$references = array();
foreach ($personnalisation->getReferencesHopital() as $infoRef)
{
$references[] = $infoRef->getReferenceHopital();
}
}
}
return $this->render('SituationsCliniques/detail-informations.html.twig',array('personnalisation' => $personnalisation,
'information'=>$information,
'references'=>$references,
'type' => $type));
} else throw $this->createNotFoundException();
}
/**
* Require ROLE_AUTHENTICATED only for this action
*
* @IsGranted("ROLE_AUTHENTICATED")
*/
public function displayNode($nodeId, Request $request)
{
if ($request->isXmlHttpRequest())
{
$idCategorie = $this->getTypeCategorieCellule($request);
$em = $this->getDoctrine()->getManager();
$session = $request->getSession();
$client_id_adada = $session->get('client_id_adada');
$pays_code = $this->parametreRepo->findParametrePaysCode($client_id_adada);
if($client_id_adada == null && $this->getParameter('version_antibiogarde') == 'web_edition') {
$pays = $this->paysRepo->findPaysWithLocale($session->get('_locale'));
if($pays != null) $pays_code = $pays->getCodePays();
}
$antibiotiques = null;
// $antibiotiques = null;
$cellule = $this->celluleRepo->findCelluleWithIdCelluleAndCategorie($nodeId,$idCategorie,$pays_code);
if($cellule != NULL) {
if($cellule->getOrdre() == '999' || $cellule->getOrdre() == '998') {
try{
$antibiotiques = $this->familleAntibiotiqueRepository->findAntibiotiqueGpr(null,$session->get('_locale'));
}
catch(Exception $e){
$antibiotiques = $e->getMessage();
}
}
elseif($cellule->getOrdre() == '996') {
$boutique_adada = $this->container->get('doctrine')->getConnection('adada');
$stmt = $boutique_adada->prepare("SELECT client_vidal as connexion_vidal, client_cbip as connexion_cbip FROM ADADA_CLIENT WHERE client_id = :client_id");
$stmt->bindValue('client_id', $client_id_adada);
$stmt = $stmt->execute();
$result = $stmt->fetchAll();
if (count($result) == 1){
$vidal = (bool) $result[0]['connexion_vidal'];
$cbip = (bool) $result[0]['connexion_cbip'];
}
try{
$antibiotiques = $this->familleAntibiotiqueRepository->findAntibiotiqueCbipVidal(null,$session->get('_locale'), $vidal, $cbip, $pays_code);
}
catch(Exception $e){
$antibiotiques = $e->getMessage();
}
}
}
$parents = array();
$content = '';
$isTrueNode = true;
if ($cellule != null /*&& $cellule->getOrdre() != '999'*/)
{
foreach ($cellule->getCellulesPeres() as $cellule_pere)
{
if ($cellule_pere->getCategorieCellule() == $cellule->getCategorieCellule())
{
$parents[] = $cellule_pere->getIdCellule();
}
if($cellule_pere->getAfficherFils() == 1)
{
foreach ($cellule_pere->getCellulesPeres() as $cellule_pere_pere)
{
if ($cellule_pere_pere->getCategorieCellule() == $cellule->getCategorieCellule())
{
$parents[] = $cellule_pere_pere->getIdCellule();
}
}
}
}
$pays = $this->paysRepo->findPaysWithCodePays($pays_code);
$content = $this->render('SituationsCliniques/situation-clinique.html.twig', array('antibiotiques' => $antibiotiques, 'situation' => $cellule, 'pays' => $pays))->getContent();
}
else
{
$isTrueNode = false;
}
return new JsonResponse( array (
'responseCode' => 0,
'nodeId' => $nodeId*1,
'content' => $content,
'isTrueNode' => $isTrueNode,
'parentNodes' => $parents
));
} else throw $this->createNotFoundException();
}
/**
* Require ROLE_AUTHENTICATED only for this action
*
* @IsGranted("ROLE_AUTHENTICATED")
*/
public function displayReferences($nodeId, Request $request)
{
if ($request->isXmlHttpRequest())
{
$session = $request->getSession();
$client_id_adada = $session->get('client_id_adada');
$em = $this->getDoctrine()->getManager();
$pays_code = $this->parametreRepo->findParametrePaysCode($client_id_adada);
if($client_id_adada == null && $this->getParameter('version_antibiogarde') == 'web_edition') {
$pays = $this->paysRepo->findPaysWithLocale($session->get('_locale'));
if($pays != null) $pays_code = $pays->getCodePays();
}
$references = $this->referenceRepo->findReferencesWithNodeId($nodeId,$pays_code);
$references_locales = $this->referenceRepo->findReferencesHopitalWithNodeId($nodeId,$client_id_adada);
$content = $this->render('SituationsCliniques/references.html.twig', array('idcellule' => $nodeId, 'references' => $references,'references_locales' => $references_locales))->getContent();
return new JsonResponse( array (
'responseCode' => 0,
'nodeId' => $nodeId*1,
'content' => $content,
));
} else throw $this->createNotFoundException();
}
/**
* Require ROLE_AUTHENTICATED only for this action
*
* @IsGranted("ROLE_AUTHENTICATED")
*/
public function displaySommaire(Request $request, $selectedId)
{
if ($request->isXmlHttpRequest())
{
$session = $request->getSession();
$client_id_adada = $session->get('client_id_adada');
$em = $this->getDoctrine()->getManager();
$pays_code = $this->parametreRepo->findParametrePaysCode($client_id_adada);
if($client_id_adada == null && $this->getParameter('version_antibiogarde') == 'web_edition') {
$pays = $this->paysRepo->findPaysWithLocale($session->get('_locale'));
if($pays != null) $pays_code = $pays->getCodePays();
}
$idCategorie = $this->getTypeCategorieCellule($request);
$parents = $this->celluleRepo->getSommaire($idCategorie,$session->get("_locale"),$pays_code);
$content = $this->render('SituationsCliniques/situation-clinique-sommaire-titre.html.twig', array('type_contenu' => $idCategorie))->getContent();
foreach ($parents as $cellule) {
if($cellule->getOrdre() == 997 || $cellule->getOrdre() == 995){
$contentFictif = new Contenu();
$cellule->addContenus($contentFictif);
$content .= $this->render('SituationsCliniques/situation-clinique-sommaire.html.twig', array('cellule' => $cellule, 'selectedId' => $selectedId))->getContent();
}
// Pour la cellule BASE DE DONNEES RCP dans le menu "outils de prescription", si le client à cocher connexion vidal ou cbip, on lui affiche le menu
elseif($cellule->getOrdre() == 996) {
//if ($this->container->getParameter('version_antibiogarde') == 'web_hopital')
$boutique_adada = $this->container->get('doctrine')->getConnection('adada');
$stmt = $boutique_adada->prepare("SELECT client_vidal as connexion_vidal, client_cbip as connexion_cbip FROM ADADA_CLIENT WHERE client_id = :client_id");
$stmt->bindValue('client_id', $client_id_adada);
$stmt = $stmt->execute();
$result = $stmt->fetchAll();
if (count($result) == 1){
$vidal = (bool) $result[0]['connexion_vidal'];
$cbip = (bool) $result[0]['connexion_cbip'];
if($vidal == true || $cbip == true) {
$content .= $this->render('SituationsCliniques/situation-clinique-sommaire.html.twig', array('cellule' => $cellule, 'selectedId' => $selectedId))->getContent();
}
}
}
else{
$content .= $this->render('SituationsCliniques/situation-clinique-sommaire.html.twig', array('cellule' => $cellule, 'selectedId' => $selectedId))->getContent();
}
}
return new JsonResponse( array (
'responseCode' => 0,
'content' => $content
));
} else throw $this->createNotFoundException();
}
/**
* Require ROLE_AUTHENTICATED only for this action
*
* @IsGranted("ROLE_AUTHENTICATED")
*/
public function contenuAntibiotique(Request $request, $id, $parentId)
{
if ($request->isXmlHttpRequest())
{
// $idCategorie = $this->getTypeCategorieCellule($request);
$session = $request->getSession();
$client_id_adada = $session->get('client_id_adada');
$em = $this->getDoctrine()->getManager();
$pays_code = $this->parametreRepo->findParametrePaysCode($client_id_adada);
if($client_id_adada == null && $this->getParameter('version_antibiogarde') == 'web_edition') {
$pays = $this->paysRepo->findPaysWithLocale($session->get('_locale'));
if($pays != null) $pays_code = $pays->getCodePays();
}
$antibiotique = $this->antibiotiqueRepo->find($id);
// foreach($antibiotique->getFamillesAntibiotiques() as $famille){
// dump($famille);
// die();
// }
$famille = $antibiotique->getFamillesAntibiotiques()[0];
$cellulePere = $this->celluleRepo->findCelluleWithIdCellule($parentId);
if($cellulePere->getOrdre() == 996){
$correspondancesVidal = $this->antibiotiqueRepo->findCorrespondanceVidal($id,$pays_code);
$correspondancesCBIP = $this->antibiotiqueRepo->findCorrespondanceCBIP($id,$pays_code);
$contentParam = array('famille' => $famille, 'antibiotique' => $antibiotique, 'correspondancesVidal' => $correspondancesVidal, 'correspondancesCBIP' => $correspondancesCBIP);
$content = $this->render('SituationsCliniques/base-rcp.html.twig', $contentParam)->getContent();
}else{
$correspondancesGPR = $this->antibiotiqueRepo->findCorrespondanceGPR($id,$pays_code);
$contentParam = array('correspondancesGPR' => $correspondancesGPR, 'famille' => $famille, 'antibiotique' => $antibiotique);
$content = $this->render('SituationsCliniques/calcul-poso.html.twig', $contentParam)->getContent();
}
return new JsonResponse( array (
'responseCode' => 0,
'content' => $content
));
#region
// $cellule = $this->celluleRepo->findCelluleWithIdCelluleAndCategorie($idCellule,$idCategorie);
// $celluleParent = $this->celluleRepo->findCelluleWithIdCelluleAndCategorie($idCelluleParent,$idCategorie);
// $titresComplets = $this->celluleTitreCompletRepo->findAllTitresCompletsWithIdCellule($idCellule,$cellule->getCategorieCellule()->getIdCategorieCellule());
// $contenus = $this->contenuRepo->findContenusWithIdCellule($idCellule,null,$pays_code);
// $personnalisations = array();
// if ($this->container->getParameter('version_antibiogarde') != 'web_edition')
// {
// foreach ($contenus as $contenu) {
// $personnalisation = $this->personnalisationRepo->findOneBy(array(
// 'clientIdAdada' => $client_id_adada,
// 'Contenu' => $contenu));
// if ($personnalisation == null)
// $personnalisation = new Personnalisation();
// $personnalisations[] = $personnalisation;
// }
// }
// $affPerso = $this->parametreRepo->findParametreAffichagePersonnalisations($client_id_adada);
// //Epp collective
// $sessionepp = $this->sessioneppRepo->findOneby(array('etatSession' => 0,'clientIdAdada' => $client_id_adada));
// $sessionurl = null;
// if ($sessionepp != null)
// {
// $sessionurl = $this->sessioneppUrlRepo->getSessioneppUrlForIdCellule($idCellule,$client_id_adada);
// }
// $content = $this->render('SituationsCliniques/situation-clinique-contenus.html.twig',
// array( 'cellule'=>$cellule,
// 'celluleParent'=>$celluleParent,
// 'contenus'=>$contenus,
// 'titresComplets'=>$titresComplets,
// 'personnalisations' => $personnalisations,
// 'affichage_personnalisation' => $affPerso->getValeur(),
// 'sessionurl' => $sessionurl
// ));
// return new JsonResponse( array (
// 'responseCode' => 0,
// 'content' => $content
// ));
#endregion
} else throw $this->createNotFoundException();
}
/**
* Require ROLE_AUTHENTICATED only for this action
*
* @IsGranted("ROLE_AUTHENTICATED")
*/
public function contenu($idCellule, $idCelluleParent, Request $request)
{
if ($request->isXmlHttpRequest())
{
$idCategorie = $this->getTypeCategorieCellule($request);
$session = $request->getSession();
$client_id_adada = $session->get('client_id_adada');
$em = $this->getDoctrine()->getManager();
$pays_code = $this->parametreRepo->findParametrePaysCode($client_id_adada);
if($client_id_adada == null && $this->getParameter('version_antibiogarde') == 'web_edition') {
$pays = $this->paysRepo->findPaysWithLocale($session->get('_locale'));
if($pays != null) $pays_code = $pays->getCodePays();
}
$cellule = $this->celluleRepo->findCelluleWithIdCelluleAndCategorie($idCellule,$idCategorie);
$celluleParent = $this->celluleRepo->findCelluleWithIdCelluleAndCategorie($idCelluleParent,$idCategorie);
$titresComplets = $this->celluleTitreCompletRepo->findAllTitresCompletsWithIdCellule($idCellule,$cellule->getCategorieCellule()->getIdCategorieCellule());
$contenus = $this->contenuRepo->findContenusWithIdCellule($idCellule,null,$pays_code);
$personnalisations = array();
if ($this->getParameter('version_antibiogarde') != 'web_edition')
{
foreach ($contenus as $contenu) {
$personnalisation = $this->personnalisationRepo->findOneBy(array(
'clientIdAdada' => $client_id_adada,
'Contenu' => $contenu));
if ($personnalisation == null)
$personnalisation = new Personnalisation();
$personnalisations[] = $personnalisation;
}
}
$affPerso = $this->parametreRepo->findParametreAffichagePersonnalisations($client_id_adada);
//Epp collective
$sessionepp = $this->sessioneppRepo->findOneby(array('etatSession' => 0,'clientIdAdada' => $client_id_adada));
$sessionurl = null;
if ($sessionepp != null)
{
$sessionurl = $this->sessioneppUrlRepo->getSessioneppUrlForIdCellule($idCellule,$client_id_adada);
}
if($cellule->getOrdre() == 997){
$content = $this->render('SituationsCliniques/calcul-poso-obesite.html.twig')->getContent();
}
else if(count($contenus) == 1 && $contenus[0]->getTypeContenu() != NULL)
{
if($contenus[0]->getTypeContenu()->getLibelleTypeContenuFR() == "Lien"){
foreach($contenus[0]->getContenulangues() as $contenulangue){
if($contenulangue->getLangue()->getCode() == $session->get("_locale")){
$url = $contenulangue->getContenuhtml();
}
}
$content = $this->render('SituationsCliniques/redirect.html.twig', array('url'=> $url))->getContent();
}
else {
$content = $this->render('SituationsCliniques/situation-clinique-contenus.html.twig',
array( 'cellule'=>$cellule,
'celluleParent'=>$celluleParent,
'contenus'=>$contenus,
'titresComplets'=>$titresComplets,
'personnalisations' => $personnalisations,
'affichage_personnalisation' => $affPerso->getValeur(),
'sessionurl' => $sessionurl
))->getContent();
}
}
else{
$content = $this->render('SituationsCliniques/situation-clinique-contenus.html.twig',
array( 'cellule'=>$cellule,
'celluleParent'=>$celluleParent,
'contenus'=>$contenus,
'titresComplets'=>$titresComplets,
'personnalisations' => $personnalisations,
'affichage_personnalisation' => $affPerso->getValeur(),
'sessionurl' => $sessionurl
))->getContent();
}
return new JsonResponse( array (
'responseCode' => 0,
'content' => $content
));
} else throw $this->createNotFoundException();
}
/**
* Require ROLE_AUTHENTICATED only for this action
*
* @IsGranted("ROLE_AUTHENTICATED")
*/
public function recherche(Request $request)
{
if ($request->isXmlHttpRequest())
{
$content = $this->render('SituationsCliniques/recherche.html.twig');
return new JsonResponse( array (
'responseCode' => 0,
'content' => $content->getContent()
));
} else throw $this->createNotFoundException();
}
//Utiliser uniquement pour rechercher
private function recursiveTitle(Request $request, &$objs, &$cell, $cellForId, $cellForTitre, $prefixe = '', $path = array())
{
$em = $this->getDoctrine()->getManager();
$session = $request->getSession();
$prefixe_initial = $prefixe;
if ($this->gestionBalises->checkValiditeArborescenceCellule($cell))
{
foreach ($cell->getCellulesPeres() as $pere)
{
$path_next = $path;
$prefixe = ($pere->getTitrelong($session->get("_locale")) != '' ? $pere->getTitrelong($session->get("_locale")) : $pere->getTitrecourt($session->get("_locale"))) . ($prefixe_initial != '' ? ' » ' . $prefixe_initial : '');
if ($pere->getAfficherFils() == 0)
$path_next[] = $pere->getIdCellule();
$this->recursiveTitle($request, $objs, $pere, $cellForId, $cellForTitre, $prefixe, $path_next);
}
// on arrive au sommaire
if (count($cell->getCellulesPeres()) == 0 && $this->gestionBalises->checkValiditeArborescenceCellule($cell))
{
$path = array_reverse($path);
// Le sommaire est une redite du premier bloc. Il ne faut donc pas le remettre.
$name = (($prefixe != '') ? $prefixe . ' » ' : "") . ($cellForTitre->getTitrelong($session->get("_locale")) != '' ? $cellForTitre->getTitrelong($session->get("_locale")) : $cellForTitre->getTitrecourt($session->get("_locale")));
switch ($cell->getCategorieCellule()->getIdCategorieCellule()) {
case $this->getParameter("categorie_situations_cliniques"):
$name = $this->translator->trans("sc_sc")." » ".$name;
break;
case $this->getParameter("categorie_prophylaxie"):
$name = $this->translator->trans("sc_prophylaxie")." » ".$name;
break;
case $this->getParameter("categorie_informations_pratiques"):
$name = $this->translator->trans("sc_informations_pratiques")." » ".$name;
break;
case $this->getParameter("categorie_elements_de_gravite"):
$name = $this->translator->trans("sc_elements_de_gravite")." » ".$name;
break;
}
$new = array('balise' => 'cell', 'id' => $cellForId->getIdCellule(), 'name' => $name, 'path' => implode('/', $path));
$objs[] = $new;
}
}
}
static function cmp($a, $b)
{
if ($a['name'] == $b['name']) {
return 0;
}
return ($a['name'] < $b['name']) ? -1 : 1;
}
/**
* Require ROLE_AUTHENTICATED only for this action
*
* @IsGranted("ROLE_AUTHENTICATED")
*/
public function rechercher(Request $request)
{
if ($request->isXmlHttpRequest())
{
$term = $request->get('term');
$session = $request->getSession();
$client_id_adada = $session->get('client_id_adada');
$em = $this->getDoctrine()->getManager();
$pays_code = $this->parametreRepo->findParametrePaysCode($client_id_adada);
if($client_id_adada == null && $this->getParameter('version_antibiogarde') == 'web_edition') {
$pays = $this->paysRepo->findPaysWithLocale($session->get('_locale'));
if($pays != null) $pays_code = $pays->getCodePays();
}
$cellules = $this->celluleRepo->findCelluleFromName($term,$session->get("_locale"),$pays_code);
$objs = array();
foreach ($cellules as $obj)
{
$this->recursiveTitle($request, $objs, $obj, $obj, $obj);
}
usort($objs, array("App\Controller\SituationsCliniquesController", "cmp"));
return new JsonResponse($objs);
} else throw $this->createNotFoundException();
}
/**
* Require ROLE_REFERENT only for this action
*
* @IsGranted("ROLE_REFERENT")
*/
public function information_personnalisation_delete($id, Request $request)
{
$session = $request->getSession();
$client_id_adada = $session->get('client_id_adada');
$em = $this->getDoctrine()->getManager();
$information = $this->informationRepo->findInformationWithId($id);
if ($information != null)
{
$personnalisation = $this->personnalisationRepo->findOneBy(array(
'clientIdAdada' => $client_id_adada,
'Information' => $information));
if ($personnalisation != null)
{
foreach ($personnalisation->getReferencesHopital() as $reference) {
$em->remove($reference);
}
$em->remove($personnalisation);
$em->flush();
}
}
return $this->redirectToRoute('information_personnalisation_form', array( 'id' => $id, 'delete' => 1));
}
/**
* Require ROLE_REFERENT only for this action
*
* @IsGranted("ROLE_REFERENT")
*/
public function information_personnalisation_form($id, $delete, Request $request)
{
$session = $request->getSession();
$client_id_adada = $session->get('client_id_adada');
$em = $this->getDoctrine()->getManager();
$errors = array();
$message = '';
if ($delete)
{
$message = $this->translator->trans("sc_suppression_enregistree");
}
$balise = null;
$personnalisation = null;
$information = $this->informationRepo->findInformationWithId($id);
if ($information != null)
{
$personnalisation = $this->personnalisationRepo->findOneBy(array(
'clientIdAdada' => $client_id_adada,
'Information' => $information));
} else throw $this->createNotFoundException();
$references = Array();
if ($personnalisation == null)
{
$personnalisation = new Personnalisation();
$personnalisation->setClientIdAdada($client_id_adada);
$personnalisation->setInformation($information);
$personnalisation->setContenuhtml($information->getContenuhtml($session->get('_locale')));
foreach ($information->getReferences() as $informationreference) {
$references[] = clone $informationreference->getReference();
}
}
else
{
foreach ($personnalisation->getReferencesHopital() as $personnalisationReference) {
$references[] = $personnalisationReference->getReferenceHopital();
}
}
if ($request->isMethod('POST')) {
$personnalisation->setContenuhtml($request->request->get('contenuHtml'));
$errors_references = array();
$references = $this->referenceService->parseReferences($request, $this->container, $em, $errors_references);
if (count($errors_references) == 0 && count($errors) == 0)
{
if ($personnalisation->getIdPersonnalisation() == null)
$em->persist($personnalisation);
$indice_ref = 1;
foreach ($references as $reference) {
if ($reference->getIdReference() == null)
{
$em->persist($reference);
$ref = new PersonnalisationReferenceHopital();
$ref->setOrdre($indice_ref);
$ref->setPersonnalisation($personnalisation);
$ref->setReferenceHopital($reference);
$em->persist($ref);
$indice_ref++;
}
}
$em->flush();
$this->referenceService->validateUpload($request, $this->container);
$balise = $this->render('Blocnotes/info.html.twig', array('information' => $information));
$balise = addslashes($balise);
$message = $this->translator->trans("sc_modifications_enregistrees");
}
$errors['references'] = $errors_references;
}
$render_references = $this->referenceService->renderReferences($this->container, $em, $references, $errors_references);
return $this->render('SituationsCliniques/information-personnalisation-form.html.twig', array('balise' => $balise, 'references' => $render_references, 'personnalisation' => $personnalisation, 'information' => $information, 'errors' => $errors, 'message' => $message));
}
/**
* Require ROLE_REFERENT only for this action
*
* @IsGranted("ROLE_REFERENT")
*/
public function information_hopital_form($id, $new, Request $request)
{
$errors = array();
$message = '';
$balise = null;
$session = $request->getSession();
$client_id_adada = $session->get('client_id_adada');
$em = $this->getDoctrine()->getManager();
if ($id > 0)
$informationHopital = $this->informationHopitalRepo->find($id);
else
$informationHopital = new InformationHopital();
$informationHopitalReferences = $informationHopital->getReferencesHopital();
$references = Array();
foreach ($informationHopitalReferences as $informationHopitalReference) {
$references[] = $informationHopitalReference->getReferenceHopital();
}
$sortType = 'libelleTypeInformation'.strtoupper($session->get('_locale'));
$typesInformation = $this->typeInformationRepo->findBy(array(), array($sortType => 'ASC'));
if ($request->isMethod('POST')) {
if ($request->request->get('typeInformation') == '')
{
$errors['typeInformation'] = $this->translator->trans("sc_selectionner_type_informations");
$references = $this->referenceService->parseReferences($request, $this->container, $em, $errors_references);
}
else
{
$typeInformation = $this->typeInformationRepo->findOneByIdTypeInformation($request->request->get('typeInformation'));
if ($typeInformation == null)
$errors['typeInformation'] = $this->translator->trans("sc_selectionner_type_informations");
$informationHopital->setTypeInformation($typeInformation);
$errors_references = array();
$references = $this->referenceService->parseReferences($request, $this->container, $em, $errors_references);
if (count($errors_references) == 0 && count($errors) == 0)
{
$informationHopital->setClientIdAdada($client_id_adada);
// form is valid
$informationHopital->setContenuhtml($request->request->get('contenuHtml'));
if ($informationHopital->getIdInformation() == null)
$em->persist($informationHopital);
$indice_ref = 1;
foreach ($references as $reference) {
if ($reference->getIdReference() == null)
{
$em->persist($reference);
$ref = new InformationHopitalReferenceHopital();
$ref->setOrdre($indice_ref);
$ref->setInformationHopital($informationHopital);
$ref->setReferenceHopital($reference);
$em->persist($ref);
$indice_ref++;
}
}
$em->flush();
$this->referenceService->validateUpload($request, $this->container);
$balise = $this->render('Blocnotes/infohopital.html.twig', array('informationHopital' => $informationHopital));
$balise = addslashes($balise->getContent());
$message = $this->translator->trans("sc_modifications_enregistrees");
}
$errors['references'] = $errors_references;
}
}
$render_references = $this->referenceService->renderReferences($this->container, $em, $references, $errors_references);
return $this->render('SituationsCliniques/information-hopital-form.html.twig', array('new' => $new, 'balise' => $balise, 'typesInformation' => $typesInformation, 'informationHopital' => $informationHopital, 'errors' => $errors, 'references' => $render_references, 'message' => $message));
}
public function reload_references(Request $request)
{
$em = $this->getDoctrine()->getManager();
$errors_references = array();
$references = $this->referenceService->parseReferences($request, $this->container, $em, $errors_references);
$render_references = array();
$errors = array();
$indice = 1;
foreach ($references as $ref)
{
$idTypeReference = $ref->getTypeReference()->getIdTypeReference();
switch ($idTypeReference)
{
case $this->getParameter('type_reference_lien'):
$render_references[$indice] = $this->container->get('twig')->render('References/lien.html.twig', array( 'indice' => $indice, 'onCreation' => true, 'reference' => $ref, 'errors' => null));
break;
case $this->getParameter('type_reference_note'):
$render_references[$indice] = $this->container->get('twig')->render('References/note.html.twig', array( 'indice' => $indice, 'onCreation' => true, 'reference' => $ref, 'errors' => null));
break;
case $this->getParameter('type_reference_fichier'):
$render_references[$indice] = $this->container->get('twig')->render('References/fichier.html.twig', array( 'indice' => $indice, 'onCreation' => true, 'reference' => $ref, 'errors' => null));
break;
case $this->getParameter('type_reference_image'):
$render_references[$indice] = $this->container->get('twig')->render('References/image.html.twig', array( 'indice' => $indice, 'onCreation' => true, 'reference' => $ref, 'errors' => null));
break;
case $this->getParameter('type_reference_texte'):
$render_references[$indice] = $this->container->get('twig')->render('References/texte.html.twig', array( 'indice' => $indice, 'onCreation' => true, 'reference' => $ref, 'errors' => null));
break;
default:
# code...
break;
}
if (array_key_exists($indice, $errors_references))
{
$errors[$indice] = '<div class="alert alert-danger">'.$errors_references[$indice].'</div>';
}
else
{
$errors[$indice] = '';
}
$indice++;
}
// $render_references = $this->referenceService->renderReferences($this->container, $em, $references, $errors_references,0,true);
return new JsonResponse( array (
'responseCode' => 0,
'content' => $render_references,
'errors' => $errors
));
}
/**
* Require ROLE_REFERENT only for this action
*
* @IsGranted("ROLE_REFERENT")
*/
public function contenu_personnalisation_delete($id,$pathPage, Request $request)
{
$session = $request->getSession();
$client_id_adada = $session->get('client_id_adada');
$em = $this->getDoctrine()->getManager();
$contenu = $this->contenuRepo->findContenuWithId($id,true);
if ($contenu != null)
{
$personnalisation = $this->personnalisationRepo->findOneBy(array(
'clientIdAdada' => $client_id_adada,
'Contenu' => $contenu));
if ($personnalisation != null)
{
foreach ($personnalisation->getReferencesHopital() as $reference) {
$em->remove($reference);
}
$em->remove($personnalisation);
$em->flush();
$this->eppService->majSessionEppURL($pathPage,$contenu->getCellule()->getCategorieCellule()->getIdCategorieCellule(),$contenu->getCellule(),true);
}
}
return $this->redirectToRoute('contenu_personnalisation_form', array( 'id' => $id,'pathPage' => $pathPage, 'delete' => 1));
}
/**
* Require ROLE_REFERENT only for this action
*
* @IsGranted("ROLE_REFERENT")
*/
public function contenu_personnalisation_form($id,$pathPage,$delete, Request $request)
{
$session = $request->getSession();
$client_id_adada = $session->get('client_id_adada');
$em = $this->getDoctrine()->getManager();
$errors = array();
$message = '';
if ($delete)
{
$message = $this->translator->trans("sc_suppression_enregistree");
}
$balise = null;
$personnalisation = null;
$contenu = $this->contenuRepo->findContenuWithId($id,true);
if ($contenu != null)
{
$personnalisation = $this->personnalisationRepo->findOneBy(array(
'clientIdAdada' => $client_id_adada,
'Contenu' => $contenu));
} else throw $this->createNotFoundException();
if ($personnalisation == null)
{
$personnalisation = new Personnalisation();
$personnalisation->setClientIdAdada($client_id_adada);
$personnalisation->setContenu($contenu);
$personnalisation->setContenuhtml($contenu->getContenuhtml($session->get('_locale')));
}
if ($request->isMethod('POST')) {
$personnalisation->setContenuhtml($this->gestionBalises->format_from_tinymce_to_bdd(trim($request->request->get('contenuHtml'))));
if ($personnalisation->getIdPersonnalisation() == null)
$em->persist($personnalisation);
$em->flush();
$this->eppService->majSessionEppURL($pathPage,$contenu->getCellule()->getCategorieCellule()->getIdCategorieCellule(),$contenu->getCellule(),false);
$message = $this->translator->trans("sc_modifications_enregistrees");
}
return $this->render('SituationsCliniques/contenu-personnalisation-form.html.twig', array('personnalisation' => $personnalisation,'pathPage' => $pathPage,'contenu' => $contenu, 'errors' => $errors, 'message' => $message));
}
}