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

class AccountUserReminderEntity extends BaseEntity
{
    const REMINDER_STATUS_1 = 'Pending';
    const REMINDER_STATUS_2 = 'Completed';

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

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

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

    /**
     * @ORM\Column(name="status", type="string")
     */
    protected $status;

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

    /**
     * @ORM\ManyToOne(targetEntity="ReminderTypeEntity", inversedBy="accountUserReminders")
     * @ORM\JoinColumn(name="reminder_type_id", referencedColumnName="id")
     */
    protected $reminderType;

    /**
     * @ORM\ManyToOne(targetEntity="AccountUserEntity", inversedBy="accountUserReminders")
     * @ORM\JoinColumn(name="account_user_id", referencedColumnName="id")
     */
    protected $accountUser;

    /**
     * @ORM\ManyToOne(targetEntity="AccountUserEntity", inversedBy="assignedToAccountUserReminders")
     * @ORM\JoinColumn(name="assigned_to_account_user_id", referencedColumnName="id")
     */
    protected $assignedToAccountUser;


    /**
     * @ORM\ManyToOne(targetEntity="UserGroupEntity", inversedBy="assignedToAccountUserReminders")
     * @ORM\JoinColumn(name="assigned_to_user_group_id", referencedColumnName="id")
     */
    protected $assignedToUserGroup;

    /**
     * @ORM\ManyToOne(targetEntity="UserEntity", inversedBy="accountUserReminders")
     * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
     */
    protected $user;

    /**
     * @ORM\OneToMany(targetEntity="AccountUserReminderRefPatientEntity", mappedBy="accountUserReminder", cascade={"persist", "remove"}, orphanRemoval=true)
     */
    protected $accountUserReminderRefPatients;


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

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

    /**
     * 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																	  */
    /*--------------------------------------------------------------------------------------------------------*/


    /**
     * Constructor
     */
    public function __construct()
    {
        $this->accountUserReminderRefPatients = new ArrayCollection();
    }


    /**
     * Set startDate
     *
     * @param \DateTime $startDate
     *
     * @return AccountUserReminderEntity
     * @throws \Exception
     */
    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 AccountUserReminderEntity
     * @throws \Exception
     */
    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 note
     *
     * @param string $note
     *
     * @return AccountUserReminderEntity
     */
    public function setNote($note)
    {
        $this->note = $note;

        return $this;
    }

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

    /**
     * Set status
     *
     * @param string $status
     *
     * @return AccountUserReminderEntity
     */
    public function setStatus($status)
    {
        $this->status = $status;

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Set accountUser
     *
     * @param \RxConnexionBundle\Entity\AccountUserEntity $accountUser
     *
     * @return AccountUserReminderEntity
     */
    public function setAccountUser(\RxConnexionBundle\Entity\AccountUserEntity $accountUser = null)
    {
        $this->accountUser = $accountUser;

        return $this;
    }

    /**
     * Get accountUser
     *
     * @return \RxConnexionBundle\Entity\AccountUserEntity
     */
    public function getAccountUser()
    {
        return $this->accountUser;
    }

    /**
     * Set user
     *
     * @param \RxConnexionBundle\Entity\UserEntity $user
     *
     * @return AccountUserReminderEntity
     */
    public function setUser(\RxConnexionBundle\Entity\UserEntity $user = null)
    {
        $this->user = $user;

        return $this;
    }

    /**
     * Get user
     *
     * @return \RxConnexionBundle\Entity\UserEntity
     */
    public function getUser()
    {
        return $this->user;
    }

    /**
     * Add accountUserReminderRefPatient
     *
     * @param \RxConnexionBundle\Entity\AccountUserReminderRefPatientEntity $accountUserReminderRefPatient
     *
     * @return AccountUserReminderEntity
     */
    public function addAccountUserReminderRefPatient(\RxConnexionBundle\Entity\AccountUserReminderRefPatientEntity $accountUserReminderRefPatient)
    {
        $accountUserReminderRefPatient->setAccountUserReminder($this);
        $this->accountUserReminderRefPatients[] = $accountUserReminderRefPatient;

        return $this;
    }

    /**
     * Remove accountUserReminderRefPatient
     *
     * @param \RxConnexionBundle\Entity\AccountUserReminderRefPatientEntity $accountUserReminderRefPatient
     */
    public function removeAccountUserReminderRefPatient(\RxConnexionBundle\Entity\AccountUserReminderRefPatientEntity $accountUserReminderRefPatient)
    {
        $this->accountUserReminderRefPatients->removeElement($accountUserReminderRefPatient);
    }

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

    /**
     * Set assignedToAccountUser
     *
     * @param \RxConnexionBundle\Entity\AccountUserEntity $assignedToAccountUser
     *
     * @return AccountUserReminderEntity
     */
    public function setAssignedToAccountUser(\RxConnexionBundle\Entity\AccountUserEntity $assignedToAccountUser = null)
    {
        $this->assignedToAccountUser = $assignedToAccountUser;

        return $this;
    }

    /**
     * Get assignedToAccountUser
     *
     * @return \RxConnexionBundle\Entity\AccountUserEntity
     */
    public function getAssignedToAccountUser()
    {
        return $this->assignedToAccountUser;
    }

    /**
     * Set reminderType
     *
     * @param \RxConnexionBundle\Entity\ReminderTypeEntity $reminderType
     *
     * @return AccountUserReminderEntity
     */
    public function setReminderType(\RxConnexionBundle\Entity\ReminderTypeEntity $reminderType = null)
    {
        $this->reminderType = $reminderType;

        return $this;
    }

    /**
     * Get reminderType
     *
     * @return \RxConnexionBundle\Entity\ReminderTypeEntity
     */
    public function getReminderType()
    {
        return $this->reminderType;
    }

    /**
     * Set assignedToUserGroup
     *
     * @param \RxConnexionBundle\Entity\UserGroupEntity $assignedToUserGroup
     *
     * @return AccountUserReminderEntity
     */
    public function setAssignedToUserGroup(\RxConnexionBundle\Entity\UserGroupEntity $assignedToUserGroup = null)
    {
        $this->assignedToUserGroup = $assignedToUserGroup;

        return $this;
    }

    /**
     * Get assignedToUserGroup
     *
     * @return \RxConnexionBundle\Entity\UserGroupEntity
     */
    public function getAssignedToUserGroup()
    {
        return $this->assignedToUserGroup;
    }
}
