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

class ChartTypeEntity extends BaseEntity
{
    const CATEGORY_CHART_TYPE_CLINICAL = "Clinical";
    const CATEGORY_CHART_TYPE_AR = "AR";
    const CATEGORY_CHART_TYPE_CBT = "CBT";
    const CATEGORY_CHART_TYPE_MARKETING = "Marketing";

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

    /**
     * @ORM\Column(name="has_billing", type="boolean")
     * @Groups("forAudit")
     */
    protected $hasBilling;

    /**
     * @ORM\Column(name="has_initial_assessment", type="boolean")
     * @Groups("forAudit")
     */
    protected $hasInitialAssessment;

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

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

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

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

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

    /**
     * @ORM\Column(name="num_day", type="decimal", precision=12, scale=2, nullable=true)
     * @Groups("forAudit")
     */
    protected $numDay;

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

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

    /**
     * @ORM\ManyToOne(targetEntity="AccountEntity", inversedBy="chartTypes")
     * @ORM\JoinColumn(name="account_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $account;

    /**
     * @ORM\OneToMany(targetEntity="ScheduleEntity", mappedBy="chartType")
     */
    protected $schedules;

    /**
     * @ORM\OneToMany(targetEntity="ScheduleQueuedEntity", mappedBy="chartType")
     */
    protected $schedulesQueued;

    /**
     * @ORM\OneToMany(targetEntity="ScheduleRequestEntity", mappedBy="chartType")
     */
    protected $scheduleRequests;

    /**
     * @ORM\OneToMany(targetEntity="ChartTypeMethodEntity", mappedBy="chartType")
     */
    protected $methods;

    /**
     * @ORM\OneToMany(targetEntity="ChartProcedureEntity", mappedBy="chartType")
     */
    protected $procedures;

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

    /**
     * @ORM\OneToMany(targetEntity="ChartStatusEntity", mappedBy="chartType")
     */
    protected $chartStatuses;

    /**
     * @ORM\OneToMany(targetEntity="ReferringHealthFacilityChartEntity", mappedBy="chartType")
     */
    protected $referringHealthFacilityCharts;

    /**
     * @ORM\OneToMany(targetEntity="ReferringProviderChartEntity", mappedBy="chartType")
     */
    protected $referringProviderCharts;

    /**
     * @ORM\OneToMany(targetEntity="RxConnexionBundle\Entity\MarketingStaffScheduleEntity", mappedBy="chartType")
     */
    protected $marketingStaffSchedules;

    public function __construct()
    {
        $this->schedules = new ArrayCollection();
        $this->schedulesQueued = new ArrayCollection();
        $this->scheduleRequests = new ArrayCollection();
        $this->methods = new ArrayCollection();
        $this->patientCharts = new ArrayCollection();
        $this->chartStatuses = new ArrayCollection();
        $this->referringHealthFacilityCharts = new ArrayCollection();
        $this->referringProviderCharts = new ArrayCollection();
        $this->marketingStaffSchedules = new ArrayCollection();
    }

