<?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\PostalCodeRepository")
 * @ORM\Table(name="postal_code", indexes={
 *     @ORM\Index(name="IDX_SEARCH_000", columns={"is_deleted", "code", "description", "city_id"}),
 *     @ORM\Index(name="IDX_SEARCH_001", columns={"is_deleted", "description", "city_id"}),
 *     @ORM\Index(name="IDX_JOIN_000", columns={"id", "description", "city_id"})
 * })
 */

class PostalCodeEntity 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="CityEntity", inversedBy="postalCodes")
     * @ORM\JoinColumn(name="city_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $city;

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

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

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

    /**
     * @ORM\OneToMany(targetEntity="ReferringProviderEntity", mappedBy="postalCode", cascade={"remove"})
     */
    protected $referringProviders;

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

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

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

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

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

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

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


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

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


    /**
     * Set code
     *
     * @param string $code
     *
     * @return PostalCodeEntity
     */
    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 PostalCodeEntity
     */
    public function setDescription($description)
    {
        $this->description = $description;

        return $this;
    }

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

    /**
     * Set city
     *
     * @param \RxConnexionBundle\Entity\CityEntity $city
     *
     * @return PostalCodeEntity
     */
    public function setCity(\RxConnexionBundle\Entity\CityEntity $city = null)
    {
        $this->city = $city;

        return $this;
    }

    /**
     * Get city
     *
     * @return \RxConnexionBundle\Entity\CityEntity
     */
    public function getCity()
    {
        return $this->city;
    }

    /**
     * Add patient
     *
     * @param \RxConnexionBundle\Entity\PatientEntity $patient
     *
     * @return PostalCodeEntity
     */
    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 PostalCodeEntity
     */
    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 PostalCodeEntity
     */
    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 referringProvider
     *
     * @param \RxConnexionBundle\Entity\ReferringProviderEntity $referringProvider
     *
     * @return PostalCodeEntity
     */
    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 PostalCodeEntity
     */
    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 referral
     *
     * @param \RxConnexionBundle\Entity\ReferralEntity $referral
     *
     * @return PostalCodeEntity
     */
    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 insurance
     *
     * @param \RxConnexionBundle\Entity\InsuranceEntity $insurance
     *
     * @return PostalCodeEntity
     */
    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 PostalCodeEntity
     */
    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 PostalCodeEntity
     */
    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 PostalCodeEntity
     */
    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 PostalCodeEntity
     */
    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 PostalCodeEntity
     */
    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 PostalCodeEntity
     */
    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 PostalCodeEntity
     */
    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;
    }
}
