<?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\PatientChartRepository")
 * @ORM\Table(name="patient_chart", indexes={
 *     @ORM\Index(name="IDX_000AAA", columns={"chart_date", "is_deleted"}),
 *     @ORM\Index(name="IDX_000BBB", columns={"chart_date", "is_done", "is_deleted"}),
 *     @ORM\Index(name="IDX_000CCC", columns={"is_deleted"}),
 *     @ORM\Index(name="IDX_000DDD", columns={"created_at"})
 *     })
 */

class PatientChartEntity extends BaseEntity
{
    const IS_DONE = array(
        'Done'  => TRUE,
        'Not Done'  => FALSE,
    );
    const BILLING_STATUS_PENDING_BILLING = 'Pending Billing';
    const BILLING_STATUS_PENDING_PAYMENT = 'Pending Payment';
    const BILLING_STATUS_PAID = 'Paid';
    const BILLING_STATUS_VOID = 'Void';


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

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

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

    /**
     * @ORM\Column(name="is_done", type="boolean", nullable=true, options={"default":false})
     * @Groups("forAudit")
     */
    protected $isDone;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

//    /**
//     * @ORM\ManyToOne(targetEntity="LocationEntity", inversedBy="patientCharts")
//     * @ORM\JoinColumn(name="location_id", referencedColumnName="id")
//     * @Groups("forAudit")
//     * @MaxDepth(1)
//     */
//    protected $location;

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

    /**
     * @ORM\ManyToOne(targetEntity="ProviderEntity", inversedBy="patientCharts")
     * @ORM\JoinColumn(name="provider_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $provider;

    /**
     * @ORM\ManyToOne(targetEntity="AccountStaffEntity", inversedBy="patientCharts")
     * @ORM\JoinColumn(name="account_staff_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $accountStaff;

    /**
     * @ORM\ManyToOne(targetEntity="AccountUserBillingEntity", inversedBy="patientCharts")
     * @ORM\JoinColumn(name="account_user_billing_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $accountUserBilling;

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

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

    /**
     * @ORM\OneToOne(targetEntity="ScheduleEntity", inversedBy="patientChart")
     * @ORM\JoinColumn(name="schedule_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $schedule;

    /**
     * @ORM\ManyToOne(targetEntity="InternalStatusEntity", inversedBy="patientCharts")
     * @ORM\JoinColumn(name="internal_status_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $internalStatus;

    /**
     * @ORM\ManyToOne(targetEntity="AccountUserEntity", inversedBy="moaAssignmentPatientCharts")
     * @ORM\JoinColumn(name="account_user_moa_assignment_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $accountUserMoaAssignment;

    /**
     * @ORM\ManyToOne(targetEntity="NoteTemplateEntity", inversedBy="patientCharts")
     * @ORM\JoinColumn(name="note_template_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $noteTemplate;

    /**
     * @ORM\OneToMany(targetEntity="PatientChartTypeMethodEntity", mappedBy="patientChart", cascade={"persist", "remove"}, orphanRemoval=true)
     */
    protected $chartTypeMethods;

    /**
     * @ORM\OneToMany(targetEntity="PatientChartFileEntity", mappedBy="patientChart", cascade={"remove"})
     */
    protected $files;

    /**
     * @ORM\OneToMany(targetEntity="PatientChartProcedureEntity", mappedBy="patientChart", cascade={"remove"})
     */
    protected $procedures;

    /**
     * @ORM\OneToMany(targetEntity="PatientChartOtherProcedureEntity", mappedBy="patientChart", cascade={"remove"})
     */
    protected $otherProcedures;

    /**
     * @ORM\OneToMany(targetEntity="PatientChartPaymentEntity", mappedBy="patientChart", cascade={"remove"})
     */
    protected $payments;

    /**
     * @ORM\OneToMany(targetEntity="PatientChartNoteEntity", mappedBy="patientChart", cascade={"remove"})
     */
    protected $patientChartNotes;

    /**
     * @ORM\OneToMany(targetEntity="DeviceEntity", mappedBy="patientChart", cascade={"remove"})
     */
    protected $devices;

