/**
  * Action page for Institution Profile Page
  *
  * @param Request $request
  */
 public function profileAction(Request $request)
 {
     $medicalProviderGroup = $this->getDoctrine()->getRepository('InstitutionBundle:MedicalProviderGroup')->getActiveMedicalGroups();
     $medicalProviderGroupArr = array();
     foreach ($medicalProviderGroup as $e) {
         $medicalProviderGroupArr[] = array('value' => $e->getName(), 'id' => $e->getId());
     }
     $this->get('services.contact_detail')->initializeContactDetails($this->institution, array(ContactDetailTypes::PHONE), $this->institution->getCountry());
     $form = $this->createForm(new InstitutionProfileFormType(), $this->institution, array(InstitutionProfileFormType::OPTION_BUBBLE_ALL_ERRORS => false));
     $currentGlobalAwards = $this->get('services.institution_property')->getGlobalAwardPropertiesByInstitution($this->institution);
     $editGlobalAwardForm = $this->createForm(new InstitutionGlobalAwardFormType());
     $params = array('institutionForm' => $form->createView(), 'institutionPhotos' => $this->get('services.institution.gallery')->getInstitutionPhotos($this->institution->getId()), 'currentGlobalAwards' => $currentGlobalAwards, 'editGlobalAwardForm' => $editGlobalAwardForm->createView(), 'medicalProvidersJSON' => \json_encode($medicalProviderGroupArr), 'ancillaryServicesData' => $this->get('services.helper.ancillary_service')->getActiveAncillaryServices());
     if ($this->isSingleCenter) {
         $doctor = new Doctor();
         $doctor->addInstitutionMedicalCenter($this->institutionMedicalCenter);
         $doctorForm = $this->createForm(new InstitutionMedicalCenterDoctorFormType(), $doctor);
         $editDoctor = new Doctor();
         $doctors = $this->getDoctrine()->getRepository('DoctorBundle:Doctor')->findByInstitutionMedicalCenter($this->institutionMedicalCenter->getId(), Query::HYDRATE_OBJECT);
         if (!empty($doctors)) {
             $editDoctor = $doctors[0];
         }
         $this->get('services.contact_detail')->initializeContactDetails($editDoctor, array(ContactDetailTypes::PHONE), $this->institution->getCountry());
         $editDoctorForm = $this->createForm(new InstitutionMedicalCenterDoctorFormType('editInstitutionMedicalCenterDoctorForm'), $editDoctor);
         $institutionMedicalCenterForm = $this->createForm(new InstitutionMedicalCenterFormType($this->institution), $this->institutionMedicalCenter, array(InstitutionMedicalCenterFormType::OPTION_BUBBLE_ALL_ERRORS => false));
         $params['editDoctorForm'] = $editDoctorForm->createView();
         $params['institutionMedicalCenter'] = $this->institutionMedicalCenter;
         $params['institutionMedicalCenterForm'] = $institutionMedicalCenterForm->createView();
         $params['commonDeleteForm'] = $this->createForm(new CommonDeleteFormType())->createView();
         $params['specializations'] = $this->getDoctrine()->getRepository('InstitutionBundle:InstitutionSpecialization')->getActiveSpecializationsByInstitutionMedicalCenter($this->institutionMedicalCenter);
         $params['doctors'] = $this->get('services.doctor')->doctorsObjectToArray($this->institutionMedicalCenter->getDoctors());
         $params['doctorForm'] = $doctorForm->createView();
     }
     return $this->render('InstitutionBundle:Institution:profile.html.twig', $params);
 }
 public function getListOfEmptyFieldsOnInstitutionMedicalCenter(InstitutionMedicalCenter $center)
 {
     $emptyFields = array();
     if (!$center->getDescription()) {
         $emptyFields[] = 'description';
     }
     if (!$center->getLogo()) {
         $emptyFields[] = 'logo';
     }
     if (!$center->getContactDetails()->count()) {
         $emptyFields[] = 'contact details';
     }
     if (!$center->getSocialMediaSites()) {
         $emptyFields[] = 'social media sites';
     }
     if (!$center->getDoctors()) {
         $emptyFields[] = 'doctors';
     }
     return $emptyFields;
 }
 public function getAvailableDoctors(InstitutionMedicalCenter $center, $searchKey)
 {
     $ids = array();
     foreach ($center->getDoctors() as $each) {
         $ids[] = $each->getId();
     }
     $exclodeExistingDoctorsId = !empty($ids) ? "a.id NOT IN (" . implode(", ", $ids) . ") AND " : '';
     $connection = $this->getEntityManager()->getConnection();
     $query = "SELECT a.*, s.name AS specialization_name FROM doctors a\n        LEFT JOIN doctor_specializations b ON a.id = b.doctor_id\n        LEFT JOIN specializations s ON s.id = b.specialization_id\n        WHERE {$exclodeExistingDoctorsId} (a.first_name LIKE :searchKey OR a.last_name LIKE :searchKey OR CONCAT(a.last_name, ' ', a.first_name) LIKE :searchKey) \n        AND a.status = :active ORDER BY a.last_name ASC";
     $stmt = $connection->prepare($query);
     $stmt->bindValue('imcId', $center->getId());
     $stmt->bindValue('searchKey', '%' . str_replace(',', '', $searchKey) . '%');
     $stmt->bindValue('active', Doctor::STATUS_ACTIVE);
     $stmt->execute();
     return $stmt->fetchAll();
 }