<?php
namespace App\Controller;
use Dompdf\Dompdf;
use App\Entity\DfGeneraliste;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use App\Entity\RemplacentGeneraliste;
use App\Form\RemplacentGeneralisteType;
use App\Entity\Prescriptions;
use App\Entity\Consultation;
use App\Entity\Examenbiologique;
use App\Entity\Examenmorphologique;
use App\Form\ConsultationType;
use App\Form\Consultation2Type;
use App\Form\Consultation2ModifType;
use App\Entity\Nomenclature2023;
use App\Form\Nomenclature2023Type;
use Knp\Component\Pager\PaginatorInterface;
use App\Form\DfGeneraliste1Type;
use App\Form\DfGeneraliste11Type;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\SecretairesGeneraliste;
use App\Form\SecretairesGeneraliste2Type;
use App\Entity\Patients;
use App\Entity\Reservationgeneraliste;
use App\Form\PatientsType;
use App\Form\PatientsAgendaType;
use App\Form\PatientsInfoType;
use App\Form\ReservationgeneralisteType;
use Symfony\Component\HttpFoundation\Request;
use Doctrine\Persistence\ManagerRegistry as PersistenceManagerRegistry;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Validator\Constraints\DateTime;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use App\Entity\User;
use App\Form\SecretairesGeneralisteType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\TimeType;
use App\Form\DfGeneralisteType;
use App\Form\PrescriptionType;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoder;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
use Symfony\Component\Validator\Constraints\Date;
class DashboardController extends AbstractController
{
/**
* @Route("/", name="app_home")
*/
public function index(): Response
{
return $this->render('dashboard/index.html.twig', [
'controller_name'=> 'controller_name',
]);
}
/**
* @Route("dashboard/infoconsultation", name="infoconsultation_dashboard", methods={"GET", "POST"})
*/
public function infoConsultation(Request $request, Patients $reservationgeneraliste, EntityManagerInterface $entityManager): Response
{
$resPatient = $entityManager->getRepository(Reservationgeneraliste::class);
$idRes = $resPatient->findOneBy(['resdoc' => '19', 'respatient'=> '120', 'datres'=>'2024-07-18']);
$consultationRepository = $entityManager->getRepository(Consultation::class);
$infoConsultations = $consultationRepository->findOneBy(['id' => $idRes]);
var_dump($infoConsultations);
}
/**
* @Route("/dashboard", name="app_dashboard", methods={"GET", "POST"})
*/
public function indexdashboard(PersistenceManagerRegistry $doctrine, EntityManagerInterface $entityManager, UserInterface $user, Request $request): Response
{
$em=$doctrine->getManager();
//$em= $doctrine;
//$medecinsRepository = $em->getRepository(DfGeneraliste::class);
$user = $this->getUser();
//$medecinsRepository = $em->getRepository(SecretairesGeneraliste::class);
//$user = $this->getUser();
$roleUser = $user->getRoles();
//var_dump($roleUser[0]);
//var_dump("sofiane");
//$roleUser = ["ROLE_ADMIN"];
//exit(\Doctrine\Common\Util\Debug::dump($roleUser));
if($roleUser[0]=="ROLE_ADMIN"){
$medecinsRepository = $em->getRepository(DfGeneraliste::class);
$profileDocteur = $medecinsRepository->findOneBy(['email' => $user->getUsername()]);
$resPatient = $entityManager->getRepository(Reservationgeneraliste::class);
$resPatientbyDoc = $resPatient->findBy(['resdoc' => $profileDocteur->getId()]);
//$resPatientbyDoc = $resPatient->findBy(['resdoc' => $profileDocteur->getId(), 'dateres' => '2024-07-26']);
$resPatientbyDoc2 = $resPatient->findOneBy(['resdoc' => $profileDocteur->getId()]);
$patientRepository = $entityManager->getRepository(Patients::class);
//$profilePatient23 = $patientRepository->findOneBy(['id' => $resPatientbyDoc2->getRespatient()]);
//$resPatientbyDoc23 = $resPatient->findOneBy(['respatient' => $profilePatient23->getId()]);
//$idRes = $resPatient->findOneBy(['resdoc' => 19, 'respatient'=> 121]);
$consultationRepository = $entityManager->getRepository(Consultation::class);
$consultationExamenBioRepository = $entityManager->getRepository(Examenbiologique::class);
$consultationExamenMorphoRepository = $entityManager->getRepository(Examenmorphologique::class);
$consultationPrescriptionRepository = $entityManager->getRepository(Prescriptions::class);
$infoConsultations = null;
$infoConsultationsExamenBio = null;
$infoConsultationsExamenMorpho = null;
if($resPatientbyDoc2){
$infoConsultations = $consultationRepository->findById(['id' => $resPatientbyDoc2->getId()]);
//var_dump($infoConsultations);
}
$test = [];
$testconsult = [];
foreach ($resPatientbyDoc as $key) {
$test[] = $key->getRespatient();
$testconsult[] = $key->getId();
}
$patients = $entityManager
->getRepository(Patients::class)
->findById($test);
$infoConsultations = $entityManager
->getRepository(Consultation::class)
->findBy(['numres' => $testconsult]);
$infoConsultations2 = $entityManager
->getRepository(Consultation::class)
->findOneBy(['numres' => $testconsult]);
//var_dump(count($test));
//var_dump(count($testconsult));
//var_dump(count($patients));
//var_dump(count($infoConsultations));
$infoConsultationsExamenBio = $consultationExamenBioRepository->findOneBy(['idconsultation' => $infoConsultations]);
$infoConsultationsExamenMorpho = $consultationExamenMorphoRepository->findOneBy(['idconsultation' => $infoConsultations]);
$infoConsultationsPrescription = $consultationPrescriptionRepository->findOneBy(['id' => $infoConsultations]);
//array result
$infoConsultationsExamenBio = $consultationExamenBioRepository->findBy(['idconsultation' => $infoConsultations]);
$infoConsultationsExamenMorpho = $consultationExamenMorphoRepository->findBy(['idconsultation' => $infoConsultations]);
$infoConsultationsPrescription = $consultationPrescriptionRepository->findBy(['id' => $infoConsultations]);
//var_dump($infoConsultationsExamenBio->getId());
//var_dump(count($infoConsultationsExamenBio));
$consultation = new Consultation();
$formConsultation = $this->createForm(Consultation2Type::class, $consultation);
$formConsultation->handleRequest($request);
$consultationmodif = new Consultation();
$formConsultationmodif = $this->createForm(Consultation2ModifType::class, $consultationmodif);
$formConsultationmodif->handleRequest($request);
$fPrescription = new Prescriptions();
$formPrescription = $this->createForm(PrescriptionType::class, $fPrescription);
$formPrescription->handleRequest($request);
$formMed = $this->createFormBuilder()
->add('medicament', TextType::class, array('property_path' => 'userinput'))
->getForm();
$formMedok = $this->createFormBuilder()
->add('medicament', TextType::class, array('property_path' => 'userinput', 'required' => false))
->getForm();
$nomenclature2023s = $entityManager
->getRepository(Nomenclature2023::class)
->findAll();
if ($request->isMethod('post') && $formConsultation->isSubmitted() && $formConsultation->isValid()) {
$idRes = $resPatient->findOneBy(['resdoc' => $profileDocteur->getId(), 'respatient'=> $formConsultation->get('idresform')->getData()]);
$consultation->setNumres($idRes);
$entityManager->persist($consultation);
$entityManager->flush();
$profileCurrentPatient = $patientRepository->findOneBy(['id' => $formConsultation->get('idresform')->getData()]);
$profileCurrentPatient->setNom($formConsultation->get('nompatient')->getData());
$entityManager->persist($profileCurrentPatient);
$entityManager->flush();
$resCurrentPatient = $resPatient->findOneBy(['resdoc' => $profileDocteur->getId(), 'respatient'=> $formConsultation->get('idresform')->getData()]);
$resCurrentPatient->setAtcdPersoMedicaux($formConsultation->get('Atcdpersomedicaux')->getData());
$resCurrentPatient->setconsultationDone("1");
$entityManager->persist($resCurrentPatient);
$entityManager->flush();
$examenBio = new Examenbiologique();
$examenBio->setNomexamen($formConsultation->get("nomexamencomplementairebio")->getData());
$examenBio->setDateexamen($formConsultation->get("examencomplementairebiodate")->getData());
$examenBio->setConclusionexamen($formConsultation->get("examencomplementairebioconclusion")->getData());
$examenBio->setIdconsultation($consultation);
$entityManager->persist($examenBio);
$entityManager->flush();
$examenMorpho = new Examenmorphologique();
$examenMorpho->setNomexamen($formConsultation->get("nomexamencomplementairemorpho")->getData());
$examenMorpho->setDateexamen($formConsultation->get("examencomplementairemorphodate")->getData());
$examenMorpho->setConclusionexamen($formConsultation->get("examencomplementairemorphoconclusion")->getData());
$examenMorpho->setIdconsultation($consultation);
$entityManager->persist($examenMorpho);
$entityManager->flush();
//echo("sofiane dump");
//echo($prescription);
$prescription = $formConsultation->get("prescription")->getData();
$prescription = explode (";;", $prescription);
foreach ($prescription as $ppp) {
$prescri = new Prescriptions();
$prescri->setId($consultation);
$prescri->setPrescription($ppp);
$entityManager->persist($prescri);
$entityManager->flush();
}
return $this->redirectToRoute('app_dashboard', [], Response::HTTP_SEE_OTHER);
}
if ($request->isMethod('post') && $formConsultationmodif->isSubmitted() && $formConsultationmodif->isValid()) {
$idRes = $resPatient->findOneBy(['resdoc' => $profileDocteur->getId(), 'respatient'=> $formConsultationmodif->get('idresform')->getData()]);
$consultationmodif = $consultationRepository->findOneBy(['numres' => $idRes]);
$consultationmodif->setAnamnese($formConsultationmodif->get('anamnese')->getData());
$consultationmodif->setConstantehemodynamique($formConsultationmodif->get('constantehemodynamique')->getData());
$consultationmodif->setSignesfonctionnels($formConsultationmodif->get('signesfonctionnels')->getData());
$consultationmodif->setSignesgeneraux($formConsultationmodif->get('signesgeneraux')->getData());
$consultationmodif->setSignesphysiques($formConsultationmodif->get('signesphysiques')->getData());
$consultationmodif->setConclusion($formConsultationmodif->get('conclusion')->getData());
//$entityManager->persist($consultationmodif);
$entityManager->flush();
$profileCurrentPatient = $patientRepository->findOneBy(['id' => $formConsultationmodif->get('idresform')->getData()]);
$profileCurrentPatient->setNom($formConsultationmodif->get('nompatient')->getData());
$profileCurrentPatient->setPrenom($formConsultationmodif->get('prenompatient')->getData());
$profileCurrentPatient->setSexe($formConsultationmodif->get('genrepatient')->getData());
$profileCurrentPatient->setDatenaissance($formConsultationmodif->get('datenaissancepatient')->getData());
$profileCurrentPatient->setLieunaissance($formConsultationmodif->get('lieunaissancepatient')->getData());
$profileCurrentPatient->setOrigine($formConsultationmodif->get('originepatient')->getData());
$profileCurrentPatient->setAdresse($formConsultationmodif->get('adressepatient')->getData());
$profileCurrentPatient->setSituationfamille($formConsultationmodif->get('situationfamillialepatient')->getData());
$profileCurrentPatient->getNombreenfant($formConsultationmodif->get('nombreenfantspatient')->getData());
//$entityManager->persist($profileCurrentPatient);
$entityManager->flush();
$resCurrentPatient = $resPatient->findOneBy(['resdoc' => $profileDocteur->getId(), 'respatient'=> $formConsultationmodif->get('idresform')->getData()]);
$resCurrentPatient->setAtcdPersoMedicaux($formConsultationmodif->get('Atcdpersomedicaux')->getData());
$resCurrentPatient->setAtcdPersoAllergieMedicaux($formConsultationmodif->get('Atcdpersoallergimedicam')->getData());
$resCurrentPatient->setAtcdpersochirurgicaux($formConsultationmodif->get('Atcdpersochurirgoco')->getData());
$resCurrentPatient->setAtcdPersoTraitementEnCours($formConsultationmodif->get('Atcdpersotraitencours')->getData());
$resCurrentPatient->setAtcdFamilleParentalMedicaux($formConsultationmodif->get('Atcdfammileparentalmedico')->getData());
$resCurrentPatient->setAtcdFamilleParentalChirurgicaux($formConsultationmodif->get('Atcdfammileparentalchirurgico')->getData());
$resCurrentPatient->setAtcdFamilleMaladiesCronique($formConsultationmodif->get('Atcdfammilemaladicronic')->getData());
$resCurrentPatient->setAtcdFamilleMaternelMedicaux($formConsultationmodif->get('Atcdfammilematrnalmedico')->getData());
$resCurrentPatient->setAtcdFamilleMaternelChirurgicaux($formConsultationmodif->get('Atcdfammilematrnalchirurgico')->getData());
$resCurrentPatient->setMotifpatient($formConsultationmodif->get('motifconsultationpatient')->getData());
$resCurrentPatient->setconsultationDone("1");
//$entityManager->persist($resCurrentPatient);
$entityManager->flush();
$examenBio = $entityManager->getRepository(Examenbiologique::class);
$examenBio = $examenBio->findOneBy(['idconsultation' => $consultationmodif]);
if (($examenBio)){
$examenBio->setNomexamen($formConsultationmodif->get("nomexamencomplementairebio")->getData());
$examenBio->setDateexamen($formConsultationmodif->get("examencomplementairebiodate")->getData());
$examenBio->setConclusionexamen($formConsultationmodif->get("examencomplementairebioconclusion")->getData());
$entityManager->flush();
}else{
$examenBio = new Examenbiologique();
$examenBio->setNomexamen($formConsultationmodif->get("nomexamencomplementairebio")->getData());
$examenBio->setDateexamen($formConsultationmodif->get("examencomplementairebiodate")->getData());
$examenBio->setConclusionexamen($formConsultationmodif->get("examencomplementairebioconclusion")->getData());
$examenBio->setIdconsultation($consultationmodif);
$entityManager->persist($examenBio);
$entityManager->flush();
}
$examenMorpho = $entityManager->getRepository(Examenmorphologique::class);
$examenMorpho = $examenMorpho->findOneBy(['idconsultation' => $consultationmodif]);
if (($examenMorpho)){
$examenMorpho->setNomexamen($formConsultationmodif->get("nomexamencomplementairemorpho")->getData());
$examenMorpho->setDateexamen($formConsultationmodif->get("examencomplementairemorphodate")->getData());
$examenMorpho->setConclusionexamen($formConsultationmodif->get("examencomplementairemorphoconclusion")->getData());
$entityManager->flush();
}else{
$examenMorpho = new Examenmorphologique();
$examenMorpho->setNomexamen($formConsultationmodif->get("nomexamencomplementairemorpho")->getData());
$examenMorpho->setDateexamen($formConsultationmodif->get("examencomplementairemorphodate")->getData());
$examenMorpho->setConclusionexamen($formConsultationmodif->get("examencomplementairemorphoconclusion")->getData());
$examenMorpho->setIdconsultation($consultationmodif);
$entityManager->persist($examenMorpho);
$entityManager->flush();
}
$prescriptionActu = $entityManager->getRepository(Prescriptions::class);
$prescriptionActu = $prescriptionActu->findBy(['id' => $consultationmodif]);
foreach ($prescriptionActu as $presa) {
$entityManager->remove($presa);
$entityManager->flush();
}
$prescription = $formConsultationmodif->get("prescription")->getData();
$prescription = explode (";;", $prescription);
foreach ($prescription as $ppp) {
if($ppp != ''){
$prescri = new Prescriptions();
$prescri->setId($consultationmodif);
$prescri->setPrescription($ppp);
$entityManager->persist($prescri);
$entityManager->flush();
}
}
return $this->redirectToRoute('app_dashboard', [], Response::HTTP_SEE_OTHER);
}
return $this->render('dashboard/doctor.html.twig', [
'currentUser' => $profileDocteur,
'patients' => $patients,
'patientsDate' => $resPatientbyDoc,
'consultationForm' => $formConsultation->createView(),
'consultationFormok' => $formConsultationmodif->createView(),
'consultationForm2' => $formConsultation->createView(),
'medform' =>$formMed->createView(),
'medformok' =>$formMedok->createView(),
'medform2' =>$formMed->createView(),
'nomenclature2023' => $nomenclature2023s,
'prescriptionForm' => $formPrescription->createView(),
'infoConsultaion' => $infoConsultations,
'infoConsultaionExamBio' => $infoConsultationsExamenBio,
'infoConsultaionExamMorpho' => $infoConsultationsExamenMorpho,
'infoConsultaionPrescription' => $infoConsultationsPrescription,
]);
}
if($roleUser[0]=="ROLE_REMPLACANT"){
$medecinsRepository = $em->getRepository(RemplacentGeneraliste::class);
$profileDocteur = $medecinsRepository->findOneBy(['email' => $user->getUsername()]);
$resPatient = $entityManager->getRepository(Reservationgeneraliste::class);
$resPatientbyDoc = $resPatient->findBy(['resdoc' => $profileDocteur->getIdadmin()]);
$test = [];
foreach ($resPatientbyDoc as $key) {
$test[] = $key->getRespatient();
}
$patients = $entityManager
->getRepository(Patients::class)
->findById($test);
return $this->render('dashboard/doctor.html.twig', [
'currentUser' => $profileDocteur,
'patients' => $patients,
'patientsDate' => $resPatientbyDoc,
]);
}
if($roleUser[0]=="ROLE_USER"){
$medecinsRepository = $em->getRepository(DfGeneraliste::class);
$secretaireRepository = $em->getRepository(SecretairesGeneraliste::class);
$user = $this->getUser();
$profileSecretaire = $secretaireRepository->findOneBy(['email' => $user->getUsername()]);
$profileDocteur= $medecinsRepository->findOneBy(['id' => $profileSecretaire->getIdadmin()]);
$resPatient = $entityManager->getRepository(Reservationgeneraliste::class);
$resPatientbyDoc = $resPatient->findBy(['resdoc' => $profileDocteur->getId()]);
$resPatientbyDoc2 = $resPatient->findOneBy(['resdoc' => $profileDocteur->getId()]);
$consultationRepository = $entityManager->getRepository(Consultation::class);
$infoConsultations = $consultationRepository->findById(['id' => $resPatientbyDoc2->getId()]);
$resPatient = $entityManager->getRepository(Reservationgeneraliste::class);
$resPatientbyDoc = $resPatient->findBy(['resdoc' => $profileSecretaire->getIdadmin()]);
$test = [];
$testconsult = [];
foreach ($resPatientbyDoc as $key) {
$test[] = $key->getRespatient();
$testconsult[] = $key->getId();
}
$patients = $entityManager
->getRepository(Patients::class)
->findById($test);
$infoConsultations = $entityManager
->getRepository(Consultation::class)
->findBy(['numres' => $testconsult]);
$paiementSec = new Reservationgeneraliste();
$formPaySec = $this->createForm(ReservationgeneralisteType::class, $paiementSec);
$formPaySec->handleRequest($request);
return $this->render('dashboard/doctor.html.twig', [
'currentUser' => $profileSecretaire,
'docteurUser' => $profileDocteur,
'patients' => $patients,
'patientsDate' => $resPatientbyDoc,
'paysec' => $formPaySec->createView(),
'infoConsultaion' => $infoConsultations,
]);
}
return $this->render('dashboard/index.html.twig', [
'controller_name'=> 'controller_name',
]);
}
/**
* @Route("dashboard/{idpaie}/paiementConsultation", name="paiementConsultation_app", methods={"GET", "POST"})
*/
public function paiementConsultation(Request $request, EntityManagerInterface $entityManager): Response
{
$resPatient = $entityManager->getRepository(Reservationgeneraliste::class);
//var_dump($request->get('_route'));
//var_dump($request->get('idpaie'));
$resPatientbyDoc = $resPatient->findOneBy(['id' => $request->get('idpaie')]);
$resPatientbyDoc->setpaiementConsultation("1");
$entityManager->persist($resPatientbyDoc);
$entityManager->flush();
return $this->redirectToRoute('app_dashboard');
}
/**
* @Route("dashboard/{idannul}/annulReservation", name="annulReservation_app", methods={"GET", "POST"})
*/
public function annulReservation(Request $request, EntityManagerInterface $entityManager): Response
{
$resPatient = $entityManager->getRepository(Reservationgeneraliste::class);
//var_dump($request->get('_route'));
//var_dump($request->get('idannul'));
$resPatientbyDoc = $resPatient->findOneBy(['id' => $request->get('idannul')]);
$resPatientbyDoc->setreservationAnnule("1");
$entityManager->persist($resPatientbyDoc);
$entityManager->flush();
return $this->redirectToRoute('app_dashboard');
}
/**
* @Route("/registration", name="app_registration")
*/
public function registration(Request $request, UserPasswordEncoderInterface $passEncoder): Response
{
$Genetaliste = new DfGeneraliste;
$form = $this->createForm(DfGeneralisteType::class, $Genetaliste);
$form->handleRequest($request);
if ($request->isMethod('post') && $form->isValid()) {
$data=$form['avecRDV']->getData();
$user = new User;
$user->setUsername($Genetaliste->getEmail());
$user->setPassword($passEncoder->encodePassword($user, $Genetaliste->getPassword()));
$user->setRoles(["ROLE_ADMIN"]);
if(!($data)) {
$Genetaliste->setAvecRdv(false);
} else {
$Genetaliste->setAvecRdv(true);
}
$Genetaliste->setPassword($passEncoder->encodePassword($user, $Genetaliste->getPassword()));
$Genetaliste->setSpecialite('Médecin Générale');
$Genetaliste->setRoles(["ROLE_ADMIN"]);
$em = $this->getDoctrine()->getManager();
$em->persist($Genetaliste);
$em->flush();
$em->persist($user);
$em->flush();
return $this->redirect($this->generateUrl('app_login'));
}
return $this->render('dashboard/registration.html.twig', [
'registrationMedecinG' => $form->createView(),
]);
}
/**
* @Route("dashboard/profile", name="doctor_profile", methods={"GET", "POST"})
*/
public function profile(PersistenceManagerRegistry $doctrine, Request $request, UserInterface $user): Response
{
$em=$doctrine->getManager();
//$em= $doctrine;
$medecinsRepository = $em->getRepository(DfGeneraliste::class);
$user = $this->getUser();
$profileDocteur = $medecinsRepository->findBy(['email' => $user->getUsername()]);
$profileDocteurr = $medecinsRepository->findOneBy(['email' => $user->getUsername()]);
//$profileDocteur = $medecinsRepository->findBy(['id' => $user->getUsername()]);
$dfGeneraliste = new DfGeneraliste();
$form = $this->createForm(DfGeneraliste1Type::class, $dfGeneraliste);
$form->handleRequest($request);
return $this->renderForm('dashboard/profile.html.twig', [
'profileDocteur' => $profileDocteur,
'form' => $form,
'currentUser' => $profileDocteurr ]);
}
/**
* @Route("dashboard/stats", name="doctor_stats", methods={"GET", "POST"})
*/
public function stats(PersistenceManagerRegistry $doctrine,EntityManagerInterface $entityManager, Request $request, UserInterface $user): Response
{
$em=$doctrine->getManager();
//$em= $doctrine;
$medecinsRepository = $em->getRepository(DfGeneraliste::class);
$user = $this->getUser();
$profileDocteur = $medecinsRepository->findBy(['email' => $user->getUsername()]);
$profileDocteurr = $medecinsRepository->findOneBy(['email' => $user->getUsername()]);
//$profileDocteur = $medecinsRepository->findBy(['id' => $user->getUsername()]);
$resPatient = $entityManager->getRepository(Reservationgeneraliste::class);
$resPatientbyDoc = $resPatient->findBy(['resdoc' => $profileDocteurr->getId()]);
$test = [];
foreach ($resPatientbyDoc as $key) {
$test[] = $key->getRespatient();
}
$patients= $entityManager
->getRepository(Patients::class)
->findById($test);
$patientsHomme = $entityManager
->getRepository(Patients::class)
//->findById($test);
->findBy(['id' => $test, "sexe"=>"Homme"]);
$patientsFemme = $entityManager
->getRepository(Patients::class)
//->findById($test);
->findBy(['id' => $test, "sexe"=>"Femme"]);
$dfGeneraliste = new DfGeneraliste();
$form = $this->createForm(DfGeneralisteType::class, $dfGeneraliste);
$form->handleRequest($request);
return $this->renderForm('dashboard/stats.html.twig', [
'profileDocteur' => $profileDocteur,
'form' => $form,
'currentUser' => $profileDocteurr,
'patients' => $patients,
'patientsHomme' => $patientsHomme,
'patientsFemme' => $patientsFemme ]);
}
/**
* @Route("dashboard/consultation", name="app_consultation", methods={"GET", "POST"})
*/
public function consultation(PersistenceManagerRegistry $doctrine, Request $request, UserInterface $user, EntityManagerInterface $entityManager): Response
{
$em=$doctrine->getManager();
//$em= $doctrine;
$medecinsRepository = $em->getRepository(DfGeneraliste::class);
$user = $this->getUser();
$profileDocteur = $medecinsRepository->findBy(['email' => $user->getUsername()]);
$profileDocteurr = $medecinsRepository->findOneBy(['email' => $user->getUsername()]);
//$profileDocteur = $medecinsRepository->findBy(['id' => $user->getUsername()]);
$consultation = new Consultation();
$formConsultation = $this->createForm(Consultation1Type::class, $consultation);
$formConsultation ->add('save', SubmitType::class, [
'attr' => ['class' => 'save'],
]);
$formConsultation->handleRequest($request);
//$formConsultation = $this->createForm(ConsultationType::class, $consultation);
if ($request->isMethod('post') && $formConsultation->isValid()) {
$entityManager->flush();
return $this->redirectToRoute('app_dashboard', [], Response::HTTP_SEE_OTHER);
}
return $this->render('dashboard/consultation.html.twig', [
'profileDocteur' => $profileDocteur,
'currentUser' => $profileDocteurr,
'consultationForm' => $formConsultation->createView() ]);
}
/**
* @Route("dashboard/profile/{id}/edit", name="app_profileDoc_edit", methods={"GET", "POST"})
*/
public function edit(PersistenceManagerRegistry $doctrine, UserInterface $user, Request $request, DfGeneraliste $dfGeneraliste, EntityManagerInterface $entityManager): Response
{
$em=$doctrine->getManager();
//$em= $doctrine;
$medecinsRepository = $em->getRepository(DfGeneraliste::class);
$user = $this->getUser();
$profileDocteur = $medecinsRepository->findOneBy(['email' => $user->getUsername()]);
$form = $this->createForm(DfGeneraliste1Type::class, $dfGeneraliste);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$entityManager->flush();
return $this->redirectToRoute('doctor_profile', [], Response::HTTP_SEE_OTHER);
}
return $this->render('dashboard/editprofile.html.twig', [
'df_generaliste' => $dfGeneraliste,
'form' => $form->createView(),
'currentUser' => $profileDocteur,
]);
}
/**
* @Route("dashboard/listeSecretaire", name="app_listesecretaires")
*/
public function secretaireprofile(PersistenceManagerRegistry $doctrine, Request $request, EntityManagerInterface $entityManager, UserInterface $user): Response
{
$em=$doctrine->getManager();
//$em= $doctrine;
$medecinsRepository = $em->getRepository(DfGeneraliste::class);
$user = $this->getUser();
$profileDocteur = $medecinsRepository->findOneBy(['email' => $user->getUsername()]);
$secretairesGeneralistes = $entityManager
->getRepository(SecretairesGeneraliste::class)
//->findBy(['emailDoctor' => $user->getUsername()]);
->findAll();
$secretairesGeneraliste = new SecretairesGeneraliste();
$formSec = $this->createForm(SecretairesGeneralisteType::class, $secretairesGeneraliste);
$formSec->handleRequest($request);
$SecretaireGeneraliste = new SecretairesGeneraliste;
$formSecretaire = $this->createForm(SecretairesGeneralisteType::class, $SecretaireGeneraliste);
$formSecretaire->handleRequest($request);
//$formSecretaire->add('save', SubmitType::class, ['label' => "Enregistrement"]);
return $this->render('dashboard/secretaires_generaliste.html.twig', [
'secretaires_generalistes' => $secretairesGeneralistes,
'form' => $formSec->createView(),
'formEnregSec' => $formSecretaire->createView(),
'currentUser' => $profileDocteur,
]);
}
/**
* @Route("dashboard/listeRemplacent", name="app_listeremplacent")
*/
public function listeRemplacent(PersistenceManagerRegistry $doctrine, EntityManagerInterface $entityManager, UserInterface $user): Response
{
$em=$doctrine->getManager();
//$em= $doctrine;
$medecinsRepository = $em->getRepository(DfGeneraliste::class);
$user = $this->getUser();
$RemplacantGeneraliste = new RemplacentGeneraliste;
$formRemplacant = $this->createForm(RemplacentGeneralisteType::class, $RemplacantGeneraliste);
$profileDocteur = $medecinsRepository->findOneBy(['email' => $user->getUsername()]);
$remplacentGeneralistes = $entityManager
->getRepository(RemplacentGeneraliste::class)
->findAll();
//->findBy(['emailDoctor' => $user->getUsername()]);
return $this->renderForm('dashboard/remplacent_generaliste.html.twig', [
'remplacent_generalistes' => $remplacentGeneralistes,
'currentUser' => $profileDocteur,
'formEnregRemp' =>$formRemplacant,
]);
}
/**
* @Route("dashboard/{id}/remplacentEdit", name="app_remplacent_edit", methods={"GET", "POST"})
*/
public function remplacentedit(Request $request, RemplacentGeneraliste $remplacentGeneraliste, EntityManagerInterface $entityManager, PersistenceManagerRegistry $doctrine, UserInterface $user): Response
{
$em=$doctrine->getManager();
//$em= $doctrine;
$medecinsRepository = $em->getRepository(DfGeneraliste::class);
$user = $this->getUser();
$profileDocteur = $medecinsRepository->findOneBy(['email' => $user->getUsername()]);
$formremp = $this->createForm(RemplacentGeneralisteType::class, $remplacentGeneraliste);
$formremp->handleRequest($request);
if ($formremp->isSubmitted() && $formremp->isValid()) {
$entityManager->flush();
return $this->redirectToRoute('app_listeremplacent', [], Response::HTTP_SEE_OTHER);
}
return $this->renderForm('dashboard/remplacent_edit.html.twig', [
'remplacent_generaliste' => $remplacentGeneraliste,
'form' => $formremp,
'currentUser' => $profileDocteur,
]);
}
/**
* @Route("dashboard/calendrierPatients", name="app_calendrierPatients")
*/
public function calendarpatients(EntityManagerInterface $entityManager, UserInterface $user): Response
{
//$medecinsRepository = $entityManager->getRepository(DfGeneraliste::class);
$medecinsRepository = $entityManager->getRepository(SecretairesGeneraliste::class);
$user = $this->getUser();
$profileDocteur = $medecinsRepository->findOneBy(['email' => $user->getUsername()]);
$resPatient = $entityManager->getRepository(Reservationgeneraliste::class);
$resPatientbyDoc = $resPatient->findBy(['resdoc' => $profileDocteur->getIdadmin()]);
//$resPatientbyDoc = $resPatient->findBy(['resdoc' => $profileDocteur->getId()]);
$test = [];
foreach ($resPatientbyDoc as $key) {
$test[] = $key->getRespatient();
}
$patients = $entityManager
->getRepository(Patients::class)
->findById($test);
return $this->render('dashboard/calendrierPatients.html.twig', [
'patients' => $patients,
'patientsDate' => $resPatientbyDoc,
'currentUser' => $profileDocteur,
]);
}
/**
* @Route("dashboard/calendrierPatientsday/{day}", name="app_calendrierPatientsday", methods={"GET", "POST"} )
*
*/
public function calendarpatientsday(EntityManagerInterface $entityManager, UserInterface $user, Request $request): Response
{
$medecinsRepository = $entityManager->getRepository(DfGeneraliste::class);
$user = $this->getUser();
$profileDocteur = $medecinsRepository->findOneBy(['email' => $user->getUsername()]);
$resPatient = $entityManager->getRepository(Reservationgeneraliste::class);
$resPatientbyDoc = $resPatient->findBy(['resdoc' => $profileDocteur->getId(), 'dateres' => new \DateTime($request->attributes->get('day')) ]);
$test = [];
foreach ($resPatientbyDoc as $key) {
$test[] = $key->getRespatient();
}
$patients = $entityManager
->getRepository(Patients::class)
->findById($test);
return $this->render('dashboard/calendrierPatientsDay.html.twig', [
'patientsday' => $patients,
'patientsDateday' => $resPatientbyDoc,
'currentUser' => $profileDocteur,
]);
}
/**
* @Route("dashoard/calendrierPatients/{day}/newPatient", name="app_calendrierPatientsNew", methods={"GET", "POST"})
*/
public function new(Request $request, EntityManagerInterface $entityManager, UserInterface $user): Response
{
/*if ($form->isSubmitted() && $form->isValid()) {
$entityManager->persist($reservationgeneraliste);
$entityManager->flush();
return $this->redirectToRoute('app_calendrierPatients', [], Response::HTTP_SEE_OTHER);
}
return $this->renderForm('dashboard/newPatient.html.twig', [
'reservationgeneraliste' => $reservationgeneraliste,
'form' => $form,
]);*/
$user = $this->getUser();
$roleUser = $user->getRoles();
if($roleUser[0]=="ROLE_ADMIN"){
$medecinsRepository = $entityManager->getRepository(DfGeneraliste::class);
$profileDocteur = $medecinsRepository->findOneBy(['email' => $user->getUsername()]);
$patient = new Patients();
$form = $this->createForm(PatientsAgendaType::class, $patient);
$form->handleRequest($request);
$patient->setPassword('12345');
$patient->setFromwho('Docteur');
$patient->setNbabsence(0);
$reservationgeneraliste = new Reservationgeneraliste();
$formRes = $this->createForm(ReservationgeneralisteType::class, $reservationgeneraliste);
$formRes->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$entityManager->persist($patient);
$entityManager->flush();
$reservationgeneraliste->setRespatient($patient);
$reservationgeneraliste->setResdoc($profileDocteur);
//$reservationgeneraliste->setNompatientord($patient->getNom());
//$reservationgeneraliste->setPrenompatientord($patient->getPrenom());
$reservationgeneraliste->setEmaildoc($user->getUsername());
//$reservationgeneraliste->setDatenaisspatientord(new \DateTime());
//$reservationgeneraliste->setSexepatientord($patient->getSexe());
$reservationgeneraliste->setMotifPatient("Consultation");
$reservationgeneraliste->setDateres(new \DateTime($request->attributes->get('day')));
$reservationgeneraliste->setHeureres('10:00-10:30');
$reservationgeneraliste->setFromwho('Docteur');
$reservationgeneraliste->setreservationAnnule(0);
$reservationgeneraliste->setconsultationDone(0);
$reservationgeneraliste->setpaiementConsultation(0);
$entityManager->persist($reservationgeneraliste);
$entityManager->flush();
return $this->redirectToRoute('app_calendrierPatients', [], Response::HTTP_SEE_OTHER);
}
return $this->renderForm('dashboard/newPatient.html.twig', [
'patient' => $patient,
'form' => $form,
'currentUser' => $profileDocteur,
]);
}
if($roleUser[0]=="ROLE_USER"){
$medecinsRepository = $entityManager->getRepository(DfGeneraliste::class);
$secretaireRepository = $entityManager->getRepository(SecretairesGeneraliste::class);
$profileSecretaire = $secretaireRepository->findOneBy(['email' => $user->getUsername()]);
$profileDocteur= $medecinsRepository->findOneBy(['id' => $profileSecretaire->getIdadmin()]);
//$profileDocteur = $medecinsRepository->findOneBy(['email' => $user->getUsername()]);
$patient = new Patients();
$form = $this->createForm(PatientsAgendaType::class, $patient);
$form->handleRequest($request);
$patient->setPassword('12345');
$patient->setFromwho('Secretaire');
$patient->setNbabsence(0);
$reservationgeneraliste = new Reservationgeneraliste();
$formRes = $this->createForm(ReservationgeneralisteType::class, $reservationgeneraliste);
$formRes->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$entityManager->persist($patient);
$entityManager->flush();
$reservationgeneraliste->setRespatient($patient);
$reservationgeneraliste->setResdoc($profileDocteur);
//$reservationgeneraliste->setNompatientord($patient->getNom());
//$reservationgeneraliste->setPrenompatientord($patient->getPrenom());
$reservationgeneraliste->setEmaildoc($profileDocteur->getEmail());
//$reservationgeneraliste->setDatenaisspatientord(new \DateTime());
//$reservationgeneraliste->setSexepatientord($patient->getSexe());
$reservationgeneraliste->setAtcdPersoMedicaux($form->get("Atcdpersomedicaux")->getData());
$reservationgeneraliste->setAtcdpersochirurgicaux($form->get("Atcdpersochurirgoco")->getData());
$reservationgeneraliste->setAtcdPersoAllergieMedicaux($form->get("Atcdpersoallergimedicam")->getData());
$reservationgeneraliste->setAtcdPersoTraitementEnCours($form->get("Atcdpersotraitencours")->getData());
$reservationgeneraliste->setAtcdFamilleParentalMedicaux($form->get("Atcdfammileparentalmedico")->getData());
$reservationgeneraliste->setAtcdFamilleParentalChirurgicaux($form->get("Atcdfammileparentalchirurgico")->getData());
$reservationgeneraliste->setAtcdFamilleMaternelMedicaux($form->get("Atcdfammilematrnalmedico")->getData());
$reservationgeneraliste->setAtcdFamilleMaternelChirurgicaux($form->get("Atcdfammilematrnalchirurgico")->getData());
$reservationgeneraliste->setAtcdFamilleMaladiesCronique($form->get("Atcdfammilemaladicronic")->getData());
$reservationgeneraliste->setMotifPatient("Consultation");
$reservationgeneraliste->setDateres(new \DateTime($request->attributes->get('day')));
$reservationgeneraliste->setHeureres('10:00-10:30');
$reservationgeneraliste->setFromwho('Secretaire');
$reservationgeneraliste->setreservationAnnule(0);
$reservationgeneraliste->setconsultationDone(0);
$reservationgeneraliste->setpaiementConsultation(0);
$entityManager->persist($reservationgeneraliste);
$entityManager->flush();
return $this->redirectToRoute('app_calendrierPatients', [], Response::HTTP_SEE_OTHER);
}
return $this->renderForm('dashboard/newPatient.html.twig', [
'patient' => $patient,
'formSecretaireReservation' => $form,
'formSecretaireReservation2' => $formRes,
'currentUser' => $profileSecretaire,
]);
}
}
/**
* @Route("dashboard/nomenclature", name="app_listeMedicament")
*/
public function listeMedicament(PersistenceManagerRegistry $doctrine, EntityManagerInterface $entityManager, UserInterface $user, Request $request): Response
{
$em=$doctrine->getManager();
//$em= $doctrine;
$medecinsRepository = $em->getRepository(DfGeneraliste::class);
$user = $this->getUser();
$profileDocteur = $medecinsRepository->findOneBy(['email' => $user->getUsername()]);
$nomenclature2023s = $entityManager
->getRepository(Nomenclature2023::class)
->findBy([], ['dci' => 'ASC']);
//->findAll();
/*$nomenclature2023s = $paginator->paginate(
$nomenclature2023s,
$request->query->getInt('page', 1),
13
);*/
return $this->render('dashboard/nomenclature2023.html.twig', [
'nomenclature2023s' => $nomenclature2023s,
'currentUser' => $profileDocteur,
]);
}
/**
* @Route("dashboard/eordonance", name="app_e-ordonance")
*/
public function eordonance(PersistenceManagerRegistry $doctrine, EntityManagerInterface $entityManager, UserInterface $user): Response
{
$em=$doctrine->getManager();
//$em= $doctrine;
$medecinsRepository = $em->getRepository(DfGeneraliste::class);
$user = $this->getUser();
$profileDocteur = $medecinsRepository->findOneBy(['email' => $user->getUsername()]);
$formMed = $this->createFormBuilder()
/*->add('medicament', EntityType::class, [
// looks for choices from this entity
'class' => Nomenclature2023Type::class,
// uses the User.username property as the visible option string
'choice_label' => 'dci',
// used to render a select box, check boxes or radios
// 'multiple' => true,
// 'expanded' => true,
])*/
->add('medicament', TextType::class, array('property_path' => 'userinput'))
//->add('saveMedi',SubmitType::class, ['label'=>"Ajouter"])
->getForm();
$nomenclature2023s = $entityManager
->getRepository(Nomenclature2023::class)
->findAll();
return $this->render('dashboard/eordonance.html.twig', [
'currentUser' => $profileDocteur,
'medform' =>$formMed->createView(),
'nomenclature2023' => $nomenclature2023s,
]);
}
/**
* @Route("dashboard/eordonanceconsultation", name="app_e-ordonanceconsultation")
*/
public function eordonanceConsultation(PersistenceManagerRegistry $doctrine, EntityManagerInterface $entityManager, UserInterface $user): Response
{
$em=$doctrine->getManager();
//$em= $doctrine;
$medecinsRepository = $em->getRepository(DfGeneraliste::class);
$user = $this->getUser();
$profileDocteur = $medecinsRepository->findOneBy(['email' => $user->getUsername()]);
$resPatient = $entityManager->getRepository(Reservationgeneraliste::class);
$resPatientbyDoc = $resPatient->findBy(['resdoc' => $profileDocteur]);
$test = [];
foreach ($resPatientbyDoc as $key) {
$test[] = $key->getRespatient();
}
$patients = $entityManager
->getRepository(Patients::class)
->findById($test);
$formMed = $this->createFormBuilder()
/*->add('medicament', EntityType::class, [
// looks for choices from this entity
'class' => Nomenclature2023Type::class,
// uses the User.username property as the visible option string
'choice_label' => 'dci',
// used to render a select box, check boxes or radios
// 'multiple' => true,
// 'expanded' => true,
])*/
->add('medicament', TextType::class, array('property_path' => 'userinput'))
//->add('saveMedi',SubmitType::class, ['label'=>"Ajouter"])
->getForm();
$nomenclature2023s = $entityManager
->getRepository(Nomenclature2023::class)
->findAll();
return $this->render('dashboard/eordonanceconsultation.html.twig', [
'currentUser' => $profileDocteur,
'medform' =>$formMed->createView(),
'nomenclature2023' => $nomenclature2023s,
'patients' => $patients,
]);
}
/**
* @Route("dashboard/calendrierTravail", name="docotr_calendrier_travail")
*/
public function calendartravail(PersistenceManagerRegistry $doctrine, UserInterface $user): Response
{
$em=$doctrine->getManager();
//$em= $doctrine;
$user = $this->getUser();
$roleUser = $user->getRoles();
if($roleUser[0]=="ROLE_ADMIN"){
$medecinsRepository = $em->getRepository(DfGeneraliste::class);
$profileDocteur = $medecinsRepository->findOneBy(['email' => $user->getUsername()]);
$profileDocteurs = $medecinsRepository->findBy(['email' => $user->getUsername()]);
return $this->render('dashboard/calendrierTravail.html.twig', [
'currentUser' => $profileDocteur,
'profileDocteur' => $profileDocteurs,
]);
}
if($roleUser[0]=="ROLE_USER"){
//need DQL
$medecinsRepository = $em->getRepository(DfGeneraliste::class);
$secretaireRepository = $em->getRepository(SecretairesGeneraliste::class);
$profileSecretaire = $secretaireRepository->findOneBy(['email' => $user->getUsername()]);
$profileDocteur= $medecinsRepository->findBy(['id' => $profileSecretaire->getIdadmin()]);
return $this->render('dashboard/calendrierTravail.html.twig', [
'currentUser' => $profileSecretaire,
'profileDocteur' => $profileDocteur,
]);
}
}
/**
* @Route("dashboard/listePatients", name="docotr_liste_patients")
*/
public function listPatients(EntityManagerInterface $entityManager, UserInterface $user): Response
{
$user = $this->getUser();
$roleUser = $user->getRoles();
if($roleUser[0]=="ROLE_ADMIN"){
$medecinsRepository = $entityManager->getRepository(DfGeneraliste::class);
$profileDocteur = $medecinsRepository->findOneBy(['email' => $user->getUsername()]);
$resPatient = $entityManager->getRepository(Reservationgeneraliste::class);
$resPatientbyDoc = $resPatient->findBy(['resdoc' => $profileDocteur->getId()]);
$test = [];
foreach ($resPatientbyDoc as $key) {
$test[] = $key->getRespatient();
}
$patients = $entityManager
->getRepository(Patients::class)
->findById($test);
//->findBy(['id' => 4]);
//->findAll();
return $this->render('dashboard/patients.html.twig', [
//'patients' => $patients,//before modification
'patients' => $patients, //$resPatientbyDoc,
'currentUser' => $profileDocteur,
]);
}
if($roleUser[0]=="ROLE_USER"){
$secretaireRepository = $entityManager->getRepository(SecretairesGeneraliste::class);
$profileSecretaire = $secretaireRepository->findOneBy(['email' => $user->getUsername()]);
$medecinsRepository = $entityManager->getRepository(DfGeneraliste::class);
$profileDocteur= $medecinsRepository->findOneBy(['id' => $profileSecretaire->getIdadmin()]);
$resPatient = $entityManager->getRepository(Reservationgeneraliste::class);
$resPatientbyDoc = $resPatient->findBy(['resdoc' => $profileSecretaire->getIdadmin()]);
$test = [];
foreach ($resPatientbyDoc as $key) {
$test[] = $key->getRespatient();
}
$patients = $entityManager
->getRepository(Patients::class)
->findById($test);
//->findBy(['id' => 4]);
//->findAll();
return $this->render('dashboard/patients.html.twig', [
//'patients' => $patients,//before modification
'patients' => $patients, //$resPatientbyDoc,
'currentUser' => $profileSecretaire,
'docteurUser' => $profileDocteur,
]);
}
}
/**
* @Route("dashboard/listePatientsSelect", name="docotr_liste_patientsSelect")
*/
public function listPatientsSelect(EntityManagerInterface $entityManager, UserInterface $user): Response
{
$medecinsRepository = $entityManager->getRepository(DfGeneraliste::class);
$user = $this->getUser();
$profileDocteur = $medecinsRepository->findOneBy(['email' => $user->getUsername()]);
$resPatient = $entityManager->getRepository(Reservationgeneraliste::class);
$resPatientbyDoc = $resPatient->findBy(['resdoc' => $profileDocteur->getId()]);
$test = [];
foreach ($resPatientbyDoc as $key) {
$test[] = $key->getRespatient();
}
$patients = $entityManager
->getRepository(Patients::class)
->findById($test);
//->findBy(['id' => 4]);
//->findAll();
return $this->render('dashboard/patientsSelect.html.twig', [
//'patients' => $patients,//before modification
'patients' => $patients, //$resPatientbyDoc,
'currentUser' => $profileDocteur,
]);
}
/**
* @Route("dashboard/registerSecretaire", name="app_registration_secretaire")
*/
public function registerSecretaire(Request $request, PersistenceManagerRegistry $doctrine, UserInterface $user, UserPasswordEncoderInterface $passEncoder): Response
{
$SecretaireGeneraliste = new SecretairesGeneraliste;
$formSecretaire = $this->createForm(SecretairesGeneralisteType::class, $SecretaireGeneraliste);
$formSecretaire->add('save', SubmitType::class, ['label' => "Enregistrement"]);
$formSecretaire->handleRequest($request);
$em = $doctrine->getManager();
$medecinsRepository = $em->getRepository(DfGeneraliste::class);
$profileDocteur = $medecinsRepository->findOneBy(['email' => $user->getUsername()]);
if ($request->isMethod('post') && $formSecretaire->isValid()) {
//return new JsonResponse($request->request->all());
//$em=$doctrine->getManager();
//$data=$form->getData();
$user = $this->getUser();
//$em= $doctrine;
$userSecretaire = new SecretairesGeneraliste;
$userSecretaire->setNamesecretaire($SecretaireGeneraliste->getNamesecretaire());
$userSecretaire->setEmail($SecretaireGeneraliste->getEmail());
//$userSecretaire->setPassword($SecretaireGeneraliste->getPassword());
$userSecretaire->setPassword($passEncoder->encodePassword($user, $SecretaireGeneraliste->getPassword()));
$userSecretaire->setEmailDoctor($user->getUsername());
$userSecretaire->setIdadmin($profileDocteur);
$userSecretaire->setRoles(["ROLE_USER"]);
$em = $this->getDoctrine()->getManager();
$em->persist($userSecretaire);
$em->flush();
return $this->redirect($this->generateUrl('app_listesecretaires'));
}
return $this->render('dashboard/registerSecretaire.html.twig', [
'form_secretaire' => $formSecretaire->createView(),
'currentUser' => $profileDocteur,
]);
}
/**
* @Route("dashboard/registerRemplacant", name="app_registration_remplacant")
*/
public function registerRemplacant(Request $request, PersistenceManagerRegistry $doctrine, UserInterface $user, UserPasswordEncoderInterface $passEncoder): Response
{
$RemplacantGeneraliste = new RemplacentGeneraliste;
$formRemplacant = $this->createForm(RemplacentGeneralisteType::class, $RemplacantGeneraliste);
$formRemplacant->add('save', SubmitType::class, ['label' => "Enregistrement"]);
$formRemplacant->handleRequest($request);
$em = $doctrine->getManager();
$medecinsRepository = $em->getRepository(DfGeneraliste::class);
$profileDocteur = $medecinsRepository->findOneBy(['email' => $user->getUsername()]);
if ($request->isMethod('post') && $formRemplacant->isValid()) {
//return new JsonResponse($request->request->all());
//$em=$doctrine->getManager();
//$data=$form->getData();
$user = $this->getUser();
//$em= $doctrine;
$userRemplacant = new RemplacentGeneraliste;
$userRemplacant->setNameremplacent($RemplacantGeneraliste->getNameRemplacent());
$userRemplacant->setEmail($RemplacantGeneraliste->getEmail());
//$userRemplacant->setPassword($RemplacantGeneraliste->getPassword());
$userRemplacant->setPassword($passEncoder->encodePassword($user, $RemplacantGeneraliste->getPassword()));
$userRemplacant->setEmailDoctor($user->getUsername());
$userRemplacant->setIdadmin($profileDocteur);
$userRemplacant->setRoles(["ROLE_USER"]);
$em = $this->getDoctrine()->getManager();
$em->persist($userRemplacant);
$em->flush();
$user = new User;
$user->setUsername($RemplacantGeneraliste->getEmail());
$user->setPassword($passEncoder->encodePassword($user, $RemplacantGeneraliste->getPassword()));
$user->setRoles("ROLE_REMPLACANT");
$em->persist($user);
$em->flush();
return $this->redirect($this->generateUrl('app_listeremplacent'));
}
return $this->render('dashboard/registerRemplacant.html.twig', [
'form_remplacant' => $formRemplacant->createView(),
'currentUser' => $profileDocteur,
]);
}
/**
* @Route("dashboard/{id}/editCalendrierTravail", name="app_df_generaliste_editxx", methods={"GET", "POST"})
*/
public function editxx(Request $request, DfGeneraliste $dfGeneraliste, EntityManagerInterface $entityManager): Response
{
$form = $this->createForm(DfGeneraliste11Type::class, $dfGeneraliste);
$form->add('ReposSamedi', CheckboxType::class, [
'mapped' => false,
'label' => ' ',
'required' => false,
]);
$form->add('SamedistartTime', TimeType::class, [
'mapped' => false,
'input' => 'datetime',
'widget' => 'choice',
'minutes' => [0, 15, 30, 45],
'hours' => [6, 7, 8, 9, 10, 11],
]);
$form->add('SamediendTime', TimeType::class, [
'mapped' => false,
'input' => 'datetime',
'widget' => 'choice',
'minutes' => [0, 15, 30, 45],
'hours' => [15, 16, 17, 18, 19, 20],
]);
$form->add('ReposDimanche', CheckboxType::class, [
'mapped' => false,
'label' => ' ',
'required' => false,
]);
$form->add('DimanchestartTime', TimeType::class, [
'mapped' => false,
'input' => 'datetime',
'widget' => 'choice',
'minutes' => [0, 15, 30, 45],
'hours' => [6, 7, 8, 9, 10, 11],
]);
$form->add('DimancheendTime', TimeType::class, [
'mapped' => false,
'input' => 'datetime',
'widget' => 'choice',
'minutes' => [0, 15, 30, 45],
'hours' => [15, 16, 17, 18, 19, 20],
]);
$form->add('ReposLundi', CheckboxType::class, [
'mapped' => false,
'label' => ' ',
'required' => false,
]);
$form->add('LundistartTime', TimeType::class, [
'mapped' => false,
'input' => 'datetime',
'widget' => 'choice',
'minutes' => [0, 15, 30, 45],
'hours' => [6, 7, 8, 9, 10, 11],
]);
$form->add('LundiendTime', TimeType::class, [
'mapped' => false,
'input' => 'datetime',
'widget' => 'choice',
'minutes' => [0, 15, 30, 45],
'hours' => [15, 16, 17, 18, 19, 20],
]);
$form->add('ReposMardi', CheckboxType::class, [
'mapped' => false,
'label' => ' ',
'required' => false,
]);
$form->add('MardistartTime', TimeType::class, [
'mapped' => false,
'input' => 'datetime',
'widget' => 'choice',
'minutes' => [0, 15, 30, 45],
'hours' => [6, 7, 8, 9, 10, 11],
]);
$form->add('MardiendTime', TimeType::class, [
'mapped' => false,
'input' => 'datetime',
'widget' => 'choice',
'minutes' => [0, 15, 30, 45],
'hours' => [15, 16, 17, 18, 19, 20],
]);
$form->add('ReposMercredi', CheckboxType::class, [
'mapped' => false,
'label' => ' ',
'required' => false,
]);
$form->add('MercredistartTime', TimeType::class, [
'mapped' => false,
'input' => 'datetime',
'widget' => 'choice',
'minutes' => [0, 15, 30, 45],
'hours' => [6, 7, 8, 9, 10, 11],
]);
$form->add('MercrediendTime', TimeType::class, [
'mapped' => false,
'input' => 'datetime',
'widget' => 'choice',
'minutes' => [0, 15, 30, 45],
'hours' => [15, 16, 17, 18, 19, 20],
]);
$form->add('ReposJeudi', CheckboxType::class, [
'mapped' => false,
'label' => ' ',
'required' => false,
]);
$form->add('JeudistartTime', TimeType::class, [
'mapped' => false,
'input' => 'datetime',
'widget' => 'choice',
'minutes' => [0, 15, 30, 45],
'hours' => [6, 7, 8, 9, 10, 11],
]);
$form->add('JeudiendTime', TimeType::class, [
'mapped' => false,
'input' => 'datetime',
'widget' => 'choice',
'minutes' => [0, 15, 30, 45],
'hours' => [15, 16, 17, 18, 19, 20],
]);
$form->add('ReposVendredi', CheckboxType::class, [
'mapped' => false,
'label' => ' ',
'required' => false,
]);
$form->add('VendredistartTime', TimeType::class, [
'mapped' => false,
'input' => 'datetime',
'widget' => 'choice',
'minutes' => [0, 15, 30, 45],
'hours' => [6, 7, 8, 9, 10, 11],
]);
$form->add('VendrediendTime', TimeType::class, [
'mapped' => false,
'input' => 'datetime',
'widget' => 'choice',
'minutes' => [0, 15, 30, 45],
'hours' => [15, 16, 17, 18, 19, 20],
]);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$entityManager->flush();
return $this->redirectToRoute('docotr_calendrier_travail', [], Response::HTTP_SEE_OTHER);
}
return $this->renderForm('dashboard/editCalendrierTravail.html.twig', [
'df_generaliste' => $dfGeneraliste,
//'form' => $form,
'registrationMedecinG' => $form,
]);
}
/**
* @Route("dashboard/{id}/editPatient", name="infopatients_edit", methods={"GET", "POST"})
*/
public function editPatient(Request $request, Patients $reservationgeneraliste, EntityManagerInterface $entityManager): Response
{
$form = $this->createForm(PatientsInfoType::class, $reservationgeneraliste);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$entityManager->flush();
return $this->redirectToRoute('docotr_liste_patients', [], Response::HTTP_SEE_OTHER);
}
return $this->renderForm('dashboard/editPatient.html.twig', [
'reservationgeneraliste' => $reservationgeneraliste,
'form' => $form,
]);
}
/**
* @Route("dashboard/{id}/editPatientReservation", name="infopatients_edit_reservation_dashboard", methods={"GET", "POST"})
*/
public function editPatientReservationDashboard(Request $request, Patients $reservationgeneraliste, EntityManagerInterface $entityManager): Response
{
$reservationgeneralistem = $entityManager->getRepository(Reservationgeneraliste::class);
$currentpatient = $reservationgeneralistem->findOneBy(['respatient'=>$reservationgeneraliste->getId()]);
$form = $this->createForm(PatientsAgendaType::class, $reservationgeneraliste);
//$currentpatient = $reservationgeneralistem->findOneBy(['ResPatient'=>$reservationgeneraliste->getId()]);
/*$form->add('RDVtime', ChoiceType::class, [
'mapped' => false,
'choices' => [
'10:30-11:00' => '10:30-11:00',
'11:00-11:30' => '11:00-11:30',
'11:30-12:00' => '11:30-12:00',
],
]);*/
$form->get('Atcdpersomedicaux')->setData($currentpatient->getAtcdPersoMedicaux());
$form->get('Atcdpersochurirgoco')->setData($currentpatient->getAtcdpersochirurgicaux());
$form->get('Atcdpersoallergimedicam')->setData($currentpatient->getAtcdPersoAllergieMedicaux());
$form->get('Atcdpersotraitencours')->setData($currentpatient->getAtcdPersoTraitementEnCours());
$form->get('Atcdfammileparentalmedico')->setData($currentpatient->getAtcdFamilleParentalMedicaux());
$form->get('Atcdfammileparentalchirurgico')->setData($currentpatient->getAtcdFamilleParentalChirurgicaux());
$form->get('Atcdfammilematrnalmedico')->setData($currentpatient->getAtcdFamilleMaternelMedicaux());
$form->get('Atcdfammilematrnalchirurgico')->setData($currentpatient->getAtcdFamilleMaternelChirurgicaux());
$form->get('Atcdfammilemaladicronic')->setData($currentpatient->getAtcdFamilleMaladiesCronique());
$form->get('Motif')->setData($currentpatient->getMotifpatient());
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$currentpatient->setAtcdPersoMedicaux($form->get("Atcdpersomedicaux")->getData());
$currentpatient->setAtcdpersochirurgicaux($form->get("Atcdpersochurirgoco")->getData());
$currentpatient->setAtcdPersoAllergieMedicaux($form->get("Atcdpersoallergimedicam")->getData());
$currentpatient->setAtcdPersoTraitementEnCours($form->get("Atcdpersotraitencours")->getData());
$currentpatient->setAtcdFamilleParentalMedicaux($form->get("Atcdfammileparentalmedico")->getData());
$currentpatient->setAtcdFamilleParentalChirurgicaux($form->get("Atcdfammileparentalchirurgico")->getData());
$currentpatient->setAtcdFamilleMaternelMedicaux($form->get("Atcdfammilematrnalmedico")->getData());
$currentpatient->setAtcdFamilleMaternelChirurgicaux($form->get("Atcdfammilematrnalchirurgico")->getData());
$currentpatient->setAtcdFamilleMaladiesCronique($form->get("Atcdfammilemaladicronic")->getData());
$currentpatient->setMotifPatient($form->get("Motif")->getData());
$entityManager->flush();
$entityManager->persist($currentpatient);
$entityManager->flush();
return $this->redirectToRoute('app_calendrierPatients', [], Response::HTTP_SEE_OTHER);
}
return $this->renderForm('dashboard/editPatientReservation.html.twig', [
'reservationgeneraliste' => $reservationgeneraliste,
'form' => $form,
]);
}
/**
* @Route("dashboard/{id}/editPatientReservation", name="infopatients_edit_reservation", methods={"GET", "POST"})
*/
public function editPatientReservation(Request $request, Patients $reservationgeneraliste, EntityManagerInterface $entityManager): Response
{
$form = $this->createForm(PatientsAgendaType::class, $reservationgeneraliste);
/*$form->add('RDVtime', ChoiceType::class, [
'mapped' => false,
'choices' => [
'10:30-11:00' => '10:30-11:00',
'11:00-11:30' => '11:00-11:30',
'11:30-12:00' => '11:30-12:00',
],
]);
$form->add('Motif', TextType::class, [
'mapped' => false,
]);*/
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$entityManager->flush();
return $this->redirectToRoute('app_calendrierPatients', [], Response::HTTP_SEE_OTHER);
}
return $this->renderForm('dashboard/editPatientReservation.html.twig', [
'reservationgeneraliste' => $reservationgeneraliste,
'form' => $form,
]);
}
/**
* @Route("dashboard/ordonance/{[patient]}", name="app_ordonancePatient", methods={"GET", "POST"})
*/
public function inordonancePatient(PersistenceManagerRegistry $doctrine, EntityManagerInterface $entityManager, UserInterface $user, Request $request): Response
{
$em=$doctrine->getManager();
//$em= $doctrine;
$medecinsRepository = $em->getRepository(DfGeneraliste::class);
$user = $this->getUser();
$profileDocteur = $medecinsRepository->findOneBy(['email' => $user->getUsername()]);
$data = [
//'imageSrc' => $this->imageToBase64($this->getParameter('kernel.project_dir') . '/public/img/profileDr.png'),
'name' => $profileDocteur->getNomMedecinFr(),
'address' => $profileDocteur->getRegion(),
'mobileNumber' => $profileDocteur->getTelephone1(),
'mobileNumber2' => $profileDocteur->getTelephone2(),
'mobileNumber3' => $profileDocteur->getTelephone3(),
'patient' => $request->get('patient')
];
$html = $this->renderView('ordonance_patient/index.html.twig', $data);
$dompdf = new Dompdf();
$dompdf->loadHtml($html);
$dompdf->render();
return new Response (
$dompdf->stream('resume', ["Attachment" => false]),
Response::HTTP_OK,
['Content-Type' => 'application/pdf']
);
return $this->render('ordonance_patient/index.html.twig', [
'controller_name' => 'OrdonancePatientController',
]);
}
private function imageToBase64($path) {
$path = $path;
$type = pathinfo($path, PATHINFO_EXTENSION);
$data = file_get_contents($path);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
return $base64;
}
/**
* @Route("Dashboard/listeSecretaire/{id}/edit", name="app_secretaires_generaliste_d_edit", methods={"GET", "POST"})
*/
public function editsecretaire(PersistenceManagerRegistry $doctrine, UserInterface $user,Request $request, SecretairesGeneraliste $secretairesGeneraliste, EntityManagerInterface $entityManager): Response
{
$form = $this->createForm(SecretairesGeneraliste2Type::class, $secretairesGeneraliste);
$form->handleRequest($request);
$em = $doctrine->getManager();
$medecinsRepository = $em->getRepository(DfGeneraliste::class);
$profileDocteur = $medecinsRepository->findOneBy(['email' => $user->getUsername()]);
if ($form->isSubmitted() && $form->isValid()) {
$entityManager->flush();
return $this->redirectToRoute('app_listesecretaires', [], Response::HTTP_SEE_OTHER);
}
return $this->renderForm('dashboard/secretaires_generaliste_edit.html.twig', [
'secretaires_generaliste' => $secretairesGeneraliste,
'form' => $form,
'currentUser' => $profileDocteur,
]);
}
/**
* @Route("dashboard/listeRemplacent/{id}", name="app_remplacent_generaliste_d_delete", methods={"POST"})
*/
public function deleteRemplacent(Request $request, RemplacentGeneraliste $remplacentGeneraliste, EntityManagerInterface $entityManager): Response
{
if ($this->isCsrfTokenValid('delete'.$remplacentGeneraliste->getId(), $request->request->get('_token'))) {
$entityManager->remove($remplacentGeneraliste);
$entityManager->flush();
}
return $this->redirectToRoute('app_listeremplacent', [], Response::HTTP_SEE_OTHER);
}
/**
* @Route("/{id}", name="app_patients_delete_Calendar", methods={"POST"})
*/
public function deletePatientFromCalendreir(Request $request, Patients $patient, EntityManagerInterface $entityManager): Response
{
if ($this->isCsrfTokenValid('delete'.$patient->getId(), $request->request->get('_token'))) {
$entityManager->remove($patient);
$entityManager->flush();
}
return $this->redirectToRoute('app_calendrierPatients', [], Response::HTTP_SEE_OTHER);
}
/**
* @Route("dashboard/listesecretaire/{id}", name="app_secretaires_generaliste_delete", methods={"POST"})
*/
public function delete(Request $request, SecretairesGeneraliste $secretairesGeneraliste, EntityManagerInterface $entityManager): Response
{
if ($this->isCsrfTokenValid('delete'.$secretairesGeneraliste->getId(), $request->request->get('_token'))) {
$entityManager->remove($secretairesGeneraliste);
$entityManager->flush();
}
return $this->redirectToRoute('app_listesecretaires', [], Response::HTTP_SEE_OTHER);
}
}