<?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;

/**
 * @ORM\Entity(repositoryClass="RxConnexionBundle\Repository\FaxTranRepository")
 * @ORM\Table(name="fax_tran", indexes={@ORM\Index(name="IDX_000AAA", columns={"fax_status"})})
 */

class FaxTranEntity extends BaseEntity
{
    const CATEGORY = array(
        'Select Category' => '',
        'Referral' => 'Referral',
        'Prescription' => 'Prescription',
        'Sleep study result' => 'Sleep study result',
        'Other' => 'Other',
    );
    const STATUS = array(
        'Active' => '0',
        'Closed' => '1',
    );

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

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

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

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

    /**
     * @ORM\Column(type="datetime", nullable=true)
     */
    protected $faxDate;

    /**
     * @ORM\Column(type="integer", nullable=true)
     */
    protected $pages;

    /**
     * @ORM\Column(type="integer", nullable=true)
     */
    protected $size;

    /**
     * @ORM\Column(type="boolean", nullable=true)
     */
    protected $viewedStatus;

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

    /**
     * @ORM\Column(type="boolean", nullable=true, options={"default" : 0})
     */
    protected $faxStatus;

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

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

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

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

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

    /**
     * @ORM\ManyToOne(targetEntity="AccountUserEntity", inversedBy="faxTrans")
     * @ORM\JoinColumn(name="account_user_id", referencedColumnName="id")
     */
    protected $accountUser;

    /**
     * @ORM\ManyToOne(targetEntity="PatientEntity", inversedBy="faxTrans")
     * @ORM\JoinColumn(name="patient_id", referencedColumnName="id")
     */
    protected $patient;

    /**
     * @ORM\OneToOne(targetEntity="ReferralEntity", mappedBy="faxTran")
     */
    protected $referral;

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

    // ---------------------
    // USER DEFINED GETTER AND SETTINGS
    // ----------------------
    /**
     * Get faxDateAsString
     *
     * @return string
     */
    public function getFaxDateAsString() {

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


    // --------------------------------------
    // SYSTEM GENERATED GETTERS AND SETTERS
    // --------------------------------------

    /**
     * Set fileName
     *
     * @param string $fileName
     *
     * @return FaxTranEntity
     */
    public function setFileName($fileName)
    {
        $this->fileName = $fileName;

        return $this;
    }

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

    /**
     * Set receiveStatus
     *
     * @param string $receiveStatus
     *
     * @return FaxTranEntity
     */
    public function setReceiveStatus($receiveStatus)
    {
        $this->receiveStatus = $receiveStatus;

        return $this;
    }

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

    /**
     * Set date
     *
     * @param string $date
     *
     * @return FaxTranEntity
     */
    public function setDate($date)
    {
        $this->date = $date;

        return $this;
    }

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

    /**
     * Set pages
     *
     * @param integer $pages
     *
     * @return FaxTranEntity
     */
    public function setPages($pages)
    {
        $this->pages = $pages;

        return $this;
    }

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

    /**
     * Set size
     *
     * @param integer $size
     *
     * @return FaxTranEntity
     */
    public function setSize($size)
    {
        $this->size = $size;

        return $this;
    }

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

    /**
     * Set viewedStatus
     *
     * @param string $viewedStatus
     *
     * @return FaxTranEntity
     */
    public function setViewedStatus($viewedStatus)
    {
        $this->viewedStatus = $viewedStatus;

        return $this;
    }

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

    /**
     * Set faxId
     *
     * @param string $faxId
     *
     * @return FaxTranEntity
     */
    public function setFaxId($faxId)
    {
        $this->faxId = $faxId;

        return $this;
    }

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

    /**
     * Set faxDate
     *
     * @param \DateTime $faxDate
     *
     * @return FaxTranEntity
     */
    public function setFaxDate($faxDate)
    {

        $this->faxDate = empty($faxDate) ? NULL : new \DateTime($faxDate);

        return $this;
    }

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

    /**
     * Set remoteId
     *
     * @param string $remoteId
     *
     * @return FaxTranEntity
     */
    public function setRemoteId($remoteId)
    {
        $this->remoteId = $remoteId;

        return $this;
    }

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


    /**
     * Set isReferral
     *
     * @param boolean $isReferral
     *
     * @return FaxTranEntity
     */
    public function setIsReferral($isReferral)
    {
        $this->isReferral = $isReferral;

        return $this;
    }

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

    /**
     * Set faxCategory
     *
     * @param string $faxCategory
     *
     * @return FaxTranEntity
     */
    public function setFaxCategory($faxCategory)
    {
        $this->faxCategory = $faxCategory;

        return $this;
    }

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

    /**
     * Set faxStatus
     *
     * @param boolean $faxStatus
     *
     * @return FaxTranEntity
     */
    public function setFaxStatus($faxStatus)
    {
        $this->faxStatus = $faxStatus;

        return $this;
    }

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

    /**
     * Set faxLocation
     *
     * @param string $faxLocation
     *
     * @return FaxTranEntity
     */
    public function setFaxLocation($faxLocation)
    {
        $this->faxLocation = $faxLocation;

        return $this;
    }

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

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

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

        return $this;
    }

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

    /**
     * Set healthFacility
     *
     * @param \RxConnexionBundle\Entity\HealthFacilityEntity $healthFacility
     *
     * @return FaxTranEntity
     */
    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 referrals
     *
     * @param \RxConnexionBundle\Entity\ReferralEntity $referrals
     *
     * @return FaxTranEntity
     */
    public function setReferrals(\RxConnexionBundle\Entity\ReferralEntity $referrals = null)
    {
        $this->referrals = $referrals;

        return $this;
    }

    /**
     * Get referrals
     *
     * @return \RxConnexionBundle\Entity\ReferralEntity
     */
    public function getReferrals()
    {
        return $this->referrals;
    }

    /**
     * Set referral
     *
     * @param \RxConnexionBundle\Entity\ReferralEntity $referral
     *
     * @return FaxTranEntity
     */
    public function setReferral(\RxConnexionBundle\Entity\ReferralEntity $referral = null)
    {
        $this->referral = $referral;

        return $this;
    }

    /**
     * Get referral
     *
     * @return \RxConnexionBundle\Entity\ReferralEntity
     */
    public function getReferral()
    {
        return $this->referral;
    }

    /**
     * Set accountUser
     *
     * @param \RxConnexionBundle\Entity\AccountUserEntity $accountUser
     *
     * @return FaxTranEntity
     */
    public function setAccountUser(\RxConnexionBundle\Entity\AccountUserEntity $accountUser = null)
    {
        $this->accountUser = $accountUser;

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Set patient
     *
     * @param \RxConnexionBundle\Entity\PatientEntity $patient
     *
     * @return FaxTranEntity
     */
    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 isDuplicate
     *
     * @param boolean $isDuplicate
     *
     * @return FaxTranEntity
     */
    public function setIsDuplicate($isDuplicate)
    {
        $this->isDuplicate = $isDuplicate;

        return $this;
    }

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

    /**
     * Set isExisting
     *
     * @param boolean $isExisting
     *
     * @return FaxTranEntity
     */
    public function setIsExisting($isExisting)
    {
        $this->isExisting = $isExisting;

        return $this;
    }

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

    /**
     * Set isUnableToProcess
     *
     * @param boolean $isUnableToProcess
     *
     * @return FaxTranEntity
     */
    public function setIsUnableToProcess($isUnableToProcess)
    {
        $this->isUnableToProcess = $isUnableToProcess;

        return $this;
    }

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