<?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;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;

/**
 * @ORM\Entity(repositoryClass="RxConnexionBundle\Repository\NoteTemplateRepository")
 * @ORM\Table(name="note_template")
 */

class NoteTemplateEntity extends BaseEntity
{

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

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

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

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

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

    /**
     * @ORM\ManyToOne(targetEntity="ChartTypeEntity", inversedBy="noteTemplates")
     * @ORM\JoinColumn(name="chart_type_id", referencedColumnName="id")
     * @Groups("forAudit")
     */
    protected $chartType;

    /**
     * @ORM\ManyToOne(targetEntity="ChartStatusEntity", inversedBy="noteTemplates")
     * @ORM\JoinColumn(name="chart_status_id", referencedColumnName="id")
     * @Groups("forAudit")
     */
    protected $chartStatus;

    /**
     * @ORM\ManyToOne(targetEntity="CompanyEntity", inversedBy="noteTemplates")
     * @ORM\JoinColumn(name="company_id", referencedColumnName="id")
     * @Groups("forAudit")
     */
    protected $company;

    /**
     * @ORM\ManyToOne(targetEntity="HealthFacilityEntity", inversedBy="noteTemplates")
     * @ORM\JoinColumn(name="health_facility_id", referencedColumnName="id")
     * @Groups("forAudit")
     */
    protected $healthFacility;

    /**
     * @ORM\OneToMany(targetEntity="PatientNoteEntity", mappedBy="noteTemplate", cascade={"remove"})
     */
    protected $patientNotes;

    /**
     * @ORM\OneToMany(targetEntity="ReferringHealthFacilityNoteEntity", mappedBy="noteTemplate", cascade={"remove"})
     */
    protected $referringHealthFacilityNotes;

    /**
     * @ORM\OneToMany(targetEntity="ReferringProviderNoteEntity", mappedBy="noteTemplate", cascade={"remove"})
     */
    protected $referringProviderNotes;

    /**
     * @ORM\OneToMany(targetEntity="ScheduleEntity", mappedBy="noteTemplate", cascade={"remove"})
     */
    protected $schedules;

    /**
     * @ORM\OneToMany(targetEntity="PatientChartEntity", mappedBy="noteTemplate", cascade={"remove"})
     */
    protected $patientCharts;

    /**
     * @ORM\OneToMany(targetEntity="ReferringProviderChartEntity", mappedBy="noteTemplate", cascade={"remove"})
     */
    protected $referringProviderCharts;

    /**
     * @ORM\OneToMany(targetEntity="ReferringHealthFacilityChartEntity", mappedBy="noteTemplate", cascade={"remove"})
     */
    protected $referringHealthFacilityCharts;

    /**
     * @ORM\OneToMany(targetEntity="MarketingStaffScheduleEntity", mappedBy="noteTemplate", cascade={"remove"})
     */
    protected $marketingStaffSchedules;

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

    public function __construct()
    {
        $this->patientNotes = new ArrayCollection();
        $this->referringProviderNotes = new ArrayCollection();
        $this->referringHealthFacilityNotes = new ArrayCollection();
        $this->patientCharts = new ArrayCollection();
        $this->marketingStaffSchedules = new ArrayCollection();
        $this->schedules = new ArrayCollection();
        $this->referringProviderCharts = new ArrayCollection();
        $this->referringHealthFacilityCharts = new ArrayCollection();
    }

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

