<?php

namespace RxConnexionBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use RxConnexionBundle\Entity\Base\BaseEntity;
use JMS\Serializer\Annotation\Groups;
use JMS\Serializer\Annotation\MaxDepth;

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

class MedicationEntity extends BaseEntity
{

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

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

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

    /**
     * @ORM\ManyToOne(targetEntity="MedicationTypeEntity", inversedBy="medications")
     * @ORM\JoinColumn(name="medication_type_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $medicationType;

    /**
     * @ORM\OneToMany(targetEntity="PatientDiagnosisMedicationEntity", mappedBy="medication")
     */
    protected $patientDiagnosisMedications;

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

    public function __construct()
    {
        $this->patientDiagnosisMedications = new ArrayCollection();
    }

    /*--------------------------------------------------------------------------------------------------------*/
    /*					User Defined Setters and Getters													  */
    /*--------------------------------------------------------------------------------------------------------*/

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


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

        return $this;
    }

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

    /**
     * Add patientDiagnosisMedication
     *
     * @param \RxConnexionBundle\Entity\PatientDiagnosisMedicationEntity $patientDiagnosisMedication
     *
     * @return MedicationEntity
     */
    public function addPatientDiagnosisMedication(\RxConnexionBundle\Entity\PatientDiagnosisMedicationEntity $patientDiagnosisMedication)
    {
        $this->patientDiagnosisMedications[] = $patientDiagnosisMedication;

        return $this;
    }

    /**
     * Remove patientDiagnosisMedication
     *
     * @param \RxConnexionBundle\Entity\PatientDiagnosisMedicationEntity $patientDiagnosisMedication
     */
    public function removePatientDiagnosisMedication(\RxConnexionBundle\Entity\PatientDiagnosisMedicationEntity $patientDiagnosisMedication)
    {
        $this->patientDiagnosisMedications->removeElement($patientDiagnosisMedication);
    }

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

    /**
     * Set medicationType
     *
     * @param \RxConnexionBundle\Entity\MedicationTypeEntity $medicationType
     *
     * @return MedicationEntity
     */
    public function setMedicationType(\RxConnexionBundle\Entity\MedicationTypeEntity $medicationType = null)
    {
        $this->medicationType = $medicationType;

        return $this;
    }

    /**
     * Get medicationType
     *
     * @return \RxConnexionBundle\Entity\MedicationTypeEntity
     */
    public function getMedicationType()
    {
        return $this->medicationType;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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