public function updatePayingClientStatus(Institution $institution, $payingClientStatus)
 {
     $qb = $this->doctrine->getEntityManagerForClass('InstitutionBundle:InstitutionMedicalCenter')->createQueryBuilder();
     $qb->select('a.payingClient')->from('InstitutionBundle:InstitutionMedicalCenter', 'a')->where('a.status = :status')->andWhere('a.institution = :institutionId')->addOrderBy('a.payingClient', 'DESC')->setMaxResults(1)->setParameter('status', InstitutionMedicalCenterStatus::APPROVED)->setParameter('institutionId', $institution->getId());
     $newInstitutionPayingClient = (int) $qb->getQuery()->getSingleScalarResult();
     if ((int) $institution->getPayingClient() != $newInstitutionPayingClient) {
         $institution->setPayingClient($newInstitutionPayingClient);
         $em = $this->doctrine->getEntityManagerForClass('InstitutionBundle:Institution');
         $em->persist($institution);
         $em->flush();
     }
 }