<?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\ReferringProviderHealthFacilityRepository")
 * @ORM\Table(name="referring_provider_health_facility")
 */

class ReferringProviderHealthFacilityEntity extends BaseEntity
{
    /**
     * @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="is_deleted", type="boolean")
     */
    protected $isDeleted;

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

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

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


    /*--------------------------------------------------------------------------------------------------------*/
    /*					Use Defined Setters and Getters														  */
    /*--------------------------------------------------------------------------------------------------------*/
    /**
     * 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))) : '';
    }
    /*--------------------------------------------------------------------------------------------------------*/
    /*					Setters and Getters																	  */
    /*--------------------------------------------------------------------------------------------------------*/


    /**
     * Set startDate
     *
     * @param \DateTime $startDate
     *
     * @return ReferringProviderHealthFacilityEntity
     */
    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 ReferringProviderHealthFacilityEntity
     */
    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 referringProvider
     *
     * @param \RxConnexionBundle\Entity\ReferringProviderEntity $referringProvider
     *
     * @return ReferringProviderHealthFacilityEntity
     */
    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 referringHealthFacility
     *
     * @param \RxConnexionBundle\Entity\ReferringHealthFacilityEntity $referringHealthFacility
     *
     * @return ReferringProviderHealthFacilityEntity
     */
    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 isDeleted
     *
     * @param boolean $isDeleted
     *
     * @return ReferringProviderHealthFacilityEntity
     */
    public function setIsDeleted($isDeleted)
    {
        $this->isDeleted = $isDeleted;

        return $this;
    }

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