    /**
     * @ORM\OneToMany(targetEntity="PatientBillingBreakdownEntity", mappedBy="patientChart")
     */
    protected $patientBillingBreakdowns;

    /**
     * @ORM\OneToMany(targetEntity="PatientChartTicketEntity", mappedBy="patientChart", cascade={"remove"})
     */
    protected $patientChartTickets;

    /**
     * @ORM\OneToMany(targetEntity="PatientChartIsDoneEntity", mappedBy="patientChart")
     */
    protected $patientChartsIsDone;

    /**
     * @ORM\OneToMany(targetEntity="RxConnexionBundle\Entity\PatientChartCcEntity", mappedBy="patientChart", orphanRemoval=true, cascade={"persist", "remove"})
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $patientChartCcs;

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

    /**
     * Set updatedAt
     *
     * @ORM\PreUpdate
     */
    public function setUpdatedAtValue()
    {
        parent::setUpdatedAtValue();
        $this->updateBillingStatus();
    }

    /**
     * @ORM\PreFlush
     */
    public function preFlush() {

        $this->updateBillingStatus();
    }

    public function __construct()
    {
        $this->chartTypeMethods = new ArrayCollection();
        $this->files = new ArrayCollection();
        $this->procedures = new ArrayCollection();
        $this->otherProcedures = new ArrayCollection();
        $this->payments = new ArrayCollection();
        $this->patientChartNotes = new ArrayCollection();
        $this->devices = new ArrayCollection();
        $this->patientBillingBreakdowns = new ArrayCollection();
        $this->patientChartTickets = new ArrayCollection();
        $this->patientChartsIsDone = new ArrayCollection();
        $this->patientChartCcs = new ArrayCollection();
    }

    /*--------------------------------------------------------------------------------------------------------*/
    /*					Use Defined Setters and Getters														  */
    /*--------------------------------------------------------------------------------------------------------*/

    /**
     * Update billingStatus
     */
    public function updateBillingStatus($action = null) {
        $this->billingStatus = null;
        $status = null;
        $amountDue = 0;
        if($this->getChartType()->getHasBilling() == 1){

            if($this->getPatientBillingBreakdowns()->count()){
                foreach ($this->getPatientBillingBreakdowns() as $patientBillingBreakdown){
                        $patientBilling = $patientBillingBreakdown->getPatientBilling();

                    if(($patientBilling->getBillingStatus() != PatientBillingEntity::BILLING_STATUS_VOID) && ($patientBilling->getBillingStatus() != PatientBillingEntity::BILLING_STATUS_RETURNED) && ($patientBilling->getBillingStatus() != PatientBillingEntity::BILLING_STATUS_REFUND)){
                        $amountDue += $patientBilling->getAmountBalance();
                    }
                }

                if($amountDue == 0 && $action != 'v' && $action != 'ret' && $action != 'ref'){
                    $this->billingStatus = 'Paid';
                    $status = 'Paid';
                } else {
                    $this->billingStatus = 'Pending Payment';
                    $status = 'Pending Payment';
                }
            }else{
                $this->billingStatus = 'Pending Billing';
                $status = 'Pending Billing';
            }
        }
        return $status;
    }

    /**
     * Get chartTypeMethodByChartTypeMethod
     *
     * @return \RxConnexionBundle\Entity\PatientChartTypeMethodEntity
     * @param \RxConnexionBundle\Entity\ChartTypeMethodEntity $chartTypeMethod
     */
    public function getChartTypeMethodByChartTypeMethod(\RxConnexionBundle\Entity\ChartTypeMethodEntity $chartTypeMethod) {

        $patientChartTypeMethod = null;

        foreach($this->chartTypeMethods as $patientChartTypeMethod_obj) {
            if($patientChartTypeMethod_obj->getChartTypeMethod() === $chartTypeMethod)
                $patientChartTypeMethod = $patientChartTypeMethod_obj;
        }

        return $patientChartTypeMethod;
    }

