<?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\PatientInsuranceRepository")
 * @ORM\Table(name="patient_insurance")
 */

class PatientInsuranceEntity extends BaseEntity
{
    /**
     * @ORM\Column(name="insurance_no",type="string", nullable=true)
     * @Groups("forAudit")
     */
    protected $insuranceNo;

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

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

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

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

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

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

    /**
     * @ORM\ManyToOne(targetEntity="InsuranceEntity", inversedBy="patientInsurances")
     * @ORM\JoinColumn(name="insurance_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $insurance;

    /**
     * @ORM\OneToMany(targetEntity="PatientLetterEntity", mappedBy="patientInsurance")
     */
    protected $patientLetters;

    /**
     * @ORM\OneToMany(targetEntity="PatientLetterCcEntity", mappedBy="patientInsurance")
     */
    protected $patientLetterCcs;

    /**
     * @ORM\OneToMany(targetEntity="AppointmentNoticeFaxEntity", mappedBy="patientInsurance")
     */
    protected $appointmentNoticeFaxes;

    /**
     * @ORM\OneToMany(targetEntity="PatientBillingEntity", mappedBy="patientInsurance")
     */
    protected $patientBillings;

    /**
     * @ORM\OneToMany(targetEntity="PatientRentalEntity", mappedBy="patientInsurance")
     */
    protected $patientRentals;

    /**
     * Constructor
     */
    public function __construct()
    {
        $this->patientLetters = new ArrayCollection();
        $this->appointmentNoticeFaxes = new ArrayCollection();
        $this->patientBillings = 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 startDateAsTime
     *
     * @return string
     */
    public function getStartDateAsTime() {

        $dttst = new DateTimeToStringTransformer();
        return !empty($this->startDate) ? strtotime($dttst->transform($this->startDate)) : 0;
    }

    /**
     * Get endDateAsString
     *
     * @return string
     */
    public function getEndDateAsString() {

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

    /**
     * Get endDateAsTime
     *
     * @return string
     */
    public function getEndDateAsTime() {

        $dttst = new DateTimeToStringTransformer();
        return !empty($this->endDate) ? strtotime($dttst->transform($this->endDate)) : 0;
    }

    /**
     * Get expireDateAsString
     *
     * @return string
     */
    public function getExpireDateAsString() {

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



    /**
     * Set insuranceNo
     *
     * @param string $insuranceNo
     *
     * @return PatientInsuranceEntity
     */
    public function setInsuranceNo($insuranceNo)
    {
        $this->insuranceNo = $insuranceNo;

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Set patient
     *
     * @param \RxConnexionBundle\Entity\PatientEntity $patient
     *
     * @return PatientInsuranceEntity
     */
    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 insurance
     *
     * @param \RxConnexionBundle\Entity\InsuranceEntity $insurance
     *
     * @return PatientInsuranceEntity
     */
    public function setInsurance(\RxConnexionBundle\Entity\InsuranceEntity $insurance = null)
    {
        $this->insurance = $insurance;

        return $this;
    }

    /**
     * Get insurance
     *
     * @return \RxConnexionBundle\Entity\InsuranceEntity
     */
    public function getInsurance()
    {
        return $this->insurance;
    }

    /**
     * Add patientLetter
     *
     * @param \RxConnexionBundle\Entity\PatientLetterEntity $patientLetter
     *
     * @return PatientInsuranceEntity
     */
    public function addPatientLetter(\RxConnexionBundle\Entity\PatientLetterEntity $patientLetter)
    {
        $this->patientLetters[] = $patientLetter;

        return $this;
    }

    /**
     * Remove patientLetter
     *
     * @param \RxConnexionBundle\Entity\PatientLetterEntity $patientLetter
     */
    public function removePatientLetter(\RxConnexionBundle\Entity\PatientLetterEntity $patientLetter)
    {
        $this->patientLetters->removeElement($patientLetter);
    }

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

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

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

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Add appointmentNoticeFax
     *
     * @param \RxConnexionBundle\Entity\AppointmentNoticeFaxEntity $appointmentNoticeFax
     *
     * @return PatientInsuranceEntity
     */
    public function addAppointmentNoticeFax(\RxConnexionBundle\Entity\AppointmentNoticeFaxEntity $appointmentNoticeFax)
    {
        $this->appointmentNoticeFaxes[] = $appointmentNoticeFax;

        return $this;
    }

    /**
     * Remove appointmentNoticeFax
     *
     * @param \RxConnexionBundle\Entity\AppointmentNoticeFaxEntity $appointmentNoticeFax
     */
    public function removeAppointmentNoticeFax(\RxConnexionBundle\Entity\AppointmentNoticeFaxEntity $appointmentNoticeFax)
    {
        $this->appointmentNoticeFaxes->removeElement($appointmentNoticeFax);
    }

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

    /**
     * Add patientBilling
     *
     * @param \RxConnexionBundle\Entity\PatientBillingEntity $patientBilling
     *
     * @return PatientInsuranceEntity
     */
    public function addPatientBilling(\RxConnexionBundle\Entity\PatientBillingEntity $patientBilling)
    {
        $this->patientBillings[] = $patientBilling;

        return $this;
    }

    /**
     * Remove patientBilling
     *
     * @param \RxConnexionBundle\Entity\PatientBillingEntity $patientBilling
     */
    public function removePatientBilling(\RxConnexionBundle\Entity\PatientBillingEntity $patientBilling)
    {
        $this->patientBillings->removeElement($patientBilling);
    }

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

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

        return $this;
    }

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

    /**
     * Set planContactNo
     *
     * @param string $planContactNo
     *
     * @return PatientInsuranceEntity
     */
    public function setPlanContactNo($planContactNo)
    {
        $this->planContactNo = $planContactNo;

        return $this;
    }

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

    /**
     * Add patientRental
     *
     * @param \RxConnexionBundle\Entity\PatientRentalEntity $patientRental
     *
     * @return PatientInsuranceEntity
     */
    public function addPatientRental(\RxConnexionBundle\Entity\PatientRentalEntity $patientRental)
    {
        $this->patientRentals[] = $patientRental;

        return $this;
    }

    /**
     * Remove patientRental
     *
     * @param \RxConnexionBundle\Entity\PatientRentalEntity $patientRental
     */
    public function removePatientRental(\RxConnexionBundle\Entity\PatientRentalEntity $patientRental)
    {
        $this->patientRentals->removeElement($patientRental);
    }

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

    /**
     * Add patientLetterCc
     *
     * @param \RxConnexionBundle\Entity\PatientLetterCcEntity $patientLetterCc
     *
     * @return PatientInsuranceEntity
     */
    public function addPatientLetterCc(\RxConnexionBundle\Entity\PatientLetterCcEntity $patientLetterCc)
    {
        $this->patientLetterCcs[] = $patientLetterCc;

        return $this;
    }

    /**
     * Remove patientLetterCc
     *
     * @param \RxConnexionBundle\Entity\PatientLetterCcEntity $patientLetterCc
     */
    public function removePatientLetterCc(\RxConnexionBundle\Entity\PatientLetterCcEntity $patientLetterCc)
    {
        $this->patientLetterCcs->removeElement($patientLetterCc);
    }

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