<?php

namespace RxConnexionBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use RxConnexionBundle\Entity\Base\BaseEntity;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;
use JMS\Serializer\Annotation\Groups;
use JMS\Serializer\Annotation\MaxDepth;

/**
 * @ORM\Entity(repositoryClass="RxConnexionBundle\Repository\ReferralRepository")
 * @ORM\Table(name="referral")
 */

class ReferralEntity extends BaseEntity
{
    const GENDER_MALE = 'Male';
    const GENDER_FEMALE = 'Female';

    /**
     * @ORM\Column(name="referral_date", type="datetime", nullable=true)
     * @Groups("forAudit")
     */
    protected $referralDate;

    /**
     * @ORM\Column(name="receive_date", type="datetime", nullable=true)
     * @Groups("forAudit")
     */
    protected $receiveDate;

    /**
     * @ORM\Column(name="first_name", type="string", nullable=true)
     * @Groups("forAudit")
     */
    protected $firstName;

    /**
     * @ORM\Column(name="middle_name", type="string", nullable=true)
     * @Groups("forAudit")
     */
    protected $middleName;

    /**
     * @ORM\Column(name="last_name", type="string", nullable=true)
     * @Groups("forAudit")
     */
    protected $lastName;

    /**
     * @ORM\Column(name="full_name", type="string", nullable=true)
     */
    protected $fullName;

    /**
     * @ORM\Column(name="gender", type="string", nullable=true)
     * @Groups("forAudit")
     */
    protected $gender;

    /**
     * @ORM\Column(name="birth_date", type="datetime", nullable=true)
     * @Groups("forAudit")
     */
    protected $birthDate;

    /**
     * @ORM\Column(type="string", nullable=true)
     * @Groups("forAudit")
     */
    protected $address;

    /**
     * @ORM\Column(type="string", nullable=true)
     * @Groups("forAudit")
     */
    protected $street;

    /**
     * @ORM\Column(name="mobile_no", type="string", nullable=true)
     * @Groups("forAudit")
     */
    protected $mobileNo;

    /**
     * @ORM\Column(name="mobile_no_two", type="string", nullable=true)
     * @Groups("forAudit")
     */
    protected $mobileNoTwo;

    /**
     * @ORM\Column(name="mobile_no_three", type="string", nullable=true)
     * @Groups("forAudit")
     */
    protected $mobileNoThree;

    /**
     * @ORM\Column(name="phone_no", type="string", nullable=true)
     * @Groups("forAudit")
     */
    protected $phoneNo;

    /**
     * @ORM\Column(name="phone_no_two", type="string", nullable=true)
     * @Groups("forAudit")
     */
    protected $phoneNoTwo;

    /**
     * @ORM\Column(name="phone_no_three", type="string", nullable=true)
     * @Groups("forAudit")
     */
    protected $phoneNoThree;

    /**
     * @ORM\Column(name="email", type="string", nullable=true)
     * @Groups("forAudit")
     */
    protected $email;

    /**
     * @ORM\Column(name="email_two", type="string", nullable=true)
     * @Groups("forAudit")
     */
    protected $emailTwo;

    /**
     * @ORM\Column(name="email_three", type="string", nullable=true)
     * @Groups("forAudit")
     */
    protected $emailThree;

    /**
     * @ORM\Column(name="note", type="text", nullable=true)
     * @Groups("forAudit")
     */
    protected $note;

    /**
     * @ORM\Column(name="is_approved", type="boolean", nullable=true)
     * @Groups("forAudit")
     */
    protected $isApproved;

    /**
     * @ORM\Column(name="personal_health_no", type="string", nullable=true)
     * @Groups("forAudit")
     */
    protected $personalHealthNo;

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

