<?php

namespace RxConnexionBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use RxConnexionBundle\Entity\Base\BaseEntity;
use JMS\Serializer\Annotation\Groups;
use JMS\Serializer\Annotation\MaxDepth;

/**
 * @ORM\Entity(repositoryClass="RxConnexionBundle\Repository\CityRepository")
 * @ORM\Table(name="city", indexes={
 *     @ORM\Index(name="IDX_SEARCH_000", columns={"is_deleted", "code", "description", "province_id"}),
 *     @ORM\Index(name="IDX_SEARCH_001", columns={"is_deleted", "description", "province_id"}),
 *     @ORM\Index(name="IDX_JOIN_000", columns={"id", "description", "province_id"})
 * })
 */

class CityEntity extends BaseEntity
{
    /**
     * @ORM\Column(type="string", nullable=true)
     * @Groups("forAudit")
     */
    protected $code;

    /**
     * @ORM\Column(type="string")
     * @Groups("forAudit")
     */
    protected $description;

    /**
     * @ORM\Column(name="is_deleted", type="boolean")
     */
    protected $isDeleted;

    /**
     * @ORM\ManyToOne(targetEntity="ProvinceEntity", inversedBy="cities")
     * @ORM\JoinColumn(name="province_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $province;

//    /**
//     * @ORM\OneToMany(targetEntity="LocationEntity", mappedBy="city")
//     */
//    protected $locations;

    /**
     * @ORM\OneToMany(targetEntity="PatientEntity", mappedBy="city")
     */
    protected $patients;

    /**
     * @ORM\OneToMany(targetEntity="ProviderEntity", mappedBy="city")
     */
    protected $providers;

    /**
     * @ORM\OneToMany(targetEntity="HealthFacilityEntity", mappedBy="city")
     */
    protected $healthFacilities;

    /**
     * @ORM\OneToMany(targetEntity="ReferringProviderEntity", mappedBy="city")
     */
    protected $referringProviders;

    /**
     * @ORM\OneToMany(targetEntity="ReferringHealthFacilityEntity", mappedBy="city")
     */
    protected $referringHealthFacilities;

    /**
     * @ORM\OneToMany(targetEntity="HealthFacilityRegistrationEntity", mappedBy="city")
     */
    protected $healthFacilityRegistrations;

    /**
     * @ORM\OneToMany(targetEntity="GeneralUserEntity", mappedBy="city")
     */
    protected $generalUsers;

    /**
     * @ORM\OneToMany(targetEntity="ReferralEntity", mappedBy="city")
     */
    protected $referrals;

    /**
     * @ORM\OneToMany(targetEntity="PostalCodeEntity", mappedBy="city", cascade={"remove"})
     */
    protected $postalCodes;

    /**
     * @ORM\OneToMany(targetEntity="InsuranceEntity", mappedBy="city")
     */
    protected $insurances;

    /**
     * @ORM\OneToMany(targetEntity="FinancingCompanyEntity", mappedBy="city")
     */
    protected $financingCompanies;

    /**
     * @ORM\OneToMany(targetEntity="MarketingStaffEntity", mappedBy="city")
     */
    protected $marketingStaffs;

    /**
     * @ORM\OneToMany(targetEntity="SupplierEntity", mappedBy="city")
     */
    protected $suppliers;


    public function __construct()
    {
//        $this->locations = new ArrayCollection();
        $this->patients = new ArrayCollection();
        $this->providers = new ArrayCollection();
        $this->referringProviders = new ArrayCollection();
        $this->referringHealthFacilities = new ArrayCollection();
        $this->healthFacilities = new ArrayCollection();
        $this->healthFacilityRegistrations = new ArrayCollection();
        $this->generalUsers = new ArrayCollection();
        $this->referrals = new ArrayCollection();
        $this->postalCodes = new ArrayCollection();
        $this->insurances = new ArrayCollection();
        $this->financingCompanies = new ArrayCollection();
        $this->marketingStaffs = new ArrayCollection();
    }

    /**
     * Set createdAt
     *
     * @ORM\PrePersist
     */
    public function setCreatedAtValue()
    {
        parent::setCreatedAtValue();
        $this->isDeleted = 0;
    }

    /*--------------------------------------------------------------------------------------------------------*/
    /*					User Defined Setters and Getters													  */
    /*--------------------------------------------------------------------------------------------------------*/