    /**
     * Set createdAt
     *
     * @ORM\PrePersist
     */
    public function setCreatedAtValue()
    {
        parent::setCreatedAtValue();
        $this->isDeleted = 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))) : '';
    }

    /**
     * Get accountAndDescription
     *
     * @return string
     */
    public function getAccountAndDescription() {

        return ($this->account ? $this->account->getIdAndDescription() . ' | ' : '') . $this->description;
    }

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


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

        return $this;
    }

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

    /**
     * Set account
     *
     * @param \RxConnexionBundle\Entity\AccountEntity $account
     *
     * @return ChartTypeEntity
     */
    public function setAccount(\RxConnexionBundle\Entity\AccountEntity $account = null)
    {
        $this->account = $account;

        return $this;
    }

    /**
     * Get account
     *
     * @return \RxConnexionBundle\Entity\AccountEntity
     */
    public function getAccount()
    {
        return $this->account;
    }

    /**
     * Add schedule
     *
     * @param \RxConnexionBundle\Entity\ScheduleEntity $schedule
     *
     * @return ChartTypeEntity
     */
    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 schedulesQueued
     *
     * @param \RxConnexionBundle\Entity\ScheduleQueuedEntity $schedulesQueued
     *
     * @return ChartTypeEntity
     */
    public function addSchedulesQueued(\RxConnexionBundle\Entity\ScheduleQueuedEntity $schedulesQueued)
    {
        $this->schedulesQueued[] = $schedulesQueued;

        return $this;
    }

    /**
     * Remove schedulesQueued
     *
     * @param \RxConnexionBundle\Entity\ScheduleQueuedEntity $schedulesQueued
     */
    public function removeSchedulesQueued(\RxConnexionBundle\Entity\ScheduleQueuedEntity $schedulesQueued)
    {
        $this->schedulesQueued->removeElement($schedulesQueued);
    }

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

    /**
     * Add scheduleRequest
     *
     * @param \RxConnexionBundle\Entity\ScheduleRequestEntity $scheduleRequest
     *
     * @return ChartTypeEntity
     */
    public function addScheduleRequest(\RxConnexionBundle\Entity\ScheduleRequestEntity $scheduleRequest)
    {
        $this->scheduleRequests[] = $scheduleRequest;

        return $this;
    }

    /**
     * Remove scheduleRequest
     *
     * @param \RxConnexionBundle\Entity\ScheduleRequestEntity $scheduleRequest
     */
    public function removeScheduleRequest(\RxConnexionBundle\Entity\ScheduleRequestEntity $scheduleRequest)
    {
        $this->scheduleRequests->removeElement($scheduleRequest);
    }

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

    /**
     * Add method
     *
     * @param \RxConnexionBundle\Entity\ChartTypeMethodEntity $method
     *
     * @return ChartTypeEntity
     */
    public function addMethod(\RxConnexionBundle\Entity\ChartTypeMethodEntity $method)
    {
        $this->methods[] = $method;

        return $this;
    }

    /**
     * Remove method
     *
     * @param \RxConnexionBundle\Entity\ChartTypeMethodEntity $method
     */
    public function removeMethod(\RxConnexionBundle\Entity\ChartTypeMethodEntity $method)
    {
        $this->methods->removeElement($method);
    }

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

    /**
     * Add patientChart
     *
     * @param \RxConnexionBundle\Entity\PatientChartEntity $patientChart
     *
     * @return ChartTypeEntity
     */
    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 chartStatus
     *
     * @param \RxConnexionBundle\Entity\ChartStatusEntity $chartStatus
     *
     * @return ChartTypeEntity
     */
    public function addChartStatus(\RxConnexionBundle\Entity\ChartStatusEntity $chartStatus)
    {
        $this->chartStatuses[] = $chartStatus;

        return $this;
    }

    /**
     * Remove chartStatus
     *
     * @param \RxConnexionBundle\Entity\ChartStatusEntity $chartStatus
     */
    public function removeChartStatus(\RxConnexionBundle\Entity\ChartStatusEntity $chartStatus)
    {
        $this->chartStatuses->removeElement($chartStatus);
    }

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

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

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

        return $this;
    }

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

    /**
     * Set startDate
     *
     * @param \DateTime $startDate
     *
     * @return ChartTypeEntity
     */
    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 ChartTypeEntity
     */
    public function setEndDate($endDate)
    {
        $this->endDate = empty($endDate) ? NULL : new \DateTime($endDate);

        return $this;
    }

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

    /**
     * Add procedure
     *
     * @param \RxConnexionBundle\Entity\ChartProcedureEntity $procedure
     *
     * @return ChartTypeEntity
     */
    public function addProcedure(\RxConnexionBundle\Entity\ChartProcedureEntity $procedure)
    {
        $this->procedures[] = $procedure;

        return $this;
    }

    /**
     * Remove procedure
     *
     * @param \RxConnexionBundle\Entity\ChartProcedureEntity $procedure
     */
    public function removeProcedure(\RxConnexionBundle\Entity\ChartProcedureEntity $procedure)
    {
        $this->procedures->removeElement($procedure);
    }

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

    /**
     * Set isActive
     *
     * @param boolean $isActive
     *
     * @return ChartTypeEntity
     */
    public function setIsActive($isActive)
    {
        $this->isActive = $isActive;

        return $this;
    }

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

    /**
     * Set color
     *
     * @param string $color
     *
     * @return ChartTypeEntity
     */
    public function setColor($color)
    {
        $this->color = $color;

        return $this;
    }

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

    /**
     * Set numDay
     *
     * @param string $numDay
     *
     * @return ChartTypeEntity
     */
    public function setNumDay($numDay)
    {
        $this->numDay = str_replace(',' ,'',$numDay);

        return $this;
    }

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

    /**
     * Set hasVitals
     *
     * @param boolean $hasVitals
     *
     * @return ChartTypeEntity
     */
    public function setHasVitals($hasVitals)
    {
        $this->hasVitals = $hasVitals;

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Set hasBilling
     *
     * @param boolean $hasBilling
     *
     * @return ChartTypeEntity
     */
    public function setHasBilling($hasBilling)
    {
        $this->hasBilling = $hasBilling;

        return $this;
    }

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

    /**
     * Set rptProdOrdinal
     *
     * @param string $rptProdOrdinal
     *
     * @return ChartTypeEntity
     */
    public function setRptProdOrdinal($rptProdOrdinal)
    {
        $this->rptProdOrdinal = $rptProdOrdinal;

        return $this;
    }

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

    /**
     * Set chartTypeCategory
     *
     * @param string $chartTypeCategory
     *
     * @return ChartTypeEntity
     */
    public function setChartTypeCategory($chartTypeCategory)
    {
        $this->chartTypeCategory = $chartTypeCategory;

        return $this;
    }

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

    /**
     * Set dailyTargetPerClinician
     *
     * @param integer $dailyTargetPerClinician
     *
     * @return ChartTypeEntity
     */
    public function setDailyTargetPerClinician($dailyTargetPerClinician)
    {
        $this->dailyTargetPerClinician = $dailyTargetPerClinician;

        return $this;
    }

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

    /**
     * Set expectedNoOfDays
     *
     * @param integer $expectedNoOfDays
     *
     * @return ChartTypeEntity
     */
    public function setExpectedNoOfDays($expectedNoOfDays)
    {
        $this->expectedNoOfDays = $expectedNoOfDays;

        return $this;
    }

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

    /**
     * Set hasInitialAssessment
     *
     * @param boolean $hasInitialAssessment
     *
     * @return ChartTypeEntity
     */
    public function setHasInitialAssessment($hasInitialAssessment)
    {
        $this->hasInitialAssessment = $hasInitialAssessment;

        return $this;
    }

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

    /**
     * Set isCurrentAssessment
     *
     * @param boolean $isCurrentAssessment
     *
     * @return ChartTypeEntity
     */
    public function setIsCurrentAssessment($isCurrentAssessment)
    {
        $this->isCurrentAssessment = $isCurrentAssessment;

        return $this;
    }

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

    /**
     * Set isInitialAssessment
     *
     * @param boolean $isInitialAssessment
     *
     * @return ChartTypeEntity
     */
    public function setIsInitialAssessment($isInitialAssessment)
    {
        $this->isInitialAssessment = $isInitialAssessment;

        return $this;
    }

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