    /**
     * @ORM\ManyToOne(targetEntity="CityEntity", inversedBy="referrals")
     * @ORM\JoinColumn(name="city_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $city;

    /**
     * @ORM\ManyToOne(targetEntity="PostalCodeEntity", inversedBy="referrals")
     * @ORM\JoinColumn(name="postal_code_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $postalCode;

    /**
     * @ORM\ManyToOne(targetEntity="ReferringHealthFacilityEntity", inversedBy="referrals", cascade={"persist"})
     * @ORM\JoinColumn(name="referring_health_facility_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $referringHealthFacility;

    /**
     * @ORM\ManyToOne(targetEntity="ReferringProviderEntity", inversedBy="referrals", cascade={"persist"})
     * @ORM\JoinColumn(name="referring_provider_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $referringProvider;

    /**
     * @ORM\ManyToOne(targetEntity="SourceEntity", inversedBy="referrals", cascade={"persist"})
     * @ORM\JoinColumn(name="source_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $source;

    /**
     * @ORM\ManyToOne(targetEntity="HealthFacilityEntity", inversedBy="referrals", cascade={"persist"})
     * @ORM\JoinColumn(name="health_facility_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $healthFacility;

    /**
     * @ORM\OneToOne(targetEntity="PatientEntity", mappedBy="referral", cascade={"remove"})
     */
    protected $patient;

    /**
     * @ORM\OneToMany(targetEntity="ReferralServiceEntity", mappedBy="referral", cascade={"persist", "remove"}, orphanRemoval=true)
     */
    protected $referralServices;

    /**
     * @ORM\OneToOne(targetEntity="FaxTranEntity", inversedBy="referral", cascade={"persist"})
     * @ORM\JoinColumn(name="fax_tran_id", referencedColumnName="id", nullable=true)
     */
    protected $faxTran;

    /**
     * Set createdAt
     *
     * @ORM\PrePersist
     */
    public function setCreatedAtValue()
    {
        parent::setCreatedAtValue();
        $this->fullName = ucfirst($this->firstName) . ' ' . ucfirst($this->lastName);
        $this->updateAddress();
        //SET IS APPROVED FOR PATIENT
        $this->isApproved = true;
        $this->isDeleted = 0;
    }

    /**
     * Set updatedAt
     *
     * @ORM\PreUpdate
     */
    public function setUpdatedAtValue()
    {
        parent::setUpdatedAtValue();
        $this->fullName = ucfirst($this->firstName) . ' ' . ucfirst($this->lastName);
        $this->updateAddress();
    }
    /*--------------------------------------------------------------------------------------------------------*/
    /*					User Defined Setters and Getters													  */
    /*--------------------------------------------------------------------------------------------------------*/
    /**
     * Concatenate address
     */
    public function updateAddress() {
        $this->address = $this->street . ' ' . ($this->city ? $this->city->getDescription() . ', ' . ($this->city->getProvince() != null ? $this->city->getProvince()->getDescription() : '') . ' ' . ($this->city->getProvince() != null ? $this->city->getProvince()->getCountry()->getDescription() : '')  . ' ' : '') . ($this->getPostalCode() ? $this->getPostalCode()->getDescription() : '');
    }

    /**
     * Get birthDateAsString
     *
     * @return string
     */
    public function getBirthDateAsString() {
        $dttst = new DateTimeToStringTransformer();
        return !empty($this->birthDate) ? date('m/d/Y', strtotime($dttst->transform($this->birthDate))) : '';
    }

    /**
     * Get referralDateAsString
     *
     * @return string
     */
    public function getReferralDateAsString() {

        $dttst = new DateTimeToStringTransformer();
        return !empty($this->referralDate) ? date('m/d/Y', strtotime($dttst->transform($this->referralDate))) : '';
    }

    /**
     * Get receiveDateAsString
     *
     * @return string
     */
    public function getReceiveDateAsString() {

        $dttst = new DateTimeToStringTransformer();
        return !empty($this->receiveDate) ? date('m/d/Y', strtotime($dttst->transform($this->receiveDate))) : '';
    }

    /**
     * Get age
     *
     * @return integer
     */
    public function getAge()
    {
        $dateTimeToStringTransformer = new DateTimeToStringTransformer();
        $year = date('Y');
        $month = date('m');
        $day = date('d');
        $birth_date_long = strtotime($dateTimeToStringTransformer->transform($this->birthDate));
        $birth_date_year = date('Y', $birth_date_long);
        $birth_date_month = date('m', $birth_date_long);
        $birth_date_day = date('d', $birth_date_long);
        $age = $year - $birth_date_year;
        if($month<$birth_date_month || ($month==$birth_date_month && $day < $birth_date_day))
            $age--;
        return $age;
    }