    /*--------------------------------------------------------------------------------------------------------*/
    /*					Setters and Getters																	  */
    /*--------------------------------------------------------------------------------------------------------*/


    /**
     * Set code
     *
     * @param string $code
     *
     * @return CityEntity
     */
    public function setCode($code)
    {
        $this->code = $code;

        return $this;
    }

    /**
     * Get code
     *
     * @return string
     */
    public function getCode()
    {
        return $this->code;
    }

    /**
     * Set description
     *
     * @param string $description
     *
     * @return CityEntity
     */
    public function setDescription($description)
    {
        $this->description = $description;

        return $this;
    }

    /**
     * Get description
     *
     * @return string
     */
    public function getDescription()
    {
        return $this->description;
    }

    /**
     * Set province
     *
     * @param \RxConnexionBundle\Entity\ProvinceEntity $province
     *
     * @return CityEntity
     */
    public function setProvince(\RxConnexionBundle\Entity\ProvinceEntity $province = null)
    {
        $this->province = $province;

        return $this;
    }

    /**
     * Get province
     *
     * @return \RxConnexionBundle\Entity\ProvinceEntity
     */
    public function getProvince()
    {
        return $this->province;
    }

    /**
     * Add patient
     *
     * @param \RxConnexionBundle\Entity\PatientEntity $patient
     *
     * @return CityEntity
     */
    public function addPatient(\RxConnexionBundle\Entity\PatientEntity $patient)
    {
        $this->patients[] = $patient;

        return $this;
    }

    /**
     * Remove patient
     *
     * @param \RxConnexionBundle\Entity\PatientEntity $patient
     */
    public function removePatient(\RxConnexionBundle\Entity\PatientEntity $patient)
    {
        $this->patients->removeElement($patient);
    }

    /**
     * Get patients
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getPatients()
    {
        return $this->patients;
    }

    /**
     * Add provider
     *
     * @param \RxConnexionBundle\Entity\ProviderEntity $provider
     *
     * @return CityEntity
     */
    public function addProvider(\RxConnexionBundle\Entity\ProviderEntity $provider)
    {
        $this->providers[] = $provider;

        return $this;
    }

    /**
     * Remove provider
     *
     * @param \RxConnexionBundle\Entity\ProviderEntity $provider
     */
    public function removeProvider(\RxConnexionBundle\Entity\ProviderEntity $provider)
    {
        $this->providers->removeElement($provider);
    }

    /**
     * Get providers
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getProviders()
    {
        return $this->providers;
    }

    /**
     * Add healthFacility
     *
     * @param \RxConnexionBundle\Entity\HealthFacilityEntity $healthFacility
     *
     * @return CityEntity
     */
    public function addHealthFacility(\RxConnexionBundle\Entity\HealthFacilityEntity $healthFacility)
    {
        $this->healthFacilities[] = $healthFacility;

        return $this;
    }

    /**
     * Remove healthFacility
     *
     * @param \RxConnexionBundle\Entity\HealthFacilityEntity $healthFacility
     */
    public function removeHealthFacility(\RxConnexionBundle\Entity\HealthFacilityEntity $healthFacility)
    {
        $this->healthFacilities->removeElement($healthFacility);
    }

    /**
     * Get healthFacilities
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getHealthFacilities()
    {
        return $this->healthFacilities;
    }

    /**
     * Add healthFacilityRegistration
     *
     * @param \RxConnexionBundle\Entity\HealthFacilityRegistrationEntity $healthFacilityRegistration
     *
     * @return CityEntity
     */
    public function addHealthFacilityRegistration(\RxConnexionBundle\Entity\HealthFacilityRegistrationEntity $healthFacilityRegistration)
    {
        $this->healthFacilityRegistrations[] = $healthFacilityRegistration;

        return $this;
    }

    /**
     * Remove healthFacilityRegistration
     *
     * @param \RxConnexionBundle\Entity\HealthFacilityRegistrationEntity $healthFacilityRegistration
     */
    public function removeHealthFacilityRegistration(\RxConnexionBundle\Entity\HealthFacilityRegistrationEntity $healthFacilityRegistration)
    {
        $this->healthFacilityRegistrations->removeElement($healthFacilityRegistration);
    }

    /**
     * Get healthFacilityRegistrations
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getHealthFacilityRegistrations()
    {
        return $this->healthFacilityRegistrations;
    }

    /**
     * Add generalUser
     *
     * @param \RxConnexionBundle\Entity\GeneralUserEntity $generalUser
     *
     * @return CityEntity
     */
    public function addGeneralUser(\RxConnexionBundle\Entity\GeneralUserEntity $generalUser)
    {
        $this->generalUsers[] = $generalUser;

        return $this;
    }

