<?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\DiagnosisRepository")
 * @ORM\Table(name="diagnosis", indexes={@ORM\Index(name="IDX_SEARCH_000", columns={"description"})})
 */

class DiagnosisEntity extends BaseEntity
{
    /**
     * @ORM\Column(name="is_deleted", type="boolean")
     */
    protected $isDeleted;

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

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

    /**
     * @ORM\ManyToOne(targetEntity="DiagnosisTypeEntity", inversedBy="diagnoses")
     * @ORM\JoinColumn(name="diagnosis_type_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $diagnosisType;

    /**
     * @ORM\OneToMany(targetEntity="PatientDiagnosisEntity", mappedBy="diagnosis")
     */
    protected $patientDiagnoses;

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

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

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

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


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

        return $this;
    }

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

    /**
     * Set diagnosisType
     *
     * @param \RxConnexionBundle\Entity\DiagnosisTypeEntity $diagnosisType
     *
     * @return DiagnosisEntity
     */
    public function setDiagnosisType(\RxConnexionBundle\Entity\DiagnosisTypeEntity $diagnosisType = null)
    {
        $this->diagnosisType = $diagnosisType;

        return $this;
    }

    /**
     * Get diagnosisType
     *
     * @return \RxConnexionBundle\Entity\DiagnosisTypeEntity
     */
    public function getDiagnosisType()
    {
        return $this->diagnosisType;
    }

    /**
     * Add patientDiagnosis
     *
     * @param \RxConnexionBundle\Entity\PatientDiagnosisEntity $patientDiagnosis
     *
     * @return DiagnosisEntity
     */
    public function addPatientDiagnosis(\RxConnexionBundle\Entity\PatientDiagnosisEntity $patientDiagnosis)
    {
        $this->patientDiagnoses[] = $patientDiagnosis;

        return $this;
    }

    /**
     * Remove patientDiagnosis
     *
     * @param \RxConnexionBundle\Entity\PatientDiagnosisEntity $patientDiagnosis
     */
    public function removePatientDiagnosis(\RxConnexionBundle\Entity\PatientDiagnosisEntity $patientDiagnosis)
    {
        $this->patientDiagnoses->removeElement($patientDiagnosis);
    }

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

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

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

        return $this;
    }

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