    /**
     * Get concatenatedMobileNo
     *
     * return string
     */
    public function getConcatenatedMobileNo() {

        $mobileNos = '';
        if(!empty($this->mobileNo)) $mobileNos .= (!empty($mobileNos) ? ', ' : '') . $this->mobileNo;
        if(!empty($this->mobileNoTwo)) $mobileNos .= (!empty($mobileNos) ? ', ' : '') . $this->mobileNoTwo;
        if(!empty($this->mobileNoThree)) $mobileNos .= (!empty($mobileNos) ? ', ' : '') . $this->mobileNoThree;

        return $mobileNos;
    }

    /**
     * Get concatenatedPhoneNo
     *
     * return string
     */
    public function getConcatenatedPhoneNo() {

        $phoneNos = '';
        if(!empty($this->phoneNo)) $phoneNos .= (!empty($phoneNos) ? ', ' : '') . $this->phoneNo;
        if(!empty($this->phoneNoTwo)) $phoneNos .= (!empty($phoneNos) ? ', ' : '') . $this->phoneNoTwo;
        if(!empty($this->phoneNoThree)) $phoneNos .= (!empty($phoneNos) ? ', ' : '') . $this->phoneNoThree;

        return $phoneNos;
    }

    /**
     * Get referralServiceByServiceId
     *
     * @param $serviceId
     * @return \RxConnexionBundle\Entity\ReferralServiceEntity | null
     */
    public function getReferralServiceByServiceId($serviceId) {
        if($this->referralServices->count()){
            foreach ($this->referralServices as $patientService){
                if($patientService->getService()->getId() == $serviceId){
                    return $patientService;
                }
            }
        }
        return null;
    }
    /*--------------------------------------------------------------------------------------------------------*/
    /*					Setters and Getters																	  */
    /*--------------------------------------------------------------------------------------------------------*/
    

    /**
     * Set firstName
     *
     * @param string $firstName
     *
     * @return ReferralEntity
     */
    public function setFirstName($firstName)
    {
        $this->firstName = $firstName;

        return $this;
    }

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

    /**
     * Set middleName
     *
     * @param string $middleName
     *
     * @return ReferralEntity
     */
    public function setMiddleName($middleName)
    {
        $this->middleName = $middleName;

        return $this;
    }

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

    /**
     * Set lastName
     *
     * @param string $lastName
     *
     * @return ReferralEntity
     */
    public function setLastName($lastName)
    {
        $this->lastName = $lastName;

        return $this;
    }

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

    /**
     * Set fullName
     *
     * @param string $fullName
     *
     * @return ReferralEntity
     */
    public function setFullName($fullName)
    {
        $this->fullName = $fullName;

        return $this;
    }

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

    /**
     * Set gender
     *
     * @param string $gender
     *
     * @return ReferralEntity
     */
    public function setGender($gender)
    {
        $this->gender = $gender;

        return $this;
    }

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

    /**
     * Set birthDate
     *
     * @param \DateTime $birthDate
     *
     * @return ReferralEntity
     */
    public function setBirthDate($birthDate)
    {
        $birthDateExploded = explode('/', $birthDate);
        if((count($birthDateExploded) == 3 && !checkdate($birthDateExploded[0], $birthDateExploded[1], $birthDateExploded[2])) || empty($birthDate)){
            $this->birthDate = NULL;
        }else{
            $this->birthDate = new \DateTime($birthDate);
        }

        return $this;
    }

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

    /**
     * Set address
     *
     * @param string $address
     *
     * @return ReferralEntity
     */
    public function setAddress($address)
    {
        $this->address = $address;

        return $this;
    }

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

    /**
     * Set street
     *
     * @param string $street
     *
     * @return ReferralEntity
     */
    public function setStreet($street)
    {
        $this->street = $street;

        return $this;
    }

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

    /**
     * Set mobileNo
     *
     * @param string $mobileNo
     *
     * @return ReferralEntity
     */
    public function setMobileNo($mobileNo)
    {
        $this->mobileNo = $mobileNo;

        return $this;
    }

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

    /**
     * Set mobileNoTwo
     *
     * @param string $mobileNoTwo
     *
     * @return ReferralEntity
     */
    public function setMobileNoTwo($mobileNoTwo)
    {
        $this->mobileNoTwo = $mobileNoTwo;

        return $this;
    }

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

    /**
     * Set mobileNoThree
     *
     * @param string $mobileNoThree
     *
     * @return ReferralEntity
     */
    public function setMobileNoThree($mobileNoThree)
    {
        $this->mobileNoThree = $mobileNoThree;

        return $this;
    }

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

