<?php

namespace RxConnexionBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
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\ProviderRepository")
 * @ORM\Table(name="provider", indexes={@ORM\Index(name="IDX_SEARCH_000", columns={"full_name"})})
 */

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

    /**
     * @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, nullable=true)
     * @Groups("forAudit")
     */
    protected $address;

    /**
     * @ORM\Column(type="string", nullable=true, 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="photo_description", type="string", nullable=true)
     * @Groups("forAudit")
     */
    protected $photoDescription;

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

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

    /**
     * @ORM\Column(name="start_date", type="datetime")
     * @Groups("forAudit")
     */
    protected $startDate;

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

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

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

    /**
     * @ORM\Column(name="is_active", type="boolean")
     * @Groups("forAudit")
     */
    protected $isActive;

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

    /**
     * @ORM\ManyToOne(targetEntity="ProviderTypeEntity", inversedBy="providers")
     * @ORM\JoinColumn(name="provider_type_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $providerType;

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

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

    /**
     * @ORM\OneToMany(targetEntity="AccountUserEntity", mappedBy="provider")
     */
    protected $accountUsers;

    /**
     * @ORM\OneToMany(targetEntity="ScheduleEntity", mappedBy="provider")
     */
    protected $schedules;

    /**
     * @ORM\OneToMany(targetEntity="ScheduleQueuedEntity", mappedBy="provider")
     */
    protected $schedulesQueued;

    /**
     * @ORM\OneToMany(targetEntity="ScheduleRequestEntity", mappedBy="provider")
     */
    protected $scheduleRequests;

    /**
     * @ORM\OneToMany(targetEntity="PatientChartEntity", mappedBy="provider")
     */
    protected $patientCharts;

    /**
     * @ORM\OneToMany(targetEntity="ProviderHealthFacilityEntity", mappedBy="provider", cascade={"remove"})
     */
    protected $healthFacilities;

    /**
     * @ORM\OneToMany(targetEntity="ProviderWorkScheduleEntity", mappedBy="provider", cascade={"remove"})
     */
    protected $providerWorkSchedules;

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

    /**
     * @ORM\OneToOne(targetEntity="PatientEntity", mappedBy="provider")
     */
    protected $patient;

    public function __construct()
    {
        $this->schedules = new ArrayCollection();
        $this->schedulesQueued = new ArrayCollection();
        $this->scheduleRequests = new ArrayCollection();
        $this->patientCharts = new ArrayCollection();
        $this->healthFacilities = new ArrayCollection();
        $this->providerWorkSchedules = new ArrayCollection();
        //$this->patient = new ArrayCollection();
        //$this->primaryPatientChart = new ArrayCollection();
    }

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

    /**
     * Set updatedAt
     *
     * @ORM\PreUpdate
     */
    public function setUpdatedAtValue()
    {
        parent::setUpdatedAtValue();
        $this->fullName = ucfirst($this->firstName) . ' ' . ucfirst($this->lastName);
        $this->updateAddress();
    }

    /**
     * Remove the photo from the disk
     *
     * @ORM\PreRemove
     */
    public function removePhoto() {

        $file = $this->getUploadRootDir() . '/' . $this->parsedPhotoDescription;
        if(!empty($this->parsedPhotoDescription) && file_exists($file)) unlink($file);
    }

    /**
     * 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() : '');
    }

    /*--------------------------------------------------------------------------------------------------------*/
    /*					Use Defined Setters and Getters														  */
    /*--------------------------------------------------------------------------------------------------------*/

	public function getWorkSchedulesToArray($params)
	{
		/**@var ProviderWorkScheduleEntity $providerWorkSchedule */

		$workSchedules = [];
		$branch_id = isset($params['branch_id']) ? $params['branch_id'] : NULL;
		$type = isset($params['type']) ? $params['type'] : NULL;

		if ($groupByType = isset($params['groupByType']) ? $params['groupByType'] : FALSE) {
			$workSchedules = [
				'regular'   => [],
				'irregular' => [],
				'out'       => [],
			];
		}

		foreach ($this->getProviderWorkSchedules() as $providerWorkSchedule) {
			if (!$providerWorkSchedule->getIsDeleted()){
				$workSchedule = [
					'id'                  => $providerWorkSchedule->getId(),
					'type'                => $providerWorkSchedule->getType(),
					'dayName'             => $providerWorkSchedule->getDayName(),
					'timeFrom'            => $providerWorkSchedule->getTimeFrom(),
					'timeTo'              => $providerWorkSchedule->getTimeTo(),
					'healthFacility'      => $providerWorkSchedule->getHealthFacility() ? $providerWorkSchedule->getHealthFacility()->getId() : NULL,
					'healthFacility_desc' => $providerWorkSchedule->getHealthFacility() ? $providerWorkSchedule->getHealthFacility()->getDescription() : NULL,
				];

				if($groupByType) {
					if($providerWorkSchedule->getType() == 'out' || (is_null($branch_id) || ($providerWorkSchedule->getHealthFacility() && $providerWorkSchedule->getHealthFacility()->getId()))) {
						$workSchedules[strtolower($providerWorkSchedule->getType())][] = $workSchedule;
					}
				} elseif((is_null($type) || $providerWorkSchedule->getType() == $type) && (is_null($branch_id) || ($providerWorkSchedule->getHealthFacility() && $providerWorkSchedule->getHealthFacility()->getId()))) {
					$workSchedules[] = $workSchedule;
				}
			}
		}

		return $workSchedules;
	}


    /**
     * Get defaultProviderHealthFacilityId
     *
     * @return string
     */
    public function getDefaultProviderHealthFacilityId(){
        $id = '';
        foreach($this->getHealthFacilities() as $healthFacility){
            if($healthFacility->getIsScheduleDefault()){
                return $healthFacility->getHealthFacility()->getId();
            }
        }
        return $id;
    }

    /**
     * Get startDateAsString
     *
     * @return string
     */
    public function getStartDateAsString() {

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

    /**
     * Get endDateAsString
     *
     * @return string
     */
    public function getEndDateAsString() {

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

    /**
     * Get uploadDir
     *
     * @return string
     */
    public function getUploadDir() {

        return 'uploads/provider/photo';
    }

    /**
     * Get uploadRootDir
     *
     * @return string
     */
    public function getUploadRootDir() {

        return __DIR__ . '/../../../web/' . $this->getUploadDir();
    }

    /**
     * get photoWebPath
     *
     * @return string
     */
    public function getPhotoWebPath() {

        $parsedDesc = $this->parsedPhotoDescription;
        $file = $this->getUploadRootDir() . '/' . $parsedDesc;

        if(!empty($parsedDesc) && file_exists($file)) {
            return '/' . $this->getUploadDir() . '/' . $parsedDesc;
        } else {
            return '';
        }
    }

    /**
     * Get allHealthFacilityIdsToArray
     *
     * @return array
     */
    public function getAllHealthFacilityIdsToArray() {

        $healthFacilityIds = array();

        foreach($this->healthFacilities as $healthFacility) {
            $healthFacilityIds[] = $healthFacility->getHealthFacility()->getId();
        }

        return $healthFacilityIds;
    }

    /**
     * Get concatenatedHealthFacilityIdsBySpace
     *
     * @return string
     */
    public function getConcatenatedHealthFacilityIdsBySpace() {

        $concatenatedHealthFacilityIdsBySpace = '';

        foreach($this->healthFacilities as $healthFacility) {

            $concatenatedHealthFacilityIdsBySpace .= (!empty($concatenatedHealthFacilityIdsBySpace) ? ' ' : '') . $healthFacility->getHealthFacility()->getId();
        }

        return $concatenatedHealthFacilityIdsBySpace;
    }

    /**
     * Get birthDateAsString
     *
     * @return string
     */
    public function getBirthDateAsString() {

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

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


    /**
     * Set firstName
     *
     * @param string $firstName
     *
     * @return ProviderEntity
     */
    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 ProviderEntity
     */
    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 ProviderEntity
     */
    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 ProviderEntity
     */
    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 ProviderEntity
     */
    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 ProviderEntity
     */
    public function setBirthDate($birthDate)
    {
        $this->birthDate = empty($birthDate) ? NULL : new \DateTime($birthDate);

        return $this;
    }

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

    /**
     * Set address
     *
     * @param string $address
     *
     * @return ProviderEntity
     */
    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 ProviderEntity
     */
    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 ProviderEntity
     */
    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 ProviderEntity
     */
    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 ProviderEntity
     */
    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 ProviderEntity
     */
    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 ProviderEntity
     */
    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 ProviderEntity
     */
    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 ProviderEntity
     */
    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 ProviderEntity
     */
    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 ProviderEntity
     */
    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 ProviderEntity
     */
    public function setNote($note)
    {
        $this->note = $note;

        return $this;
    }

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

    /**
     * Set photoDescription
     *
     * @param string $photoDescription
     *
     * @return ProviderEntity
     */
    public function setPhotoDescription($photoDescription)
    {
        $this->photoDescription = $photoDescription;

        return $this;
    }

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

    /**
     * Set parsedPhotoDescription
     *
     * @param string $parsedPhotoDescription
     *
     * @return ProviderEntity
     */
    public function setParsedPhotoDescription($parsedPhotoDescription)
    {
        $this->parsedPhotoDescription = $parsedPhotoDescription;

        return $this;
    }

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

    /**
     * Set providerType
     *
     * @param \RxConnexionBundle\Entity\ProviderTypeEntity $providerType
     *
     * @return ProviderEntity
     */
    public function setProviderType(\RxConnexionBundle\Entity\ProviderTypeEntity $providerType = null)
    {
        $this->providerType = $providerType;

        return $this;
    }

    /**
     * Get providerType
     *
     * @return \RxConnexionBundle\Entity\ProviderTypeEntity
     */
    public function getProviderType()
    {
        return $this->providerType;
    }

    /**
     * Set city
     *
     * @param \RxConnexionBundle\Entity\CityEntity $city
     *
     * @return ProviderEntity
     */
    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 schedule
     *
     * @param \RxConnexionBundle\Entity\ScheduleEntity $schedule
     *
     * @return ProviderEntity
     */
    public function addSchedule(\RxConnexionBundle\Entity\ScheduleEntity $schedule)
    {
        $this->schedules[] = $schedule;

        return $this;
    }

    /**
     * Remove schedule
     *
     * @param \RxConnexionBundle\Entity\ScheduleEntity $schedule
     */
    public function removeSchedule(\RxConnexionBundle\Entity\ScheduleEntity $schedule)
    {
        $this->schedules->removeElement($schedule);
    }

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

    /**
     * Add schedulesQueued
     *
     * @param \RxConnexionBundle\Entity\ScheduleQueuedEntity $schedulesQueued
     *
     * @return ProviderEntity
     */
    public function addSchedulesQueued(\RxConnexionBundle\Entity\ScheduleQueuedEntity $schedulesQueued)
    {
        $this->schedulesQueued[] = $schedulesQueued;

        return $this;
    }

    /**
     * Remove schedulesQueued
     *
     * @param \RxConnexionBundle\Entity\ScheduleQueuedEntity $schedulesQueued
     */
    public function removeSchedulesQueued(\RxConnexionBundle\Entity\ScheduleQueuedEntity $schedulesQueued)
    {
        $this->schedulesQueued->removeElement($schedulesQueued);
    }

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

    /**
     * Add scheduleRequest
     *
     * @param \RxConnexionBundle\Entity\ScheduleRequestEntity $scheduleRequest
     *
     * @return ProviderEntity
     */
    public function addScheduleRequest(\RxConnexionBundle\Entity\ScheduleRequestEntity $scheduleRequest)
    {
        $this->scheduleRequests[] = $scheduleRequest;

        return $this;
    }

    /**
     * Remove scheduleRequest
     *
     * @param \RxConnexionBundle\Entity\ScheduleRequestEntity $scheduleRequest
     */
    public function removeScheduleRequest(\RxConnexionBundle\Entity\ScheduleRequestEntity $scheduleRequest)
    {
        $this->scheduleRequests->removeElement($scheduleRequest);
    }

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

    /**
     * Add patientChart
     *
     * @param \RxConnexionBundle\Entity\PatientChartEntity $patientChart
     *
     * @return ProviderEntity
     */
    public function addPatientChart(\RxConnexionBundle\Entity\PatientChartEntity $patientChart)
    {
        $this->patientCharts[] = $patientChart;

        return $this;
    }

    /**
     * Remove patientChart
     *
     * @param \RxConnexionBundle\Entity\PatientChartEntity $patientChart
     */
    public function removePatientChart(\RxConnexionBundle\Entity\PatientChartEntity $patientChart)
    {
        $this->patientCharts->removeElement($patientChart);
    }

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

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

        return $this;
    }

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

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

    /**
     * Set postalCode
     *
     * @param \RxConnexionBundle\Entity\PostalCodeEntity $postalCode
     *
     * @return ProviderEntity
     */
    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;
    }

    /**
     * Set oldSysId
     *
     * @param string $oldSysId
     *
     * @return ProviderEntity
     */
    public function setOldSysId($oldSysId)
    {
        $this->oldSysId = $oldSysId;

        return $this;
    }

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

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

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

        return $this;
    }

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

    /**
     * Add providerWorkSchedule
     *
     * @param \RxConnexionBundle\Entity\ProviderWorkScheduleEntity $providerWorkSchedule
     *
     * @return ProviderEntity
     */
    public function addProviderWorkSchedule(\RxConnexionBundle\Entity\ProviderWorkScheduleEntity $providerWorkSchedule)
    {
        $this->providerWorkSchedules[] = $providerWorkSchedule;

        return $this;
    }

    /**
     * Remove providerWorkSchedule
     *
     * @param \RxConnexionBundle\Entity\ProviderWorkScheduleEntity $providerWorkSchedule
     */
    public function removeProviderWorkSchedule(\RxConnexionBundle\Entity\ProviderWorkScheduleEntity $providerWorkSchedule)
    {
        $this->providerWorkSchedules->removeElement($providerWorkSchedule);
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Set isActive
     *
     * @param boolean $isActive
     *
     * @return ProviderEntity
     */
    public function setIsActive($isActive)
    {
        $this->isActive = $isActive;

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Add accountUser
     *
     * @param \RxConnexionBundle\Entity\AccountUserEntity $accountUser
     *
     * @return ProviderEntity
     */
    public function addAccountUser(\RxConnexionBundle\Entity\AccountUserEntity $accountUser)
    {
        $this->accountUsers[] = $accountUser;

        return $this;
    }

    /**
     * Remove accountUser
     *
     * @param \RxConnexionBundle\Entity\AccountUserEntity $accountUser
     */
    public function removeAccountUser(\RxConnexionBundle\Entity\AccountUserEntity $accountUser)
    {
        $this->accountUsers->removeElement($accountUser);
    }

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

    /**
     * Set patient
     *
     * @param \RxConnexionBundle\Entity\PatientEntity $patient
     *
     * @return ProviderEntity
     */
    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 primaryPatientChart
     *
     * @param \RxConnexionBundle\Entity\PatientChartEntity $primaryPatientChart
     *
     * @return ProviderEntity
     */
    public function setPrimaryPatientChart(\RxConnexionBundle\Entity\PatientChartEntity $primaryPatientChart = null)
    {
        $this->primaryPatientChart = $primaryPatientChart;

        return $this;
    }

    /**
     * Get primaryPatientChart
     *
     * @return \RxConnexionBundle\Entity\PatientChartEntity
     */
    public function getPrimaryPatientChart()
    {
        return $this->primaryPatientChart;
    }

    /**
     * Add primaryPatientChart
     *
     * @param \RxConnexionBundle\Entity\PatientChartEntity $primaryPatientChart
     *
     * @return ProviderEntity
     */
    public function addPrimaryPatientChart(\RxConnexionBundle\Entity\PatientChartEntity $primaryPatientChart)
    {
        $this->primaryPatientCharts[] = $primaryPatientChart;

        return $this;
    }

    /**
     * Remove primaryPatientChart
     *
     * @param \RxConnexionBundle\Entity\PatientChartEntity $primaryPatientChart
     */
    public function removePrimaryPatientChart(\RxConnexionBundle\Entity\PatientChartEntity $primaryPatientChart)
    {
        $this->primaryPatientCharts->removeElement($primaryPatientChart);
    }

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

    /**
     * Add patientPrimaryProvider
     *
     * @param \RxConnexionBundle\Entity\PatientEntity $patientPrimaryProvider
     *
     * @return ProviderEntity
     */
    public function addPatientPrimaryProvider(\RxConnexionBundle\Entity\PatientEntity $patientPrimaryProvider)
    {
        $this->patientPrimaryProviders[] = $patientPrimaryProvider;

        return $this;
    }

    /**
     * Remove patientPrimaryProvider
     *
     * @param \RxConnexionBundle\Entity\PatientEntity $patientPrimaryProvider
     */
    public function removePatientPrimaryProvider(\RxConnexionBundle\Entity\PatientEntity $patientPrimaryProvider)
    {
        $this->patientPrimaryProviders->removeElement($patientPrimaryProvider);
    }

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

    /**
     * Set emergencyContactName
     *
     * @param string $emergencyContactName
     *
     * @return ProviderEntity
     */
    public function setEmergencyContactName($emergencyContactName)
    {
        $this->emergencyContactName = $emergencyContactName;

        return $this;
    }

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

    /**
     * Set emergencyContactNo
     *
     * @param string $emergencyContactNo
     *
     * @return ProviderEntity
     */
    public function setEmergencyContactNo($emergencyContactNo)
    {
        $this->emergencyContactNo = $emergencyContactNo;

        return $this;
    }

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