src/Entity/SortingSessionStack.php line 33

Open in your IDE?
  1. <?php
  2. namespace MedBrief\MSR\Entity;
  3. use function array_map;
  4. use DateTime;
  5. use DH\Auditor\Provider\Doctrine\Auditing\Annotation as Audit;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use MedBrief\MSR\Repository\SortingSessionStackRepository;
  10. /**
  11. * SortingSessionStack
  12. *
  13. * An intermediary entity that links pages from a sorting session and stacks
  14. * from the sorting session structure with physical Document entities.
  15. *
  16. * @ORM\Table(name="SortingSessionStack", indexes={
  17. *
  18. * @ORM\Index(name="idx_sorting_session_stack_session", columns={"sortingSession_id"}),
  19. * @ORM\Index(name="idx_sorting_session_stack_document", columns={"document_id"})
  20. * })
  21. *
  22. * @ORM\Entity(repositoryClass=SortingSessionStackRepository::class)
  23. *
  24. * @Audit\Auditable
  25. *
  26. * @Audit\Security(view={"ROLE_ALLOWED_TO_AUDIT"})
  27. */
  28. class SortingSessionStack
  29. {
  30. /**
  31. * @var int
  32. *
  33. * @ORM\Column(name="id", type="integer")
  34. *
  35. * @ORM\Id
  36. *
  37. * @ORM\GeneratedValue(strategy="IDENTITY")
  38. */
  39. protected ?int $id = null;
  40. /**
  41. * @var DateTime
  42. *
  43. * @ORM\Column(name="created", type="datetime")
  44. */
  45. protected DateTime $created;
  46. /**
  47. * @var DateTime
  48. *
  49. * @ORM\Column(name="updated", type="datetime")
  50. */
  51. protected DateTime $updated;
  52. /**
  53. * The sorting session this stack belongs to.
  54. *
  55. * @var SortingSession
  56. *
  57. * @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\SortingSession")
  58. *
  59. * @ORM\JoinColumns({
  60. *
  61. * @ORM\JoinColumn(name="sortingSession_id", referencedColumnName="id")
  62. * })
  63. */
  64. protected SortingSession $sortingSession;
  65. /**
  66. * The join rows linking pages that belong to this stack to their physical
  67. * position within the stack's merged PDF.
  68. *
  69. * @var Collection|SortingSessionStackPage[]
  70. *
  71. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\SortingSessionStackPage", mappedBy="sortingSessionStack")
  72. */
  73. protected Collection $stackPages;
  74. /**
  75. * The individual DocSorter documents contained within this stack file.
  76. *
  77. * @var Collection|SortingSessionStackDocument[]
  78. *
  79. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\SortingSessionStackDocument", mappedBy="sortingSessionStack")
  80. */
  81. protected Collection $documents;
  82. /**
  83. * The physical document (file) in the system that represents the stack.
  84. * A stack is made up of a collection of DocSorter documents.
  85. *
  86. * @var Document|null
  87. *
  88. * @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\Document")
  89. *
  90. * @ORM\JoinColumns({
  91. *
  92. * @ORM\JoinColumn(name="document_id", referencedColumnName="id", nullable=true, unique=true)
  93. * })
  94. */
  95. protected ?Document $document = null;
  96. /**
  97. * The sorterId of the stack within the sorting session structure (StackModel).
  98. * i.e. the string field identifying the stack within the sorting session JSON structure
  99. *
  100. * @var string|null
  101. *
  102. * @ORM\Column(name="stackModelSorterId", type="string", length=255, nullable=true)
  103. */
  104. protected ?string $stackModelSorterId = null;
  105. /**
  106. * @var DateTime|null
  107. *
  108. * @ORM\Column(name="startDate", type="datetime", nullable=true)
  109. */
  110. protected ?DateTime $startDate = null;
  111. /**
  112. * @var DateTime|null
  113. *
  114. * @ORM\Column(name="endDate", type="datetime", nullable=true)
  115. */
  116. protected ?DateTime $endDate = null;
  117. /**
  118. * The name of the centre (BatchRequest centre) this stack belongs to.
  119. *
  120. * @var string|null
  121. *
  122. * @ORM\Column(name="centreName", type="string", length=255, nullable=true)
  123. */
  124. protected ?string $centreName = null;
  125. /**
  126. * The admission title as it appears on the generated index (with prefix, e.g. "A - Hospital Name").
  127. *
  128. * @var string|null
  129. *
  130. * @ORM\Column(name="admissionTitle", type="string", length=255, nullable=true)
  131. */
  132. protected ?string $admissionTitle = null;
  133. /**
  134. * The stack title as it appears on the generated index (e.g. "01 - GP Records").
  135. *
  136. * @var string|null
  137. *
  138. * @ORM\Column(name="stackTitle", type="string", length=255, nullable=true)
  139. */
  140. protected ?string $stackTitle = null;
  141. /**
  142. * @var DateTime|null
  143. *
  144. * @ORM\Column(name="admissionStartDate", type="datetime", nullable=true)
  145. */
  146. protected ?DateTime $admissionStartDate = null;
  147. /**
  148. * @var DateTime|null
  149. *
  150. * @ORM\Column(name="admissionEndDate", type="datetime", nullable=true)
  151. */
  152. protected ?DateTime $admissionEndDate = null;
  153. /**
  154. * @var DateTime|null
  155. *
  156. * @ORM\Column(name="docStartDate", type="datetime", nullable=true)
  157. */
  158. protected ?DateTime $docStartDate = null;
  159. /**
  160. * @var DateTime|null
  161. *
  162. * @ORM\Column(name="docEndDate", type="datetime", nullable=true)
  163. */
  164. protected ?DateTime $docEndDate = null;
  165. /**
  166. * The clinical section title, clean without any prefixes.
  167. *
  168. * @var string|null
  169. *
  170. * @ORM\Column(name="clinicalSectionTitle", type="string", length=255, nullable=true)
  171. */
  172. protected ?string $clinicalSectionTitle = null;
  173. /**
  174. * Constructor
  175. */
  176. public function __construct()
  177. {
  178. $this->stackPages = new ArrayCollection();
  179. $this->documents = new ArrayCollection();
  180. }
  181. /**
  182. * __toString
  183. *
  184. * @return string
  185. */
  186. public function __toString(): string
  187. {
  188. return (string) $this->getId();
  189. }
  190. /**
  191. * Get id
  192. *
  193. * @return int|null
  194. */
  195. public function getId(): ?int
  196. {
  197. return $this->id;
  198. }
  199. /**
  200. * Get created
  201. *
  202. * @return DateTime
  203. */
  204. public function getCreated(): DateTime
  205. {
  206. return $this->created;
  207. }
  208. /**
  209. * Set created
  210. *
  211. * @param DateTime $created
  212. *
  213. * @return SortingSessionStack
  214. */
  215. public function setCreated(DateTime $created): self
  216. {
  217. $this->created = $created;
  218. return $this;
  219. }
  220. /**
  221. * Get updated
  222. *
  223. * @return DateTime
  224. */
  225. public function getUpdated(): DateTime
  226. {
  227. return $this->updated;
  228. }
  229. /**
  230. * Set updated
  231. *
  232. * @param DateTime $updated
  233. *
  234. * @return SortingSessionStack
  235. */
  236. public function setUpdated(DateTime $updated): self
  237. {
  238. $this->updated = $updated;
  239. return $this;
  240. }
  241. /**
  242. * Get sortingSession
  243. *
  244. * @return SortingSession
  245. */
  246. public function getSortingSession(): SortingSession
  247. {
  248. return $this->sortingSession;
  249. }
  250. /**
  251. * Set sortingSession
  252. *
  253. * @param SortingSession $sortingSession
  254. *
  255. * @return SortingSessionStack
  256. */
  257. public function setSortingSession(SortingSession $sortingSession): self
  258. {
  259. $this->sortingSession = $sortingSession;
  260. return $this;
  261. }
  262. /**
  263. * Get stackPages
  264. *
  265. * @return Collection|SortingSessionStackPage[]
  266. */
  267. public function getStackPages(): Collection
  268. {
  269. return $this->stackPages;
  270. }
  271. /**
  272. * Get pages
  273. *
  274. * Convenience accessor deriving the underlying Page entities from stackPages,
  275. * for callers that only need the pages themselves.
  276. *
  277. * @return Collection|Page[]
  278. */
  279. public function getPages(): Collection
  280. {
  281. return new ArrayCollection(array_map(
  282. static fn (SortingSessionStackPage $stackPage): Page => $stackPage->getPage(),
  283. $this->stackPages->toArray()
  284. ));
  285. }
  286. /**
  287. * Add stackPage
  288. *
  289. * @param SortingSessionStackPage $stackPage
  290. *
  291. * @return SortingSessionStack
  292. */
  293. public function addStackPage(SortingSessionStackPage $stackPage): self
  294. {
  295. if (!$this->stackPages->contains($stackPage)) {
  296. $this->stackPages[] = $stackPage;
  297. $stackPage->setSortingSessionStack($this);
  298. }
  299. return $this;
  300. }
  301. /**
  302. * Remove stackPage
  303. *
  304. * @param SortingSessionStackPage $stackPage
  305. *
  306. * @return SortingSessionStack
  307. */
  308. public function removeStackPage(SortingSessionStackPage $stackPage): self
  309. {
  310. $this->stackPages->removeElement($stackPage);
  311. return $this;
  312. }
  313. /**
  314. * Get document
  315. *
  316. * @return Document|null
  317. */
  318. public function getDocument(): ?Document
  319. {
  320. return $this->document;
  321. }
  322. /**
  323. * Set document
  324. *
  325. * @param Document|null $document
  326. *
  327. * @return SortingSessionStack
  328. */
  329. public function setDocument(?Document $document): self
  330. {
  331. $this->document = $document;
  332. return $this;
  333. }
  334. /**
  335. * Get stackModelSorterId
  336. *
  337. * @return string|null
  338. */
  339. public function getStackModelSorterId(): ?string
  340. {
  341. return $this->stackModelSorterId;
  342. }
  343. /**
  344. * Set stackModelSorterId
  345. *
  346. * @param string|null $stackModelSorterId
  347. *
  348. * @return SortingSessionStack
  349. */
  350. public function setStackModelSorterId(?string $stackModelSorterId): self
  351. {
  352. $this->stackModelSorterId = $stackModelSorterId;
  353. return $this;
  354. }
  355. /**
  356. * Get startDate
  357. *
  358. * @return DateTime|null
  359. */
  360. public function getStartDate(): ?DateTime
  361. {
  362. return $this->startDate;
  363. }
  364. /**
  365. * Set startDate
  366. *
  367. * @param DateTime|null $startDate
  368. *
  369. * @return SortingSessionStack
  370. */
  371. public function setStartDate(?DateTime $startDate): self
  372. {
  373. $this->startDate = $startDate;
  374. return $this;
  375. }
  376. /**
  377. * Get endDate
  378. *
  379. * @return DateTime|null
  380. */
  381. public function getEndDate(): ?DateTime
  382. {
  383. return $this->endDate;
  384. }
  385. /**
  386. * Set endDate
  387. *
  388. * @param DateTime|null $endDate
  389. *
  390. * @return SortingSessionStack
  391. */
  392. public function setEndDate(?DateTime $endDate): self
  393. {
  394. $this->endDate = $endDate;
  395. return $this;
  396. }
  397. /**
  398. * Get centreName
  399. *
  400. * @return string|null
  401. */
  402. public function getCentreName(): ?string
  403. {
  404. return $this->centreName;
  405. }
  406. /**
  407. * Set centreName
  408. *
  409. * @param string|null $centreName
  410. *
  411. * @return SortingSessionStack
  412. */
  413. public function setCentreName(?string $centreName): self
  414. {
  415. $this->centreName = $centreName;
  416. return $this;
  417. }
  418. /**
  419. * Get admissionTitle
  420. *
  421. * @return string|null
  422. */
  423. public function getAdmissionTitle(): ?string
  424. {
  425. return $this->admissionTitle;
  426. }
  427. /**
  428. * Set admissionTitle
  429. *
  430. * @param string|null $admissionTitle
  431. *
  432. * @return SortingSessionStack
  433. */
  434. public function setAdmissionTitle(?string $admissionTitle): self
  435. {
  436. $this->admissionTitle = $admissionTitle;
  437. return $this;
  438. }
  439. /**
  440. * Get stackTitle
  441. *
  442. * @return string|null
  443. */
  444. public function getStackTitle(): ?string
  445. {
  446. return $this->stackTitle;
  447. }
  448. /**
  449. * Set stackTitle
  450. *
  451. * @param string|null $stackTitle
  452. *
  453. * @return SortingSessionStack
  454. */
  455. public function setStackTitle(?string $stackTitle): self
  456. {
  457. $this->stackTitle = $stackTitle;
  458. return $this;
  459. }
  460. /**
  461. * Get admissionStartDate
  462. *
  463. * @return DateTime|null
  464. */
  465. public function getAdmissionStartDate(): ?DateTime
  466. {
  467. return $this->admissionStartDate;
  468. }
  469. /**
  470. * Set admissionStartDate
  471. *
  472. * @param DateTime|null $admissionStartDate
  473. *
  474. * @return SortingSessionStack
  475. */
  476. public function setAdmissionStartDate(?DateTime $admissionStartDate): self
  477. {
  478. $this->admissionStartDate = $admissionStartDate;
  479. return $this;
  480. }
  481. /**
  482. * Get admissionEndDate
  483. *
  484. * @return DateTime|null
  485. */
  486. public function getAdmissionEndDate(): ?DateTime
  487. {
  488. return $this->admissionEndDate;
  489. }
  490. /**
  491. * Set admissionEndDate
  492. *
  493. * @param DateTime|null $admissionEndDate
  494. *
  495. * @return SortingSessionStack
  496. */
  497. public function setAdmissionEndDate(?DateTime $admissionEndDate): self
  498. {
  499. $this->admissionEndDate = $admissionEndDate;
  500. return $this;
  501. }
  502. /**
  503. * Get docStartDate
  504. *
  505. * @return DateTime|null
  506. */
  507. public function getDocStartDate(): ?DateTime
  508. {
  509. return $this->docStartDate;
  510. }
  511. /**
  512. * Set docStartDate
  513. *
  514. * @param DateTime|null $docStartDate
  515. *
  516. * @return SortingSessionStack
  517. */
  518. public function setDocStartDate(?DateTime $docStartDate): self
  519. {
  520. $this->docStartDate = $docStartDate;
  521. return $this;
  522. }
  523. /**
  524. * Get docEndDate
  525. *
  526. * @return DateTime|null
  527. */
  528. public function getDocEndDate(): ?DateTime
  529. {
  530. return $this->docEndDate;
  531. }
  532. /**
  533. * Set docEndDate
  534. *
  535. * @param DateTime|null $docEndDate
  536. *
  537. * @return SortingSessionStack
  538. */
  539. public function setDocEndDate(?DateTime $docEndDate): self
  540. {
  541. $this->docEndDate = $docEndDate;
  542. return $this;
  543. }
  544. /**
  545. * Get clinicalSectionTitle
  546. *
  547. * @return string|null
  548. */
  549. public function getClinicalSectionTitle(): ?string
  550. {
  551. return $this->clinicalSectionTitle;
  552. }
  553. /**
  554. * Set clinicalSectionTitle
  555. *
  556. * @param string|null $clinicalSectionTitle
  557. *
  558. * @return SortingSessionStack
  559. */
  560. public function setClinicalSectionTitle(?string $clinicalSectionTitle): self
  561. {
  562. $this->clinicalSectionTitle = $clinicalSectionTitle;
  563. return $this;
  564. }
  565. /**
  566. * Get documents
  567. *
  568. * @return Collection|SortingSessionStackDocument[]
  569. */
  570. public function getDocuments(): Collection
  571. {
  572. return $this->documents;
  573. }
  574. /**
  575. * Add document
  576. *
  577. * @param SortingSessionStackDocument $document
  578. *
  579. * @return SortingSessionStack
  580. */
  581. public function addDocument(SortingSessionStackDocument $document): self
  582. {
  583. if (!$this->documents->contains($document)) {
  584. $this->documents[] = $document;
  585. $document->setSortingSessionStack($this);
  586. }
  587. return $this;
  588. }
  589. /**
  590. * Remove document
  591. *
  592. * @param SortingSessionStackDocument $document
  593. *
  594. * @return SortingSessionStack
  595. */
  596. public function removeDocument(SortingSessionStackDocument $document): self
  597. {
  598. if ($this->documents->removeElement($document)) {
  599. if ($document->getSortingSessionStack() === $this) {
  600. $document->setSortingSessionStack(null);
  601. }
  602. }
  603. return $this;
  604. }
  605. }