    /**
     * Set phoneNo
     *
     * @param string $phoneNo
     *
     * @return ReferralEntity
     */
    public function setPhoneNo($phoneNo)
    {
        $this->phoneNo = $phoneNo;

        return $this;
    }

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

    /**
     * Set phoneNoTwo
     *
     * @param string $phoneNoTwo
     *
     * @return ReferralEntity
     */
    public function setPhoneNoTwo($phoneNoTwo)
    {
        $this->phoneNoTwo = $phoneNoTwo;

        return $this;
    }

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

    /**
     * Set phoneNoThree
     *
     * @param string $phoneNoThree
     *
     * @return ReferralEntity
     */
    public function setPhoneNoThree($phoneNoThree)
    {
        $this->phoneNoThree = $phoneNoThree;

        return $this;
    }

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

    /**
     * Set email
     *
     * @param string $email
     *
     * @return ReferralEntity
     */
    public function setEmail($email)
    {
        $this->email = $email;

        return $this;
    }

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

    /**
     * Set emailTwo
     *
     * @param string $emailTwo
     *
     * @return ReferralEntity
     */
    public function setEmailTwo($emailTwo)
    {
        $this->emailTwo = $emailTwo;

        return $this;
    }

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

    /**
     * Set emailThree
     *
     * @param string $emailThree
     *
     * @return ReferralEntity
     */
    public function setEmailThree($emailThree)
    {
        $this->emailThree = $emailThree;

        return $this;
    }

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

    /**
     * Set note
     *
     * @param string $note
     *
     * @return ReferralEntity
     */
    public function setNote($note)
    {
        $this->note = $note;

        return $this;
    }

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

    /**
     * Set isApproved
     *
     * @param boolean $isApproved
     *
     * @return ReferralEntity
     */
    public function setIsApproved($isApproved)
    {
        $this->isApproved = $isApproved;

        return $this;
    }

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

