src/Entity/User.php line 46

Open in your IDE?
  1. <?php
  2. namespace MedBrief\MSR\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use DH\Auditor\Provider\Doctrine\Auditing\Annotation as Audit;
  5. use Doctrine\Common\Collections\Collection as DoctrineCollection;
  6. use Doctrine\ORM\EntityManagerInterface;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. use libphonenumber\PhoneNumber;
  10. use MedBrief\MSR\Entity\Analytics\AnalyticsUser;
  11. use MedBrief\MSR\Model\User\MultiFactorEnabledUser;
  12. use MedBrief\MSR\Repository\UserInternalRepository;
  13. use MedBrief\MSR\Repository\UserRepository;
  14. use MedBrief\MSR\Security\AdvancedUserInterface;
  15. use MedBrief\MSR\Traits\FilterableClassConstantsTrait;
  16. use Ramsey\Uuid\Uuid;
  17. use Symfony\Component\Security\Core\User\EquatableInterface;
  18. use Symfony\Component\Security\Core\User\UserInterface;
  19. use Symfony\Component\Serializer\Annotation\Groups;
  20. use Symfony\Component\Validator\Context\ExecutionContextInterface;
  21. /**
  22. * @ApiResource(
  23. * itemOperations={
  24. * "get"={"access_control"="is_granted('READ', object)"}
  25. * },
  26. * attributes={
  27. * "normalization_context"={"groups"={"user:read"}}
  28. * }
  29. * )
  30. *
  31. * @ORM\Table(name="fos_user")
  32. *
  33. * @ORM\Entity(repositoryClass=UserRepository::class)
  34. *
  35. * @ORM\HasLifecycleCallbacks
  36. *
  37. * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
  38. *
  39. * @Audit\Auditable
  40. *
  41. * @Audit\Security(view={"ROLE_ALLOWED_TO_AUDIT"})
  42. */
  43. class User extends MultiFactorEnabledUser implements AdvancedUserInterface, EquatableInterface
  44. {
  45. use FilterableClassConstantsTrait;
  46. // CONSTANTS
  47. public const NOTIFICATION_STATUS_PENDING = 1;
  48. public const NOTIFICATION_STATUS_SENT = 2;
  49. public const NOTIFICATION_STATUS_FAILED = 3;
  50. public const NOTIFICATION_STATUS_UNSUBSCRIBE = 4;
  51. public const NOTIFICATION_FORMAT_PREFERENCE_EMAIL = UserNotification::NOTIFICATION_FORMAT_EMAIL;
  52. public const NOTIFICATION_FORMAT_PREFERENCE_SMS = UserNotification::NOTIFICATION_FORMAT_SMS;
  53. public const NOTIFICATION_FORMAT_PREFERENCE_PUSH = UserNotification::NOTIFICATION_FORMAT_PUSH;
  54. public const USER_TYPE_INTERNAL = 'internal';
  55. public const USER_TYPE_INTERNAL__LABEL = 'Internal';
  56. public const USER_TYPE_CLIENT = 'client';
  57. public const USER_TYPE_CLIENT__LABEL = 'Client';
  58. public const USER_TYPE_EXPERT = 'expert';
  59. public const USER_TYPE_EXPERT__LABEL = 'Expert';
  60. public const USER_TYPE_OTHER = 'other';
  61. public const USER_TYPE_OTHER__LABEL = 'Other';
  62. public const DEFAULT_ROLE_SUPER_ADMIN = 'ROLE_SUPER_ADMIN';
  63. public const DEFAULT_ROLE_SUPER_ADMIN__LABEL = 'MedBrief Super Administrator';
  64. public const DEFAULT_ROLE_ADMIN = 'ROLE_ADMIN';
  65. public const DEFAULT_ROLE_ADMIN__LABEL = 'MedBrief Administrator';
  66. // PROTECTED VARIABLES
  67. /**
  68. * @var int
  69. *
  70. * @ORM\Column(name="id", type="integer")
  71. *
  72. * @ORM\Id
  73. *
  74. * @ORM\GeneratedValue(strategy="IDENTITY")
  75. */
  76. protected $id;
  77. /**
  78. * @var string
  79. *
  80. * @ORM\Column(name="password", type="string", length=255)
  81. */
  82. protected $password;
  83. /**
  84. * @var string|null
  85. *
  86. * @ORM\Column(name="salt", type="string", length=255, nullable=true)
  87. */
  88. protected $salt;
  89. /**
  90. * @var bool
  91. *
  92. * @ORM\Column(name="enabled", type="boolean")
  93. */
  94. protected $enabled = false;
  95. /**
  96. * @var \DateTime|null
  97. *
  98. * @ORM\Column(name="last_login", type="datetime", nullable=true)
  99. */
  100. protected $last_login;
  101. /**
  102. * @var array
  103. *
  104. * @ORM\Column(name="roles", type="array")
  105. */
  106. protected $roles = [];
  107. /**
  108. * @var string|null
  109. *
  110. * @ORM\Column(name="first_name", type="string", length=255, nullable=true)
  111. */
  112. protected $first_name;
  113. /**
  114. * @var string|null
  115. *
  116. * @ORM\Column(name="last_name", type="string", length=255, nullable=true)
  117. */
  118. protected $last_name;
  119. /**
  120. * @var \DateTime
  121. *
  122. * @ORM\Column(name="created", type="datetime")
  123. *
  124. * @Gedmo\Timestampable(on="create")
  125. */
  126. protected $created;
  127. /**
  128. * @var \DateTime
  129. *
  130. * @ORM\Column(name="updated", type="datetime")
  131. *
  132. * @Gedmo\Timestampable(on="update")
  133. */
  134. protected $updated;
  135. /**
  136. * @var \DateTime|null
  137. *
  138. * @ORM\Column(name="deletedAt", type="datetime", nullable=true)
  139. */
  140. protected $deletedAt;
  141. /**
  142. * @var string
  143. *
  144. * @ORM\Column(name="search_index", type="text", nullable=false)
  145. */
  146. protected $search_index;
  147. /**
  148. * @var string|null
  149. *
  150. * @ORM\Column(name="phone_number", type="string", length=155, nullable=true)
  151. */
  152. protected $phoneNumber;
  153. /**
  154. * @var \DateTime|null
  155. *
  156. * @ORM\Column(name="lastActivity", type="datetime", nullable=true)
  157. *
  158. * @Audit\Ignore
  159. */
  160. protected $lastActivity;
  161. /**
  162. * @var \DateTime|null
  163. *
  164. * @ORM\Column(name="firstLoginDate", type="datetime", nullable=true)
  165. */
  166. protected $firstLoginDate;
  167. /**
  168. * Whether the user account is locked or not
  169. *
  170. * @var bool|null
  171. *
  172. * @ORM\Column(name="locked", type="boolean", nullable=true, options={"default"=false})
  173. */
  174. protected $locked = false;
  175. /**
  176. * @var string
  177. */
  178. protected $plainPassword;
  179. /**
  180. * mobileNumber - Used for SMS verification.
  181. *
  182. * @var PhoneNumber|null
  183. *
  184. * @ORM\Column(name="mobileNumber", type="phone_number", nullable=true)
  185. */
  186. private $mobileNumber;
  187. /**
  188. * @var bool
  189. *
  190. * @ORM\Column(name="hasDocSorterAccess", type="boolean")
  191. */
  192. private $hasDocSorterAccess = false;
  193. /**
  194. * Whether a User has billing admin rights
  195. *
  196. * @var bool
  197. *
  198. * @ORM\Column(name="billingAdmin", type="boolean", options={"default"=false})
  199. */
  200. private $billingAdmin = false;
  201. /**
  202. * @var bool
  203. *
  204. * @ORM\Column(name="matterDashboardEnabled", type="boolean")
  205. */
  206. private $matterDashboardEnabled = false;
  207. /**
  208. * @var string|null
  209. *
  210. * @ORM\Column(name="userType", type="string", length=255, nullable=true)
  211. */
  212. private $userType;
  213. /**
  214. * @var string|null
  215. *
  216. * @ORM\Column(name="azureId", type="string", length=255, nullable=true)
  217. */
  218. private $azureId;
  219. /**
  220. * @var bool
  221. *
  222. * @ORM\Column(name="receiveDailyUploadNotificationEmail", type="boolean")
  223. */
  224. private $receiveDailyUploadNotificationEmail = true;
  225. /**
  226. * @var bool|null
  227. *
  228. * @ORM\Column(name="tfaEnabled", type="boolean", nullable=true)
  229. */
  230. private $tfaEnabled;
  231. /**
  232. * @var string|null
  233. *
  234. * @ORM\Column(name="tfaUserId", type="string", nullable=true)
  235. */
  236. private $tfaUserId;
  237. /**
  238. * @var int|null
  239. *
  240. * @ORM\Column(name="notificationStatus", type="integer", nullable=true)
  241. */
  242. private $notificationStatus;
  243. /**
  244. * The User's own preference for the format they would like to receive UserNotifications in
  245. *
  246. * @var int
  247. *
  248. * @ORM\Column(name="notificationFormatPreference", type="integer", options={"default"="1"})
  249. */
  250. private $notificationFormatPreference = self::NOTIFICATION_FORMAT_PREFERENCE_EMAIL;
  251. /**
  252. * @var Invitation
  253. *
  254. * @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\Invitation", inversedBy="user", cascade={"remove"})
  255. *
  256. * @ORM\JoinColumns({
  257. *
  258. * @ORM\JoinColumn(name="invitation_id", referencedColumnName="code", unique=true)
  259. * })
  260. */
  261. private $invitation;
  262. /**
  263. * @var HumanResource
  264. *
  265. * @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\HumanResource", mappedBy="user")
  266. */
  267. private $humanResource;
  268. /**
  269. * @var AnalyticsUser
  270. *
  271. * @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\Analytics\AnalyticsUser", mappedBy="user", cascade={"persist","remove"})
  272. */
  273. private $analyticsUser;
  274. /**
  275. * @var LinkedEmailAddressInvitation
  276. *
  277. * @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\LinkedEmailAddressInvitation", mappedBy="userToLink", cascade={"persist","remove"})
  278. */
  279. private $linkedEmailAddressInvitation;
  280. /**
  281. * @var DoctrineCollection
  282. *
  283. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\Document", mappedBy="creator", cascade={"detach"})
  284. */
  285. private $documents;
  286. /**
  287. * @var DoctrineCollection
  288. *
  289. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\Disc", mappedBy="creator", cascade={"detach"})
  290. */
  291. private $discs;
  292. /**
  293. * @var DoctrineCollection
  294. *
  295. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\Project", mappedBy="manager", cascade={"detach"})
  296. */
  297. private $managedProjects;
  298. /**
  299. * @var DoctrineCollection
  300. *
  301. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\RoleInvitation", mappedBy="user", cascade={"persist","remove"})
  302. */
  303. private $roleInvitations;
  304. /**
  305. * @var DoctrineCollection
  306. *
  307. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\LinkedEmailAddressInvitation", mappedBy="user", cascade={"persist","remove"})
  308. */
  309. private $linkedEmailAddressInvitations;
  310. /**
  311. * @var DoctrineCollection
  312. *
  313. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\DiscImportSession", mappedBy="creator", cascade={"all"})
  314. */
  315. private $discImportSessions;
  316. /**
  317. * @var DoctrineCollection
  318. *
  319. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\ProjectUser", mappedBy="user", cascade={"all"})
  320. */
  321. private $projectUsers;
  322. /**
  323. * @var DoctrineCollection
  324. *
  325. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\Invitation", mappedBy="creator", cascade={"persist","detach","merge","refresh"})
  326. */
  327. private $invitationsCreated;
  328. /**
  329. * @var DoctrineCollection
  330. *
  331. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\User", mappedBy="creator")
  332. */
  333. private $usersCreated;
  334. /**
  335. * @var DoctrineCollection
  336. *
  337. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\RecordsRequestDetail", mappedBy="creator")
  338. */
  339. private $recordsRequestDetails;
  340. /**
  341. * @var DoctrineCollection
  342. *
  343. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\ChronologyItem", mappedBy="creator")
  344. */
  345. private $chronologyItemsCreated;
  346. /**
  347. * This relates to the UserNotifications that have been sent or are queued to send to the User
  348. *
  349. * @var DoctrineCollection
  350. *
  351. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\UserNotification", mappedBy="recipient", cascade={"persist","remove"})
  352. */
  353. private $notifications;
  354. /**
  355. * @var DoctrineCollection
  356. *
  357. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\MatterNote", mappedBy="creator")
  358. */
  359. private $matterNotes;
  360. /**
  361. * @var DoctrineCollection
  362. *
  363. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\LinkedEmailAddress", mappedBy="user")
  364. */
  365. private $linkedEmailAddress;
  366. /**
  367. * @var DoctrineCollection
  368. *
  369. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\ProjectClosure", mappedBy="closedBy")
  370. */
  371. private $projectClosures;
  372. /**
  373. * @var Account
  374. *
  375. * @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\Account")
  376. *
  377. * @ORM\JoinColumns({
  378. *
  379. * @ORM\JoinColumn(name="account_id", referencedColumnName="id")
  380. * })
  381. */
  382. private $account;
  383. /**
  384. * @var ExpertAgency
  385. *
  386. * @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\ExpertAgency", inversedBy="users")
  387. *
  388. * @ORM\JoinColumns({
  389. *
  390. * @ORM\JoinColumn(name="expertAgency_id", referencedColumnName="id")
  391. * })
  392. */
  393. private $expertAgency;
  394. /**
  395. * @var User
  396. *
  397. * @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\User", inversedBy="usersCreated")
  398. *
  399. * @ORM\JoinColumns({
  400. *
  401. * @ORM\JoinColumn(name="creator_id", referencedColumnName="id", nullable=true)
  402. * })
  403. */
  404. private $creator;
  405. /**
  406. * @var DoctrineCollection
  407. *
  408. * @ORM\ManyToMany(targetEntity="MedBrief\MSR\Entity\Specialisation")
  409. *
  410. * @ORM\JoinTable(name="user_specialisation",
  411. * joinColumns={
  412. *
  413. * @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE")
  414. * },
  415. * inverseJoinColumns={
  416. * @ORM\JoinColumn(name="specialisation_id", referencedColumnName="id", onDelete="CASCADE")
  417. * }
  418. * )
  419. *
  420. * @ORM\OrderBy({
  421. * "title"="ASC"
  422. * })
  423. */
  424. private $specialisations;
  425. /**
  426. * @var DoctrineCollection
  427. *
  428. * @ORM\ManyToMany(targetEntity="MedBrief\MSR\Entity\Project")
  429. *
  430. * @ORM\JoinTable(name="user_project",
  431. * joinColumns={
  432. *
  433. * @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE")
  434. * },
  435. * inverseJoinColumns={
  436. * @ORM\JoinColumn(name="project_id", referencedColumnName="id", onDelete="CASCADE")
  437. * }
  438. * )
  439. */
  440. private $favouriteProjects;
  441. private $azureAccessToken;
  442. /**
  443. * @ORM\OneToMany(targetEntity=ClinicalSummary::class, mappedBy="creator")
  444. */
  445. private $clinicalSummaries;
  446. /**
  447. * This property will track whether the 'Billed' checkbox in various modals is visible to MB Admins.
  448. *
  449. * @ORM\Column(type="boolean", options={"default": false})
  450. */
  451. private bool $accessToBilled = false;
  452. /**
  453. * @var \DateTime|null
  454. *
  455. * @ORM\Column(name="legacyRadiologyViewerLastUsed", type="datetime", nullable=true)
  456. */
  457. private $legacyRadiologyViewerLastUsed;
  458. public function __construct()
  459. {
  460. $this->username = Uuid::uuid4()->toString();
  461. $this->documents = new \Doctrine\Common\Collections\ArrayCollection();
  462. $this->discs = new \Doctrine\Common\Collections\ArrayCollection();
  463. $this->managedProjects = new \Doctrine\Common\Collections\ArrayCollection();
  464. $this->roleInvitations = new \Doctrine\Common\Collections\ArrayCollection();
  465. $this->linkedEmailAddressInvitations = new \Doctrine\Common\Collections\ArrayCollection();
  466. $this->discImportSessions = new \Doctrine\Common\Collections\ArrayCollection();
  467. $this->projectUsers = new \Doctrine\Common\Collections\ArrayCollection();
  468. $this->invitationsCreated = new \Doctrine\Common\Collections\ArrayCollection();
  469. $this->usersCreated = new \Doctrine\Common\Collections\ArrayCollection();
  470. $this->recordsRequestDetails = new \Doctrine\Common\Collections\ArrayCollection();
  471. $this->chronologyItemsCreated = new \Doctrine\Common\Collections\ArrayCollection();
  472. $this->notifications = new \Doctrine\Common\Collections\ArrayCollection();
  473. $this->matterNotes = new \Doctrine\Common\Collections\ArrayCollection();
  474. $this->linkedEmailAddress = new \Doctrine\Common\Collections\ArrayCollection();
  475. $this->projectClosures = new \Doctrine\Common\Collections\ArrayCollection();
  476. $this->specialisations = new \Doctrine\Common\Collections\ArrayCollection();
  477. $this->favouriteProjects = new \Doctrine\Common\Collections\ArrayCollection();
  478. $this->clinicalSummaries = new \Doctrine\Common\Collections\ArrayCollection();
  479. }
  480. /**
  481. * Returns a textual representation of this user (their full name)
  482. */
  483. public function __toString()
  484. {
  485. return $this->getFullName();
  486. }
  487. /**
  488. * @return int|null
  489. */
  490. public function getId(): ?int
  491. {
  492. return $this->id;
  493. }
  494. /**
  495. * A visual identifier that represents this user.
  496. *
  497. * @see UserInterface
  498. */
  499. public function getUsername(): string
  500. {
  501. return (string) $this->username;
  502. }
  503. /**
  504. * @param string $username
  505. *
  506. * @return $this
  507. */
  508. public function setUsername(string $username): self
  509. {
  510. $this->username = $username;
  511. return $this;
  512. }
  513. /**
  514. * @see UserInterface
  515. */
  516. public function getRoles(): array
  517. {
  518. $roles = $this->roles;
  519. // guarantee every user at least has ROLE_USER
  520. $roles[] = 'ROLE_USER';
  521. return array_unique($roles);
  522. }
  523. /**
  524. * @param array $roles
  525. *
  526. * @return $this
  527. */
  528. public function setRoles(array $roles): self
  529. {
  530. $this->roles = $roles;
  531. return $this;
  532. }
  533. /**
  534. * @param string $role
  535. *
  536. * @return $this
  537. */
  538. public function addRole(string $role)
  539. {
  540. $this->roles[] = $role;
  541. return $this;
  542. }
  543. /**
  544. * @param string $role
  545. *
  546. * @return $this
  547. */
  548. public function removeRole(string $role)
  549. {
  550. if (($key = array_search($role, $this->roles)) !== false) {
  551. unset($this->roles[$key]);
  552. }
  553. return $this;
  554. }
  555. /**
  556. * @see UserInterface
  557. */
  558. public function getPassword(): string
  559. {
  560. return $this->password;
  561. }
  562. /**
  563. * @param string $password
  564. *
  565. * @return $this
  566. */
  567. public function setPassword(string $password): self
  568. {
  569. $this->password = $password;
  570. return $this;
  571. }
  572. /**
  573. * Returning a salt is only needed, if you are not using a modern
  574. * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  575. *
  576. * @see UserInterface
  577. */
  578. public function getSalt(): ?string
  579. {
  580. return $this->salt;
  581. }
  582. /**
  583. * Setting a salt is generally unnecessary (modern hashing algorithms), but we have implemented this so that we can
  584. * clear the salt on upgrade of a User's password.
  585. *
  586. * @param string|null $salt
  587. *
  588. * @return $this
  589. */
  590. public function setSalt(?string $salt)
  591. {
  592. $this->salt = $salt;
  593. return $this;
  594. }
  595. /**
  596. * @see UserInterface
  597. */
  598. public function eraseCredentials()
  599. {
  600. // If you store any temporary, sensitive data on the user, clear it here
  601. // $this->plainPassword = null;
  602. }
  603. /**
  604. * @return bool
  605. */
  606. public function isEnabled()
  607. {
  608. return $this->enabled;
  609. }
  610. /**
  611. * @return mixed
  612. */
  613. public function getLastLogin()
  614. {
  615. return $this->last_login;
  616. }
  617. /**
  618. * @param mixed $last_login
  619. *
  620. * @return User
  621. */
  622. public function setLastLogin($last_login)
  623. {
  624. $this->last_login = $last_login;
  625. return $this;
  626. }
  627. /**
  628. * @return string
  629. */
  630. public function getAzureId()
  631. {
  632. return $this->azureId;
  633. }
  634. /**
  635. * @param string $azureId
  636. *
  637. * @return User
  638. */
  639. public function setAzureId($azureId)
  640. {
  641. $this->azureId = $azureId;
  642. return $this;
  643. }
  644. /**
  645. * @return string
  646. */
  647. public function getAzureAccessToken()
  648. {
  649. return $this->azureAccessToken;
  650. }
  651. /**
  652. * @param mixed $azureAccessToken
  653. *
  654. * @return User
  655. */
  656. public function setAzureAccessToken($azureAccessToken)
  657. {
  658. $this->azureAccessToken = $azureAccessToken;
  659. return $this;
  660. }
  661. /**
  662. * @return string
  663. */
  664. public function getMicrosoftId()
  665. {
  666. return $this->getAzureId();
  667. }
  668. /**
  669. * @param mixed $azureId
  670. *
  671. * @return User
  672. */
  673. public function setMicrosoftId($azureId)
  674. {
  675. return $this->setAzureId($azureId);
  676. }
  677. /**
  678. * @return string
  679. */
  680. public function getMicrosoftAccessToken()
  681. {
  682. return $this->getAzureAccessToken();
  683. }
  684. /**
  685. * @param mixed $azureAccessToken
  686. *
  687. * @return User
  688. */
  689. public function setMicrosoftAccessToken($azureAccessToken)
  690. {
  691. return $this->setAzureAccessToken($azureAccessToken);
  692. }
  693. /**
  694. * @return string
  695. */
  696. public function getFullName()
  697. {
  698. $prefix = '';
  699. if ($this->getDeletedAt() !== null) {
  700. $prefix = '[REMOVED] ';
  701. }
  702. return $prefix . trim($this->getFirstName() . ' ' . $this->getLastName());
  703. }
  704. /**
  705. * @param string $first_name
  706. *
  707. * @return User
  708. */
  709. public function setFirstName($first_name)
  710. {
  711. $this->first_name = $first_name;
  712. return $this;
  713. }
  714. /**
  715. * @Groups({"user:read", "matter_request:read", "account:read"})
  716. *
  717. * @return string
  718. */
  719. public function getFirstName()
  720. {
  721. return $this->first_name;
  722. }
  723. /**
  724. * @param string $last_name
  725. *
  726. * @return User
  727. */
  728. public function setLastName($last_name)
  729. {
  730. $this->last_name = $last_name;
  731. return $this;
  732. }
  733. /**
  734. * @Groups({"user:read", "matter_request:read", "account:read"})
  735. *
  736. * @return string
  737. */
  738. public function getLastName()
  739. {
  740. return $this->last_name;
  741. }
  742. /**
  743. * @param \DateTime $created
  744. *
  745. * @return User
  746. */
  747. public function setCreated($created)
  748. {
  749. $this->created = $created;
  750. return $this;
  751. }
  752. /**
  753. * @return \DateTime
  754. */
  755. public function getCreated()
  756. {
  757. return $this->created;
  758. }
  759. /**
  760. * @param \DateTime $updated
  761. *
  762. * @return User
  763. */
  764. public function setUpdated($updated)
  765. {
  766. $this->updated = $updated;
  767. return $this;
  768. }
  769. /**
  770. * @return \DateTime
  771. */
  772. public function getUpdated()
  773. {
  774. return $this->updated;
  775. }
  776. /**
  777. * @param string $search_index
  778. *
  779. * @return User
  780. */
  781. public function setSearchIndex($search_index)
  782. {
  783. $this->search_index = $search_index;
  784. return $this;
  785. }
  786. /**
  787. * @return string
  788. */
  789. public function getSearchIndex()
  790. {
  791. return $this->search_index;
  792. }
  793. /**
  794. * @param Account|null $account
  795. *
  796. * @return User
  797. */
  798. public function setAccount(?Account $account = null)
  799. {
  800. $this->account = $account;
  801. return $this;
  802. }
  803. /**
  804. * @return Account
  805. */
  806. public function getAccount()
  807. {
  808. return $this->account;
  809. }
  810. /**
  811. * @param string $phoneNumber
  812. *
  813. * @return User
  814. */
  815. public function setPhoneNumber($phoneNumber)
  816. {
  817. $this->phoneNumber = $phoneNumber;
  818. return $this;
  819. }
  820. /**
  821. * @return string
  822. */
  823. public function getPhoneNumber()
  824. {
  825. return $this->phoneNumber;
  826. }
  827. /**
  828. * @param Document $documents
  829. *
  830. * @return User
  831. */
  832. public function addDocument(Document $documents)
  833. {
  834. $this->documents[] = $documents;
  835. return $this;
  836. }
  837. /**
  838. * @param Document $documents
  839. */
  840. public function removeDocument(Document $documents)
  841. {
  842. $this->documents->removeElement($documents);
  843. }
  844. /**
  845. * @return DoctrineCollection
  846. */
  847. public function getDocuments()
  848. {
  849. return $this->documents;
  850. }
  851. /**
  852. * @param Project $managedProjects
  853. *
  854. * @return User
  855. */
  856. public function addManagedProject(Project $managedProjects)
  857. {
  858. $this->managedProjects[] = $managedProjects;
  859. return $this;
  860. }
  861. /**
  862. * @param Project $managedProjects
  863. */
  864. public function removeManagedProject(Project $managedProjects)
  865. {
  866. $this->managedProjects->removeElement($managedProjects);
  867. }
  868. /**
  869. * @return DoctrineCollection
  870. */
  871. public function getManagedProjects()
  872. {
  873. return $this->managedProjects;
  874. }
  875. /**
  876. * @param Invitation|null $invitation
  877. *
  878. * @return User
  879. */
  880. public function setInvitation(?Invitation $invitation = null)
  881. {
  882. $this->invitation = $invitation;
  883. return $this;
  884. }
  885. /**
  886. * @return Invitation
  887. */
  888. public function getInvitation()
  889. {
  890. return $this->invitation;
  891. }
  892. /**
  893. * This is a validation callback function specified in our validation.yml file
  894. *
  895. * @param ExecutionContextInterface $context
  896. */
  897. public function validate(ExecutionContextInterface $context)
  898. {
  899. // this user is not valid if their email address does not match that of their invitation
  900. if (trim($this->getEmail()) != trim($this->getInvitation()->getEmail())) {
  901. $context->buildViolation('This email address does not match the one on the invitation')
  902. ->atPath('email')
  903. ->addViolation()
  904. ;
  905. }
  906. }
  907. /**
  908. * @param RoleInvitation $roleInvitations
  909. *
  910. * @return User
  911. */
  912. public function addRoleInvitation(RoleInvitation $roleInvitations)
  913. {
  914. $this->roleInvitations[] = $roleInvitations;
  915. return $this;
  916. }
  917. /**
  918. * @param RoleInvitation $roleInvitations
  919. */
  920. public function removeRoleInvitation(RoleInvitation $roleInvitations)
  921. {
  922. $this->roleInvitations->removeElement($roleInvitations);
  923. }
  924. /**
  925. * @return DoctrineCollection
  926. */
  927. public function getRoleInvitations()
  928. {
  929. return $this->roleInvitations;
  930. }
  931. /**
  932. * Checks to see if this entity has a RoleInvitation that matches the given
  933. * role. If there is one, it is returned.
  934. *
  935. * @param $role
  936. *
  937. * @return RoleInvitation|null
  938. */
  939. public function getMatchingRoleInvitation($role)
  940. {
  941. foreach ($this->getRoleInvitations() as $roleInvitation) {
  942. if ($role == $roleInvitation->getRole()) {
  943. return $roleInvitation;
  944. }
  945. }
  946. return null;
  947. }
  948. /**
  949. * Checks to see if this entity has a RoleInvitation that is pending
  950. * approval and matches the given role. If there is one, it is returned.
  951. *
  952. * @param $role
  953. *
  954. * @return RoleInvitation|null
  955. */
  956. public function getMatchingRoleInvitationPendingApproval($role)
  957. {
  958. foreach ($this->getRoleInvitations() as $roleInvitation) {
  959. if ($role == $roleInvitation->getRole()
  960. && ($roleInvitation->getStatus() == RoleInvitation::STATUS_PENDING_APPROVAL
  961. || $roleInvitation->getStatus() == RoleInvitation::STATUS_SUPPRESSED)) {
  962. return $roleInvitation;
  963. }
  964. }
  965. return null;
  966. }
  967. /**
  968. * Checks to see if this entity has a RoleInvitation that is pending one-time authentication
  969. * and matches the given role. If there is one, it is returned.
  970. *
  971. * @param $role
  972. *
  973. * @return bool
  974. */
  975. public function getMatchingRoleInvitationPendingAuthentication($role)
  976. {
  977. foreach ($this->getRoleInvitations() as $roleInvitation) {
  978. if ($role == $roleInvitation->getRole()
  979. && $roleInvitation->getStatus() == RoleInvitation::STATUS_PENDING_AUTHENTICATION) {
  980. return $roleInvitation;
  981. }
  982. }
  983. return null;
  984. }
  985. /**
  986. * Checks to see if this entity has an accepted RoleInvitation that
  987. * matches the given role.
  988. *
  989. * @param $role
  990. *
  991. * @return bool
  992. */
  993. public function hasMatchingAcceptedRoleInvitation($role): bool
  994. {
  995. foreach ($this->getRoleInvitations() as $roleInvitation) {
  996. if ($role === $roleInvitation->getRole() && $roleInvitation->getAccepted() !== null) {
  997. return true;
  998. }
  999. }
  1000. return false;
  1001. }
  1002. /**
  1003. * Returns true if this user has any RoleInvitations linked directly to them
  1004. * or their Invitation that are in PENDING_APPROVAL state
  1005. *
  1006. * @return bool
  1007. */
  1008. public function hasRoleInvitationsPendingApproval()
  1009. {
  1010. $roleInvitations = $this->getPendingRoleInvitations();
  1011. return !empty($roleInvitations);
  1012. }
  1013. /**
  1014. * Returns true if this user has any RoleInvitations linked directly to them
  1015. * or their Invitation that are in PENDING_APPROVAL state
  1016. *
  1017. * @param string $role
  1018. *
  1019. * @return bool
  1020. */
  1021. public function hasMatchingRoleInvitationsPendingApproval($role): bool
  1022. {
  1023. $roleInvitations = $this->getMatchingRoleInvitationPendingApproval($role);
  1024. return !empty($roleInvitations);
  1025. }
  1026. /**
  1027. * Gets all the Pending RoleInvitations linked to this user and to their
  1028. * invitation
  1029. *
  1030. * @return array
  1031. */
  1032. public function getPendingRoleInvitations()
  1033. {
  1034. $array = [];
  1035. foreach ($this->getRoleInvitations() as $roleInvitation) {
  1036. if ($roleInvitation->getStatus() == RoleInvitation::STATUS_PENDING_APPROVAL
  1037. || $roleInvitation->getStatus() == RoleInvitation::STATUS_SUPPRESSED) {
  1038. $array[] = $roleInvitation;
  1039. }
  1040. }
  1041. if ($this->getInvitation()) {
  1042. foreach ($this->getInvitation()->getRoleInvitations() as $roleInvitation) {
  1043. if ($roleInvitation->getStatus() == RoleInvitation::STATUS_PENDING_APPROVAL
  1044. || $roleInvitation->getStatus() == RoleInvitation::STATUS_SUPPRESSED) {
  1045. $array[] = $roleInvitation;
  1046. }
  1047. }
  1048. }
  1049. return $array;
  1050. }
  1051. // @todo Should the below two be bundled in to the more accommodating functions with a "suppressed" arg?
  1052. /**
  1053. * Checks whether the User has any Role Invitations that are pending as well as not suppressed
  1054. *
  1055. * @return bool
  1056. */
  1057. public function hasUnsuppressedRoleInvitationsPendingApproval()
  1058. {
  1059. $roleInvitations = $this->getUnsuppressedRoleInvitationsPending();
  1060. return !empty($roleInvitations);
  1061. }
  1062. /**
  1063. * Grabs all the Role Invitations for this User that are pending approval and not suppressed
  1064. *
  1065. * @return array
  1066. */
  1067. public function getUnsuppressedRoleInvitationsPending()
  1068. {
  1069. $array = [];
  1070. foreach ($this->getRoleInvitations() as $roleInvitation) {
  1071. if ($roleInvitation->getStatus() == RoleInvitation::STATUS_PENDING_APPROVAL) {
  1072. $array[] = $roleInvitation;
  1073. }
  1074. }
  1075. if ($this->getInvitation()) {
  1076. foreach ($this->getInvitation()->getRoleInvitations() as $roleInvitation) {
  1077. if ($roleInvitation->getStatus() == RoleInvitation::STATUS_PENDING_APPROVAL) {
  1078. $array[] = $roleInvitation;
  1079. }
  1080. }
  1081. }
  1082. return $array;
  1083. }
  1084. /**
  1085. * Returns true if this user is a client administrator for at least one
  1086. * account. Note that this needs to match against Client Administrators and Client Super Administrators
  1087. *
  1088. * @return bool
  1089. */
  1090. public function isAccountAdministrator()
  1091. {
  1092. foreach ($this->getRoles() as $role) {
  1093. if ((stripos($role, 'ROLE_ACCOUNT_') !== false && stripos($role, '_ADMINISTRATOR') !== false)
  1094. || (stripos($role, 'ROLE_ACCOUNT_') !== false && stripos($role, '_SUPERADMINISTRATOR') !== false)) {
  1095. return true;
  1096. }
  1097. }
  1098. return false;
  1099. }
  1100. /**
  1101. * Checks whether a user is the Technical Administrator for *ANY* account
  1102. *
  1103. * @return bool
  1104. */
  1105. public function isAccountTechnicalAdmin(): bool
  1106. {
  1107. foreach ($this->getRoles() as $role) {
  1108. if (preg_match('/ROLE_ACCOUNT_\d+_TECHNICAL_ADMIN/', $role)) {
  1109. return true;
  1110. }
  1111. }
  1112. return false;
  1113. }
  1114. /**
  1115. * Checks whether a user is a sorter for *ANY* account
  1116. *
  1117. * @return bool
  1118. */
  1119. public function isAccountSorter(): bool
  1120. {
  1121. foreach ($this->getRoles() as $role) {
  1122. if (preg_match('/ROLE_ACCOUNT_\d+_SORTER/', $role)) {
  1123. return true;
  1124. }
  1125. }
  1126. return false;
  1127. }
  1128. /**
  1129. * Checks whether a user is the Technical Administrator for a specific Account (basically the same as the Voter)
  1130. *
  1131. * @param Account $account
  1132. *
  1133. * @return bool
  1134. */
  1135. public function isTechnicalAdminForSpecificAccount(Account $account): bool
  1136. {
  1137. $accountId = $account->getId();
  1138. foreach ($this->getRoles() as $role) {
  1139. if (preg_match("/ROLE_ACCOUNT_{$accountId}_TECHNICAL_ADMIN/", $role)) {
  1140. return true;
  1141. }
  1142. }
  1143. return false;
  1144. }
  1145. /**
  1146. * Returns true if this user is a client administrator for the specified Account.
  1147. * Note that this needs to match against Client Administrators and Client Super Administrators
  1148. *
  1149. * @param Account $account
  1150. *
  1151. * @return bool
  1152. */
  1153. public function isAccountAdministratorForAccount(Account $account)
  1154. {
  1155. foreach ($this->getRoles() as $role) {
  1156. if (
  1157. $role == sprintf('ROLE_ACCOUNT_%1$s_ADMINISTRATOR', $account->getId())
  1158. || $role == sprintf('ROLE_ACCOUNT_%1$s_SUPERADMINISTRATOR', $account->getId())
  1159. ) {
  1160. return true;
  1161. }
  1162. }
  1163. return false;
  1164. }
  1165. /**
  1166. * Returns true if this user is a client project manager for at least one
  1167. * account.
  1168. *
  1169. * @return bool
  1170. */
  1171. public function isAccountProjectManager()
  1172. {
  1173. foreach ($this->getRoles() as $role) {
  1174. if ((stripos($role, 'ROLE_ACCOUNT_') !== false && stripos($role, '_PROJECTMANAGER') !== false)) {
  1175. return true;
  1176. }
  1177. }
  1178. return false;
  1179. }
  1180. /**
  1181. * Returns true if this user is a client project manager for the specified Account.
  1182. *
  1183. * @param Account $account
  1184. *
  1185. * @return bool
  1186. */
  1187. public function isAccountProjectManagerForAccount(Account $account)
  1188. {
  1189. foreach ($this->getRoles() as $role) {
  1190. if ($role == sprintf('ROLE_ACCOUNT_%1$s_PROJECTMANAGER', $account->getId())) {
  1191. return true;
  1192. }
  1193. }
  1194. return false;
  1195. }
  1196. /**
  1197. * Returns true if this user is a client project manager for the specified Project.
  1198. *
  1199. * @param Project $project
  1200. *
  1201. * @return bool
  1202. */
  1203. public function isProjectManagerForSpecificProject(Project $project)
  1204. {
  1205. foreach ($this->getRoles() as $role) {
  1206. if ($role == sprintf('ROLE_PROJECT_%1$s_PROJECTMANAGER', $project->getId())) {
  1207. return true;
  1208. }
  1209. }
  1210. return false;
  1211. }
  1212. /**
  1213. * Returns true if this user is a expert agency administrator
  1214. *
  1215. * @return bool
  1216. */
  1217. public function isExpertAgencyAdministrator()
  1218. {
  1219. foreach ($this->getRoles() as $role) {
  1220. if (stripos($role, 'ROLE_EXPERTAGENCY_') !== false && stripos($role, '_ADMINISTRATOR') !== false) {
  1221. return true;
  1222. }
  1223. }
  1224. return false;
  1225. }
  1226. /**
  1227. * Returns true if this user is a project manager for at least one project
  1228. *
  1229. * @return bool
  1230. */
  1231. public function isProjectManager()
  1232. {
  1233. foreach ($this->getRoles() as $role) {
  1234. if (stripos($role, 'ROLE_PROJECT_') !== false && stripos($role, '_PROJECTMANAGER') !== false) {
  1235. return true;
  1236. }
  1237. }
  1238. return false;
  1239. }
  1240. /**
  1241. * Returns true if this user is a project scanner for at least one project
  1242. *
  1243. * @return bool
  1244. */
  1245. public function isProjectScanner(): bool
  1246. {
  1247. foreach ($this->getRoles() as $role) {
  1248. if (preg_match('/ROLE_PROJECT_\d+_SCANNER/', $role)) {
  1249. return true;
  1250. }
  1251. }
  1252. return false;
  1253. }
  1254. /**
  1255. * Returns true if this user is a project scanner downloader for at least one project
  1256. *
  1257. * @return bool
  1258. */
  1259. public function isProjectScannerDownload(): bool
  1260. {
  1261. foreach ($this->getRoles() as $role) {
  1262. if (stripos($role, 'ROLE_PROJECT_') !== false && stripos($role, '_SCANNERDOWNLOAD') !== false) {
  1263. return true;
  1264. }
  1265. }
  1266. return false;
  1267. }
  1268. /**
  1269. * Returns true if this user only has expert roles or role invitations associated with their account.
  1270. *
  1271. * @return bool
  1272. */
  1273. public function isExpertOnly()
  1274. {
  1275. if ($this->getRoles()) {
  1276. foreach ($this->getRoles() as $role) {
  1277. if ((stripos($role, 'ROLE_PROJECT_') === false || stripos($role, '_EXPERT') === false) && $role !== 'ROLE_USER') {
  1278. return false;
  1279. }
  1280. }
  1281. }
  1282. foreach ($this->getRoleInvitations() as $invitation) {
  1283. if (stripos($invitation->getRole(), 'ROLE_PROJECT_') === false || stripos($invitation->getRole(), '_EXPERT') === false) {
  1284. return false;
  1285. }
  1286. }
  1287. return true;
  1288. }
  1289. /**
  1290. * Returns true if the user only has an expert viewer role or role invitations, associated with their account.
  1291. *
  1292. * @return bool
  1293. */
  1294. public function isExpertViewerOnly()
  1295. {
  1296. if ($this->getRoles()) {
  1297. foreach ($this->getRoles() as $role) {
  1298. if ((stripos($role, 'ROLE_PROJECT_') === false || stripos($role, '_EXPERTVIEWER') === false) && $role !== 'ROLE_USER') {
  1299. return false;
  1300. }
  1301. }
  1302. }
  1303. foreach ($this->getRoleInvitations() as $invitation) {
  1304. if (stripos($invitation->getRole(), 'ROLE_PROJECT_') === false || stripos($invitation->getRole(), '_EXPERTVIEWER') === false) {
  1305. return false;
  1306. }
  1307. }
  1308. return true;
  1309. }
  1310. /**
  1311. * @param \DateTime $deletedAt
  1312. *
  1313. * @return User
  1314. */
  1315. public function setDeletedAt($deletedAt)
  1316. {
  1317. $this->deletedAt = $deletedAt;
  1318. return $this;
  1319. }
  1320. /**
  1321. * @return \DateTime
  1322. */
  1323. public function getDeletedAt()
  1324. {
  1325. return $this->deletedAt;
  1326. }
  1327. /**
  1328. * @param Disc $disc
  1329. *
  1330. * @return User
  1331. */
  1332. public function addDisc(Disc $disc)
  1333. {
  1334. $this->discs[] = $disc;
  1335. return $this;
  1336. }
  1337. /**
  1338. * @param Disc $disc
  1339. */
  1340. public function removeDisc(Disc $disc)
  1341. {
  1342. $this->discs->removeElement($disc);
  1343. }
  1344. /**
  1345. * @return DoctrineCollection
  1346. */
  1347. public function getDiscs()
  1348. {
  1349. return $this->discs;
  1350. }
  1351. /**
  1352. * @param DiscImportSession $discImportSession
  1353. *
  1354. * @return User
  1355. */
  1356. public function addDiscImportSession(DiscImportSession $discImportSession)
  1357. {
  1358. $this->discImportSessions[] = $discImportSession;
  1359. return $this;
  1360. }
  1361. /**
  1362. * @param DiscImportSession $discImportSession
  1363. */
  1364. public function removeDiscImportSession(DiscImportSession $discImportSession)
  1365. {
  1366. $this->discImportSessions->removeElement($discImportSession);
  1367. }
  1368. /**
  1369. * @return DoctrineCollection
  1370. */
  1371. public function getDiscImportSessions()
  1372. {
  1373. return $this->discImportSessions;
  1374. }
  1375. /**
  1376. * @param ProjectUser $projectUser
  1377. *
  1378. * @return User
  1379. */
  1380. public function addProjectUser(ProjectUser $projectUser)
  1381. {
  1382. $this->projectUsers[] = $projectUser;
  1383. return $this;
  1384. }
  1385. /**
  1386. * @param ProjectUser $projectUser
  1387. */
  1388. public function removeProjectUser(ProjectUser $projectUser)
  1389. {
  1390. $this->projectUsers->removeElement($projectUser);
  1391. }
  1392. /**
  1393. * @return DoctrineCollection
  1394. */
  1395. public function getProjectUsers()
  1396. {
  1397. return $this->projectUsers;
  1398. }
  1399. /**
  1400. * @param Invitation $invitationsCreated
  1401. *
  1402. * @return User
  1403. */
  1404. public function addInvitationsCreated(Invitation $invitationsCreated)
  1405. {
  1406. $this->invitationsCreated[] = $invitationsCreated;
  1407. return $this;
  1408. }
  1409. /**
  1410. * @param Invitation $invitationsCreated
  1411. */
  1412. public function removeInvitationsCreated(Invitation $invitationsCreated)
  1413. {
  1414. $this->invitationsCreated->removeElement($invitationsCreated);
  1415. }
  1416. /**
  1417. * @return DoctrineCollection
  1418. */
  1419. public function getInvitationsCreated()
  1420. {
  1421. return $this->invitationsCreated;
  1422. }
  1423. /**
  1424. * @param ExpertAgency|null $expertAgency
  1425. *
  1426. * @return User
  1427. */
  1428. public function setExpertAgency(?ExpertAgency $expertAgency = null)
  1429. {
  1430. $this->expertAgency = $expertAgency;
  1431. return $this;
  1432. }
  1433. /**
  1434. * @return ExpertAgency
  1435. */
  1436. public function getExpertAgency()
  1437. {
  1438. return $this->expertAgency;
  1439. }
  1440. /**
  1441. * @param \DateTime $lastActivity
  1442. *
  1443. * @return User
  1444. */
  1445. public function setLastActivity($lastActivity)
  1446. {
  1447. $this->lastActivity = $lastActivity;
  1448. return $this;
  1449. }
  1450. /**
  1451. * @return \DateTime
  1452. */
  1453. public function getLastActivity()
  1454. {
  1455. return $this->lastActivity;
  1456. }
  1457. /**
  1458. * @return bool whether the user is active or not
  1459. */
  1460. public function isActiveNow()
  1461. {
  1462. $delay = new \DateTime('2 minutes ago');
  1463. return $this->getlastActivity() > $delay;
  1464. }
  1465. /**
  1466. * @param User $usersCreated
  1467. *
  1468. * @return User
  1469. */
  1470. public function addUsersCreated(User $usersCreated)
  1471. {
  1472. $this->usersCreated[] = $usersCreated;
  1473. return $this;
  1474. }
  1475. /**
  1476. * @param User $usersCreated
  1477. */
  1478. public function removeUsersCreated(User $usersCreated)
  1479. {
  1480. $this->usersCreated->removeElement($usersCreated);
  1481. }
  1482. /**
  1483. * @return DoctrineCollection
  1484. */
  1485. public function getUsersCreated()
  1486. {
  1487. return $this->usersCreated;
  1488. }
  1489. /**
  1490. * @param User|null $creator
  1491. *
  1492. * @return User
  1493. */
  1494. public function setCreator(?User $creator = null)
  1495. {
  1496. $this->creator = $creator;
  1497. return $this;
  1498. }
  1499. /**
  1500. * @return User
  1501. */
  1502. public function getCreator()
  1503. {
  1504. return $this->creator;
  1505. }
  1506. /**
  1507. * @param bool $receiveDailyUploadNotificationEmail
  1508. *
  1509. * @return User
  1510. */
  1511. public function setReceiveDailyUploadNotificationEmail($receiveDailyUploadNotificationEmail)
  1512. {
  1513. $this->receiveDailyUploadNotificationEmail = $receiveDailyUploadNotificationEmail;
  1514. return $this;
  1515. }
  1516. /**
  1517. * @return bool
  1518. */
  1519. public function getReceiveDailyUploadNotificationEmail()
  1520. {
  1521. return $this->receiveDailyUploadNotificationEmail;
  1522. }
  1523. /**
  1524. * @param ChronologyItem $chronologyItemsCreated
  1525. *
  1526. * @return User
  1527. */
  1528. public function addChronologyItemsCreated(ChronologyItem $chronologyItemsCreated)
  1529. {
  1530. $this->chronologyItemsCreated[] = $chronologyItemsCreated;
  1531. return $this;
  1532. }
  1533. /**
  1534. * @param ChronologyItem $chronologyItemsCreated
  1535. */
  1536. public function removeChronologyItemsCreated(ChronologyItem $chronologyItemsCreated)
  1537. {
  1538. $this->chronologyItemsCreated->removeElement($chronologyItemsCreated);
  1539. }
  1540. /**
  1541. * @return DoctrineCollection
  1542. */
  1543. public function getChronologyItemsCreated()
  1544. {
  1545. return $this->chronologyItemsCreated;
  1546. }
  1547. /**
  1548. * @param RecordsRequestDetail $recordsRequestDetail
  1549. *
  1550. * @return User
  1551. */
  1552. public function addRecordsRequestDetail(RecordsRequestDetail $recordsRequestDetail)
  1553. {
  1554. $this->recordsRequestDetails[] = $recordsRequestDetail;
  1555. return $this;
  1556. }
  1557. /**
  1558. * @param RecordsRequestDetail $recordsRequestDetail
  1559. */
  1560. public function removeRecordsRequestDetail(RecordsRequestDetail $recordsRequestDetail)
  1561. {
  1562. $this->recordsRequestDetails->removeElement($recordsRequestDetail);
  1563. }
  1564. /**
  1565. * @return DoctrineCollection
  1566. */
  1567. public function getRecordsRequestDetails()
  1568. {
  1569. return $this->recordsRequestDetails;
  1570. }
  1571. /**
  1572. * @return bool
  1573. */
  1574. public function isAccountNonLocked()
  1575. {
  1576. return !$this->locked;
  1577. }
  1578. /**
  1579. * @return bool
  1580. */
  1581. public function isLocked()
  1582. {
  1583. return !$this->isAccountNonLocked();
  1584. }
  1585. /**
  1586. * @param $boolean
  1587. *
  1588. * @return $this
  1589. */
  1590. public function setLocked($boolean)
  1591. {
  1592. $this->locked = $boolean;
  1593. return $this;
  1594. }
  1595. /**
  1596. * @param PhoneNumber $mobileNumber
  1597. *
  1598. * @return User
  1599. */
  1600. public function setMobileNumber($mobileNumber)
  1601. {
  1602. $this->mobileNumber = $mobileNumber;
  1603. return $this;
  1604. }
  1605. /**
  1606. * @return PhoneNumber
  1607. */
  1608. public function getMobileNumber()
  1609. {
  1610. return $this->mobileNumber;
  1611. }
  1612. /**
  1613. * @param int $notificationStatus
  1614. *
  1615. * @return User
  1616. */
  1617. public function setNotificationStatus($notificationStatus)
  1618. {
  1619. $this->notificationStatus = $notificationStatus;
  1620. return $this;
  1621. }
  1622. /**
  1623. * @return int
  1624. */
  1625. public function getNotificationStatus()
  1626. {
  1627. return $this->notificationStatus;
  1628. }
  1629. /**
  1630. * @param int $notificationFormatPreference
  1631. *
  1632. * @return User
  1633. */
  1634. public function setNotificationFormatPreference($notificationFormatPreference)
  1635. {
  1636. $this->notificationFormatPreference = $notificationFormatPreference;
  1637. return $this;
  1638. }
  1639. /**
  1640. * @return int
  1641. */
  1642. public function getNotificationFormatPreference()
  1643. {
  1644. return $this->notificationFormatPreference;
  1645. }
  1646. /**
  1647. * @param UserNotification $notification
  1648. *
  1649. * @return User
  1650. */
  1651. public function addNotification(UserNotification $notification)
  1652. {
  1653. $this->notifications[] = $notification;
  1654. return $this;
  1655. }
  1656. /**
  1657. * @param UserNotification $notification
  1658. */
  1659. public function removeNotification(UserNotification $notification)
  1660. {
  1661. $this->notifications->removeElement($notification);
  1662. }
  1663. /**
  1664. * @return DoctrineCollection
  1665. */
  1666. public function getNotifications()
  1667. {
  1668. return $this->notifications;
  1669. }
  1670. /**
  1671. * @param bool $billingAdmin
  1672. *
  1673. * @return User
  1674. */
  1675. public function setBillingAdmin($billingAdmin)
  1676. {
  1677. $this->billingAdmin = $billingAdmin;
  1678. return $this;
  1679. }
  1680. /**
  1681. * @return bool
  1682. */
  1683. public function isBillingAdmin()
  1684. {
  1685. return $this->billingAdmin;
  1686. }
  1687. /**
  1688. * NOTE: Doctrine wants to add a ::getBillingAdmin() function but a User
  1689. * does not have a billingAdmin, but they can BE a billing admin. We will
  1690. * keep this here to appease the Doctrinosaurus.
  1691. *
  1692. * @return bool
  1693. */
  1694. public function getBillingAdmin()
  1695. {
  1696. return $this->billingAdmin;
  1697. }
  1698. /**
  1699. * @param Specialisation $specialisation
  1700. *
  1701. * @return User
  1702. */
  1703. public function addSpecialisation(Specialisation $specialisation)
  1704. {
  1705. $this->specialisations[] = $specialisation;
  1706. return $this;
  1707. }
  1708. /**
  1709. * @param Specialisation $specialisation
  1710. */
  1711. public function removeSpecialisation(Specialisation $specialisation)
  1712. {
  1713. $this->specialisations->removeElement($specialisation);
  1714. }
  1715. /**
  1716. * @return DoctrineCollection
  1717. */
  1718. public function getSpecialisations()
  1719. {
  1720. return $this->specialisations;
  1721. }
  1722. /**
  1723. * Check if this User has a particular Specialisation
  1724. *
  1725. * @param Specialisation $specialisation
  1726. *
  1727. * @return bool
  1728. */
  1729. public function hasSpecialisation(Specialisation $specialisation)
  1730. {
  1731. return $this->getSpecialisations()->contains($specialisation);
  1732. }
  1733. /**
  1734. * @param Project $favouriteProject
  1735. *
  1736. * @return User
  1737. */
  1738. public function addFavouriteProject(Project $favouriteProject)
  1739. {
  1740. $this->favouriteProjects[] = $favouriteProject;
  1741. return $this;
  1742. }
  1743. /**
  1744. * @param Project $favouriteProject
  1745. */
  1746. public function removeFavouriteProject(Project $favouriteProject)
  1747. {
  1748. $this->favouriteProjects->removeElement($favouriteProject);
  1749. }
  1750. /**
  1751. * @return DoctrineCollection
  1752. */
  1753. public function getFavouriteProjects()
  1754. {
  1755. return $this->favouriteProjects;
  1756. }
  1757. /**
  1758. * @return bool
  1759. */
  1760. public function getLocked()
  1761. {
  1762. return $this->locked;
  1763. }
  1764. /**
  1765. * @param MatterNote $matterNote
  1766. *
  1767. * @return User
  1768. */
  1769. public function addMatterNote(MatterNote $matterNote)
  1770. {
  1771. $this->matterNotes[] = $matterNote;
  1772. return $this;
  1773. }
  1774. /**
  1775. * @param MatterNote $matterNote
  1776. */
  1777. public function removeMatterNote(MatterNote $matterNote)
  1778. {
  1779. $this->matterNotes->removeElement($matterNote);
  1780. }
  1781. /**
  1782. * @return DoctrineCollection
  1783. */
  1784. public function getMatterNotes()
  1785. {
  1786. return $this->matterNotes;
  1787. }
  1788. public function isUser(?UserInterface $user = null): bool
  1789. {
  1790. return $user instanceof self && $user->id === $this->id;
  1791. }
  1792. /**
  1793. * @ORM\PrePersist
  1794. */
  1795. public function copyEmailToUsername()
  1796. {
  1797. $this->setUsername($this->getEmail());
  1798. }
  1799. /**
  1800. * Updates the Search Index field with internal data. The Search Index Field
  1801. * provides an easy way to perform a 'like' query for a generalised search.
  1802. *
  1803. * @ORM\PrePersist
  1804. *
  1805. * @ORM\PreUpdate
  1806. */
  1807. public function updateSearchIndex()
  1808. {
  1809. $searchIndex
  1810. = $this->getFullName()
  1811. . ' '
  1812. . $this->getEmail();
  1813. // Add any linked email address to the search index
  1814. /** @var LinkedEmailAddress $linkedEmailAddress */
  1815. foreach ($this->linkedEmailAddress as $linkedEmailAddress) {
  1816. $searchIndex .= ' ' . strtolower($linkedEmailAddress->getEmail());
  1817. }
  1818. $this->setSearchIndex($searchIndex);
  1819. }
  1820. /**
  1821. * @param HumanResource|null $humanResource
  1822. *
  1823. * @return User
  1824. */
  1825. public function setHumanResource(?HumanResource $humanResource = null)
  1826. {
  1827. $this->humanResource = $humanResource;
  1828. return $this;
  1829. }
  1830. /**
  1831. * @return HumanResource|null
  1832. */
  1833. public function getHumanResource()
  1834. {
  1835. return $this->humanResource;
  1836. }
  1837. /**
  1838. * @param AnalyticsUser|null $analyticsUser
  1839. *
  1840. * @return User
  1841. */
  1842. public function setAnalyticsUser(?AnalyticsUser $analyticsUser = null)
  1843. {
  1844. $this->analyticsUser = $analyticsUser;
  1845. $this->analyticsUser->setUser($this);
  1846. return $this;
  1847. }
  1848. /**
  1849. * @return AnalyticsUser|null
  1850. */
  1851. public function getAnalyticsUser()
  1852. {
  1853. return $this->analyticsUser;
  1854. }
  1855. /**
  1856. * @param LinkedEmailAddress $linkedEmailAddress
  1857. *
  1858. * @return User
  1859. */
  1860. public function addLinkedEmailAddress(LinkedEmailAddress $linkedEmailAddress)
  1861. {
  1862. $this->linkedEmailAddress[] = $linkedEmailAddress;
  1863. // Update the search index, so we include the newly linked email address
  1864. $this->updateSearchIndex();
  1865. return $this;
  1866. }
  1867. /**
  1868. * @param LinkedEmailAddress $linkedEmailAddress
  1869. *
  1870. * @return bool TRUE if this collection contained the specified element, FALSE otherwise.
  1871. */
  1872. public function removeLinkedEmailAddress(LinkedEmailAddress $linkedEmailAddress)
  1873. {
  1874. $returnValue = $this->linkedEmailAddress->removeElement($linkedEmailAddress);
  1875. // Update the search index, so we exclude the removed linked email address
  1876. $this->updateSearchIndex();
  1877. return $returnValue;
  1878. }
  1879. /**
  1880. * @return DoctrineCollection
  1881. */
  1882. public function getLinkedEmailAddress()
  1883. {
  1884. return $this->linkedEmailAddress;
  1885. }
  1886. /**
  1887. * @param string $linkedEmailAddress
  1888. *
  1889. * @return bool
  1890. */
  1891. public function hasLinkedEmailAddress(string $linkedEmailAddress): bool
  1892. {
  1893. $linkedEmailAddresses = array_map(function (LinkedEmailAddress $linkedEmailAddress) {
  1894. return $linkedEmailAddress->getEmail();
  1895. }, $this->getLinkedEmailAddress()->toArray());
  1896. if (!$linkedEmailAddresses) {
  1897. return false;
  1898. }
  1899. return in_array($linkedEmailAddress, $linkedEmailAddresses);
  1900. }
  1901. /**
  1902. * @param LinkedEmailAddressInvitation $linkedEmailAddressInvitation
  1903. *
  1904. * @return User
  1905. */
  1906. public function addLinkedEmailAddressInvitation(LinkedEmailAddressInvitation $linkedEmailAddressInvitation)
  1907. {
  1908. $this->linkedEmailAddressInvitations[] = $linkedEmailAddressInvitation;
  1909. return $this;
  1910. }
  1911. /**
  1912. * @param LinkedEmailAddressInvitation $linkedEmailAddressInvitation
  1913. *
  1914. * @return bool TRUE if this collection contained the specified element, FALSE otherwise.
  1915. */
  1916. public function removeLinkedEmailAddressInvitation(LinkedEmailAddressInvitation $linkedEmailAddressInvitation)
  1917. {
  1918. return $this->linkedEmailAddressInvitations->removeElement($linkedEmailAddressInvitation);
  1919. }
  1920. /**
  1921. * @return DoctrineCollection
  1922. */
  1923. public function getLinkedEmailAddressInvitations()
  1924. {
  1925. return $this->linkedEmailAddressInvitations;
  1926. }
  1927. /**
  1928. * @param string $linkedEmailAddress
  1929. *
  1930. * @return bool
  1931. */
  1932. public function hasMatchingLinkedEmailAddressInvitationPendingApproval(string $linkedEmailAddress): bool
  1933. {
  1934. $linkedEmailAddressInvitations = $this->getLinkedEmailAddressInvitations();
  1935. /** @var LinkedEmailAddressInvitation $linkedEmailAddressInvitation */
  1936. foreach ($linkedEmailAddressInvitations as $linkedEmailAddressInvitation) {
  1937. switch ($linkedEmailAddressInvitation->getStatus()) {
  1938. case LinkedEmailAddressInvitation::STATUS_PENDING_APPROVAL:
  1939. return $linkedEmailAddress == $linkedEmailAddressInvitation->getEmail();
  1940. case LinkedEmailAddressInvitation::STATUS_APPROVED:
  1941. case LinkedEmailAddressInvitation::STATUS_DECLINED:
  1942. default:
  1943. }
  1944. }
  1945. return false;
  1946. }
  1947. /**
  1948. * Grabs all the Role Invitations for this User that are pending approval and not suppressed
  1949. *
  1950. * @TODO this function seems inefficient, as it is basically just checking if the passed linkedEmailAddressInvitation is pending?
  1951. *
  1952. * @param LinkedEmailAddressInvitation $linkedEmailAddressInvitation
  1953. *
  1954. * @return array
  1955. */
  1956. public function getLinkedEmailAddressInvitationPending(LinkedEmailAddressInvitation $linkedEmailAddressInvitation)
  1957. {
  1958. $linkedEmailAddresses = [];
  1959. if ($linkedEmailAddressInvitation->getStatus() == LinkedEmailAddressInvitation::STATUS_PENDING_APPROVAL) {
  1960. $linkedEmailAddresses[] = $linkedEmailAddressInvitation;
  1961. }
  1962. return $linkedEmailAddresses;
  1963. }
  1964. /**
  1965. * @param LinkedEmailAddressInvitation|null $linkedEmailAddressInvitation
  1966. *
  1967. * @return User
  1968. */
  1969. public function setLinkedEmailAddressInvitation(?LinkedEmailAddressInvitation $linkedEmailAddressInvitation = null)
  1970. {
  1971. $this->linkedEmailAddressInvitation = $linkedEmailAddressInvitation;
  1972. return $this;
  1973. }
  1974. /**
  1975. * @return LinkedEmailAddressInvitation|null
  1976. */
  1977. public function getLinkedEmailAddressInvitation()
  1978. {
  1979. return $this->linkedEmailAddressInvitation;
  1980. }
  1981. /**
  1982. * @param bool $matterDashboardEnabled
  1983. *
  1984. * @return User
  1985. */
  1986. public function setMatterDashboardEnabled($matterDashboardEnabled)
  1987. {
  1988. $this->matterDashboardEnabled = $matterDashboardEnabled;
  1989. return $this;
  1990. }
  1991. /**
  1992. * @return bool
  1993. */
  1994. public function getMatterDashboardEnabled()
  1995. {
  1996. return $this->matterDashboardEnabled;
  1997. }
  1998. /**
  1999. * @param bool $hasDocSorterAccess
  2000. *
  2001. * @return User
  2002. */
  2003. public function setHasDocSorterAccess($hasDocSorterAccess)
  2004. {
  2005. $this->hasDocSorterAccess = $hasDocSorterAccess;
  2006. return $this;
  2007. }
  2008. /**
  2009. * @return bool
  2010. */
  2011. public function getHasDocSorterAccess()
  2012. {
  2013. return $this->hasDocSorterAccess;
  2014. }
  2015. /**
  2016. * Returns user type options as an array, usable as the choices for a form.
  2017. *
  2018. * @throws \Exception
  2019. *
  2020. * @return array
  2021. */
  2022. public static function getUserTypeOptions(): array
  2023. {
  2024. $matterCreationProcessOptions = self::getConstantsWithLabelsAsChoices('USER_TYPE');
  2025. return array_flip($matterCreationProcessOptions);
  2026. }
  2027. /**
  2028. * Get the value of userType
  2029. *
  2030. * @return string
  2031. */
  2032. public function getUserType()
  2033. {
  2034. return $this->userType;
  2035. }
  2036. /**
  2037. * Returns true if the userType is USER_TYPE_INTERNAL
  2038. *
  2039. * @return bool
  2040. */
  2041. public function isUserTypeInternal(): bool
  2042. {
  2043. return $this->getUserType() === self::USER_TYPE_INTERNAL;
  2044. }
  2045. /**
  2046. * @param string|null $userType
  2047. *
  2048. * @return self
  2049. */
  2050. public function setUserType(?string $userType = null)
  2051. {
  2052. $this->userType = $userType;
  2053. return $this;
  2054. }
  2055. /**
  2056. * @return \DateTime
  2057. */
  2058. public function getFirstLoginDate()
  2059. {
  2060. return $this->firstLoginDate;
  2061. }
  2062. /**
  2063. * @param \DateTime|null $firstLoginDate
  2064. *
  2065. * @return self
  2066. */
  2067. public function setFirstLoginDate(?\DateTime $firstLoginDate = null)
  2068. {
  2069. $this->firstLoginDate = $firstLoginDate;
  2070. return $this;
  2071. }
  2072. /**
  2073. * @param ProjectClosure $projectClosure
  2074. *
  2075. * @return User
  2076. */
  2077. public function addProjectClosure(ProjectClosure $projectClosure)
  2078. {
  2079. $this->projectClosure[] = $projectClosure;
  2080. return $this;
  2081. }
  2082. /**
  2083. * @param ProjectClosure $projectClosure
  2084. *
  2085. * @return bool TRUE if this collection contained the specified element, FALSE otherwise.
  2086. */
  2087. public function removeProjectClosure(ProjectClosure $projectClosure)
  2088. {
  2089. return $this->projectClosure->removeElement($projectClosure);
  2090. }
  2091. /**
  2092. * @return DoctrineCollection
  2093. */
  2094. public function getProjectClosures()
  2095. {
  2096. return $this->projectClosures;
  2097. }
  2098. /**
  2099. * @param int $id
  2100. *
  2101. * @return User
  2102. */
  2103. public function setId(int $id): User
  2104. {
  2105. $this->id = $id;
  2106. return $this;
  2107. }
  2108. /**
  2109. * @param bool $true
  2110. *
  2111. * @return $this
  2112. */
  2113. public function setEnabled(bool $true)
  2114. {
  2115. $this->enabled = $true;
  2116. return $this;
  2117. }
  2118. /**
  2119. * @inheritDoc
  2120. */
  2121. public function isEqualTo(UserInterface $user)
  2122. {
  2123. // There are only a few attributes on a user that we should enforce a logout should they change
  2124. // If their password has changed...
  2125. if ($this->getPassword() !== $user->getPassword()) {
  2126. return false;
  2127. }
  2128. // If they've been disabled...
  2129. if ($this->isEnabled() !== $user->isEnabled()) {
  2130. return false;
  2131. }
  2132. // Check that the roles are the same, in any order. If the role is revoked while the user is logged in, it needs to log them out.
  2133. $isEqual = count($this->getRoles()) == count($user->getRoles());
  2134. if ($isEqual) {
  2135. foreach ($this->getRoles() as $role) {
  2136. $isEqual = $isEqual && in_array($role, $user->getRoles());
  2137. }
  2138. }
  2139. return $isEqual;
  2140. }
  2141. /**
  2142. * @param string $role
  2143. *
  2144. * @return bool
  2145. */
  2146. public function hasRole(string $role): bool
  2147. {
  2148. return in_array($role, $this->getRoles());
  2149. }
  2150. /**
  2151. * @return DoctrineCollection<int, ClinicalSummary>
  2152. */
  2153. public function getClinicalSummaries(): DoctrineCollection
  2154. {
  2155. return $this->clinicalSummaries;
  2156. }
  2157. /**
  2158. * @param ClinicalSummary $clinicalSummary
  2159. *
  2160. * @return self
  2161. */
  2162. public function addClinicalSummary(ClinicalSummary $clinicalSummary): self
  2163. {
  2164. if (!$this->clinicalSummaries->contains($clinicalSummary)) {
  2165. $this->clinicalSummaries[] = $clinicalSummary;
  2166. $clinicalSummary->setCreator($this);
  2167. }
  2168. return $this;
  2169. }
  2170. /**
  2171. * @param ClinicalSummary $clinicalSummary
  2172. *
  2173. * @return self
  2174. */
  2175. public function removeClinicalSummary(ClinicalSummary $clinicalSummary): self
  2176. {
  2177. if ($this->clinicalSummaries->removeElement($clinicalSummary)) {
  2178. // set the owning side to null (unless already changed)
  2179. if ($clinicalSummary->getCreator() === $this) {
  2180. $clinicalSummary->setCreator(null);
  2181. }
  2182. }
  2183. return $this;
  2184. }
  2185. /**
  2186. * Check if the user's email matches any regex pattern in the UserInternal table.
  2187. *
  2188. * @param bool $isRecursive
  2189. * @param UserInternalRepository $repository
  2190. * @param EntityManagerInterface $entityManager
  2191. *
  2192. * @return bool
  2193. */
  2194. public function isUserInternal(UserInternalRepository $repository, EntityManagerInterface $entityManager, bool $isRecursive = false): bool
  2195. {
  2196. //return true if internal user
  2197. if ($this->isUserTypeInternal()) {
  2198. return true;
  2199. }
  2200. $email = strtolower($this->getEmail());
  2201. // Get stored regex patterns from the database
  2202. $patterns = $repository->getAllPatterns();
  2203. // If the user's email matches a domain that is specified in the patterns (e.g. medbrief) then set the userType to internal.
  2204. foreach ($patterns as $pattern) {
  2205. if (preg_match('/' . $pattern . '/i', $email)) {
  2206. // Set user type to internal
  2207. $this->setUserType(self::USER_TYPE_INTERNAL);
  2208. // Persist the change to the database
  2209. $entityManager->persist($this);
  2210. $entityManager->flush();
  2211. return true;
  2212. }
  2213. }
  2214. // In case the user's email does not match we check to see if they have an admin role and avoid an infinite loop.
  2215. if (!$isRecursive) {
  2216. return $this->updateUserTypeInternal($repository, $entityManager);
  2217. }
  2218. return false;
  2219. }
  2220. /**
  2221. * Update user to internal type if they have medbrief email address and have an admin or super admin role.
  2222. *
  2223. * @param UserInternalRepository $repository
  2224. * @param EntityManagerInterface $entityManager
  2225. *
  2226. * @return bool
  2227. */
  2228. public function updateUserTypeInternal(UserInternalRepository $repository, EntityManagerInterface $entityManager): bool
  2229. {
  2230. // Check if the user is already internal
  2231. if ($this->userType === self::USER_TYPE_INTERNAL) {
  2232. return false;
  2233. }
  2234. if ($this->isUserInternal($repository, $entityManager, true) && (in_array(self::DEFAULT_ROLE_ADMIN, $this->roles) || in_array(self::DEFAULT_ROLE_SUPER_ADMIN, $this->roles))) {
  2235. $this->userType = self::USER_TYPE_INTERNAL;
  2236. $entityManager->persist($this);
  2237. $entityManager->flush();
  2238. return true;
  2239. }
  2240. return false;
  2241. }
  2242. /**
  2243. * This method tracks whether the 'Billed' checkbox is visible to MB Admins
  2244. *
  2245. * @return bool
  2246. */
  2247. public function hasAccessToBilled(): bool
  2248. {
  2249. return $this->accessToBilled;
  2250. }
  2251. /**
  2252. * This method sets whether a MB Admin can view the 'Billed' checkbox.
  2253. *
  2254. * @param bool $value
  2255. *
  2256. * @return self
  2257. */
  2258. public function setAccessToBilled(bool $value): self
  2259. {
  2260. $this->accessToBilled = $value;
  2261. return $this;
  2262. }
  2263. /**
  2264. * This method fetches the value which determines whether a MB Admin can view the 'Billed' checkbox.
  2265. *
  2266. * @return bool
  2267. */
  2268. public function getAccessToBilled(): bool
  2269. {
  2270. return $this->accessToBilled;
  2271. }
  2272. /**
  2273. * @return \DateTime|null
  2274. */
  2275. public function getLegacyRadiologyViewerLastUsed()
  2276. {
  2277. return $this->legacyRadiologyViewerLastUsed;
  2278. }
  2279. /**
  2280. * @param \DateTime|null $legacyRadiologyViewerLastUsed
  2281. *
  2282. * @return self
  2283. */
  2284. public function setLegacyRadiologyViewerLastUsed(?\DateTime $legacyRadiologyViewerLastUsed = null): self
  2285. {
  2286. $this->legacyRadiologyViewerLastUsed = $legacyRadiologyViewerLastUsed;
  2287. return $this;
  2288. }
  2289. }