<?php
namespace MedBrief\MSR\Entity;
use DH\Auditor\Provider\Doctrine\Auditing\Annotation as Audit;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use MedBrief\MSR\Entity\Embeddable\RecordsReceived;
use MedBrief\MSR\Entity\MatterRequest\TrustCentre as MatterRequestTrustCentre;
use MedBrief\MSR\Entity\RequestType\RequestTypeAwareInterface;
use MedBrief\MSR\Entity\RequestType\RequestTypeAwareTrait;
use MedBrief\MSR\Entity\Serviceable\ServiceableInterface;
use MedBrief\MSR\Entity\Serviceable\ServiceableTrait;
use MedBrief\MSR\Service\LetterGenerator\Letter\LetterInterface;
/**
* Uses the ServiceableInterface to indicate this entity represents a service rendered to an Account,
* and can be associated with a ServiceRequest.
*
* @ORM\Table(name="RecordsRequest", indexes={@ORM\Index(name="status_idx", columns={"status"})})
*
* @ORM\Entity
*
* @ORM\HasLifecycleCallbacks
*
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
*
* @Audit\Auditable
*
* @Audit\Security(view={"ROLE_ALLOWED_TO_AUDIT"})
*/
class RecordsRequest implements ServiceableInterface, RequestTypeAwareInterface, LetterInterface
{
use ServiceableTrait;
use RequestTypeAwareTrait;
// These are the old status constants.
// The new constants live on the \MedBrief\MSR\Entity\Timeline\AbstractTimelineType
// object associated with the ServiceRequest::serviceOption for the RecordsRequest.
public const STATUS_INSTRUCTED = 1;
public const STATUS_REQUESTED = 2;
public const STATUS_CHASED = 3;
public const STATUS_RECEIVED = 4;
public const STATUS_SORTED = 5;
public const STATUS_UPLOADED = 6;
public const STATUS_CHRONOLOGY = 7;
// request_method constants
public const REQUEST_METHOD_EMAIL = 0;
public const REQUEST_METHOD_FAX = 1;
public const REQUEST_METHOD_POST = 2;
public const REQUEST_METHOD_PORTAL = 3;
// The prefix we use to identify a RecordsRequests's reference ID.
public const REFERENCE_ID_PREFIX = 'RR-';
// Constants used for auto date calculation
public const AUTO_DUE_DATE = '+30day';
/**
* @var ServiceRequest
*
* @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\ServiceRequest", mappedBy="recordsRequest", cascade={"persist"})
*/
protected $serviceRequest;
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\Id
*
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var \DateTime|null
*
* @ORM\Column(name="deletedAt", type="datetime", nullable=true)
*/
private $deletedAt;
/**
* @var string|null
*
* @ORM\Column(name="records_requested_from_other", type="string", nullable=true)
*/
private $records_requested_from_other;
/**
* @var int|null
*
* @ORM\Column(name="archiveBoxNumber", type="integer", nullable=true)
*/
private $archiveBoxNumber;
/**
* @var \DateTime|null
*
* @ORM\Column(name="dateDestroyedOrReturned", type="date", nullable=true)
*/
private $dateDestroyedOrReturned;
/**
* @var \DateTime|null
*
* @ORM\Column(name="date_records_requested", type="date", nullable=true)
*/
private $date_records_requested;
/**
* @var string|null
*
* @ORM\Column(name="records_sent_by", type="string", nullable=true)
*/
private $records_sent_by;
/**
* @var \DateTime|null
*
* @ORM\Column(name="date_records_received", type="date", nullable=true)
*/
private $date_records_received;
/**
* @var int|null
*
* @ORM\Column(name="status", type="integer", nullable=true)
*/
private $status;
/**
* @var \DateTime|null
*
* @ORM\Column(name="date_acknowledged", type="date", nullable=true)
*/
private $date_acknowledged;
/**
* @var \DateTime|null
*
* @ORM\Column(name="date_password_provided", type="date", nullable=true)
*/
private $date_password_provided;
/**
* @var int|null
*
* @ORM\Column(name="request_method", type="integer", nullable=true)
*/
private $request_method;
/**
* @var string|null
*
* @ORM\Column(name="internal_document_password", type="string", nullable=true)
*/
private $internal_document_password;
/**
* @var string|null
*
* @ORM\Column(name="centre_password", type="string", nullable=true)
*/
private $centre_password;
/**
* @var bool
*
* @ORM\Column(name="postage_paid", type="boolean", options={"default"=false})
*/
private $postage_paid = false;
/**
* @var string|null
*
* @ORM\Column(name="postage_amount", type="decimal", precision=7, scale=2, nullable=true)
*/
private $postage_amount;
/**
* @var int|null
*
* @ORM\Column(name="radiology_disc_count", type="integer", nullable=true)
*/
private $radiology_disc_count;
/**
* The date that an update is due on this records request.
*
* @var \DateTime|null
*
* @ORM\Column(name="update_due_date", type="date", nullable=true)
*/
private $update_due_date;
/**
* The date that the records request is due.
*
* @var \DateTime|null
*
* @ORM\Column(name="due_date", type="date", nullable=true)
*/
private $due_date;
/**
* @var string|null
*
* @ORM\Column(name="trust_reference", type="string", nullable=true)
*/
private $trust_reference;
/**
* @var bool
*
* @ORM\Column(name="collate_before_processing", type="boolean", options={"default"=false})
*/
private $collate_before_processing = false;
/**
* @var string|null
*
* @ORM\Column(name="patientName", type="string", nullable=true)
*/
private $patientName;
/**
* @var \DateTime|null
*
* @ORM\Column(name="patientDateOfBirth", type="date", nullable=true)
*/
private $patientDateOfBirth;
/**
* @var bool
*
* @ORM\Column(name="patientDeceased", type="boolean", options={"default"=false})
*/
private $patientDeceased = false;
/**
* @var \DateTime
*
* @ORM\Column(name="created", type="datetime")
*
* @Gedmo\Timestampable(on="create")
*/
private $created;
/**
* @var \DateTime
*
* @ORM\Column(name="updated", type="datetime")
*
* @Gedmo\Timestampable(on="update")
*/
private $updated;
/**
* @var RecordsReceived
*
* @ORM\Embedded(class="MedBrief\MSR\Entity\Embeddable\RecordsReceived", columnPrefix="recordsReceived_")
*/
private $recordsReceived;
/**
* @var RecordsRequestLetter
*
* @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\RecordsRequestLetter", inversedBy="recordsRequest", cascade={"all"})
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="recordsRequestLetter_id", referencedColumnName="id", unique=true, nullable=true)
* })
*/
private $recordsRequestLetter;
/**
* @var \Doctrine\Common\Collections\Collection
*
* @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\RecordsRequestDetail", mappedBy="recordsRequest")
*
* @ORM\OrderBy({
* "displayDate"="ASC"
* })
*/
private $recordsRequestDetails;
/**
* @var Project
*
* @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\Project", inversedBy="recordsRequests")
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="project_id", referencedColumnName="id", nullable=false)
* })
*/
private $project;
/**
* @var RecordsRequestCentre
*
* @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\RecordsRequestCentre")
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="recordsRequestedFromExisting_id", referencedColumnName="id", nullable=true)
* })
*/
private $recordsRequestedFromExisting;
/**
* @var RecordsRequestCentreParent
*
* @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\RecordsRequestCentreParent")
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="recordsRequestedFromExistingParent_id", referencedColumnName="id", nullable=true)
* })
*/
private $recordsRequestedFromExistingParent;
/**
* @var MatterRequestTrustCentre
*
* @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\MatterRequest\TrustCentre", inversedBy="recordsRequests")
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="matterRequestTrustCentre_id", referencedColumnName="id", nullable=true)
* })
*/
private $matterRequestTrustCentre;
/**
* @var User
*
* @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\User")
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="assignedTo_id", referencedColumnName="id")
* })
*/
private $assignedTo;
/**
* Constructor
*/
public function __construct()
{
$this->recordsRequestDetails = new \Doctrine\Common\Collections\ArrayCollection();
$this->recordsReceived = new RecordsReceived();
}
public function __toString()
{
return (string) $this->getId();
}
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set records_requested_from_other
*
* @param string $recordsRequestedFromOther
*
* @return RecordsRequest
*/
public function setRecordsRequestedFromOther($recordsRequestedFromOther)
{
$this->records_requested_from_other = $recordsRequestedFromOther;
return $this;
}
/**
* Get records_requested_from_other
*
* @return string
*/
public function getRecordsRequestedFromOther()
{
return $this->records_requested_from_other;
}
/**
* Set records_sent_by
*
* @param string $recordsSentBy
*
* @return RecordsRequest
*/
public function setRecordsSentBy($recordsSentBy)
{
$this->records_sent_by = $recordsSentBy;
return $this;
}
/**
* Get records_sent_by
*
* @return string
*/
public function getRecordsSentBy()
{
return $this->records_sent_by;
}
/**
* Set created
*
* @param \DateTime $created
*
* @return RecordsRequest
*/
public function setCreated($created)
{
$this->created = $created;
return $this;
}
/**
* Get created
*
* @return \DateTime
*/
public function getCreated()
{
return $this->created;
}
/**
* Set updated
*
* @param \DateTime $updated
*
* @return RecordsRequest
*/
public function setUpdated($updated)
{
$this->updated = $updated;
return $this;
}
/**
* Get updated
*
* @return \DateTime
*/
public function getUpdated()
{
return $this->updated;
}
/**
* Set project
*
* @param Project $project
*
* @return RecordsRequest
*/
public function setProject(Project $project)
{
$this->project = $project;
return $this;
}
/**
* Get project
*
* @return Project
*/
public function getProject()
{
return $this->project;
}
/**
* Set deletedAt
*
* @param \DateTime $deletedAt
*
* @return RecordsRequest
*/
public function setDeletedAt($deletedAt)
{
$this->deletedAt = $deletedAt;
return $this;
}
/**
* Get deletedAt
*
* @return \DateTime
*/
public function getDeletedAt()
{
return $this->deletedAt;
}
/**
* Set dateRecordsRequested
*
* @param \DateTime $dateRecordsRequested
*
* @return RecordsRequest
*/
public function setDateRecordsRequested($dateRecordsRequested)
{
$this->date_records_requested = $dateRecordsRequested;
return $this;
}
/**
* Get dateRecordsRequested
*
* @return \DateTime
*/
public function getDateRecordsRequested()
{
return $this->date_records_requested;
}
/**
* Set dateRecordsReceived
*
* @param \DateTime $dateRecordsReceived
*
* @return RecordsRequest
*/
public function setDateRecordsReceived($dateRecordsReceived)
{
$this->date_records_received = $dateRecordsReceived;
return $this;
}
/**
* Get dateRecordsReceived
*
* @return \DateTime
*/
public function getDateRecordsReceived()
{
return $this->date_records_received;
}
/**
* Set status
*
* @param int $status
*
* @return RecordsRequest
*/
public function setStatus($status)
{
$this->status = $status;
return $this;
}
/**
* Get status
*
* @return int
*/
public function getStatus()
{
return $this->status;
}
/**
* Get status
*
* @return string
*/
public function getStatusName()
{
$statuses = self::getStatusOptions();
// if the status is not set, or does not exist in our array we return an appropriate value
if (!array_key_exists($this->getStatus(), $statuses)) {
return 'Status Not Set';
}
return $statuses[$this->getStatus()];
}
/**
* Get statuses
*
* My recommendation is that we leave this with string keys pointing to
* string values: it just makes the data much more readable.
*
* @return array
*/
public static function getStatusOptions()
{
return [
self::STATUS_INSTRUCTED => 'Instructed',
self::STATUS_REQUESTED => 'Requested',
self::STATUS_CHASED => 'Chased',
self::STATUS_RECEIVED => 'Received',
self::STATUS_SORTED => 'Sorted',
self::STATUS_UPLOADED => 'Uploaded',
self::STATUS_CHRONOLOGY => 'Chronology',
];
}
/**
* Add recordsRequestDetail
*
* @param RecordsRequestDetail $recordsRequestDetail
*
* @return RecordsRequest
*/
public function addRecordsRequestDetail(RecordsRequestDetail $recordsRequestDetail)
{
$this->recordsRequestDetails[] = $recordsRequestDetail;
return $this;
}
/**
* Remove recordsRequestDetail
*
* @param RecordsRequestDetail $recordsRequestDetail
*/
public function removeRecordsRequestDetail(RecordsRequestDetail $recordsRequestDetail)
{
$this->recordsRequestDetails->removeElement($recordsRequestDetail);
}
/**
* Get recordsRequestDetails
*
* @return \Doctrine\Common\Collections\Collection|RecordsRequestDetail[]
*/
public function getRecordsRequestDetails()
{
return $this->recordsRequestDetails;
}
/**
* @return array
*/
public function getNoteCounts(): array
{
$noteCounts = [];
foreach ($this->getRecordsRequestDetails() as $note) {
if (!isset($noteCounts[$note->getType()])) {
$noteCounts[$note->getType()] = 0;
}
$noteCounts[$note->getType()]++;
}
return $noteCounts;
}
/**
* Get recordsRequestDetailsByType.
*
* Filters out RecordsRequestDetails by type.
*
* @param mixed $type
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getRecordsRequestDetailsByType($type)
{
return $this->getRecordsRequestDetails()->filter(function ($detail) use ($type) {
return $detail->getType() === $type;
});
}
/**
* Get getChaseCount
*
* The number of RecordsRequestDetails that have type Chase.
*
* @return int
*/
public function getChaseCount()
{
return $this->getRecordsRequestDetailsByType(RecordsRequestDetail::TYPE_CHASE)->count();
}
/**
* Set updateDueDate
*
* @param \DateTime $updateDueDate
*
* @return RecordsRequest
*/
public function setUpdateDueDate($updateDueDate)
{
$this->update_due_date = $updateDueDate;
return $this;
}
/**
* Get updateDueDate
*
* @return \DateTime
*/
public function getUpdateDueDate()
{
return $this->update_due_date;
}
/**
* Returns the number of days until a RecordsRequest's update is due,
* as a SIGNED integer.
*
*
* @return int|null
*/
public function getDaysToUpdateDue()
{
if ($this->update_due_date) {
// %r = signed
// %d = days
$days = (new \DateTime('midnight'))->diff($this->update_due_date)->format('%r%a');
return $days;
}
return null;
}
/**
* Returns whether the RecordsRequest has an update due,
* by checking if the updateDueDate has passed, and if the updateDueDate
* is more recent than the updated date.
*
* @return bool
*/
public function hasUpdateDue()
{
return
$this->getServiceRequest()
&& $this->getServiceRequest()->isInprogress()
&& $this->getDaysToUpdateDue() != null
&& $this->getDaysToUpdateDue() <= 0
&& $this->getUpdated() && $this->getUpdated() < $this->getUpdateDueDate();
}
/**
* Set dateAcknowledged
*
* @param \DateTime $dateAcknowledged
*
* @return RecordsRequest
*/
public function setDateAcknowledged($dateAcknowledged)
{
$this->date_acknowledged = $dateAcknowledged;
return $this;
}
/**
* Get dateAcknowledged
*
* @return \DateTime
*/
public function getDateAcknowledged()
{
return $this->date_acknowledged;
}
/**
* Set datePasswordProvided
*
* @param \DateTime $datePasswordProvided
*
* @return RecordsRequest
*/
public function setDatePasswordProvided($datePasswordProvided)
{
$this->date_password_provided = $datePasswordProvided;
return $this;
}
/**
* Get datePasswordProvided
*
* @return \DateTime
*/
public function getDatePasswordProvided()
{
return $this->date_password_provided;
}
/**
* Set requestMethod
*
* @param int $requestMethod
*
* @return RecordsRequest
*/
public function setRequestMethod($requestMethod)
{
$this->request_method = $requestMethod;
return $this;
}
/**
* Get requestMethod
*
* @return int
*/
public function getRequestMethod()
{
return $this->request_method;
}
/**
* Get requestMethodOptions
*
* @return array
*/
public static function getRequestMethodOptions()
{
return [
self::REQUEST_METHOD_EMAIL => 'Email',
self::REQUEST_METHOD_FAX => 'Fax',
self::REQUEST_METHOD_POST => 'Post',
self::REQUEST_METHOD_PORTAL => 'Portal',
];
}
/**
* Get requestMethodLabel
*
* @return int
*/
public function getRequestMethodLabel()
{
$options = self::getRequestMethodOptions();
return $options[$this->getRequestMethod()] ?? '';
}
/**
* Set internalDocumentPassword
*
* @param string $internalDocumentPassword
*
* @return RecordsRequest
*/
public function setInternalDocumentPassword($internalDocumentPassword)
{
$this->internal_document_password = $internalDocumentPassword;
return $this;
}
/**
* Get internalDocumentPassword
*
* @return string
*/
public function getInternalDocumentPassword()
{
return $this->internal_document_password;
}
/**
* Set recordsRequestedFromExisting
*
* @param RecordsRequestCentre $recordsRequestedFromExisting
*
* @return RecordsRequest
*/
public function setRecordsRequestedFromExisting(?RecordsRequestCentre $recordsRequestedFromExisting = null)
{
$this->recordsRequestedFromExisting = $recordsRequestedFromExisting;
return $this;
}
/**
* Get recordsRequestedFromExisting
*
* @return RecordsRequestCentre
*/
public function getRecordsRequestedFromExisting()
{
return $this->recordsRequestedFromExisting;
}
/**
* Set recordsRequestedFromExistingParent.
*
* @param RecordsRequestCentreParent|null $recordsRequestedFromExistingParent
*
* @return RecordsRequest
*/
public function setRecordsRequestedFromExistingParent(?RecordsRequestCentreParent $recordsRequestedFromExistingParent = null)
{
$this->recordsRequestedFromExistingParent = $recordsRequestedFromExistingParent;
return $this;
}
/**
* Get recordsRequestedFromExistingParent.
*
* @return RecordsRequestCentreParent|null
*/
public function getRecordsRequestedFromExistingParent()
{
return $this->recordsRequestedFromExistingParent;
}
/**
* Helper function for displaying where the records are being
* requested from.
*
* Correctly displays based on if the RecordsRequest has an existing
* RecordsRequestCentre linked to it, or a string RecordsRequestedFromOther
* field.
*
* @return string
*/
public function getRecordsRequestedFrom()
{
// Return the name of the RecordsRequestedFromExistingParent if set.
if ($this->getRecordsRequestedFromExistingParent()) {
return $this->getRecordsRequestedFromExistingParent()->getName();
}
// Else return the string value assigned to RecordsRequestedFromOther.
return $this->getRecordsRequestedFromOther();
}
/**
* Set postagePaid
*
* @param bool $postagePaid
*
* @return RecordsRequest
*/
public function setPostagePaid($postagePaid)
{
$this->postage_paid = $postagePaid;
return $this;
}
/**
* Get postagePaid
*
* @return bool
*/
public function getPostagePaid()
{
return $this->postage_paid;
}
/**
* Get postagePaidLabel
*
* @return string
*/
public function getPostagePaidLabel()
{
return $this->postage_paid ? 'Yes' : 'No';
}
/**
* Set postageAmount
*
* @param string $postageAmount
*
* @return RecordsRequest
*/
public function setPostageAmount($postageAmount)
{
$this->postage_amount = $postageAmount;
return $this;
}
/**
* Get postageAmount
*
* @return string
*/
public function getPostageAmount()
{
return $this->postage_amount;
}
/**
* Get postageAmountFormatted
*
* @return string
*/
public function getPostageAmountFormatted()
{
return number_format($this->postage_amount, 2, '.', ' ');
}
/**
* Set radiologyDiscCount
*
* @param int $radiologyDiscCount
*
* @return RecordsRequest
*/
public function setRadiologyDiscCount($radiologyDiscCount)
{
$this->radiology_disc_count = $radiologyDiscCount;
return $this;
}
/**
* Get radiologyDiscCount
*
* @return int
*/
public function getRadiologyDiscCount()
{
return $this->radiology_disc_count;
}
/**
* Set assignedTo
*
* @param User $assignedTo
*
* @return RecordsRequest
*/
public function setAssignedTo(?User $assignedTo = null)
{
$this->assignedTo = $assignedTo;
return $this;
}
/**
* Get assignedTo
*
* @return User
*/
public function getAssignedTo()
{
return $this->assignedTo;
}
/**
* Set recordsReceived
*
* @param RecordsReceived $recordsReceived
*
* @return RecordsRequest
*/
public function setRecordsReceived(RecordsReceived $recordsReceived)
{
$this->recordsReceived = $recordsReceived;
return $this;
}
/**
* Get recordsReceived
*
* @return RecordsReceived
*/
public function getRecordsReceived()
{
return $this->recordsReceived;
}
/**
* Set trustReference
*
* @param string $trustReference
*
* @return RecordsRequest
*/
public function setTrustReference($trustReference)
{
$this->trust_reference = $trustReference;
return $this;
}
/**
* Get trustReference
*
* @return string
*/
public function getTrustReference()
{
return $this->trust_reference;
}
/**
* Set collateBeforeProcessing
*
* @param bool $collateBeforeProcessing
*
* @return RecordsRequest
*/
public function setCollateBeforeProcessing($collateBeforeProcessing)
{
$this->collate_before_processing = $collateBeforeProcessing;
return $this;
}
/**
* Get collateBeforeProcessing
*
* @return bool
*/
public function getCollateBeforeProcessing()
{
return $this->collate_before_processing;
}
/**
* Get collateBeforeProcessingLabel
*
* @return string
*/
public function getCollateBeforeProcessingLabel()
{
return $this->collate_before_processing ? 'Yes' : 'No';
}
/**
* Set centrePassword
*
* @param string $centrePassword
*
* @return RecordsRequest
*/
public function setCentrePassword($centrePassword)
{
$this->centre_password = $centrePassword;
return $this;
}
/**
* Get centrePassword
*
* @return string
*/
public function getCentrePassword()
{
return $this->centre_password;
}
/**
* Set dueDate
*
* @param \DateTime $dueDate
*
* @return RecordsRequest
*/
public function setDueDate($dueDate)
{
$this->due_date = $dueDate;
return $this;
}
/**
* Get dueDate
*
* @return \DateTime
*/
public function getDueDate()
{
return $this->due_date;
}
/**
* Updates the due date based on if the date_records_requested field is set.
*
* Used as a lifecycleCallback.
*
* @ORM\PrePersist
*
* @ORM\PreUpdate
*
* @return RecordsRequest
*/
public function generateDueDate()
{
if (!$this->getDueDate() && $this->getDateRecordsRequested()) {
$dueDate = clone $this->getDateRecordsRequested();
$dueDate->modify(self::AUTO_DUE_DATE);
$this->setDueDate($dueDate);
} elseif (!$this->getDueDate()) {
$this->setDueDate(null);
}
return $this;
}
/**
* Set archiveBoxNumber
*
* @param int $archiveBoxNumber
*
* @return RecordsRequest
*/
public function setArchiveBoxNumber($archiveBoxNumber)
{
$this->archiveBoxNumber = $archiveBoxNumber;
return $this;
}
/**
* Get archiveBoxNumber
*
* @return int
*/
public function getArchiveBoxNumber()
{
return $this->archiveBoxNumber;
}
/**
* Set dateDestroyedOrReturned
*
* @param \DateTime $dateDestroyedOrReturned
*
* @return RecordsRequest
*/
public function setDateDestroyedOrReturned($dateDestroyedOrReturned)
{
$this->dateDestroyedOrReturned = $dateDestroyedOrReturned;
return $this;
}
/**
* Get dateDestroyedOrReturned
*
* @return \DateTime
*/
public function getDateDestroyedOrReturned()
{
return $this->dateDestroyedOrReturned;
}
/**
* Set matterRequestTrustCentre.
*
* @param MatterRequestTrustCentre|null $matterRequestTrustCentre
*
* @return RecordsRequest
*/
public function setMatterRequestTrustCentre(?MatterRequestTrustCentre $matterRequestTrustCentre = null)
{
$this->matterRequestTrustCentre = $matterRequestTrustCentre;
return $this;
}
/**
* Get matterRequestTrustCentre.
*
* @return MatterRequestTrustCentre|null
*/
public function getMatterRequestTrustCentre()
{
return $this->matterRequestTrustCentre;
}
/**
* Set recordsRequestLetter.
*
* @param RecordsRequestLetter|null $recordsRequestLetter
*
* @return RecordsRequest
*/
public function setRecordsRequestLetter(?RecordsRequestLetter $recordsRequestLetter = null)
{
$this->recordsRequestLetter = $recordsRequestLetter;
return $this;
}
/**
* Get recordsRequestLetter.
*
* @return RecordsRequestLetter|null
*/
public function getRecordsRequestLetter()
{
return $this->recordsRequestLetter;
}
/**
* Set patientName
*
* @param string $patientName
*
* @return RecordsRequest
*/
public function setPatientName($patientName)
{
$this->patientName = $patientName;
return $this;
}
/**
* Get patientName
*
* @return string
*/
public function getPatientName()
{
return $this->patientName;
}
/**
* Set patientDateOfBirth
*
* @param \DateTime $patientDateOfBirth
*
* @return RecordsRequest
*/
public function setPatientDateOfBirth($patientDateOfBirth)
{
$this->patientDateOfBirth = $patientDateOfBirth;
return $this;
}
/**
* Get patientDateOfBirth
*
* @return \DateTime
*/
public function getPatientDateOfBirth()
{
return $this->patientDateOfBirth;
}
/**
* Set patientDeceased
*
* @param bool $patientDeceased
*
* @return RecordsRequest
*/
public function setPatientDeceased($patientDeceased)
{
$this->patientDeceased = $patientDeceased;
return $this;
}
/**
* Get patientDeceased
*
* @return bool
*/
public function getPatientDeceased()
{
return $this->patientDeceased;
}
/**
* @inheritDoc
*/
public function getLetterContent(): ?string
{
if ($this->getRecordsRequestLetter() instanceof RecordsRequestLetter) {
return $this->getRecordsRequestLetter()->getContent();
}
return null;
}
/**
* @inheritDoc
*/
public function getLetterSubject()
{
return $this;
}
/**
* @return bool
*/
public function hasImportantNotes(): bool
{
return $this->getRecordsRequestDetails()->filter(function (RecordsRequestDetail $detail) {
return $detail->getIsImportant();
})->count();
}
/**
* @return bool
*/
public function canAutoCancel(): bool
{
return $this->getServiceRequest() && $this->getServiceRequest()->getStatus() === ServiceRequest::STATUS_BACK_TO_CLIENT;
}
}