<?php
namespace MedBrief\MSR\Entity;
use DH\Auditor\Provider\Doctrine\Auditing\Annotation as Audit;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use MedBrief\MSR\Entity\Embeddable\RecordsReceived;
use MedBrief\MSR\Entity\Preprocessing\PreprocessDocument;
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\Repository\BatchRequestRepository;
use MedBrief\MSR\Service\Preprocessing\PreprocessItemInterface;
use MedBrief\MSR\Service\RecordsRequestCentreTypeAwareInterface;
use MedBrief\MSR\Service\SortingSession\Preprocessing\PreprocessingCriteriaAwareInterface;
use MedBrief\MSR\Traits\FilterableClassConstantsTrait;
/**
* @ORM\Table(name="BatchRequest")
*
* @ORM\Entity(repositoryClass=BatchRequestRepository::class)
*
* @ORM\HasLifecycleCallbacks
*
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
*
* @Audit\Auditable
*
* @Audit\Security(view={"ROLE_ALLOWED_TO_AUDIT"})
*/
class BatchRequest implements ServiceableInterface, RequestTypeAwareInterface, PreprocessItemInterface, RecordsRequestCentreTypeAwareInterface, PreprocessingCriteriaAwareInterface
{
use ServiceableTrait;
use RequestTypeAwareTrait;
use FilterableClassConstantsTrait;
public const BATCH_STANDARD_SHELF_LOCATIONS = [
'Records With Issues' => 'RWI',
'Returns Shelf' => 'Returns Shelf',
];
public const PAGINATION_INDENT_LEVEL_1 = 1;
public const PAGINATION_INDENT_LEVEL_1__LABEL = 1;
public const PAGINATION_INDENT_LEVEL_2 = 2;
public const PAGINATION_INDENT_LEVEL_2__LABEL = 2;
public const PAGINATION_INDENT_LEVEL_3 = 3;
public const PAGINATION_INDENT_LEVEL_3__LABEL = 3;
public const PAGINATION_INDENT_LEVEL_4 = 4;
public const PAGINATION_INDENT_LEVEL_4__LABEL = 4;
public const PAGINATION_INDENT_LEVEL_5 = 5;
public const PAGINATION_INDENT_LEVEL_5__LABEL = 5;
/**
* paginationType constants
*/
public const PAGINATION_TYPE_NORMAL = 1;
public const PAGINATION_TYPE_INSERTION = 2;
public const PAGINATION_TYPE_UPDATE = 3;
// dataCategory constant values
public const DATA_CATEGORY_RADIOLOGY = 1;
public const DATA_CATEGORY_VIDEO = 2;
public const DATA_CATEGORY_AUDIO = 3;
public const DATA_CATEGORY_HARD_COPY_INDEXED = 4;
public const DATA_CATEGORY_MEDICAL_RECORDS = 5;
public const DATA_CATEGORY_ELECTRONIC_INDEXED = 6;
// destroyOrReturn constant values
// This is not a simple boolean value, to allow for more future values (such as both)
// and to force a value selection.
public const RECORDS_DESTROY = 1;
public const RECORDS_RETURN = 2;
// Constants used for auto date calculation
public const AUTO_DATE_SORT_DEADLINE = '+6weekday';
public const AUTO_DATE_ESTIMATED_DEADLINE = '+10weekday';
public const AUTO_DATE_DESTRUCTION = '+30day';
// Constants for quoteStatus
public const QUOTE_STATUS_PENDING = 1;
public const QUOTE_STATUS_ACCEPTED = 2;
public const QUOTE_STATUS_DECLINED = 3;
public const COMPUTERIZED_RECORDS_BILLING_THRESHOLD = 1000;
public const EXCLUDE_FROM_PREPROCESSIN_LABEL = '(Excl. from pre-processing)';
public const INCLUDE_FOR_PREPROCESSIN_LABEL = '(Incl. for pre-processing)';
public const CENTRE_TYPE_OTHER_PRE_PROCESSING = 1000;
public const CENTRE_TYPE_OTHER_PRE_PROCESSING__LABEL = 'Other - Pre-processing';
/**
* @var ServiceRequest
*
* @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\ServiceRequest", mappedBy="batchRequest", cascade={"persist"})
*/
protected $serviceRequest;
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\Id
*
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $id;
/**
* @var string|null
*
* @ORM\Column(name="receivedFrom", type="text", nullable=true)
*/
protected $receivedFrom;
/**
* @var string|null
*
* @ORM\Column(name="centreName", type="text", nullable=true)
*/
protected $centreName;
/**
* @var int|null
*
* @ORM\Column(name="dataCategory", type="integer", nullable=true)
*/
protected $dataCategory;
/**
* @var bool|null
*
* @ORM\Column(name="isCopy", type="boolean", options={"default"=true} , nullable=true)
*/
protected $isCopy;
/**
* @var \DateTime|null
*
* @ORM\Column(name="dateReceived", type="date", nullable=true)
*/
protected $dateReceived;
/**
* @var \DateTime|null
*
* @ORM\Column(name="sortDeadlineDate", type="date", nullable=true)
*/
protected $sortDeadlineDate;
/**
* @var \DateTime|null
*
* @ORM\Column(name="estimatedDeadlineDate", type="date", nullable=true)
*/
protected $estimatedDeadlineDate;
/**
* @var \DateTime|null
*
* @ORM\Column(name="dateCompleted", type="date", nullable=true)
*/
protected $dateCompleted;
/**
* @var string|null
*
* @ORM\Column(name="passwords", type="string", nullable=true)
*/
protected $passwords;
/**
* @var bool
*
* @ORM\Column(name="chronologyRequired", type="boolean", options={"default"=false})
*/
protected $chronologyRequired;
/**
* @var int|null
*
* @ORM\Column(name="destroyOrReturn", type="integer", nullable=true)
*/
protected $destroyOrReturn;
/**
* @var \DateTime|null
*
* @ORM\Column(name="destructionDate", type="date", nullable=true)
*/
protected $destructionDate;
/**
* @var \DateTime|null
*
* @ORM\Column(name="dateDestroyedOrReturned", type="date", nullable=true)
*/
protected $dateDestroyedOrReturned;
/**
* @var int|null
*
* @ORM\Column(name="archiveBoxNumber", type="integer", nullable=true)
*/
protected $archiveBoxNumber;
/**
* The physical location where Records are to be/have been stored
*
* @var string
*
* @ORM\Column(name="shelfLocation", type="string", length=255, nullable=true)
*/
protected $shelfLocation;
/**
* @var \DateTime|null
*
* @ORM\Column(name="qaDate", type="date", nullable=true)
*/
protected $qaDate;
/**
* @var string|null
*
* @ORM\Column(name="qaDuration", type="decimal", precision=7, scale=2, nullable=true)
*/
protected $qaDuration;
/**
* @var \DateTime|null
*
* @ORM\Column(name="uploadedDate", type="date", nullable=true)
*/
protected $uploadedDate;
/**
* @var \DateTime|null
*
* @ORM\Column(name="sortedDate", type="date", nullable=true)
*/
protected $sortedDate;
/**
* @var \DateTime|null
*
* @ORM\Column(name="scannedDate", type="date", nullable=true)
*/
protected $scannedDate;
/**
* @var int|null
*
* @ORM\Column(name="pageCount", type="integer", nullable=true)
*/
protected $pageCount;
/**
* @var int|null
*
* @ORM\Column(name="blankAndDupesCount", type="integer", nullable=true)
*/
protected $blankAndDupesCount;
/**
* @var int|null
*
* @ORM\Column(name="computerizedRecordsCount", type="integer", nullable=true)
*/
protected $computerizedRecordsCount;
/**
* @var string|null
*
* @ORM\Column(name="scanDuration", type="decimal", precision=7, scale=2, nullable=true)
*/
protected $scanDuration;
/**
* @var string|null
*
* @ORM\Column(name="sectionSortDuration", type="decimal", precision=7, scale=2, nullable=true)
*/
protected $sectionSortDuration;
/**
* @var string|null
*
* @ORM\Column(name="dateSortDuration", type="decimal", precision=7, scale=2, nullable=true)
*/
protected $dateSortDuration;
/**
* @var string|null
*
* @ORM\Column(name="admissionSortDuration", type="decimal", precision=7, scale=2, nullable=true)
*/
protected $admissionSortDuration;
/**
* @var Project
*
* @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\Project", inversedBy="batchRequests")
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="project_id", referencedColumnName="id")
* })
*/
protected $project;
/**
* @var \DateTime|null
*
* @ORM\Column(name="deletedAt", type="datetime", nullable=true)
*/
protected $deletedAt;
/**
* @var \DateTime
*
* @ORM\Column(name="created", type="datetime")
*
* @Gedmo\Timestampable(on="create")
*/
protected $created;
/**
* @var \DateTime
*
* @ORM\Column(name="updated", type="datetime")
*
* @Gedmo\Timestampable(on="update")
*/
protected $updated;
/**
* @var HumanResource
*
* @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\HumanResource")
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="sortedBy_id", referencedColumnName="id")
* })
*/
protected $sortedBy;
/**
* @var HumanResource
*
* @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\HumanResource")
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="dateSortedBy_id", referencedColumnName="id")
* })
*/
protected $dateSortedBy;
/**
* @var HumanResource
*
* @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\HumanResource")
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="admissionSortedBy_id", referencedColumnName="id")
* })
*/
protected $admissionSortedBy;
/**
* @var HumanResource
*
* @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\HumanResource")
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="scanCompletedBy_id", referencedColumnName="id")
* })
*/
protected $scanCompletedBy;
/**
* @var HumanResource
*
* @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\HumanResource")
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="qaBy_id", referencedColumnName="id")
* })
*/
protected $qaBy;
/**
* @var HumanResource
*
* @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\HumanResource")
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="uploadedBy_id", referencedColumnName="id")
* })
*/
protected $uploadedBy;
/**
* @var Collection
*
* @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\BatchRequestDetail", mappedBy="batchRequest", cascade={"persist","remove"}, orphanRemoval=true)
*/
protected $details;
/**
* @var ChronologyRequest
*
* @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\ChronologyRequest", inversedBy="batches")
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="chronologyRequest_id", referencedColumnName="id")
* })
*/
protected $chronologyRequest;
/**
* @var RecordsReceived
*
* @ORM\Embedded(class="MedBrief\MSR\Entity\Embeddable\RecordsReceived", columnPrefix="recordsReceived_")
*/
protected $recordsReceived;
/**
* @var int|null
*
* @ORM\Column(name="radiologyDiscCount", type="integer", nullable=true)
*/
protected $radiologyDiscCount;
/**
* @var string|null
*
* @ORM\Column(name="hoursQuoted", type="decimal", precision=7, scale=2, nullable=true)
*/
protected $hoursQuoted;
/**
* @var int|null
*
* @ORM\Column(name="quoteStatus", type="integer", nullable=true)
*/
protected $quoteStatus;
/**
* @var Collection
*
* @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\Disc", mappedBy="batchRequest", cascade={"persist"})
*/
protected $discs;
/**
* @var SortingSession
*
* @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\SortingSession", inversedBy="batchRequests")
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="sortingSession_id", referencedColumnName="id")
* })
*/
protected $sortingSession;
/**
* @var Collection
*
* @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\BatchDocument", mappedBy="batchRequest", cascade={"persist"})
*
* @ORM\OrderBy({
* "sortOrder"="ASC"
* })
*/
protected $batchDocuments;
/**
* @var Collection
*
* @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\Page", mappedBy="batchRequest", cascade={"persist"})
*/
protected $pages;
/**
* @var bool
*
* @ORM\Column(name="locked", type="boolean", nullable=true, options={"default"=false})
*/
protected $locked;
/**
* @var string
*
* @ORM\Column(name="paginationPrefix", type="string", nullable=true)
*/
protected $paginationPrefix;
/**
* @var string
*
* @ORM\Column(name="paginationIndentLevel", type="integer", nullable=true)
*/
protected $paginationIndentLevel;
/**
* @var int
*
* @ORM\Column(name="paginationType", type="integer", nullable=true, options={"default"="1"})
*/
protected $paginationType;
/**
* @var int|null
*
* @ORM\Column(name="clonedPageCount", type="integer", nullable=true)
*/
protected $clonedPageCount;
/**
* @var string|null
*
* @ORM\Column(name="centreNameHistory", type="string", nullable=true)
*/
protected $centreNameHistory;
/**
* @var Collection
*
* @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\Preprocessing\PreprocessDocument", mappedBy="batchRequest")
*/
private $preprocessDocuments;
/**
* @var int|null
*
* @ORM\Column(name="centreType", type="integer", nullable=true)
*/
private $centreType;
/**
* @var int|null
*
* @ORM\Column(name="scannedPageCount", type="integer", nullable=true)
*
*/
private ?int $scannedPageCount;
/**
* Constructor
*/
public function __construct()
{
$this->isCopy = true;
$this->chronologyRequired = false;
$this->details = new ArrayCollection();
$this->discs = new ArrayCollection();
$this->recordsReceived = new RecordsReceived();
$this->pages = new ArrayCollection();
$this->batchDocuments = new ArrayCollection();
$this->preprocessDocuments = new ArrayCollection();
}
/**
* __toString
*
* @return string
*/
public function __toString()
{
return (string) $this->getId();
}
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set isCopy
*
* @param bool $isCopy
*
* @return BatchRequest
*/
public function setIsCopy($isCopy)
{
$this->isCopy = $isCopy;
return $this;
}
/**
* Get isCopy
*
* @return bool
*/
public function getIsCopy()
{
return $this->isCopy;
}
/**
* Get isCopyLabel
*
* @return bool
*/
public function getIsCopyLabel()
{
return $this->isCopy ? 'Copy' : 'Original Records';
}
/**
* Get isCopyOptions
*
* @return array
*/
public static function getIsCopyOptions()
{
return [
'Copy' => true,
'Original Records' => false,
];
}
/**
* Set dateReceived
*
* @param \DateTime $dateReceived
*
* @return BatchRequest
*/
public function setDateReceived($dateReceived)
{
$this->dateReceived = $dateReceived;
return $this;
}
/**
* Get dateReceived
*
* @return \DateTime
*/
public function getDateReceived()
{
return $this->dateReceived;
}
/**
* Set estimatedDeadlineDate
*
* @param \DateTime $estimatedDeadlineDate
*
* @return BatchRequest
*/
public function setEstimatedDeadlineDate($estimatedDeadlineDate)
{
$this->estimatedDeadlineDate = $estimatedDeadlineDate;
return $this;
}
/**
* Get estimatedDeadlineDate
*
* @return \DateTime
*/
public function getEstimatedDeadlineDate()
{
return $this->estimatedDeadlineDate;
}
/**
* Get generateEstimatedDeadlineDate
*
* @return BatchRequest
*/
public function generateEstimatedDeadlineDate()
{
if (!$this->estimatedDeadlineDate && $this->getDateReceived()) {
$estimatedDeadlineDate = clone $this->getDateReceived();
$estimatedDeadlineDate->modify(self::AUTO_DATE_ESTIMATED_DEADLINE);
$this->setEstimatedDeadlineDate($estimatedDeadlineDate);
}
return $this;
}
/**
* Set dateCompleted
*
* @param \DateTime $dateCompleted
*
* @return BatchRequest
*/
public function setDateCompleted($dateCompleted)
{
$this->dateCompleted = $dateCompleted;
return $this;
}
/**
* Get dateCompleted
*
* @return \DateTime
*/
public function getDateCompleted()
{
return $this->dateCompleted;
}
/**
* Set destructionDate
*
* @param \DateTime $destructionDate
*
* @return BatchRequest
*/
public function setDestructionDate($destructionDate)
{
$this->destructionDate = $destructionDate;
return $this;
}
/**
* Get destructionDate
*
* @return \DateTime
*/
public function getDestructionDate()
{
return $this->destructionDate;
}
/**
* Updates the destruction date based on if the destroyOrReturned field
* is set to RECORDS_DESTROY, and a dateCompleted is set.
*
* Used as a lifecycleCallback.
*
* @ORM\PrePersist
*
* @ORM\PreUpdate
*/
public function updateDestructionDate()
{
// If the records are set to be destroyed, calculate and set the destruction date.
if ($this->getDestroyOrReturn() === self::RECORDS_DESTROY && $this->getDateCompleted()) {
$destructionDate = clone $this->getDateCompleted();
$destructionDate->modify(self::AUTO_DATE_DESTRUCTION);
$this->setDestructionDate($destructionDate);
} else {
$this->setDestructionDate(null);
}
return $this;
}
/**
* Returns true if the batch has been destroyed.
*
* Functions by checking if the destroyOrReturn value was set to destroy,
* and if a dateDestroyedOrReturned is set.
*
* @return bool
*/
public function isDestroyed()
{
return $this->getDestroyOrReturn() === self::RECORDS_DESTROY && $this->getDateDestroyedOrReturned();
}
/**
* Set dateDestroyedOrReturned
*
* @param \DateTime $dateDestroyedOrReturned
*
* @return BatchRequest
*/
public function setDateDestroyedOrReturned($dateDestroyedOrReturned)
{
$this->dateDestroyedOrReturned = $dateDestroyedOrReturned;
return $this;
}
/**
* Get dateDestroyedOrReturned
*
* @return \DateTime
*/
public function getDateDestroyedOrReturned()
{
return $this->dateDestroyedOrReturned;
}
/**
* Set archiveBoxNumber
*
* @param string $archiveBoxNumber
*
* @return BatchRequest
*/
public function setArchiveBoxNumber($archiveBoxNumber)
{
$this->archiveBoxNumber = $archiveBoxNumber;
return $this;
}
/**
* Get archiveBoxNumber
*
* @return string
*/
public function getArchiveBoxNumber()
{
return $this->archiveBoxNumber;
}
/**
* Get archiveBoxNumber
*
* @return string
*/
public function getArchiveBoxNumberInclPrefix()
{
$prefix = '';
if ($this->getProject() && $this->getProject()->getAccount()) {
$prefix = $this->getProject()->getAccount()->getPrefix();
}
return ($prefix ? $prefix . '-' : '') . $this->archiveBoxNumber;
}
/**
* Set qaDate
*
* @param \DateTime $qaDate
*
* @return BatchRequest
*/
public function setQaDate($qaDate)
{
$this->qaDate = $qaDate;
return $this;
}
/**
* Get qaDate
*
* @return \DateTime
*/
public function getQaDate()
{
return $this->qaDate;
}
/**
* Set qaDuration
*
* @param int $qaDuration
*
* @return BatchRequest
*/
public function setQaDuration($qaDuration)
{
$this->qaDuration = $qaDuration;
return $this;
}
/**
* Get qaDuration
*
* @return int
*/
public function getQaDuration()
{
return $this->qaDuration;
}
/**
* Set uploadedDate
*
* @param \DateTime $uploadedDate
*
* @return BatchRequest
*/
public function setUploadedDate($uploadedDate)
{
$this->uploadedDate = $uploadedDate;
return $this;
}
/**
* Get uploadedDate
*
* @return \DateTime
*/
public function getUploadedDate()
{
return $this->uploadedDate;
}
/**
* Set deletedAt
*
* @param \DateTime $deletedAt
*
* @return BatchRequest
*/
public function setDeletedAt($deletedAt)
{
$this->deletedAt = $deletedAt;
return $this;
}
/**
* Get deletedAt
*
* @return \DateTime
*/
public function getDeletedAt()
{
return $this->deletedAt;
}
/**
* Set dataCategory
*
* @param int $dataCategory
*
* @return BatchRequest
*/
public function setDataCategory($dataCategory)
{
$this->dataCategory = $dataCategory;
return $this;
}
/**
* Get dataCategory
*
* @return int
*/
public function getDataCategory()
{
return $this->dataCategory;
}
/**
* Convenience function for checking if this BatchRequest is
* dataCategory DATA_CATEGORY_RADIOLOGY.
*
* @return bool
*/
public function isRadiologyDataCategory()
{
return $this->getDataCategory() === self::DATA_CATEGORY_RADIOLOGY;
}
/**
* Convenience function for checking if this BatchRequest is
* of type media - which includes certain dataCategories.
*
* @return bool
*/
public function isDataCategoryTypeMedia()
{
$mediaTypeDataCategories = [
self::DATA_CATEGORY_RADIOLOGY,
self::DATA_CATEGORY_AUDIO,
self::DATA_CATEGORY_VIDEO,
];
return in_array($this->getDataCategory(), $mediaTypeDataCategories);
}
/**
* Get dataCategoryOptions
*
* @return array
*/
public static function getDataCategoryOptions()
{
return [
self::DATA_CATEGORY_RADIOLOGY => 'Radiology',
self::DATA_CATEGORY_VIDEO => 'Video',
self::DATA_CATEGORY_AUDIO => 'Audio',
self::DATA_CATEGORY_HARD_COPY_INDEXED => 'Hard copy indexed',
self::DATA_CATEGORY_MEDICAL_RECORDS => 'Medical records',
self::DATA_CATEGORY_ELECTRONIC_INDEXED => 'Electronic indexed',
];
}
/**
* Get dataCategoryLabel
*
* @return int
*/
public function getDataCategoryLabel()
{
$options = self::getDataCategoryOptions();
return $options[$this->getDataCategory()] ?? '';
}
/**
* Set sortedDate
*
* @param \DateTime $sortedDate
*
* @return BatchRequest
*/
public function setSortedDate($sortedDate)
{
$this->sortedDate = $sortedDate;
return $this;
}
/**
* Get sortedDate
*
* @return \DateTime
*/
public function getSortedDate()
{
return $this->sortedDate;
}
/**
* Set scannedDate
*
* @param \DateTime $scannedDate
*
* @return BatchRequest
*/
public function setScannedDate($scannedDate)
{
$this->scannedDate = $scannedDate;
return $this;
}
/**
* Get scannedDate
*
* @return \DateTime
*/
public function getScannedDate()
{
return $this->scannedDate;
}
/**
* Set pageCount
*
* @param int $pageCount
*
* @return BatchRequest
*/
public function setPageCount($pageCount)
{
$this->pageCount = $pageCount;
return $this;
}
/**
* Get pageCount
*
* @return int
*/
public function getPageCount()
{
return $this->pageCount;
}
/**
* Set blankAndDupesCount
*
* @param int $blankAndDupesCount
*
* @return BatchRequest
*/
public function setBlankAndDupesCount($blankAndDupesCount)
{
$this->blankAndDupesCount = $blankAndDupesCount;
return $this;
}
/**
* Get blankAndDupesCount
*
* @return int
*/
public function getBlankAndDupesCount()
{
return $this->blankAndDupesCount;
}
/**
* Set scanDuration
*
* @param int $scanDuration
*
* @return BatchRequest
*/
public function setScanDuration($scanDuration)
{
$this->scanDuration = $scanDuration;
return $this;
}
/**
* Get scanDuration
*
* @return int
*/
public function getScanDuration()
{
return $this->scanDuration;
}
/**
* Set sectionSortDuration
*
* @param int $sectionSortDuration
*
* @return BatchRequest
*/
public function setSectionSortDuration($sectionSortDuration)
{
$this->sectionSortDuration = $sectionSortDuration;
return $this;
}
/**
* Get sectionSortDuration
*
* @return int
*/
public function getSectionSortDuration()
{
return $this->sectionSortDuration;
}
/**
* Set dateSortDuration
*
* @param int $dateSortDuration
*
* @return BatchRequest
*/
public function setDateSortDuration($dateSortDuration)
{
$this->dateSortDuration = $dateSortDuration;
return $this;
}
/**
* Get dateSortDuration
*
* @return int
*/
public function getDateSortDuration()
{
return $this->dateSortDuration;
}
/**
* Set project
*
* @param Project $project
*
* @return BatchRequest
*/
public function setProject(?Project $project = null)
{
$this->project = $project;
return $this;
}
/**
* Get project
*
* @return Project
*/
public function getProject()
{
return $this->project;
}
/**
* Set sortDeadlineDate
*
* @param \DateTime $sortDeadlineDate
*
* @return BatchRequest
*/
public function setSortDeadlineDate($sortDeadlineDate)
{
$this->sortDeadlineDate = $sortDeadlineDate;
return $this;
}
/**
* Get sortDeadlineDate
*
* @return \DateTime
*/
public function getSortDeadlineDate()
{
if (!$this->sortDeadlineDate && $this->getDateReceived()) {
$sortDeadlineDate = clone $this->getDateReceived();
$sortDeadlineDate->modify(self::AUTO_DATE_SORT_DEADLINE);
return $sortDeadlineDate;
}
return $this->sortDeadlineDate;
}
/**
* Set created
*
* @param \DateTime $created
*
* @return BatchRequest
*/
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 BatchRequest
*/
public function setUpdated($updated)
{
$this->updated = $updated;
return $this;
}
/**
* Get updated
*
* @return \DateTime
*/
public function getUpdated()
{
return $this->updated;
}
/**
* Set sortedBy
*
* @param HumanResource $sortedBy
*
* @return BatchRequest
*/
public function setSortedBy(?HumanResource $sortedBy = null)
{
$this->sortedBy = $sortedBy;
return $this;
}
/**
* Get sortedBy
*
* @return HumanResource
*/
public function getSortedBy()
{
return $this->sortedBy;
}
/**
* Set scanCompletedBy
*
* @param HumanResource $scanCompletedBy
*
* @return BatchRequest
*/
public function setScanCompletedBy(?HumanResource $scanCompletedBy = null)
{
$this->scanCompletedBy = $scanCompletedBy;
return $this;
}
/**
* Get scanCompletedBy
*
* @return HumanResource
*/
public function getScanCompletedBy()
{
return $this->scanCompletedBy;
}
/**
* Set qaBy
*
* @param HumanResource $qaBy
*
* @return BatchRequest
*/
public function setQaBy(?HumanResource $qaBy = null)
{
$this->qaBy = $qaBy;
return $this;
}
/**
* Get qaBy
*
* @return HumanResource
*/
public function getQaBy()
{
return $this->qaBy;
}
/**
* Set uploadedBy
*
* @param HumanResource $uploadedBy
*
* @return BatchRequest
*/
public function setUploadedBy(?HumanResource $uploadedBy = null)
{
$this->uploadedBy = $uploadedBy;
return $this;
}
/**
* Get uploadedBy
*
* @return HumanResource
*/
public function getUploadedBy()
{
return $this->uploadedBy;
}
/**
* Set destroyOrReturn
*
* @param int $destroyOrReturn
*
* @return BatchRequest
*/
public function setDestroyOrReturn($destroyOrReturn)
{
$this->destroyOrReturn = $destroyOrReturn;
return $this;
}
/**
* Get destroyOrReturn
*
* @return int
*/
public function getDestroyOrReturn()
{
return $this->destroyOrReturn;
}
/**
* Get reasonForCancellationOptions
*
* @return array
*/
public static function getDestroyOrReturnOptions()
{
return [
self::RECORDS_RETURN => 'Return',
self::RECORDS_DESTROY => 'Destroy',
];
}
/**
* Get reasonForCancellationLabel
*
* @return string
*/
public function getDestroyOrReturnLabel()
{
$options = self::getDestroyOrReturnOptions();
return $options[$this->getDestroyOrReturn()] ?? '';
}
/**
* Set chronologyRequired
*
* @param bool $chronologyRequired
*
* @return BatchRequest
*/
public function setChronologyRequired($chronologyRequired)
{
$this->chronologyRequired = $chronologyRequired;
// Remove the linked ChronologyRequest if we indicate the BatchRequest does not require Chronology
if (!$chronologyRequired) {
$this->setChronologyRequest(null);
}
return $this;
}
/**
* Get chronologyRequired
*
* @return bool
*/
public function getChronologyRequired()
{
return $this->chronologyRequired;
}
/**
* Get chronologyRequired
*
* @return bool
*/
public function getChronologyRequiredLabel()
{
return $this->chronologyRequired ? 'Yes' : 'No';
}
/**
* Add detail
*
* @param BatchRequestDetail $detail
*
* @return BatchRequest
*/
public function addDetail(BatchRequestDetail $detail)
{
$this->details[] = $detail;
return $this;
}
/**
* Remove detail
*
* @param BatchRequestDetail $detail
*/
public function removeDetail(BatchRequestDetail $detail)
{
$this->details->removeElement($detail);
}
/**
* Get details
*
* @return Collection
*/
public function getDetails()
{
return $this->details;
}
/**
* Set chronologyRequest
*
* @param ChronologyRequest $chronologyRequest
*
* @return BatchRequest
*/
public function setChronologyRequest(?ChronologyRequest $chronologyRequest = null)
{
$this->chronologyRequest = $chronologyRequest;
return $this;
}
/**
* Get chronologyRequest
*
* @return ChronologyRequest
*/
public function getChronologyRequest()
{
return $this->chronologyRequest;
}
/**
* Set receivedFrom
*
* @param string $receivedFrom
*
* @return BatchRequest
*/
public function setReceivedFrom($receivedFrom)
{
$this->receivedFrom = $receivedFrom;
return $this;
}
/**
* Get receivedFrom
*
* @return string
*/
public function getReceivedFrom()
{
return $this->receivedFrom;
}
/**
* Set recordsReceived
*
* @param RecordsReceived $recordsReceived
*
* @return BatchRequest
*/
public function setRecordsReceived(RecordsReceived $recordsReceived)
{
$this->recordsReceived = $recordsReceived;
return $this;
}
/**
* Get recordsReceived
*
* @return RecordsReceived
*/
public function getRecordsReceived()
{
return $this->recordsReceived;
}
/**
* Set passwords
*
* @param string $passwords
*
* @return BatchRequest
*/
public function setPasswords($passwords)
{
$this->passwords = $passwords;
return $this;
}
/**
* Get passwords
*
* @return string
*/
public function getPasswords()
{
return $this->passwords;
}
/**
* Add disc
*
* @param Disc $disc
*
* @return BatchRequest
*/
public function addDisc(Disc $disc)
{
$this->discs[] = $disc;
return $this;
}
/**
* Remove disc
*
* @param Disc $disc
*/
public function removeDisc(Disc $disc)
{
$this->discs->removeElement($disc);
}
/**
* Get discs
*
* @return Collection
*/
public function getDiscs()
{
return $this->discs;
}
/**
* Unsets the association between this BatchRequest and Discs.
* Used as a preRemove lifecycle event, to avoid broken relationships when
* soft deleting a BatchRequest. Takes the place of a onDelete=NULL database
* call.
*
* @ORM\PreRemove
*
* @return void
*/
public function clearDiscs()
{
foreach ($this->getDiscs() as $disc) {
// Only set the owning side relation to null.
$disc->setBatchRequest(null);
}
}
/**
* Set radiologyDiscCount
*
* @param int $radiologyDiscCount
*
* @return BatchRequest
*/
public function setRadiologyDiscCount($radiologyDiscCount)
{
$this->radiologyDiscCount = $radiologyDiscCount;
return $this;
}
/**
* Get radiologyDiscCount
*
* @return int
*/
public function getRadiologyDiscCount()
{
return $this->radiologyDiscCount;
}
/**
* Returns the number of Discs that still need to be created for this BatchRequest.
*
* @return int
*/
public function getOutstandingRadiologyDiscCount()
{
return (int) $this->getRadiologyDiscCount() - $this->getDiscs()->count();
}
/**
* Gets all BatchRequests related to this BatchRequest, i.e.
* those that belong to the same ServiceRequestGroup
*
* @param $inclCurrent - Optionally include the current BatchRequest
*
* @return array
*/
public function getRelatedBatchRequests($inclCurrent = false)
{
// If the BatchRequest does not belong to a ServiceRequest group,
// it has no related batches.
if (!$this->getServiceRequestGroup()) {
return [];
}
// Assign the calling class to a more readable variable
$currentBatchRequest = $this;
// Filter through the ServiceRequests on the ServiceRequestGroup and return the BatchRequests only.
$relatedBatchRequests = $this->getServiceRequestGroup()->getServiceRequests()->filter(function ($serviceRequest) use ($inclCurrent, $currentBatchRequest) {
// If the serviceRequest belongs to the currentBatchRequest...
if ($serviceRequest->getId() === $currentBatchRequest->getServiceRequest()->getId()) {
// include it if we want to include the current batchRequest
return $inclCurrent;
}
// If the serviceRequest is attached to a batchRequest, include it.
if ($serviceRequest->isBatchRequest()) {
return true;
}
// Don't include any others
return false;
});
// Extract the Serviceable from the ServiceRequest, which should be a BatchRequest.
return array_map(function ($serviceRequest) {
return $serviceRequest->getServiceable();
}, $relatedBatchRequests->toArray());
}
/**
* Set hoursQuoted
*
* @param int $hoursQuoted
*
* @return BatchRequest
*/
public function setHoursQuoted($hoursQuoted)
{
$this->hoursQuoted = $hoursQuoted;
return $this;
}
/**
* Get hoursQuoted
*
* @return int
*/
public function getHoursQuoted()
{
return $this->hoursQuoted;
}
/**
* Set quoteStatus
*
* @param int $quoteStatus
*
* @return BatchRequest
*/
public function setQuoteStatus($quoteStatus)
{
$this->quoteStatus = $quoteStatus;
return $this;
}
/**
* Get quoteStatus
*
* @return int
*/
public function getQuoteStatus()
{
return $this->quoteStatus;
}
/**
* Get quoteStatusLabel
*
* @return bool
*/
public function getQuoteStatusLabel()
{
$options = self::getQuoteStatusOptions();
return $options[$this->getQuoteStatus()] ?? '';
}
/**
* Get quoteStatusOptions
*
* @return array
*/
public static function getQuoteStatusOptions()
{
return [
self::QUOTE_STATUS_PENDING => 'Pending',
self::QUOTE_STATUS_ACCEPTED => 'Accepted',
self::QUOTE_STATUS_DECLINED => 'Declined',
];
}
/**
* Set shelfLocation
*
* @param string $shelfLocation
*
* @return BatchRequest
*/
public function setShelfLocation($shelfLocation)
{
$this->shelfLocation = $shelfLocation;
return $this;
}
/**
* Get shelfLocation
*
* @return string
*/
public function getShelfLocation()
{
return $this->shelfLocation;
}
/**
* Set sortingSession
*
* @param SortingSession $sortingSession
*
* @return BatchRequest
*/
public function setSortingSession(?SortingSession $sortingSession = null)
{
$this->sortingSession = $sortingSession;
return $this;
}
/**
* Get sortingSession
*
* @return SortingSession
*/
public function getSortingSession()
{
return $this->sortingSession;
}
/**
* Add page
*
* @param Page $page
*
* @return BatchRequest
*/
public function addPage(Page $page)
{
$this->pages[] = $page;
return $this;
}
/**
* Remove page
*
* @param Page $page
*/
public function removePage(Page $page)
{
$this->pages->removeElement($page);
}
/**
* Get pages
*
* @return Collection
*/
public function getPages()
{
return $this->pages;
}
/**
* Add batchDocument
*
* @param BatchDocument $batchDocument
*
* @return BatchRequest
*/
public function addBatchDocument(BatchDocument $batchDocument)
{
$this->batchDocuments[] = $batchDocument;
return $this;
}
/**
* Remove batchDocument
*
* @param BatchDocument $batchDocument
*/
public function removeBatchDocument(BatchDocument $batchDocument)
{
$this->batchDocuments->removeElement($batchDocument);
}
/**
* Get batchDocuments
*
* @return Collection|BatchDocument[]
*/
public function getBatchDocuments()
{
return $this->batchDocuments;
}
/**
* Get batchDocuments that are PDF only.
*
* @return Collection|BatchDocument[]
*/
public function getBatchDocumentsPdfOnly()
{
return $this->batchDocuments->filter(function (BatchDocument $item) {
return $item->getDocument()->getFileFamilyType() === Document::FILE_TYPE_PDF;
});
}
/**
* Set locked
*
* @param bool $locked
*
* @return BatchRequest
*/
public function setLocked($locked)
{
$this->locked = $locked;
return $this;
}
/**
* Get locked
*
* @return bool
*/
public function isLocked()
{
return $this->locked;
}
/**
* Checks to see if this BatchRequest has pending BatchDocuments
*
* @return bool
*/
public function hasPendingBatchDocuments()
{
/** @var BatchDocument $batchDocument */
foreach ($this->getBatchDocuments() as $batchDocument) {
if ($batchDocument->getStatus() === BatchDocument::STATUS_PENDING) {
return true;
}
}
return false;
}
/**
* Checks to see if this BatchRequest has in progress BatchDocuments
*
* @return bool
*/
public function hasInProgressBatchDocuments()
{
/** @var BatchDocument $batchDocument */
foreach ($this->getBatchDocuments() as $batchDocument) {
if ($batchDocument->getStatus() === BatchDocument::STATUS_IN_PROGRESS) {
return true;
}
}
return false;
}
/**
* Set centreName
*
* @param string $centreName
*
* @return BatchRequest
*/
public function setCentreName($centreName)
{
$centreName = trim($centreName);
if ($this->getReceivedFrom() === null) {
$this->setReceivedFrom($centreName);
}
$this->centreName = $centreName;
return $this;
}
/**
* Set paginationType
*
* @param int $paginationType
*
* @return BatchRequest
*/
public function setPaginationType($paginationType)
{
$this->paginationType = $paginationType;
return $this;
}
/**
* Get centreName
*
* @return string
*/
public function getCentreName()
{
return $this->centreName;
}
/**
* Get paginationType
*
* @return int
*/
public function getPaginationType()
{
return $this->paginationType;
}
/**
* Get paginationTypeOptions
*
* @return array
*/
public static function getPaginationTypeOptions()
{
return [
self::PAGINATION_TYPE_NORMAL => 'Normal',
self::PAGINATION_TYPE_INSERTION => 'Insertion',
self::PAGINATION_TYPE_UPDATE => 'Update',
];
}
/**
* Get paginationTypeLabel
*
* @return int
*/
public function getPaginationTypeLabel()
{
$options = self::getPaginationTypeOptions();
return $options[$this->getPaginationType()] ?? '';
}
/**
* Returns true if the pagination type insertion.
*
* @return bool
*/
public function isInsertionPaginationType()
{
return $this->getPaginationType() === self::PAGINATION_TYPE_INSERTION;
}
/**
* Returns true if the pagination type is update.
*
* @return bool
*/
public function isUpdatePaginationType()
{
return $this->getPaginationType() === self::PAGINATION_TYPE_UPDATE;
}
/**
* Gets the label to use in the choice drop downs.
*
* @return string
*/
public function getChoiceLabel()
{
return sprintf('%1$s (%2$s Pag.)', $this->getServiceRequestGroupId(), $this->getPaginationTypeLabel());
}
/**
* Set admissionSortDuration.
*
* @param string|null $admissionSortDuration
*
* @return BatchRequest
*/
public function setAdmissionSortDuration($admissionSortDuration = null)
{
$this->admissionSortDuration = $admissionSortDuration;
return $this;
}
/**
* Get admissionSortDuration.
*
* @return string|null
*/
public function getAdmissionSortDuration()
{
return $this->admissionSortDuration;
}
/**
* Get locked.
*
* @return bool|null
*/
public function getLocked()
{
return $this->locked;
}
/**
* Set dateSortedBy.
*
* @param HumanResource|null $dateSortedBy
*
* @return BatchRequest
*/
public function setDateSortedBy(?HumanResource $dateSortedBy = null)
{
$this->dateSortedBy = $dateSortedBy;
return $this;
}
/**
* Get dateSortedBy.
*
* @return HumanResource|null
*/
public function getDateSortedBy()
{
return $this->dateSortedBy;
}
/**
* Set admissionSortedBy.
*
* @param HumanResource|null $admissionSortedBy
*
* @return BatchRequest
*/
public function setAdmissionSortedBy(?HumanResource $admissionSortedBy = null)
{
$this->admissionSortedBy = $admissionSortedBy;
return $this;
}
/**
* Get admissionSortedBy.
*
* @return HumanResource|null
*/
public function getAdmissionSortedBy()
{
return $this->admissionSortedBy;
}
/**
* Set paginationPrefix.
*
* @param string|null $paginationPrefix
*
* @return BatchRequest
*/
public function setPaginationPrefix($paginationPrefix = null)
{
$this->paginationPrefix = $paginationPrefix;
return $this;
}
/**
* Get paginationPrefix.
*
* @return string|null
*/
public function getPaginationPrefix()
{
return $this->paginationPrefix;
}
/**
* Set paginationIndentLevel.
*
* @param int|null $paginationIndentLevel
*
* @return BatchRequest
*/
public function setPaginationIndentLevel($paginationIndentLevel = null)
{
$this->paginationIndentLevel = $paginationIndentLevel;
return $this;
}
/**
* Get paginationIndentLevel.
*
* @return int|null
*/
public function getPaginationIndentLevel()
{
return $this->paginationIndentLevel ?: self::PAGINATION_INDENT_LEVEL_1;
}
/**
* Set clonedPageCount.
*
* @param int|null $clonedPageCount
*
* @return BatchRequest
*/
public function setClonedPageCount($clonedPageCount = null)
{
$this->clonedPageCount = $clonedPageCount;
return $this;
}
/**
* Get clonedPageCount.
*
* @return int|null
*/
public function getClonedPageCount(): ?int
{
return $this->clonedPageCount;
}
/**
* Get the value of centreNameHistory
*
* @return string|null
*/
public function getCentreNameHistory()
{
return $this->centreNameHistory;
}
/**
* Set the value of centreNameHistory
*
* @param string|null $centreNameHistory
*
* @return BatchRequest
*/
public function setCentreNameHistory($centreNameHistory = null)
{
$this->centreNameHistory = $centreNameHistory;
return $this;
}
/**
* @return Collection|PreprocessDocument[]
*/
public function getPreprocessDocuments(): Collection
{
return $this->preprocessDocuments;
}
/**
* @return PreprocessDocument[]
*/
public function getPreprocessDocumentsArray(): array
{
return $this->preprocessDocuments->toArray();
}
/**
* @param PreprocessDocument $preprocessDocument
*
* @return self
*/
public function addPreprocessDocument(PreprocessDocument $preprocessDocument): self
{
if (!$this->preprocessDocuments->contains($preprocessDocument)) {
$this->preprocessDocuments[] = $preprocessDocument;
$preprocessDocument->setBatchRequest($this);
}
return $this;
}
/**
* @param PreprocessDocument $preprocessDocument
*
* @return self
*/
public function removePreprocessDocument(PreprocessDocument $preprocessDocument): self
{
if ($this->preprocessDocuments->removeElement($preprocessDocument)) {
// set the owning side to null (unless already changed)
if ($preprocessDocument->getBatchRequest() === $this) {
$preprocessDocument->setBatchRequest(null);
}
}
return $this;
}
/**
* @return int|null
*/
public function getCentreType(): ?int
{
return $this->centreType;
}
/**
* @param int|null $centreType
*
* @return self
*/
public function setCentreType(?int $centreType): self
{
$this->centreType = $centreType;
return $this;
}
/**
* @return array
*/
public static function getCentreTypeOptions(): array
{
$options = self::getConstantsWithLabelsAsChoices('CENTRE_TYPE');
$includeOptions = [
self::CENTRE_TYPE_TRUST,
self::CENTRE_TYPE_GP,
self::CENTRE_TYPE_AMBULANCE_SERVICE,
self::CENTRE_TYPE_CARE_HOME,
self::CENTRE_TYPE_MARIE_STOPES,
self::CENTRE_TYPE_PHARMACY,
self::CENTRE_TYPE_CONSULTANT,
self::CENTRE_TYPE_HOSPITAL,
self::CENTRE_TYPE_PSYCHOLOGY,
self::CENTRE_TYPE_PHYSIO,
self::CENTRE_TYPE_PODIATRIST,
self::CENTRE_TYPE_URGENT_CARE_CENTRE,
self::CENTRE_TYPE_WALKIN_CENTRE,
self::CENTRE_TYPE_OTHER_PRE_PROCESSING,
];
// Only return certain options for batch requests
$options = array_intersect($options, $includeOptions);
ksort($options);
$reLabeledOptions = [];
// Append the incl or excl label. Currently, we show the include label as so few centre types are included for pre-processing.
$preprocessingCentreTypes = static::getAllowedPreprocessingCentreTypes();
foreach ($options as $label => $value) {
if (in_array($value, $preprocessingCentreTypes) === true) {
$reLabeledOptions[sprintf('%1$s %2$s', $label, self::INCLUDE_FOR_PREPROCESSIN_LABEL)] = $value;
} else {
$reLabeledOptions[$label] = $value;
}
}
// Add other at the back
$reLabeledOptions[self::CENTRE_TYPE_OTHER__LABEL] = self::CENTRE_TYPE_OTHER;
return $reLabeledOptions;
}
/**
* Returns an array of allowed centre types for preprocessing.
*
* @return array
*/
public static function getAllowedPreprocessingCentreTypes(): array
{
return [
// self::CENTRE_TYPE_TRUST,
self::CENTRE_TYPE_GP,
// self::CENTRE_TYPE_AMBULANCE_SERVICE,
// self::CENTRE_TYPE_CARE_HOME,
// self::CENTRE_TYPE_MARIE_STOPES,
// self::CENTRE_TYPE_PHARMACY,
// self::CENTRE_TYPE_CONSULTANT,
// self::CENTRE_TYPE_HOSPITAL,
// self::CENTRE_TYPE_PSYCHOLOGY,
// self::CENTRE_TYPE_PHYSIO,
// self::CENTRE_TYPE_PODIATRIST,
// self::CENTRE_TYPE_URGENT_CARE_CENTRE,
// self::CENTRE_TYPE_WALKIN_CENTRE,
// self::CENTRE_TYPE_OTHER_PRE_PROCESSING,
];
}
/**
* Returns true if the batch request is for GP Records.
*
* @return bool
*/
public function isGpRecords(): bool
{
return $this->getCentreType() === self::CENTRE_TYPE_GP;
}
/**
* Returns true of the batch request should be included for pre-processing.
*
* @return bool
*/
public function allowPreprocessing(): bool
{
$isServiceRequestComplete = $this->getServiceRequest()->isComplete();
$isAllowedCentreType = in_array($this->getCentreType(), static::getAllowedPreprocessingCentreTypes());
// If the type of records is not a GP records set, we only want to allow certain centre names
// to go for pre-processing.
$isCentreNameMatch = true;
// If not a GP records set...
if ($this->isGpRecords() === false) {
// Check if the centre wildcards appear in the name
$pattern = '/' . implode('|', array_map('preg_quote', self::TRUST_NAME_WILDCARDS)) . '/i';
// Use preg_match to check if any of the wildcards are found
if (preg_match($pattern, $this->getCentreName()) === 0) {
$isCentreNameMatch = false;
}
}
return $isServiceRequestComplete === false && $isAllowedCentreType === true && $isCentreNameMatch === true;
}
/**
* @return string
*/
public function getCentreTypeLabel(): string
{
$options = array_flip(self::getCentreTypeOptions());
return $options[$this->getCentreType()] ?? '';
}
/**
* Returns true if the batch is to be included for preprocessing.
*
* @return bool
*/
public function includedForPreProcessing(): bool
{
if (!$this->getSortingSession() || $this->getSortingSession()->getRequiresPreProcessing() === false) {
return false;
}
return !empty(array_filter($this->getSortingSession()->getPreprocessItems(), function (BatchRequest $batchRequest) {
return $batchRequest->getId() === $this->getId();
}));
}
/**
* @return bool
*/
public function isSubmittedForPreprocessing(): bool
{
$preprocessDocument = $this->getPreprocessDocuments()->last();
return $preprocessDocument instanceof PreprocessDocument && !$preprocessDocument->isIgnore();
}
/**
* @return int|null
*/
public function getComputerizedRecordsCount(): ?int
{
return $this->computerizedRecordsCount;
}
/**
* @param int|null $computerizedRecordsCount
*
* @return self
*/
public function setComputerizedRecordsCount(?int $computerizedRecordsCount = null): self
{
$this->computerizedRecordsCount = $computerizedRecordsCount;
return $this;
}
/**
* Returns the pages that should be billed at the standard rate, based on this logic:
* Total @ Standard Rate (new) = SUM of the following page counts:
* - Sorted Page Count
* - Blanks and Dupes Count
* - Computerised Records, but only if count is < 1000. @see COMPUTERIZED_RECORDS_BILLING_THRESHOLD
*
* @return int
*/
public function getPageCountBilledAtStandardRate(): int
{
return $this->getPageCount() + $this->getBlankAndDupesCount() + ($this->getComputerizedRecordsCount() < self::COMPUTERIZED_RECORDS_BILLING_THRESHOLD ? $this->getComputerizedRecordsCount() : 0);
}
/**
* @return bool
*/
public function hasImportantNotes(): bool
{
return $this->getDetails()->filter(function (BatchRequestDetail $batchRequestDetail) {
return $batchRequestDetail->getIsImportant();
})->count();
}
/**
* @return bool
*/
public function canAutoCancel(): bool
{
if ($this->getServiceRequest() && ($this->getServiceRequest()->getStatus() === ServiceRequest::STATUS_AWAITING_RECORDS_ARRIVAL || $this->getServiceRequest()->getStatus() === ServiceRequest::STATUS_AWAITING_QUOTE_APPROVAL)) {
return true;
}
return false;
}
/**
* Gets the number of pages scanned
*
* @return int|null
*/
public function getScannedPageCount(): ?int
{
return $this->scannedPageCount;
}
/**
* Sets the number of pages scanned
*
* @param int|null $scannedPageCount
*
* @return self
*/
public function setScannedPageCount(?int $scannedPageCount): self
{
$this->scannedPageCount = $scannedPageCount;
return $this;
}
}