<?php

namespace RxConnexionBundle\Entity;

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

/**
 * @ORM\Entity(repositoryClass="RxConnexionBundle\Repository\InternalStatusRepository")
 * @ORM\Table(name="internal_status", indexes={@ORM\Index(name="IDX_SEARCH_000", columns={"description"})})
 */

class InternalStatusEntity extends BaseEntity
{

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

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

    /**
     * @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_active", type="boolean")
     * @Groups("forAudit")
     */
    protected $isActive;

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

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

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

    /**
     * Set createdAt
     *
     * @ORM\PrePersist
     */
    public function setCreatedAtValue()
    {
        parent::setCreatedAtValue();
        $this->isDeleted = 0;
        $this->removeFromDashboard = 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																	  */
    /*--------------------------------------------------------------------------------------------------------*/
    
    /**
     * Constructor
     */
    public function __construct()
    {
        $this->patientCharts = new \Doctrine\Common\Collections\ArrayCollection();
    }

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

        return $this;
    }

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

    /**
     * Set startDate
     *
     * @param \DateTime $startDate
     *
     * @return InternalStatusEntity
     */
    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 InternalStatusEntity
     */
    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 InternalStatusEntity
     */
    public function setIsActive($isActive)
    {
        $this->isActive = $isActive;

        return $this;
    }

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

    /**
     * Add patientChart
     *
     * @param \RxConnexionBundle\Entity\PatientChartEntity $patientChart
     *
     * @return InternalStatusEntity
     */
    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;
    }

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

        return $this;
    }

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

    /**
     * Set removeFromDashboard
     *
     * @param boolean $removeFromDashboard
     *
     * @return InternalStatusEntity
     */
    public function setRemoveFromDashboard($removeFromDashboard)
    {
        $this->removeFromDashboard = $removeFromDashboard;

        return $this;
    }

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