    /**
     * Get totalProceduresAmount
     *
     * @return string
     */
    public function getTotalProceduresAmount() {

        $totalProceduresAmount = 0;

        foreach($this->procedures as $patientChartProcedure) {
            $totalProceduresAmount += $patientChartProcedure->getAmount();
        }

        foreach($this->otherProcedures as $patientChartOtherProcedure) {
            $totalProceduresAmount += $patientChartOtherProcedure->getAmount();
        }

        return $totalProceduresAmount;
    }

    /**
     * Get totalPaymentAmount
     *
     * @return string
     */
    public function getTotalPaymentAmount() {

        $totalPaymentAmount = 0;

        foreach($this->payments as $patientChartPayment) {
            $totalPaymentAmount += $patientChartPayment->getAmount();
        }

        return $totalPaymentAmount;
    }

    /**
     * Get totalBalance
     *
     * @return string
     */
    public function getTotalBalance() {
        return $this->getTotalProceduresAmount() - $this->getTotalPaymentAmount();
    }

    /**
     * Get chartDateAsString
     *
     * @return string
     */
    public function getChartDateAsString() {

        $dttst = new DateTimeToStringTransformer();
        return !empty($this->chartDate) ? date('m/d/Y', strtotime($dttst->transform($this->chartDate))) : '';
    }

    /**
     * Get patientChartIdWithLink
     *
     * @return string
     */
    public function getPatientChartIdWithLink() {

        $result = '<a target="_blank" href="/main/patient/chart/form/' . base64_encode($this->getPatient()->getId()) . '/u/' . base64_encode($this->id) . '">' . $this->id . '</a>';
        return $result;
    }

    /**
     * Get idAndChartDateAndChartType
     *
     * @return string
     */
    public function getIdAndChartDateAndChartType() {

        return $this->id . ' - ' . $this->getChartDateAsString() . ' - ' . $this->chartType->getDescription();
    }

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



    /**
     * Set chartDate
     *
     * @param \DateTime $chartDate
     *
     * @return PatientChartEntity
     */
    public function setChartDate($chartDate)
    {
        $this->chartDate = empty($chartDate) ? NULL : new \DateTime($chartDate);

        return $this;
    }

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

    /**
     * Set height
     *
     * @param string $height
     *
     * @return PatientChartEntity
     */
    public function setHeight($height)
    {
        $this->height = str_replace(',', '', $height);

        return $this;
    }

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

    /**
     * Set weight
     *
     * @param string $weight
     *
     * @return PatientChartEntity
     */
    public function setWeight($weight)
    {
        $this->weight = str_replace(',', '', $weight);

        return $this;
    }

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

    /**
     * Set bmi
     *
     * @param string $bmi
     *
     * @return PatientChartEntity
     */
    public function setBmi($bmi)
    {
        $this->bmi = str_replace(',', '', $bmi);

        return $this;
    }

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

    /**
     * Set bloodPressureFirst
     *
     * @param string $bloodPressureFirst
     *
     * @return PatientChartEntity
     */
    public function setBloodPressureFirst($bloodPressureFirst)
    {
        $this->bloodPressureFirst = str_replace(',', '', $bloodPressureFirst);

        return $this;
    }

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

    /**
     * Set bloodPressureSecond
     *
     * @param string $bloodPressureSecond
     *
     * @return PatientChartEntity
     */
    public function setBloodPressureSecond($bloodPressureSecond)
    {
        $this->bloodPressureSecond = str_replace(',', '', $bloodPressureSecond);

        return $this;
    }

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

    /**
     * Set temperature
     *
     * @param string $temperature
     *
     * @return PatientChartEntity
     */
    public function setTemperature($temperature)
    {
        $this->temperature = str_replace(',', '', $temperature);

        return $this;
    }

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

    /**
     * Set pulse
     *
     * @param string $pulse
     *
     * @return PatientChartEntity
     */
    public function setPulse($pulse)
    {
        $this->pulse = str_replace(',', '', $pulse);

        return $this;
    }

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