    /**
     * Remove generalUser
     *
     * @param \RxConnexionBundle\Entity\GeneralUserEntity $generalUser
     */
    public function removeGeneralUser(\RxConnexionBundle\Entity\GeneralUserEntity $generalUser)
    {
        $this->generalUsers->removeElement($generalUser);
    }

    /**
     * Get generalUsers
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getGeneralUsers()
    {
        return $this->generalUsers;
    }

    /**
     * Add referral
     *
     * @param \RxConnexionBundle\Entity\ReferralEntity $referral
     *
     * @return CityEntity
     */
    public function addReferral(\RxConnexionBundle\Entity\ReferralEntity $referral)
    {
        $this->referrals[] = $referral;

        return $this;
    }

    /**
     * Remove referral
     *
     * @param \RxConnexionBundle\Entity\ReferralEntity $referral
     */
    public function removeReferral(\RxConnexionBundle\Entity\ReferralEntity $referral)
    {
        $this->referrals->removeElement($referral);
    }

    /**
     * Get referrals
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getReferrals()
    {
        return $this->referrals;
    }

    /**
     * Add referringProvider
     *
     * @param \RxConnexionBundle\Entity\ReferringProviderEntity $referringProvider
     *
     * @return CityEntity
     */
    public function addReferringProvider(\RxConnexionBundle\Entity\ReferringProviderEntity $referringProvider)
    {
        $this->referringProviders[] = $referringProvider;

        return $this;
    }

    /**
     * Remove referringProvider
     *
     * @param \RxConnexionBundle\Entity\ReferringProviderEntity $referringProvider
     */
    public function removeReferringProvider(\RxConnexionBundle\Entity\ReferringProviderEntity $referringProvider)
    {
        $this->referringProviders->removeElement($referringProvider);
    }

    /**
     * Get referringProviders
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getReferringProviders()
    {
        return $this->referringProviders;
    }

    /**
     * Add referringHealthFacility
     *
     * @param \RxConnexionBundle\Entity\ReferringHealthFacilityEntity $referringHealthFacility
     *
     * @return CityEntity
     */
    public function addReferringHealthFacility(\RxConnexionBundle\Entity\ReferringHealthFacilityEntity $referringHealthFacility)
    {
        $this->referringHealthFacilities[] = $referringHealthFacility;

        return $this;
    }

    /**
     * Remove referringHealthFacility
     *
     * @param \RxConnexionBundle\Entity\ReferringHealthFacilityEntity $referringHealthFacility
     */
    public function removeReferringHealthFacility(\RxConnexionBundle\Entity\ReferringHealthFacilityEntity $referringHealthFacility)
    {
        $this->referringHealthFacilities->removeElement($referringHealthFacility);
    }

    /**
     * Get referringHealthFacilities
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getReferringHealthFacilities()
    {
        return $this->referringHealthFacilities;
    }

    /**
     * Add postalCode
     *
     * @param \RxConnexionBundle\Entity\PostalCodeEntity $postalCode
     *
     * @return CityEntity
     */
    public function addPostalCode(\RxConnexionBundle\Entity\PostalCodeEntity $postalCode)
    {
        $this->postalCodes[] = $postalCode;

        return $this;
    }

    /**
     * Remove postalCode
     *
     * @param \RxConnexionBundle\Entity\PostalCodeEntity $postalCode
     */
    public function removePostalCode(\RxConnexionBundle\Entity\PostalCodeEntity $postalCode)
    {
        $this->postalCodes->removeElement($postalCode);
    }

    /**
     * Get postalCodes
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getPostalCodes()
    {
        return $this->postalCodes;
    }

    /**
     * Add insurance
     *
     * @param \RxConnexionBundle\Entity\InsuranceEntity $insurance
     *
     * @return CityEntity
     */
    public function addInsurance(\RxConnexionBundle\Entity\InsuranceEntity $insurance)
    {
        $this->insurances[] = $insurance;

        return $this;
    }

    /**
     * Remove insurance
     *
     * @param \RxConnexionBundle\Entity\InsuranceEntity $insurance
     */
    public function removeInsurance(\RxConnexionBundle\Entity\InsuranceEntity $insurance)
    {
        $this->insurances->removeElement($insurance);
    }

