public function saveContactDetail(Doctor $doctor) { $contactIdsArray = array(); $contactNumberArray = \json_decode($doctor->getContactNumber(), true); if (\is_array($contactNumberArray)) { if (isset($contactNumberArray['country_code'])) { $contactDetail = new ContactDetail(); $contactDetail->setCountryCode(isset($contactNumberArray['country_code']) ? $contactNumberArray['country_code'] : NULL); $contactDetail->setAreaCode(isset($contactNumberArray['area_code']) ? $contactNumberArray['area_code'] : NULL); $contactDetail->setNumber($contactNumberArray['number']); $contactDetail->setType(ContactDetailTypes::PHONE); $doctor->addContactDetail($contactDetail); } else { foreach ($contactNumberArray as $each) { if ($each['number']) { $contactDetail = new ContactDetail(); $contactDetail->setNumber($each['number']); $contactDetail->setType($this->getContactDetailType($each['type'])); $doctor->addContactDetail($contactDetail); } } } } return $doctor; }
function uploadLogo($file, Doctor $doctor, $flushObject = true) { $result = parent::uploadFile($file); if (is_object($result)) { $media = $result; $sizes = $this->getSizesByType(self::LOGO_TYPE_IMAGE); // Delete current logo $this->deleteMediaAndFiles($doctor->getMedia(), $sizes); // set newly uploaded logo $doctor->setMedia($media); $this->resize($media, $sizes, false); if ($flushObject) { $this->entityManager->persist($doctor); $this->entityManager->flush($doctor); } return $media; } return null; }
public function doctorToArray(Doctor $doctor) { $arr = array('id' => $doctor->getId(), 'name' => "{$doctor->getFirstName()} {$doctor->getMiddleName()} {$doctor->getLastName()}", 'medicalCenters' => array()); foreach ($doctor->getMedicalCenters() as $dmc) { $arr['medicalCenters'][$dmc->getId()] = $dmc->getName(); } return $arr; }
public function testContactDetailAction(Request $request) { $contactDetail = new ContactDetail(); $contactDetail->setType(ContactDetailTypes::PHONE); $doctor = new Doctor(); $doctor->setFirstName('Test Only'); $doctor->setLastName('Doctor'); $doctor->addContactDetail($contactDetail); $form = $this->createFormBuilder($doctor)->add('contactDetails', 'collection', array('type' => 'simple_contact_detail', 'allow_add' => true))->getForm(); if ($request->isMethod('POST')) { $form->bind($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($contactDetail); //$em->flush(); exit; } else { var_dump($form->getErrors()); exit; } } return $this->render('HelperBundle:Test:contactDetailTest.html.twig', array('form' => $form->createView())); }
static function getFullName(Doctor $doctor) { $name = 'Dr. ' . ucwords($doctor->getFirstName()) . ' '; if ($doctor->getMiddleName()) { $name .= ucfirst(substr($doctor->getMiddleName(), 0, 1)) . '. '; } $name .= ucwords($doctor->getLastName()); if ($doctor->getSuffix()) { $name .= ' ' . $doctor->getSuffix(); } return $name; }
public function saveAction(Request $request) { if ($doctorId = $request->get('idId', 0)) { $doctor = $this->getDoctrine()->getRepository('DoctorBundle:Doctor')->find($doctorId); if (!$doctor) { throw $this->createNotFoundException("Invalid doctor."); } $media = $doctor->getMedia(); $msg = "Successfully updated doctors profile"; $title = 'Edit Doctor Details'; } else { $doctor = new Doctor(); $doctor->setStatus(Doctor::STATUS_ACTIVE); $msg = "Successfully added doctor"; $title = 'Add Doctor Details'; } $this->get('services.contact_detail')->initializeContactDetails($doctor, array(ContactDetailTypes::PHONE)); $form = $this->createForm(new DoctorFormType(), $doctor); if ($this->getRequest()->isMethod('POST')) { $form->bind($request); if ($form->isValid()) { $fileBag = $request->files->get('doctor'); if (isset($fileBag['media']) && $fileBag['media']) { $this->get('services.doctor.media')->uploadLogo($fileBag['media'], $doctor, false); } if ($medicalSpecialitiesIds = $request->get('doctor_medical_specialities', array())) { $qb = $this->getDoctrine()->getEntityManagerForClass('DoctorBundle:MedicalSpeciality')->createQueryBuilder(); $qb->select('a')->from('DoctorBundle:MedicalSpeciality', 'a')->where($qb->expr()->in('a.id', ':medicalSpecialitiesIds'))->setParameter(':medicalSpecialitiesIds', $medicalSpecialitiesIds); $medicalSpecialities = $qb->getQuery()->getResult(); // Add selected medicalSpecialities foreach ($medicalSpecialities as $each) { if (!$doctor->getMedicalSpecialities()->contains($each)) { $doctor->addMedicalSpeciality($each); } } } // Remove non-selected medicalSpecialities foreach ($doctor->getMedicalSpecialities() as $each) { if (!in_array($each->getId(), $medicalSpecialitiesIds)) { $doctor->removeMedicalSpeciality($each); } } $this->get('services.contact_detail')->removeInvalidContactDetails($doctor); $em = $this->getDoctrine()->getEntityManager(); $em->persist($doctor); $em->flush(); if ($doctor) { $data = $request->get('doctor'); if (count($data['specializations']) > 1) { $this->get('session')->setFlash('info', 'Successfully added doctor! Note: you have added multiple specializations to this doctor.'); } else { $this->get('session')->setFlash('success', $msg); } return $this->redirect($this->generateUrl('admin_doctor_index')); } else { $this->get('session')->setFlash('error', "Unable to update account"); } } } return $this->render('AdminBundle:Doctor:edit.html.twig', array('doctor' => $doctor, 'form' => $form->createView(), 'title' => $title)); }
/** * 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); }
/** * Modified for new markup in adding specialist in clinic profile doctors tab * @return \Symfony\Component\HttpFoundation\Response */ public function addDoctorAction(Request $request) { $doctor = new Doctor(); $doctor->addInstitutionMedicalCenter($this->institutionMedicalCenter); $form = $this->createForm(new InstitutionMedicalCenterDoctorFormType(), $doctor); 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); // 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())); $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')); }