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); } try { $_id = $institutionSpecialization->getId(); $em = $this->getDoctrine()->getEntityManager(); $em->remove($institutionSpecialization); $em->flush(); // Invalidate InstitutionMedicalCenter Profile cache $this->get('services.memcache')->delete(FrontendMemcacheKeysHelper::generateInsitutionMedicalCenterProfileKey($this->institutionMedicalCenter->getId())); // Invalidate Institution Profile cache $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')); } catch (\Exception $e) { $response = new Response($e->getMessage(), 500); } return $response; }
/** * Load available specializations for autocomplete field. * * @param Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function ajaxSpecializationSourceAction(Request $request) { $start = \microtime(true); $output = array(); $term = \trim($request->get('term', '')); $specializations = $this->getDoctrine()->getRepository('TreatmentBundle:Specialization')->getAvailableSpecializationsByMedicalCenterId($this->institutionMedicalCenter->getId(), array('name' => $term)); $end = \microtime(true); $diff = $end - $start; $output = array('specializations' => $specializations, 'executionTime' => $diff); $response = new Response(\json_encode($output), 200, array('content-type' => 'application/json')); return $response; }
/** * Remove an ancillary service to institution medical center * Required parameters: * - institutionId * - imcId institution medical center id * - asId ancillary service id * * @param Request $request * @return \Symfony\Component\HttpFoundation\Response * @author acgvelarde */ public function ajaxRemoveInstitutionMedicalCenterAncillaryServiceAction(Request $request) { $property = $this->getDoctrine()->getRepository('InstitutionBundle:InstitutionMedicalCenterProperty')->find($request->get('id', 0)); if (!$property) { throw $this->createNotFoundException('Invalid property.'); } // get global,current and selcted ancillary services $ancillaryService = $this->getDoctrine()->getRepository('AdminBundle:OfferedService')->find($property->getValue()); $ancillaryServicesData = array('globalList' => $this->get('services.helper.ancillary_service')->getActiveAncillaryServices(), 'selected' => array(), 'currentAncillaryData' => array()); $ancillaryServicesData = $this->get('services.institution_medical_center_property')->getCurrentAndSelectedAncillaryServicesByPropertyType($this->institutionMedicalCenter, InstitutionPropertyType::TYPE_ANCILLIARY_SERVICE, $ancillaryServicesData); try { $em = $this->getDoctrine()->getEntityManager(); $em->remove($property); $em->flush(); // Invalidate InstitutionMedicalCenter Profile cache $this->get('services.memcache')->delete(FrontendMemcacheKeysHelper::generateInsitutionMedicalCenterProfileKey($request->get('imcId'))); $output = array('label' => 'Add Service', 'href' => $this->generateUrl('admin_institution_medicalCenter_ajaxAddAncillaryService', array('institutionId' => $this->institution->getId(), 'imcId' => $this->institutionMedicalCenter->getId(), 'id' => $ancillaryService->getId())), 'ancillaryServicesData' => $ancillaryServicesData, '_isSelected' => false); $response = new Response(\json_encode($output), 200, array('content-type' => 'application/json')); } catch (\Exception $e) { $response = new Response($e->getMessage(), 500); } return $response; }