    /**
     * Get insurances
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getInsurances()
    {
        return $this->insurances;
    }

    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set createdBy
     *
     * @param string $createdBy
     *
     * @return CityEntity
     */
    public function setCreatedBy($createdBy)
    {
        $this->createdBy = $createdBy;

        return $this;
    }

    /**
     * Get createdBy
     *
     * @return string
     */
    public function getCreatedBy()
    {
        return $this->createdBy;
    }

    /**
     * Set createdAt
     *
     * @param \DateTime $createdAt
     *
     * @return CityEntity
     */
    public function setCreatedAt($createdAt)
    {
        $this->createdAt = $createdAt;

        return $this;
    }

    /**
     * Get createdAt
     *
     * @return \DateTime
     */
    public function getCreatedAt()
    {
        return $this->createdAt;
    }

    /**
     * Set updatedBy
     *
     * @param string $updatedBy
     *
     * @return CityEntity
     */
    public function setUpdatedBy($updatedBy)
    {
        $this->updatedBy = $updatedBy;

        return $this;
    }

    /**
     * Get updatedBy
     *
     * @return string
     */
    public function getUpdatedBy()
    {
        return $this->updatedBy;
    }

    /**
     * Set updatedAt
     *
     * @param \DateTime $updatedAt
     *
     * @return CityEntity
     */
    public function setUpdatedAt($updatedAt)
    {
        $this->updatedAt = $updatedAt;

        return $this;
    }

    /**
     * Get updatedAt
     *
     * @return \DateTime
     */
    public function getUpdatedAt()
    {
        return $this->updatedAt;
    }

    /**
     * Set isDeleted
     *
     * @param boolean $isDeleted
     *
     * @return CityEntity
     */
    public function setIsDeleted($isDeleted)
    {
        $this->isDeleted = $isDeleted;

        return $this;
    }

    /**
     * Get isDeleted
     *
     * @return boolean
     */
    public function getIsDeleted()
    {
        return $this->isDeleted;
    }

    /**
     * Add financingCompany
     *
     * @param \RxConnexionBundle\Entity\FinancingCompanyEntity $financingCompany
     *
     * @return CityEntity
     */
    public function addFinancingCompany(\RxConnexionBundle\Entity\FinancingCompanyEntity $financingCompany)
    {
        $this->financingCompanies[] = $financingCompany;

        return $this;
    }

    /**
     * Remove financingCompany
     *
     * @param \RxConnexionBundle\Entity\FinancingCompanyEntity $financingCompany
     */
    public function removeFinancingCompany(\RxConnexionBundle\Entity\FinancingCompanyEntity $financingCompany)
    {
        $this->financingCompanies->removeElement($financingCompany);
    }

    /**
     * Get financingCompanies
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getFinancingCompanies()
    {
        return $this->financingCompanies;
    }

    /**
     * Add marketingStaff
     *
     * @param \RxConnexionBundle\Entity\MarketingStaffEntity $marketingStaff
     *
     * @return CityEntity
     */
    public function addMarketingStaff(\RxConnexionBundle\Entity\MarketingStaffEntity $marketingStaff)
    {
        $this->marketingStaffs[] = $marketingStaff;

        return $this;
    }

    /**
     * Remove marketingStaff
     *
     * @param \RxConnexionBundle\Entity\MarketingStaffEntity $marketingStaff
     */
    public function removeMarketingStaff(\RxConnexionBundle\Entity\MarketingStaffEntity $marketingStaff)
    {
        $this->marketingStaffs->removeElement($marketingStaff);
    }

    /**
     * Get marketingStaffs
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getMarketingStaffs()
    {
        return $this->marketingStaffs;
    }

    /**
     * Add supplier
     *
     * @param \RxConnexionBundle\Entity\SupplierEntity $supplier
     *
     * @return CityEntity
     */
    public function addSupplier(\RxConnexionBundle\Entity\SupplierEntity $supplier)
    {
        $this->suppliers[] = $supplier;

        return $this;
    }

    /**
     * Remove supplier
     *
     * @param \RxConnexionBundle\Entity\SupplierEntity $supplier
     */
    public function removeSupplier(\RxConnexionBundle\Entity\SupplierEntity $supplier)
    {
        $this->suppliers->removeElement($supplier);
    }

    /**
     * Get suppliers
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getSuppliers()
    {
        return $this->suppliers;
    }
}
