<commit_before><?php
namespace HealthCareAbroad\InstitutionBundle\Repository;

use Doctrine\ORM\Tools\Pagination\Paginator;

use HealthCareAbroad\DoctorBundle\Entity\Doctor;
use HealthCareAbroad\InstitutionBundle\Entity\InstitutionMedicalCenterStatus;
use HealthCareAbroad\InstitutionBundle\Entity\InstitutionStatus;
use HealthCareAbroad\InstitutionBundle\Entity\InstitutionMedicalCenter;
use HealthCareAbroad\InstitutionBundle\Entity\Institution;
use HealthCareAbroad\InstitutionBundle\Entity\InstitutionMedicalCenterGroupStatus;
use HealthCareAbroad\TreatmentBundle\Entity\Specialization;
use HealthCareAbroad\TreatmentBundle\Entity\TreatmentProcedure;
use HealthCareAbroad\TreatmentBundle\Entity\Treatment;
use HealthCareAbroad\TreatmentBundle\Entity\MedicalCenter;
use HealthCareAbroad\HelperBundle\Entity\City;
use HealthCareAbroad\HelperBundle\Entity\Country;
use Doctrine\ORM\QueryBuilder;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\ORM\EntityRepository;

/**
 * InstitutionMedicalCenterRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class InstitutionMedicalCenterRepository extends EntityRepository
{
    
    /**
     * Create query builder for finding a medical center with relationships eagerly loaded
     * 
     * @return QueryBuilder
     * @author acgvelarde
     */
    public function getQueryBuilderForEagerlyLoadedMedicalCenter()
    {
        $qb = $this->getEntityManager()->createQueryBuilder();
        
        $qb->select('imc, inst, imc_media, imc_bh, imc_cd, imc_pr, co, ci, imc_sp, sp, tr, tr_subs, doctors, docSpecializations, docMedia, docContacts')
            ->from('InstitutionBundle:InstitutionMedicalCenter', 'imc')
            ->leftJoin('imc.institution', 'inst')
            ->leftJoin('imc.media', 'imc_media')
            ->leftJoin('imc.institutionMedicalCenterProperties', 'imc_pr')
            ->leftJoin('imc.businessHours', 'imc_bh')
            ->leftJoin('imc.contactDetails', 'imc_cd')
            ->leftJoin('imc.institutionSpecializations', 'imc_sp')
            ->leftJoin('imc_sp.specialization', 'sp')
            ->leftJoin('imc_sp.treatments', 'tr')
            ->leftJoin('tr.subSpecializations', 'tr_subs')
            ->leftJoin('imc.doctors', 'doctors')
            ->leftJoin('doctors.specializations', 'docSpecializations')
            ->leftJoin('doctors.media', 'docMedia')
            ->leftJoin('doctors.contactDetails', 'docContacts')
            ->leftJoin('inst.country', 'co')
            ->leftJoin('inst.city', 'ci');
        
        
        return $qb;
    }

    /** TODO - Verify Method! - Moved from medicalCenterGroupRepo
     * Find Doctors that has specializations matching $institutionMedicalCenter by search keyword $searchKey
     *
     * @param InstitutionMedicalCenterGroup $institutionMedicalCenter
     * @param string $searchKey
     */
    public function findAvailableDoctorBySearchKey(InstitutionMedicalCenter $institutionMedicalCenter, $searchKey='')
    {
        /**
         SELECT d.*
         FROM `doctors` d
         INNER JOIN `doctor_to_medical_centers` dmc ON d.id = dmc.doctor_id
         INNER JOIN `institution_medical_centers` imc ON dmc.medical_center_id = imc.medical_center_id AND imc.institution_medical_center_group_id = 1
         WHERE
         d.status = 1

         SELECT d0_.id AS id0, d0_.first_name AS first_name1, d0_.middle_name AS middle_name2, d0_.last_name AS last_name3, d0_.date_created AS date_created4, d0_.status AS status5
         FROM doctors d0_
         INNER JOIN doctor_to_medical_centers d2_ ON d0_.id = d2_.doctor_id
         INNER JOIN medical_centers m1_ ON m1_.id = d2_.medical_center_id
         INNER JOIN institution_medical_centers i3_ ON m1_.id = i3_.medical_center_id AND (i3_.institution_medical_center_group_id = 1)
         LEFT JOIN institution_medical_center_group_doctors i5_ ON d0_.id = i5_.doctor_id<commit_msg>Do not eagerly load doctors because of data problem<commit_after><?php
namespace HealthCareAbroad\InstitutionBundle\Repository;

use Doctrine\ORM\Tools\Pagination\Paginator;

use HealthCareAbroad\DoctorBundle\Entity\Doctor;
use HealthCareAbroad\InstitutionBundle\Entity\InstitutionMedicalCenterStatus;
use HealthCareAbroad\InstitutionBundle\Entity\InstitutionStatus;
use HealthCareAbroad\InstitutionBundle\Entity\InstitutionMedicalCenter;
use HealthCareAbroad\InstitutionBundle\Entity\Institution;
use HealthCareAbroad\InstitutionBundle\Entity\InstitutionMedicalCenterGroupStatus;
use HealthCareAbroad\TreatmentBundle\Entity\Specialization;
use HealthCareAbroad\TreatmentBundle\Entity\TreatmentProcedure;
use HealthCareAbroad\TreatmentBundle\Entity\Treatment;
use HealthCareAbroad\TreatmentBundle\Entity\MedicalCenter;
use HealthCareAbroad\HelperBundle\Entity\City;
use HealthCareAbroad\HelperBundle\Entity\Country;
use Doctrine\ORM\QueryBuilder;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\ORM\EntityRepository;

/**
 * InstitutionMedicalCenterRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class InstitutionMedicalCenterRepository extends EntityRepository
{
    
    /**
     * Create query builder for finding a medical center with relationships eagerly loaded
     * 
     * @return QueryBuilder
     * @author acgvelarde
     */
    public function getQueryBuilderForEagerlyLoadedMedicalCenter()
    {
        $qb = $this->getEntityManager()->createQueryBuilder();
        
        $qb->select('imc, inst, imc_media, imc_bh, imc_cd, imc_pr, co, ci, imc_sp, sp, tr, tr_subs')
            ->from('InstitutionBundle:InstitutionMedicalCenter', 'imc')
            ->leftJoin('imc.institution', 'inst')
            ->leftJoin('imc.media', 'imc_media')
            ->leftJoin('imc.institutionMedicalCenterProperties', 'imc_pr')
            ->leftJoin('imc.businessHours', 'imc_bh')
            ->leftJoin('imc.contactDetails', 'imc_cd')
            ->leftJoin('imc.institutionSpecializations', 'imc_sp')
            ->leftJoin('imc_sp.specialization', 'sp')
            ->leftJoin('imc_sp.treatments', 'tr')
            ->leftJoin('tr.subSpecializations', 'tr_subs')
            ->leftJoin('inst.country', 'co')
            ->leftJoin('inst.city', 'ci');
        
        
        return $qb;
    }

    /** TODO - Verify Method! - Moved from medicalCenterGroupRepo
     * Find Doctors that has specializations matching $institutionMedicalCenter by search keyword $searchKey
     *
     * @param InstitutionMedicalCenterGroup $institutionMedicalCenter
     * @param string $searchKey
     */
    public function findAvailableDoctorBySearchKey(InstitutionMedicalCenter $institutionMedicalCenter, $searchKey='')
    {
        /**
         SELECT d.*
         FROM `doctors` d
         INNER JOIN `doctor_to_medical_centers` dmc ON d.id = dmc.doctor_id
         INNER JOIN `institution_medical_centers` imc ON dmc.medical_center_id = imc.medical_center_id AND imc.institution_medical_center_group_id = 1
         WHERE
         d.status = 1

         SELECT d0_.id AS id0, d0_.first_name AS first_name1, d0_.middle_name AS middle_name2, d0_.last_name AS last_name3, d0_.date_created AS date_created4, d0_.status AS status5
         FROM doctors d0_
         INNER JOIN doctor_to_medical_centers d2_ ON d0_.id = d2_.doctor_id
         INNER JOIN medical_centers m1_ ON m1_.id = d2_.medical_center_id
         INNER JOIN institution_medical_centers i3_ ON m1_.id = i3_.medical_center_id AND (i3_.institution_medical_center_group_id = 1)
         LEFT JOIN institution_medical_center_group_doctors i5_ ON d0_.id = i5_.doctor_id
{'fraction_non_alphanumeric': 0.0915100453661698, 'fraction_numerical': 0.007517822423849643, 'mean_word_length': 3.7541589648798523, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5760695', 'n_tokens_mistral': 2394, 'n_tokens_neox': 2246, 'n_words': 463}