    /**
     * Set respiratoryRate
     *
     * @param string $respiratoryRate
     *
     * @return PatientChartEntity
     */
    public function setRespiratoryRate($respiratoryRate)
    {
        $this->respiratoryRate = str_replace(',', '', $respiratoryRate);

        return $this;
    }

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

    /**
     * Set otwoSaturation
     *
     * @param string $otwoSaturation
     *
     * @return PatientChartEntity
     */
    public function setOtwoSaturation($otwoSaturation)
    {
        $this->otwoSaturation = str_replace(',', '', $otwoSaturation);

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Set patient
     *
     * @param \RxConnexionBundle\Entity\PatientEntity $patient
     *
     * @return PatientChartEntity
     */
    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 healthFacility
     *
     * @param \RxConnexionBundle\Entity\HealthFacilityEntity $healthFacility
     *
     * @return PatientChartEntity
     */
    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 provider
     *
     * @param \RxConnexionBundle\Entity\ProviderEntity $provider
     *
     * @return PatientChartEntity
     */
    public function setProvider(\RxConnexionBundle\Entity\ProviderEntity $provider = null)
    {
        $this->provider = $provider;

        return $this;
    }

    /**
     * Get provider
     *
     * @return \RxConnexionBundle\Entity\ProviderEntity
     */
    public function getProvider()
    {
        return $this->provider;
    }

    /**
     * Set chartType
     *
     * @param \RxConnexionBundle\Entity\ChartTypeEntity $chartType
     *
     * @return PatientChartEntity
     */
    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 PatientChartEntity
     */
    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 chartTypeMethod
     *
     * @param \RxConnexionBundle\Entity\PatientChartTypeMethodEntity $chartTypeMethod
     *
     * @return PatientChartEntity
     */
    public function addChartTypeMethod(\RxConnexionBundle\Entity\PatientChartTypeMethodEntity $chartTypeMethod)
    {
        $chartTypeMethod->setPatientChart($this);
        $this->chartTypeMethods[] = $chartTypeMethod;

        return $this;
    }

    /**
     * Remove chartTypeMethod
     *
     * @param \RxConnexionBundle\Entity\PatientChartTypeMethodEntity $chartTypeMethod
     */
    public function removeChartTypeMethod(\RxConnexionBundle\Entity\PatientChartTypeMethodEntity $chartTypeMethod)
    {
        $this->chartTypeMethods->removeElement($chartTypeMethod);
    }

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

    /**
     * Add file
     *
     * @param \RxConnexionBundle\Entity\PatientChartFileEntity $file
     *
     * @return PatientChartEntity
     */
    public function addFile(\RxConnexionBundle\Entity\PatientChartFileEntity $file)
    {
        $this->files[] = $file;

        return $this;
    }

    /**
     * Remove file
     *
     * @param \RxConnexionBundle\Entity\PatientChartFileEntity $file
     */
    public function removeFile(\RxConnexionBundle\Entity\PatientChartFileEntity $file)
    {
        $this->files->removeElement($file);
    }

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

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

        return $this;
    }

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

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

    /**
     * Add otherProcedure
     *
     * @param \RxConnexionBundle\Entity\PatientChartOtherProcedureEntity $otherProcedure
     *
     * @return PatientChartEntity
     */
    public function addOtherProcedure(\RxConnexionBundle\Entity\PatientChartOtherProcedureEntity $otherProcedure)
    {
        $this->otherProcedures[] = $otherProcedure;

        return $this;
    }

    /**
     * Remove otherProcedure
     *
     * @param \RxConnexionBundle\Entity\PatientChartOtherProcedureEntity $otherProcedure
     */
    public function removeOtherProcedure(\RxConnexionBundle\Entity\PatientChartOtherProcedureEntity $otherProcedure)
    {
        $this->otherProcedures->removeElement($otherProcedure);
    }

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

    /**
     * Add payment
     *
     * @param \RxConnexionBundle\Entity\PatientChartPaymentEntity $payment
     *
     * @return PatientChartEntity
     */
    public function addPayment(\RxConnexionBundle\Entity\PatientChartPaymentEntity $payment)
    {
        $this->payments[] = $payment;

        return $this;
    }

