*/ #[ORM\OneToMany(targetEntity: Note::class, mappedBy: 'referral', orphanRemoval: true)] private Collection $notes; /** * @var Collection */ #[ORM\ManyToMany(targetEntity: Member::class)] private Collection $present; /** * @var float $hoursUsed */ private float $hoursUsed = 0.0; /** * Constructor */ public function __construct() { $this->notes = new ArrayCollection(); $this->present = new ArrayCollection(); $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; } /** * @return Collection */ public function getNotes(): Collection { return $this->notes; } public function addNote(Note $note): static { if (!$this->notes->contains($note)) { $this->notes->add($note); $note->setReferral($this); $this->hoursUsed += ($note->calcTimeUsed() / 60); } return $this; } public function removeNote(Note $note): static { if ($this->notes->removeElement($note)) { $this->hoursUsed -= $note->calcTimeUsed(); // set the owning side to null (unless already changed) if ($note->getReferral() === $this) { $note->setReferral(null); } } return $this; } public function setNotes(ArrayCollection $notes): void { $this->notes = $notes; $this->hoursUsed = 0.0; foreach ($this->notes as $note) { $this->hoursUsed += ($note->calcTimeUsed() / 60); } } /** * @return Collection */ public function getPresent(): Collection { return $this->present; } public function addPresent(Member $present): static { if (!$this->present->contains($present)) { $this->present->add($present); } return $this; } public function removePresent(Member $present): static { $this->present->removeElement($present); return $this; } public function getHoursRemaining(): float { return $this->hours - $this->hoursUsed; } }