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

class PatientRedFlagEntity 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="red_flag_note", type="text", nullable=true)
     * @Groups("forAudit")
     */
    protected $redFlagNote;

    /**
     * @ORM\Column(name="is_green_flag", type="boolean", nullable=true)
     */
    protected $isGreenFlag;

    /**
     * @ORM\Column(name="is_yellow_flag", type="boolean", nullable=true)
     */
    protected $isYellowFlag;

    /**
     * @ORM\Column(name="is_blue_flag", type="boolean", nullable=true)
     */
    protected $isBlueFlag;

    /**
     * @ORM\Column(name="is_red_flag", type="boolean", nullable=true)
     */
    protected $isRedFlag;

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

    /**
     * @ORM\ManyToOne(targetEntity="PatientEntity", inversedBy="patientRedFlags")
     * @ORM\JoinColumn(name="patient_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $patient;

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

    /*--------------------------------------------------------------------------------------------------------*/
    /*					User 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 PatientRedFlagEntity
     */
    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 PatientRedFlagEntity
     */
    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 redFlagNote
     *
     * @param string $redFlagNote
     *
     * @return PatientRedFlagEntity
     */
    public function setRedFlagNote($redFlagNote)
    {
        $this->redFlagNote = $redFlagNote;

        return $this;
    }

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

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

        return $this;
    }

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


    /**
     * Set patient
     *
     * @param \RxConnexionBundle\Entity\PatientEntity $patient
     *
     * @return PatientRedFlagEntity
     */
    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 isGreenFlag
     *
     * @param boolean $isGreenFlag
     *
     * @return PatientRedFlagEntity
     */
    public function setIsGreenFlag($isGreenFlag)
    {
        $this->isGreenFlag = $isGreenFlag;

        return $this;
    }

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

    /**
     * Set isYellowFlag
     *
     * @param boolean $isYellowFlag
     *
     * @return PatientRedFlagEntity
     */
    public function setIsYellowFlag($isYellowFlag)
    {
        $this->isYellowFlag = $isYellowFlag;

        return $this;
    }

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

    /**
     * Set isBlueFlag
     *
     * @param boolean $isBlueFlag
     *
     * @return PatientRedFlagEntity
     */
    public function setIsBlueFlag($isBlueFlag)
    {
        $this->isBlueFlag = $isBlueFlag;

        return $this;
    }

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

    /**
     * Set isRedFlag
     *
     * @param boolean $isRedFlag
     *
     * @return PatientRedFlagEntity
     */
    public function setIsRedFlag($isRedFlag)
    {
        $this->isRedFlag = $isRedFlag;

        return $this;
    }

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