public function ajaxEditGlobalAwardAction() { $globalAward = $this->getDoctrine()->getRepository('HelperBundle:GlobalAward')->find($this->request->get('globalAwardId', 0)); if (!$globalAward) { throw $this->createNotFoundException('Invalid global award'); } $propertyType = $this->get('services.institution_property')->getAvailablePropertyType(InstitutionPropertyType::TYPE_GLOBAL_AWARD); $imcProperty = $this->imcService->getPropertyValue($this->institutionMedicalCenter, $propertyType, $globalAward->getId(), $this->request->get('propertyId', 0)); $imcProperty->setValueObject($globalAward); $editGlobalAwardForm = $this->createForm(new InstitutionGlobalAwardFormType(), $imcProperty); if ($this->request->isMethod('POST')) { $editGlobalAwardForm->bind($this->request); if ($editGlobalAwardForm->isValid()) { $imcProperty = $editGlobalAwardForm->getData(); $em = $this->getDoctrine()->getEntityManager(); $em->persist($imcProperty); $em->flush(); // Invalidate InstitutionMedicalCenterProfile memcache $this->get('services.memcache')->delete(FrontendMemcacheKeysHelper::generateInsitutionMedicalCenterProfileKey($this->institutionMedicalCenter->getId())); $output = array('status' => true, 'extraValue' => $imcProperty->getExtraValue()); $response = new Response(\json_encode($output), 200, array('content-type' => 'application/json')); } else { $response = new Response('Form error', 400); } } return $response; }
public function getAvailableGlobalAwardsOfInstitutionMedicalCenter(InstitutionMedicalCenter $institutionMedicalCenter, QueryOptionBag $options) { $globalAwardPropertyType = $this->getEntityManager()->getRepository('InstitutionBundle:InstitutionPropertyType')->findOneBy(array('name' => InstitutionPropertyType::TYPE_GLOBAL_AWARD)); $sql = "SELECT a.value FROM institution_medical_center_properties a WHERE a.institution_property_type_id = :propertyType AND a.institution_medical_center_id = :institutionMedicalCenterId"; $statement = $this->getEntityManager()->getConnection()->prepare($sql); $statement->execute(array('propertyType' => $globalAwardPropertyType->getId(), 'institutionMedicalCenterId' => $institutionMedicalCenter->getId())); $result = array(); $ids = array(); if ($statement->rowCount() > 0) { while ($row = $statement->fetch(Query::HYDRATE_ARRAY)) { $ids[] = $row['value']; } } $qb = $this->getEntityManager()->createQueryBuilder()->select('a,b')->from('HelperBundle:GlobalAward', 'a')->innerJoin('a.awardingBody', 'b')->where('a.status = :globalAwardActiveStatus')->setParameter('globalAwardActiveStatus', GlobalAward::STATUS_ACTIVE)->orderBy('a.name', 'ASC'); if ($options->has('globalAward.name')) { $qb->andWhere('a.name LIKE :globalAwardName')->setParameter('globalAwardName', '%' . $options->get('globalAward.name') . '%'); } if ($options->has('globalAward.type')) { $qb->andWhere('a.type = :globalAwardType')->setParameter('globalAwardType', $options->get('globalAward.type')); } if (\count($ids)) { $qb->andWhere($qb->expr()->notIn('a.id', ':globalAwardIds'))->setParameter('globalAwardIds', $ids); } //echo $qb->getQuery()->getSQL(); exit; return $qb->getQuery()->getResult(); }
/** * @param InstitutionMedicalCenter $center */ function updateInstitutionMedicalCenterListing(InstitutionMedicalCenter $center) { $institution = $center->getInstitution(); $criteria = array('institution' => $institution->getId(), 'institutionMedicalCenter' => $center->getId()); $recentlyApprovedListing = $this->em->getRepository('AdminBundle:RecentlyApprovedListing')->findOneBy($criteria); if ($recentlyApprovedListing) { if ($center->getStatus() == InstitutionMedicalCenterStatus::APPROVED) { $recentlyApprovedListing->setDateUpdated(new \DateTime()); $this->em->persist($recentlyApprovedListing); } else { $this->em->remove($recentlyApprovedListing); } $this->em->flush(); } else { if ($center->getStatus() == InstitutionMedicalCenterStatus::APPROVED) { $recentlyApprovedListingService = new RecentlyApprovedListingService(); $recentlyApprovedListingService->setEntityManager($this->em); $recentlyApprovedListing = new RecentlyApprovedListing(); $recentlyApprovedListing->setInstitution($institution); $recentlyApprovedListing->setInstitutionMedicalCenter($center); $recentlyApprovedListing->setDateUpdated(new \DateTime()); $recentlyApprovedListing->setStatus(1); $this->em->persist($recentlyApprovedListing); $this->em->flush($recentlyApprovedListing); } } }
/** * Remove institution specialization * * @param Request $request */ public function ajaxRemoveSpecializationAction(Request $request) { $institutionSpecialization = $this->getDoctrine()->getRepository('InstitutionBundle:InstitutionSpecialization')->find($request->get('isId', 0)); if (!$institutionSpecialization) { throw $this->createNotFoundException('Invalid instituiton specialization'); } if ($institutionSpecialization->getInstitutionMedicalCenter()->getId() != $this->institutionMedicalCenter->getId()) { return new Response("Cannot remove specialization that does not belong to this institution", 401); } $form = $this->createForm(new CommonDeleteFormType(), $institutionSpecialization); if ($request->isMethod('POST')) { $form->bind($request); if ($form->isValid()) { $_id = $institutionSpecialization->getId(); $em = $this->getDoctrine()->getEntityManager(); $em->remove($institutionSpecialization); $em->flush(); // Invalidate InstitutionMedicalCenterProfile memcache $this->get('services.memcache')->delete(FrontendMemcacheKeysHelper::generateInsitutionMedicalCenterProfileKey($this->institutionMedicalCenter->getId())); // Invalidate InstitutionProfile memcache $this->get('services.memcache')->delete(FrontendMemcacheKeysHelper::generateInsitutionProfileKey($this->institutionMedicalCenter->getInstitution()->getId())); $responseContent = array('id' => $_id); $response = new Response(\json_encode($responseContent), 200, array('content-type' => 'application/json')); } else { $response = new Response("Invalid form", 400); } } return $response; }
/** * 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 setupDoctorsAction(Request $request) { //TODO: check institution signupStepStatus $doctor = new Doctor(); $doctor->addInstitutionMedicalCenter($this->institutionMedicalCenter); $form = $this->createForm(new InstitutionMedicalCenterDoctorFormType(), $doctor); $doctors = $this->getDoctrine()->getRepository('DoctorBundle:Doctor')->findByInstitutionMedicalCenter($this->institutionMedicalCenter->getId(), Query::HYDRATE_OBJECT); if ($request->isMethod('POST')) { $form->bind($request); if ($form->isValid()) { $doctor = $form->getData(); $doctor->setStatus(Doctor::STATUS_ACTIVE); $em = $this->getDoctrine()->getEntityManager(); $em->persist($doctor); $em->flush($doctor); $data = array('status' => true, 'message' => 'Doctor has been added to your clinic!', 'doctor' => $this->get('services.doctor')->toArrayDoctor($doctor), 'editDoctorUrl' => $this->generateUrl('institution_medicalCenter_ajaxUpdateDoctor', array('imcId' => $this->institutionMedicalCenter->getId(), 'doctorId' => $doctor->getId())), 'removeDoctorUrl' => $this->generateUrl('institution_medicalCenter_removeDoctor', array('imcId' => $this->institutionMedicalCenter->getId(), 'doctorId' => $doctor->getId())), 'uploadLogoUrl' => $this->generateUrl('institution_doctor_logo_upload', array('imcId' => $this->institutionMedicalCenter->getId(), 'doctorId' => $doctor->getId()))); } else { $data = array('status' => false, 'message' => $form->getErrorsAsString()); } return new Response(json_encode($data), 200, array('Content-Type' => 'application/json')); } $params = array('doctorForm' => $form->createView(), 'institution' => $this->institution, 'institutionMedicalCenter' => $this->institutionMedicalCenter, 'thumbnailSize' => ImageSizes::DOCTOR_LOGO, 'doctors' => $this->get('services.doctor')->doctorsObjectToArray($doctors)); $editDoctor = new Doctor(); 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); $params['editDoctorForm'] = $editDoctorForm->createView(); return $this->render('InstitutionBundle:SignUp:setupDoctors.html.twig', $params); }
public function checkIfExists(InstitutionProperty $institutionProperty, InstitutionMedicalCenter $center) { $this->doctrine = $this->getContainer()->get('doctrine'); $qb = $this->doctrine->getEntityManager()->createQueryBuilder()->select('a')->from('InstitutionBundle:InstitutionMedicalCenterProperty', 'a')->where('a.institution = :institution')->andWhere('a.institutionMedicalCenter = :imc')->andWhere('a.institutionPropertyType = :insProperty')->andWhere('a.value = :value')->setParameter('institution', $institutionProperty->getInstitution()->getId())->setParameter('imc', $center->getId())->setParameter('insProperty', $institutionProperty->getInstitutionPropertyType()->getId())->setParameter('value', $institutionProperty->getValue())->getQuery(); if (count($qb->getResult()) >= 1) { return true; } return false; }
private function migrateClinicLogo(InstitutionMedicalCenter $imc) { $this->output->write("LOGO of clinic {$imc->getId()}: "); $oldDirectory = $this->getWebRootDirectory() . '/' . $imc->getInstitution()->getId(); if ($media = $imc->getLogo()) { $mediaFile = $oldDirectory . '/' . $media->getName(); if (\file_exists($mediaFile)) { $this->doMove($imc->getInstitution(), $media, $this->logoSizes); $this->output->write('[OK]'); } else { $this->output->write('[NOT FOUND]'); } $this->output->writeln(""); } else { $this->output->writeln("NO LOGO"); } }
/** * Upload logo for Institution Medical Center * @param Request $request */ public function uploadAction(Request $request) { if ($request->files->get('logo')) { $file = $request->files->get('logo'); $media = $this->get('services.institution.media')->medicalCenterUploadLogo($file, $this->institutionMedicalCenter); if ($media->getName()) { $src = $this->get('services.institution')->mediaTwigExtension->getInstitutionMediaSrc($media->getName(), ImageSizes::MEDIUM); $data['mediaSrc'] = $src; } $data['status'] = true; // Invalidate InstitutionMedicalCenterProfile memcache $this->get('services.memcache')->delete(FrontendMemcacheKeysHelper::generateInsitutionMedicalCenterProfileKey($this->institutionMedicalCenter->getId())); // Invalidate InstitutionProfile memcache $this->get('services.memcache')->delete(FrontendMemcacheKeysHelper::generateInsitutionProfileKey($this->institutionMedicalCenter->getInstitution()->getId())); } return new Response(\json_encode($data), 200, array('content-type' => 'application/json')); }
public static function institutionMedicalCenterToArray(InstitutionMedicalCenter $institutionMedicalCenter) { $data = array('id' => $institutionMedicalCenter->getId(), 'name' => $institutionMedicalCenter->getName()); return $data; }
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(); }
public function getInstitutionMedicalCenterByPropertyType(InstitutionMedicalCenter $institutionMedicalCenter, $propertyName) { if (isset(static::$institutionMedicalCenterPropertiesByType[$propertyName])) { return static::$institutionMedicalCenterPropertiesByType[$propertyName]; } $propertyType = $this->getAvailablePropertyType($propertyName); $criteria = array('institutionMedicalCenter' => $institutionMedicalCenter->getId(), 'institutionPropertyType' => $propertyType); static::$institutionMedicalCenterPropertiesByType[$propertyName] = $this->propertyRepository->findBy($criteria); return static::$institutionMedicalCenterPropertiesByType[$propertyName]; }