<?php

namespace App\Entity;

use App\Enums\DischargeReason;
use App\Enums\ReferralServiceType;
use App\Repository\ReferralRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Component\Uid\Uuid;

#[ORM\Entity(repositoryClass: ReferralRepository::class)]
class Referral
{
    #[ORM\Id]
    #[ORM\Column(type: UuidType::NAME, unique: true)]
    #[ORM\GeneratedValue(strategy: 'CUSTOM')]
    #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
    private ?Uuid $id = null;

    #[ORM\ManyToOne(inversedBy: 'referrals')]
    #[ORM\JoinColumn(nullable: false)]
    private ?MemberCase $memberCase = null;

    #[ORM\Column(length: 20)]
    private ?string $referralId = null;

    #[ORM\Column(enumType: ReferralServiceType::class)]
    private ?ReferralServiceType $serviceCode = null;

    #[ORM\Column]
    private ?int $hours = null;

    #[ORM\Column(type: Types::DATE_MUTABLE)]
    private ?\DateTimeInterface $endDate = null;

    #[ORM\Column(nullable: true, enumType: DischargeReason::class)]
    private ?DischargeReason $dischargeReason = null;

    #[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
    private ?\DateTimeInterface $dischargeDate = null;

    /**
     * @var float $hoursUsed
     */
    private float $hoursUsed = 0.0;

    /**
     * Constructor
     */
    public function __construct()
    {
        $this->hoursUsed = 0.0;
    }

    public function getId(): ?Uuid
    {
        return $this->id;
    }

    public function getMemberCase(): ?MemberCase
    {
        return $this->memberCase;
    }

    public function setMemberCase(?MemberCase $memberCase): static
    {
        $this->memberCase = $memberCase;

        return $this;
    }

    public function getReferralId(): ?string
    {
        return $this->referralId;
    }

    public function setReferralId(string $referralId): static
    {
        $this->referralId = $referralId;

        return $this;
    }

    public function getServiceCode(): ?ReferralServiceType
    {
        return $this->serviceCode;
    }

    public function setServiceCode(ReferralServiceType $serviceCode): static
    {
        $this->serviceCode = $serviceCode;

        return $this;
    }

    public function getHours(): ?int
    {
        return $this->hours;
    }

    public function setHours(int $hours): static
    {
        $this->hours = $hours;

        return $this;
    }

    public function getEndDate(): ?\DateTimeInterface
    {
        return $this->endDate;
    }

    public function setEndDate(\DateTimeInterface $endDate): static
    {
        $this->endDate = $endDate;

        return $this;
    }

    public function getDischargeReason(): ?DischargeReason
    {
        return $this->dischargeReason;
    }

    public function setDischargeReason(?DischargeReason $dischargeReason): static
    {
        $this->dischargeReason = $dischargeReason;

        return $this;
    }

    public function getDischargeDate(): ?\DateTimeInterface
    {
        return $this->dischargeDate;
    }

    public function setDischargeDate(?\DateTimeInterface $dischargeDate): static
    {
        $this->dischargeDate = $dischargeDate;

        return $this;
    }

    public function getHoursRemaining(): float
    {
        return $this->hours - $this->hoursUsed;
    }

    public function getHoursUsed(): float
    {
        return $this->hoursUsed;
    }
}