        return $this;
    }

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

    /**
     * Set note
     *
     * @param string $note
     *
     * @return NoteTemplateEntity
     */
    public function setNote($note)
    {
        $this->note = $note;

        return $this;
    }

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

    /**
     * Set company
     *
     * @param \RxConnexionBundle\Entity\CompanyEntity $company
     *
     * @return NoteTemplateEntity
     */
    public function setCompany(\RxConnexionBundle\Entity\CompanyEntity $company = null)
    {
        $this->company = $company;

        return $this;
    }

    /**
     * Get company
     *
     * @return \RxConnexionBundle\Entity\CompanyEntity
     */
    public function getCompany()
    {
        return $this->company;
    }
    /**
     * Constructor
     */

    /**
     * Add patientNote
     *
     * @param \RxConnexionBundle\Entity\PatientNoteEntity $patientNote
     *
     * @return NoteTemplateEntity
     */
    public function addPatientNote(\RxConnexionBundle\Entity\PatientNoteEntity $patientNote)
    {
        $this->patientNotes[] = $patientNote;

        return $this;
    }

    /**
     * Remove patientNote
     *
     * @param \RxConnexionBundle\Entity\PatientNoteEntity $patientNote
     */
    public function removePatientNote(\RxConnexionBundle\Entity\PatientNoteEntity $patientNote)
    {
        $this->patientNotes->removeElement($patientNote);
    }

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

    /**
     * Set description
     *
     * @param string $description
     *
     * @return NoteTemplateEntity
     */
    public function setDescription($description)
    {
        $this->description = $description;

        return $this;
    }

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

    /**
     * Add referringHealthFacilityNote
     *
     * @param \RxConnexionBundle\Entity\ReferringHealthFacilityNoteEntity $referringHealthFacilityNote
     *
     * @return NoteTemplateEntity
     */
    public function addReferringHealthFacilityNote(\RxConnexionBundle\Entity\ReferringHealthFacilityNoteEntity $referringHealthFacilityNote)
    {
        $this->referringHealthFacilityNotes[] = $referringHealthFacilityNote;

        return $this;
    }

    /**
     * Remove referringHealthFacilityNote
     *
     * @param \RxConnexionBundle\Entity\ReferringHealthFacilityNoteEntity $referringHealthFacilityNote
     */
    public function removeReferringHealthFacilityNote(\RxConnexionBundle\Entity\ReferringHealthFacilityNoteEntity $referringHealthFacilityNote)
    {
        $this->referringHealthFacilityNotes->removeElement($referringHealthFacilityNote);
    }

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

    /**
     * Add referringProvider
     *
     * @param \RxConnexionBundle\Entity\ReferringProviderNoteEntity $referringProvider
     *
     * @return NoteTemplateEntity
     */
    public function addReferringProvider(\RxConnexionBundle\Entity\ReferringProviderNoteEntity $referringProvider)
    {
        $this->referringProvider[] = $referringProvider;

        return $this;
    }

    /**
     * Remove referringProvider
     *
     * @param \RxConnexionBundle\Entity\ReferringProviderNoteEntity $referringProvider
     */
    public function removeReferringProvider(\RxConnexionBundle\Entity\ReferringProviderNoteEntity $referringProvider)
    {
        $this->referringProvider->removeElement($referringProvider);
    }

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

    /**
     * Add schedule
     *
     * @param \RxConnexionBundle\Entity\ScheduleEntity $schedule
     *
     * @return NoteTemplateEntity
     */
    public function addSchedule(\RxConnexionBundle\Entity\ScheduleEntity $schedule)
    {
        $this->schedules[] = $schedule;

        return $this;
    }

    /**
     * Remove schedule
     *
     * @param \RxConnexionBundle\Entity\ScheduleEntity $schedule
     */
    public function removeSchedule(\RxConnexionBundle\Entity\ScheduleEntity $schedule)
    {
        $this->schedules->removeElement($schedule);
    }

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

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

    /**
     * Add referringProviderChart
     *
     * @param \RxConnexionBundle\Entity\ReferringProviderChartEntity $referringProviderChart
     *
     * @return NoteTemplateEntity
     */
    public function addReferringProviderChart(\RxConnexionBundle\Entity\ReferringProviderChartEntity $referringProviderChart)
    {
        $this->referringProviderCharts[] = $referringProviderChart;

        return $this;
    }

    /**
     * Remove referringProviderChart
     *
     * @param \RxConnexionBundle\Entity\ReferringProviderChartEntity $referringProviderChart
     */
    public function removeReferringProviderChart(\RxConnexionBundle\Entity\ReferringProviderChartEntity $referringProviderChart)
    {
        $this->referringProviderCharts->removeElement($referringProviderChart);
    }

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

    /**
     * Add referringHealthFacilityChart
     *
     * @param \RxConnexionBundle\Entity\ReferringHealthFacilityChartEntity $referringHealthFacilityChart
     *
     * @return NoteTemplateEntity
     */
    public function addReferringHealthFacilityChart(\RxConnexionBundle\Entity\ReferringHealthFacilityChartEntity $referringHealthFacilityChart)
    {
        $this->referringHealthFacilityCharts[] = $referringHealthFacilityChart;

        return $this;
    }

    /**
     * Remove referringHealthFacilityChart
     *
     * @param \RxConnexionBundle\Entity\ReferringHealthFacilityChartEntity $referringHealthFacilityChart
     */
    public function removeReferringHealthFacilityChart(\RxConnexionBundle\Entity\ReferringHealthFacilityChartEntity $referringHealthFacilityChart)
    {
        $this->referringHealthFacilityCharts->removeElement($referringHealthFacilityChart);
    }

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

    /**
     * Add marketingStaffSchedule
     *
     * @param \RxConnexionBundle\Entity\MarketingStaffScheduleEntity $marketingStaffSchedule
     *
     * @return NoteTemplateEntity
     */
    public function addMarketingStaffSchedule(\RxConnexionBundle\Entity\MarketingStaffScheduleEntity $marketingStaffSchedule)
    {
        $this->marketingStaffSchedules[] = $marketingStaffSchedule;

        return $this;
    }

    /**
     * Remove marketingStaffSchedule
     *
     * @param \RxConnexionBundle\Entity\MarketingStaffScheduleEntity $marketingStaffSchedule
     */
    public function removeMarketingStaffSchedule(\RxConnexionBundle\Entity\MarketingStaffScheduleEntity $marketingStaffSchedule)
    {
        $this->marketingStaffSchedules->removeElement($marketingStaffSchedule);
    }

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

    /**
     * Set healthFacility
     *
     * @param \RxConnexionBundle\Entity\HealthFacilityEntity $healthFacility
     *
     * @return NoteTemplateEntity
     */
    public function setHealthFacility(\RxConnexionBundle\Entity\HealthFacilityEntity $healthFacility = null)
    {
        $this->healthFacility = $healthFacility;

        return $this;
    }

    /**
     * Get healthFacility
     *
     * @return \RxConnexionBundle\Entity\HealthFacilityEntity
     */
    public function getHealthFacility()
    {
        return $this->healthFacility;
    }

    /**
     * Set userType
     *
     * @param string $userType
     *
     * @return NoteTemplateEntity
     */
    public function setUserType($userType)
    {
        $this->userType = $userType;

        return $this;
    }

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

    /**
     * Set noteType
     *
     * @param string $noteType
     *
     * @return NoteTemplateEntity
     */
    public function setNoteType($noteType)
    {
        $this->noteType = $noteType;

        return $this;
    }

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

    /**
     * Set chartType
     *
     * @param \RxConnexionBundle\Entity\ChartTypeEntity $chartType
     *
     * @return NoteTemplateEntity
     */
    public function setChartType(\RxConnexionBundle\Entity\ChartTypeEntity $chartType = null)
    {
        $this->chartType = $chartType;

        return $this;
    }

    /**
     * Get chartType
     *
     * @return \RxConnexionBundle\Entity\ChartTypeEntity
     */
    public function getChartType()
    {
        return $this->chartType;
    }

    /**
     * Set chartStatus
     *
     * @param \RxConnexionBundle\Entity\ChartStatusEntity $chartStatus
     *
     * @return NoteTemplateEntity
     */
    public function setChartStatus(\RxConnexionBundle\Entity\ChartStatusEntity $chartStatus = null)
    {
        $this->chartStatus = $chartStatus;

        return $this;
    }

    /**
     * Get chartStatus
     *
     * @return \RxConnexionBundle\Entity\ChartStatusEntity
     */
    public function getChartStatus()
    {
        return $this->chartStatus;
    }

    /**
     * Add referringProviderNote
     *
     * @param \RxConnexionBundle\Entity\ReferringProviderNoteEntity $referringProviderNote
     *
     * @return NoteTemplateEntity
     */
    public function addReferringProviderNote(\RxConnexionBundle\Entity\ReferringProviderNoteEntity $referringProviderNote)
    {
        $this->referringProviderNotes[] = $referringProviderNote;

        return $this;
    }

    /**
     * Remove referringProviderNote
     *
     * @param \RxConnexionBundle\Entity\ReferringProviderNoteEntity $referringProviderNote
     */
    public function removeReferringProviderNote(\RxConnexionBundle\Entity\ReferringProviderNoteEntity $referringProviderNote)
    {
        $this->referringProviderNotes->removeElement($referringProviderNote);
    }

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