    /**
     * Set city
     *
     * @param \RxConnexionBundle\Entity\CityEntity $city
     *
     * @return ReferralEntity
     */
    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;
    }

    /**
     * Set patient
     *
     * @param \RxConnexionBundle\Entity\PatientEntity $patient
     *
     * @return ReferralEntity
     */
    public function setPatient(\RxConnexionBundle\Entity\PatientEntity $patient = null)
    {
        $this->patient = $patient;

        return $this;
    }

    /**
     * Get patient
     *
     * @return \RxConnexionBundle\Entity\PatientEntity
     */
    public function getPatient()
    {
        return $this->patient;
    }

    /**
     * Set referringHealthFacility
     *
     * @param \RxConnexionBundle\Entity\ReferringHealthFacilityEntity $referringHealthFacility
     *
     * @return ReferralEntity
     */
    public function setReferringHealthFacility(\RxConnexionBundle\Entity\ReferringHealthFacilityEntity $referringHealthFacility = null)
    {
        $this->referringHealthFacility = $referringHealthFacility;

        return $this;
    }

    /**
     * Get referringHealthFacility
     *
     * @return \RxConnexionBundle\Entity\ReferringHealthFacilityEntity
     */
    public function getReferringHealthFacility()
    {
        return $this->referringHealthFacility;
    }

    /**
     * Set referringProvider
     *
     * @param \RxConnexionBundle\Entity\ReferringProviderEntity $referringProvider
     *
     * @return ReferralEntity
     */
    public function setReferringProvider(\RxConnexionBundle\Entity\ReferringProviderEntity $referringProvider = null)
    {
        $this->referringProvider = $referringProvider;

        return $this;
    }

    /**
     * Get referringProvider
     *
     * @return \RxConnexionBundle\Entity\ReferringProviderEntity
     */
    public function getReferringProvider()
    {
        return $this->referringProvider;
    }

    /**
     * Set source
     *
     * @param \RxConnexionBundle\Entity\SourceEntity $source
     *
     * @return ReferralEntity
     */
    public function setSource(\RxConnexionBundle\Entity\SourceEntity $source = null)
    {
        $this->source = $source;

        return $this;
    }

    /**
     * Get source
     *
     * @return \RxConnexionBundle\Entity\SourceEntity
     */
    public function getSource()
    {
        return $this->source;
    }

    /**
     * Set postalCode
     *
     * @param \RxConnexionBundle\Entity\PostalCodeEntity $postalCode
     *
     * @return ReferralEntity
     */
    public function setPostalCode(\RxConnexionBundle\Entity\PostalCodeEntity $postalCode = null)
    {
        $this->postalCode = $postalCode;

        return $this;
    }

    /**
     * Get postalCode
     *
     * @return \RxConnexionBundle\Entity\PostalCodeEntity
     */
    public function getPostalCode()
    {
        return $this->postalCode;
    }

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

    /**
     * Set createdBy
     *
     * @param string $createdBy
     *
     * @return ReferralEntity
     */
    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 ReferralEntity
     */
    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 ReferralEntity
     */
    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 ReferralEntity
     */
    public function setUpdatedAt($updatedAt)
    {
        $this->updatedAt = $updatedAt;

        return $this;
    }

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

    /**
     * Set personalHealthNo
     *
     * @param string $personalHealthNo
     *
     * @return ReferralEntity
     */
    public function setPersonalHealthNo($personalHealthNo)
    {
        $this->personalHealthNo = $personalHealthNo;

        return $this;
    }

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

    /**
     * Set referral
     *
     * @param \RxConnexionBundle\Entity\PatientEntity $referral
     *
     * @return ReferralEntity
     */
    public function setReferral(\RxConnexionBundle\Entity\PatientEntity $referral = null)
    {
        $this->referral = $referral;

        return $this;
    }

    /**
     * Get referral
     *
     * @return \RxConnexionBundle\Entity\PatientEntity
     */
    public function getReferral()
    {
        return $this->referral;
    }

    /**
     * Set faxTran
     *
     * @param \RxConnexionBundle\Entity\FaxTranEntity $faxTran
     *
     * @return ReferralEntity
     */
    public function setFaxTran(\RxConnexionBundle\Entity\FaxTranEntity $faxTran = null)
    {
        $this->faxTran = $faxTran;

        return $this;
    }

    /**
     * Get faxTran
     *
     * @return \RxConnexionBundle\Entity\FaxTranEntity
     */
    public function getFaxTran()
    {
        return $this->faxTran;
    }

    /**
     * Set healthFacility
     *
     * @param \RxConnexionBundle\Entity\HealthFacilityEntity $healthFacility
     *
     * @return ReferralEntity
     */
    public function setHealthFacility(\RxConnexionBundle\Entity\HealthFacilityEntity $healthFacility = null)
    {
        $this->healthFacility = $healthFacility;

        return $this;
    }

    /**
     * Get healthFacility
     *
     * @return \RxConnexionBundle\Entity\HealthFacilityEntity
     */
    public function getHealthFacility()
    {
        return $this->healthFacility;
    }

    /**
     * Set referralDate
     *
     * @param \DateTime $referralDate
     *
     * @return ReferralEntity
     */
    public function setReferralDate($referralDate)
    {
        $referralDateExploded = explode('/', $referralDate);
        if((count($referralDateExploded) == 3 && !checkdate($referralDateExploded[0], $referralDateExploded[1], $referralDateExploded[2])) || empty($referralDate)){
            $this->referralDate = NULL;
        }else{
            $this->referralDate = new \DateTime($referralDate);
        }

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Get isDeleted
     *
     * @return boolean
     */
    public function getIsDeleted()
    {
        return $this->isDeleted;
    }
    /**
     * Constructor
     */
    public function __construct()
    {
        $this->referralServices = new ArrayCollection();
    }


    /**
     * Add referralService
     *
     * @param \RxConnexionBundle\Entity\ReferralServiceEntity $referralService
     *
     * @return ReferralEntity
     */
    public function addReferralService(\RxConnexionBundle\Entity\ReferralServiceEntity $referralService)
    {
        $this->referralServices[] = $referralService;

        return $this;
    }

    /**
     * Remove referralService
     *
     * @param \RxConnexionBundle\Entity\ReferralServiceEntity $referralService
     */
    public function removeReferralService(\RxConnexionBundle\Entity\ReferralServiceEntity $referralService)
    {
        $this->referralServices->removeElement($referralService);
    }

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

    /**
     * Set receiveDate
     *
     * @param \DateTime $receiveDate
     *
     * @return ReferralEntity
     */
    public function setReceiveDate($receiveDate)
    {
        $this->receiveDate = empty($receiveDate) ? NULL : new \DateTime($receiveDate);

        return $this;
    }

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