<?php
namespace MedBrief\MSR\Entity;
use function array_map;
use DateTime;
use DH\Auditor\Provider\Doctrine\Auditing\Annotation as Audit;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use MedBrief\MSR\Repository\SortingSessionStackRepository;
/**
* SortingSessionStack
*
* An intermediary entity that links pages from a sorting session and stacks
* from the sorting session structure with physical Document entities.
*
* @ORM\Table(name="SortingSessionStack", indexes={
*
* @ORM\Index(name="idx_sorting_session_stack_session", columns={"sortingSession_id"}),
* @ORM\Index(name="idx_sorting_session_stack_document", columns={"document_id"})
* })
*
* @ORM\Entity(repositoryClass=SortingSessionStackRepository::class)
*
* @Audit\Auditable
*
* @Audit\Security(view={"ROLE_ALLOWED_TO_AUDIT"})
*/
class SortingSessionStack
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\Id
*
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected ?int $id = null;
/**
* @var DateTime
*
* @ORM\Column(name="created", type="datetime")
*/
protected DateTime $created;
/**
* @var DateTime
*
* @ORM\Column(name="updated", type="datetime")
*/
protected DateTime $updated;
/**
* The sorting session this stack belongs to.
*
* @var SortingSession
*
* @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\SortingSession")
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="sortingSession_id", referencedColumnName="id")
* })
*/
protected SortingSession $sortingSession;
/**
* The join rows linking pages that belong to this stack to their physical
* position within the stack's merged PDF.
*
* @var Collection|SortingSessionStackPage[]
*
* @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\SortingSessionStackPage", mappedBy="sortingSessionStack")
*/
protected Collection $stackPages;
/**
* The individual DocSorter documents contained within this stack file.
*
* @var Collection|SortingSessionStackDocument[]
*
* @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\SortingSessionStackDocument", mappedBy="sortingSessionStack")
*/
protected Collection $documents;
/**
* The physical document (file) in the system that represents the stack.
* A stack is made up of a collection of DocSorter documents.
*
* @var Document|null
*
* @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\Document")
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="document_id", referencedColumnName="id", nullable=true, unique=true)
* })
*/
protected ?Document $document = null;
/**
* The sorterId of the stack within the sorting session structure (StackModel).
* i.e. the string field identifying the stack within the sorting session JSON structure
*
* @var string|null
*
* @ORM\Column(name="stackModelSorterId", type="string", length=255, nullable=true)
*/
protected ?string $stackModelSorterId = null;
/**
* @var DateTime|null
*
* @ORM\Column(name="startDate", type="datetime", nullable=true)
*/
protected ?DateTime $startDate = null;
/**
* @var DateTime|null
*
* @ORM\Column(name="endDate", type="datetime", nullable=true)
*/
protected ?DateTime $endDate = null;
/**
* The name of the centre (BatchRequest centre) this stack belongs to.
*
* @var string|null
*
* @ORM\Column(name="centreName", type="string", length=255, nullable=true)
*/
protected ?string $centreName = null;
/**
* The admission title as it appears on the generated index (with prefix, e.g. "A - Hospital Name").
*
* @var string|null
*
* @ORM\Column(name="admissionTitle", type="string", length=255, nullable=true)
*/
protected ?string $admissionTitle = null;
/**
* The stack title as it appears on the generated index (e.g. "01 - GP Records").
*
* @var string|null
*
* @ORM\Column(name="stackTitle", type="string", length=255, nullable=true)
*/
protected ?string $stackTitle = null;
/**
* @var DateTime|null
*
* @ORM\Column(name="admissionStartDate", type="datetime", nullable=true)
*/
protected ?DateTime $admissionStartDate = null;
/**
* @var DateTime|null
*
* @ORM\Column(name="admissionEndDate", type="datetime", nullable=true)
*/
protected ?DateTime $admissionEndDate = null;
/**
* @var DateTime|null
*
* @ORM\Column(name="docStartDate", type="datetime", nullable=true)
*/
protected ?DateTime $docStartDate = null;
/**
* @var DateTime|null
*
* @ORM\Column(name="docEndDate", type="datetime", nullable=true)
*/
protected ?DateTime $docEndDate = null;
/**
* The clinical section title, clean without any prefixes.
*
* @var string|null
*
* @ORM\Column(name="clinicalSectionTitle", type="string", length=255, nullable=true)
*/
protected ?string $clinicalSectionTitle = null;
/**
* Constructor
*/
public function __construct()
{
$this->stackPages = new ArrayCollection();
$this->documents = new ArrayCollection();
}
/**
* __toString
*
* @return string
*/
public function __toString(): string
{
return (string) $this->getId();
}
/**
* Get id
*
* @return int|null
*/
public function getId(): ?int
{
return $this->id;
}
/**
* Get created
*
* @return DateTime
*/
public function getCreated(): DateTime
{
return $this->created;
}
/**
* Set created
*
* @param DateTime $created
*
* @return SortingSessionStack
*/
public function setCreated(DateTime $created): self
{
$this->created = $created;
return $this;
}
/**
* Get updated
*
* @return DateTime
*/
public function getUpdated(): DateTime
{
return $this->updated;
}
/**
* Set updated
*
* @param DateTime $updated
*
* @return SortingSessionStack
*/
public function setUpdated(DateTime $updated): self
{
$this->updated = $updated;
return $this;
}
/**
* Get sortingSession
*
* @return SortingSession
*/
public function getSortingSession(): SortingSession
{
return $this->sortingSession;
}
/**
* Set sortingSession
*
* @param SortingSession $sortingSession
*
* @return SortingSessionStack
*/
public function setSortingSession(SortingSession $sortingSession): self
{
$this->sortingSession = $sortingSession;
return $this;
}
/**
* Get stackPages
*
* @return Collection|SortingSessionStackPage[]
*/
public function getStackPages(): Collection
{
return $this->stackPages;
}
/**
* Get pages
*
* Convenience accessor deriving the underlying Page entities from stackPages,
* for callers that only need the pages themselves.
*
* @return Collection|Page[]
*/
public function getPages(): Collection
{
return new ArrayCollection(array_map(
static fn (SortingSessionStackPage $stackPage): Page => $stackPage->getPage(),
$this->stackPages->toArray()
));
}
/**
* Add stackPage
*
* @param SortingSessionStackPage $stackPage
*
* @return SortingSessionStack
*/
public function addStackPage(SortingSessionStackPage $stackPage): self
{
if (!$this->stackPages->contains($stackPage)) {
$this->stackPages[] = $stackPage;
$stackPage->setSortingSessionStack($this);
}
return $this;
}
/**
* Remove stackPage
*
* @param SortingSessionStackPage $stackPage
*
* @return SortingSessionStack
*/
public function removeStackPage(SortingSessionStackPage $stackPage): self
{
$this->stackPages->removeElement($stackPage);
return $this;
}
/**
* Get document
*
* @return Document|null
*/
public function getDocument(): ?Document
{
return $this->document;
}
/**
* Set document
*
* @param Document|null $document
*
* @return SortingSessionStack
*/
public function setDocument(?Document $document): self
{
$this->document = $document;
return $this;
}
/**
* Get stackModelSorterId
*
* @return string|null
*/
public function getStackModelSorterId(): ?string
{
return $this->stackModelSorterId;
}
/**
* Set stackModelSorterId
*
* @param string|null $stackModelSorterId
*
* @return SortingSessionStack
*/
public function setStackModelSorterId(?string $stackModelSorterId): self
{
$this->stackModelSorterId = $stackModelSorterId;
return $this;
}
/**
* Get startDate
*
* @return DateTime|null
*/
public function getStartDate(): ?DateTime
{
return $this->startDate;
}
/**
* Set startDate
*
* @param DateTime|null $startDate
*
* @return SortingSessionStack
*/
public function setStartDate(?DateTime $startDate): self
{
$this->startDate = $startDate;
return $this;
}
/**
* Get endDate
*
* @return DateTime|null
*/
public function getEndDate(): ?DateTime
{
return $this->endDate;
}
/**
* Set endDate
*
* @param DateTime|null $endDate
*
* @return SortingSessionStack
*/
public function setEndDate(?DateTime $endDate): self
{
$this->endDate = $endDate;
return $this;
}
/**
* Get centreName
*
* @return string|null
*/
public function getCentreName(): ?string
{
return $this->centreName;
}
/**
* Set centreName
*
* @param string|null $centreName
*
* @return SortingSessionStack
*/
public function setCentreName(?string $centreName): self
{
$this->centreName = $centreName;
return $this;
}
/**
* Get admissionTitle
*
* @return string|null
*/
public function getAdmissionTitle(): ?string
{
return $this->admissionTitle;
}
/**
* Set admissionTitle
*
* @param string|null $admissionTitle
*
* @return SortingSessionStack
*/
public function setAdmissionTitle(?string $admissionTitle): self
{
$this->admissionTitle = $admissionTitle;
return $this;
}
/**
* Get stackTitle
*
* @return string|null
*/
public function getStackTitle(): ?string
{
return $this->stackTitle;
}
/**
* Set stackTitle
*
* @param string|null $stackTitle
*
* @return SortingSessionStack
*/
public function setStackTitle(?string $stackTitle): self
{
$this->stackTitle = $stackTitle;
return $this;
}
/**
* Get admissionStartDate
*
* @return DateTime|null
*/
public function getAdmissionStartDate(): ?DateTime
{
return $this->admissionStartDate;
}
/**
* Set admissionStartDate
*
* @param DateTime|null $admissionStartDate
*
* @return SortingSessionStack
*/
public function setAdmissionStartDate(?DateTime $admissionStartDate): self
{
$this->admissionStartDate = $admissionStartDate;
return $this;
}
/**
* Get admissionEndDate
*
* @return DateTime|null
*/
public function getAdmissionEndDate(): ?DateTime
{
return $this->admissionEndDate;
}
/**
* Set admissionEndDate
*
* @param DateTime|null $admissionEndDate
*
* @return SortingSessionStack
*/
public function setAdmissionEndDate(?DateTime $admissionEndDate): self
{
$this->admissionEndDate = $admissionEndDate;
return $this;
}
/**
* Get docStartDate
*
* @return DateTime|null
*/
public function getDocStartDate(): ?DateTime
{
return $this->docStartDate;
}
/**
* Set docStartDate
*
* @param DateTime|null $docStartDate
*
* @return SortingSessionStack
*/
public function setDocStartDate(?DateTime $docStartDate): self
{
$this->docStartDate = $docStartDate;
return $this;
}
/**
* Get docEndDate
*
* @return DateTime|null
*/
public function getDocEndDate(): ?DateTime
{
return $this->docEndDate;
}
/**
* Set docEndDate
*
* @param DateTime|null $docEndDate
*
* @return SortingSessionStack
*/
public function setDocEndDate(?DateTime $docEndDate): self
{
$this->docEndDate = $docEndDate;
return $this;
}
/**
* Get clinicalSectionTitle
*
* @return string|null
*/
public function getClinicalSectionTitle(): ?string
{
return $this->clinicalSectionTitle;
}
/**
* Set clinicalSectionTitle
*
* @param string|null $clinicalSectionTitle
*
* @return SortingSessionStack
*/
public function setClinicalSectionTitle(?string $clinicalSectionTitle): self
{
$this->clinicalSectionTitle = $clinicalSectionTitle;
return $this;
}
/**
* Get documents
*
* @return Collection|SortingSessionStackDocument[]
*/
public function getDocuments(): Collection
{
return $this->documents;
}
/**
* Add document
*
* @param SortingSessionStackDocument $document
*
* @return SortingSessionStack
*/
public function addDocument(SortingSessionStackDocument $document): self
{
if (!$this->documents->contains($document)) {
$this->documents[] = $document;
$document->setSortingSessionStack($this);
}
return $this;
}
/**
* Remove document
*
* @param SortingSessionStackDocument $document
*
* @return SortingSessionStack
*/
public function removeDocument(SortingSessionStackDocument $document): self
{
if ($this->documents->removeElement($document)) {
if ($document->getSortingSessionStack() === $this) {
$document->setSortingSessionStack(null);
}
}
return $this;
}
}