    /**
     * Remove payment
     *
     * @param \RxConnexionBundle\Entity\PatientChartPaymentEntity $payment
     */
    public function removePayment(\RxConnexionBundle\Entity\PatientChartPaymentEntity $payment)
    {
        $this->payments->removeElement($payment);
    }

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

    /**
     * Set schedule
     *
     * @param \RxConnexionBundle\Entity\ScheduleEntity $schedule
     *
     * @return PatientChartEntity
     */
    public function setSchedule(\RxConnexionBundle\Entity\ScheduleEntity $schedule = null)
    {
        $this->schedule = $schedule;

        return $this;
    }

    /**
     * Get schedule
     *
     * @return \RxConnexionBundle\Entity\ScheduleEntity
     */
    public function getSchedule()
    {
        return $this->schedule;
    }

    /**
     * Set oldSysId
     *
     * @param string $oldSysId
     *
     * @return PatientChartEntity
     */
    public function setOldSysId($oldSysId)
    {
        $this->oldSysId = $oldSysId;

        return $this;
    }

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

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

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

        return $this;
    }

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

    /**
     * Add patientChartNote
     *
     * @param \RxConnexionBundle\Entity\PatientChartNoteEntity $patientChartNote
     *
     * @return PatientChartEntity
     */
    public function addPatientChartNote(\RxConnexionBundle\Entity\PatientChartNoteEntity $patientChartNote)
    {
        $this->patientChartNotes[] = $patientChartNote;

        return $this;
    }

    /**
     * Remove patientChartNote
     *
     * @param \RxConnexionBundle\Entity\PatientChartNoteEntity $patientChartNote
     */
    public function removePatientChartNote(\RxConnexionBundle\Entity\PatientChartNoteEntity $patientChartNote)
    {
        $this->patientChartNotes->removeElement($patientChartNote);
    }

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

    /**
     * Add device
     *
     * @param \RxConnexionBundle\Entity\DeviceEntity $device
     *
     * @return PatientChartEntity
     */
    public function addItem(\RxConnexionBundle\Entity\DeviceEntity $device)
    {
        $this->devices[] = $device;

        return $this;
    }

    /**
     * Remove device
     *
     * @param \RxConnexionBundle\Entity\DeviceEntity $device
     */
    public function removeItem(\RxConnexionBundle\Entity\DeviceEntity $device)
    {
        $this->devices->removeElement($device);
    }

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

    /**
     * Set isDone
     *
     * @param boolean $isDone
     *
     * @return PatientChartEntity
     */
    public function setIsDone($isDone)
    {
        $this->isDone = $isDone;

        return $this;
    }

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

    /**
     * Add device
     *
     * @param \RxConnexionBundle\Entity\DeviceEntity $device
     *
     * @return PatientChartEntity
     */
    public function addDevice(\RxConnexionBundle\Entity\DeviceEntity $device)
    {
        $this->devices[] = $device;

        return $this;
    }

    /**
     * Remove device
     *
     * @param \RxConnexionBundle\Entity\DeviceEntity $device
     */
    public function removeDevice(\RxConnexionBundle\Entity\DeviceEntity $device)
    {
        $this->devices->removeElement($device);
    }

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

    /**
     * Add patientBillingBreakdown
     *
     * @param \RxConnexionBundle\Entity\PatientBillingBreakdownEntity $patientBillingBreakdown
     *
     * @return PatientChartEntity
     */
    public function addPatientBillingBreakdown(\RxConnexionBundle\Entity\PatientBillingBreakdownEntity $patientBillingBreakdown)
    {
        $this->patientBillingBreakdowns[] = $patientBillingBreakdown;

        return $this;
    }

    /**
     * Remove patientBillingBreakdown
     *
     * @param \RxConnexionBundle\Entity\PatientBillingBreakdownEntity $patientBillingBreakdown
     */
    public function removePatientBillingBreakdown(\RxConnexionBundle\Entity\PatientBillingBreakdownEntity $patientBillingBreakdown)
    {
        $this->patientBillingBreakdowns->removeElement($patientBillingBreakdown);
    }

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

    /**
     * Set internalStatus
     *
     * @param \RxConnexionBundle\Entity\InternalStatusEntity $internalStatus
     *
     * @return PatientChartEntity
     */
    public function setInternalStatus(\RxConnexionBundle\Entity\InternalStatusEntity $internalStatus = null)
    {
        $this->internalStatus = $internalStatus;

        return $this;
    }

    /**
     * Get internalStatus
     *
     * @return \RxConnexionBundle\Entity\InternalStatusEntity
     */
    public function getInternalStatus()
    {
        return $this->internalStatus;
    }

    /**
     * Set accountUserMoaAssignment
     *
     * @param \RxConnexionBundle\Entity\AccountUserEntity $accountUserMoaAssignment
     *
     * @return PatientChartEntity
     */
    public function setAccountUserMoaAssignment(\RxConnexionBundle\Entity\AccountUserEntity $accountUserMoaAssignment = null)
    {
        $this->accountUserMoaAssignment = $accountUserMoaAssignment;
        return $this;
    }

    /**
     * Get accountUserMoaAssignment
     *
     * @return \RxConnexionBundle\Entity\AccountUserEntity
     */
    public function getAccountUserMoaAssignment()
    {
        return $this->accountUserMoaAssignment;
    }

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

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

    /**
     * Set isEndorsed
     *
     * @param boolean $isEndorsed
     *
     * @return PatientChartEntity
     */
    public function setIsEndorsed($isEndorsed)
    {
        $this->isEndorsed = $isEndorsed;

        return $this;
    }

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

    /**
     * Set endorsedBy
     *
     * @param string $endorsedBy
     *
     * @return PatientChartEntity
     */
    public function setEndorsedBy($endorsedBy)
    {
        $this->endorsedBy = $endorsedBy;

        return $this;
    }

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

    /**
     * Add patientChartTicket
     *
     * @param \RxConnexionBundle\Entity\PatientChartTicketEntity $patientChartTicket
     *
     * @return PatientChartEntity
     */
    public function addPatientChartTicket(\RxConnexionBundle\Entity\PatientChartTicketEntity $patientChartTicket)
    {
        $this->patientChartTickets[] = $patientChartTicket;

        return $this;
    }

    /**
     * Remove patientChartTicket
     *
     * @param \RxConnexionBundle\Entity\PatientChartTicketEntity $patientChartTicket
     */
    public function removePatientChartTicket(\RxConnexionBundle\Entity\PatientChartTicketEntity $patientChartTicket)
    {
        $this->patientChartTickets->removeElement($patientChartTicket);
    }

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

    /**
     * Set billingStatus
     *
     * @param string $billingStatus
     *
     * @return PatientChartEntity
     */
    public function setBillingStatus($billingStatus)
    {
        $this->billingStatus = $billingStatus;

        return $this;
    }

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

    /**
     * Add patientChartsIsDone
     *
     * @param \RxConnexionBundle\Entity\PatientChartIsDoneEntity $patientChartsIsDone
     *
     * @return PatientChartEntity
     */
    public function addPatientChartsIsDone(\RxConnexionBundle\Entity\PatientChartIsDoneEntity $patientChartsIsDone)
    {
        $this->patientChartsIsDone[] = $patientChartsIsDone;

        return $this;
    }

    /**
     * Remove patientChartsIsDone
     *
     * @param \RxConnexionBundle\Entity\PatientChartIsDoneEntity $patientChartsIsDone
     */
    public function removePatientChartsIsDone(\RxConnexionBundle\Entity\PatientChartIsDoneEntity $patientChartsIsDone)
    {
        $this->patientChartsIsDone->removeElement($patientChartsIsDone);
    }

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

    /**
     * Set accountUserBilling
     *
     * @param \RxConnexionBundle\Entity\AccountUserBillingEntity $accountUserBilling
     *
     * @return PatientChartEntity
     */
    public function setAccountUserBilling(\RxConnexionBundle\Entity\AccountUserBillingEntity $accountUserBilling = null)
    {
        $this->accountUserBilling = $accountUserBilling;

        return $this;
    }

    /**
     * Get accountUserBilling
     *
     * @return \RxConnexionBundle\Entity\AccountUserBillingEntity
     */
    public function getAccountUserBilling()
    {
        return $this->accountUserBilling;
    }

    /**
     * Set accountStaff
     *
     * @param \RxConnexionBundle\Entity\AccountStaffEntity $accountStaff
     *
     * @return PatientChartEntity
     */
    public function setAccountStaff(\RxConnexionBundle\Entity\AccountStaffEntity $accountStaff = null)
    {
        $this->accountStaff = $accountStaff;

        return $this;
    }

    /**
     * Get accountStaff
     *
     * @return \RxConnexionBundle\Entity\AccountStaffEntity
     */
    public function getAccountStaff()
    {
        return $this->accountStaff;
    }

    /**
     * Set neckSize
     *
     * @param string $neckSize
     *
     * @return PatientChartEntity
     */
    public function setNeckSize($neckSize)
    {
        $this->neckSize = str_replace(',', '', $neckSize);

        return $this;
    }

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

    /**
     * Set smoker
     *
     * @param string $smoker
     *
     * @return PatientChartEntity
     */
    public function setSmoker($smoker)
    {
        $this->smoker = $smoker;

        return $this;
    }

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

    /**
     * Set drinker
     *
     * @param string $drinker
     *
     * @return PatientChartEntity
     */
    public function setDrinker($drinker)
    {
        $this->drinker = $drinker;

        return $this;
    }

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

    /**
     * Set nose
     *
     * @param string $nose
     *
     * @return PatientChartEntity
     */
    public function setNose($nose)
    {
        $this->nose = $nose;

        return $this;
    }

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

    /**
     * Set stopBang
     *
     * @param string $stopBang
     *
     * @return PatientChartEntity
     */
    public function setStopBang($stopBang)
    {
        $this->stopBang = $stopBang;

        return $this;
    }

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

    /**
     * Set preEss
     *
     * @param string $preEss
     *
     * @return PatientChartEntity
     */
    public function setPreEss($preEss)
    {
        $this->preEss = $preEss;

        return $this;
    }

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

    /**
     * Set postEss
     *
     * @param string $postEss
     *
     * @return PatientChartEntity
     */
    public function setPostEss($postEss)
    {
        $this->postEss = $postEss;

        return $this;
    }

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


    /**
     * Add patientChartCc
     *
     * @param \RxConnexionBundle\Entity\PatientChartCcEntity $patientChartCc
     *
     * @return PatientChartEntity
     */
    public function addPatientChartCc(\RxConnexionBundle\Entity\PatientChartCcEntity $patientChartCc)
    {
        $this->patientChartCcs[] = $patientChartCc;
        $patientChartCc->setPatientChart($this);
        return $this;
    }

    /**
     * Remove patientChartCc
     *
     * @param \RxConnexionBundle\Entity\PatientChartCcEntity $patientChartCc
     */
    public function removePatientChartCc(\RxConnexionBundle\Entity\PatientChartCcEntity $patientChartCc)
    {
        $this->patientChartCcs->removeElement($patientChartCc);
    }

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

    /**
     * Set noteTemplate
     *
     * @param \RxConnexionBundle\Entity\NoteTemplateEntity $noteTemplate
     *
     * @return PatientChartEntity
     */
    public function setNoteTemplate(\RxConnexionBundle\Entity\NoteTemplateEntity $noteTemplate = null)
    {
        $this->noteTemplate = $noteTemplate;

        return $this;
    }

    /**
     * Get noteTemplate
     *
     * @return \RxConnexionBundle\Entity\NoteTemplateEntity
     */
    public function getNoteTemplate()
    {
        return $this->noteTemplate;
    }
}
