<?php
namespace MedBrief\MSR\Entity\MatterRequest;
use ApiPlatform\Core\Annotation\ApiResource;
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\Account;
use MedBrief\MSR\Entity\MatterRequest\Details\Sort;
use MedBrief\MSR\Traits\FilterableClassConstantsTrait;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ApiResource(
* itemOperations={
* "get"={"access_control"="is_granted('READ', object.getAccount())"}
* },
* collectionOperations={},
* attributes={
* "normalization_context"={"groups"={"account:read"}},
* }
* )
*
* @ORM\Table(name="MatterRequestDefaults")
*
* @ORM\Entity
*
* @Audit\Auditable
*
* @Audit\Security(view={"ROLE_ALLOWED_TO_AUDIT"})
*/
class MatterRequestDefaults
{
use FilterableClassConstantsTrait;
// forceOptionalFields Constants
public const FORCE_OPTIONAL_FIELDS_CLAIM_CATEGORY = 'claimCategory';
public const FORCE_OPTIONAL_FIELDS_CLAIM_CATEGORY__LABEL = 'Case Type';
public const FORCE_OPTIONAL_FIELDS_KEY_ALLEGATIONS = 'keyAllegations';
public const FORCE_OPTIONAL_FIELDS_KEY_ALLEGATIONS__LABEL = 'Key Allegations';
public const FORCE_OPTIONAL_FIELDS_CLAIM_VALUE = 'claimValue';
public const FORCE_OPTIONAL_FIELDS_CLAIM_VALUE__LABEL = 'Estimated Claim Value';
public const FORCE_OPTIONAL_FIELDS_NEGLIGENCE_DATE = 'negligenceDate';
public const FORCE_OPTIONAL_FIELDS_NEGLIGENCE_DATE__LABEL = 'Date of Alleged Negligence';
public const FORCE_OPTIONAL_FIELDS_LIMITATION_DATE = 'limitationDate';
public const FORCE_OPTIONAL_FIELDS_LIMITATION_DATE__LABEL = 'Limitation Date';
public const FORCE_OPTIONAL_FIELDS_LIABILITY = 'liability';
public const FORCE_OPTIONAL_FIELDS_LIABILITY__LABEL = 'Is liability admitted?';
// forceCompulsoryFields Constants
public const FORCE_COMPULSORY_FIELDS_BILLING_CODE = 'billingCode';
public const FORCE_COMPULSORY_FIELDS_BILLING_CODE__LABEL = 'Billing Code';
/**
* @var int
*
* @Groups({"account:read", "matter_request:read"})
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\Id
*
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $id;
/**
* @var string
*
* @Groups({"account:read", "matter_request:read"})
*
* @ORM\Column(name="selectedServiceGroup", type="string", nullable=true)
*/
protected $selectedServiceGroup;
/**
* @var string
*
* @Groups({"account:read", "matter_request:read"})
*
* @ORM\Column(name="requestingChoice", type="string", nullable=true)
*/
protected $requestingChoice;
/**
* @var string
*
* @Groups({"account:read", "matter_request:read"})
*
* @ORM\Column(type="string", nullable=true)
*/
protected ?string $firmReviewChoice;
/**
* @var string
*
* @Groups({"account:read", "matter_request:read"})
*
* @ORM\Column(name="reviewChoice", type="string", nullable=true)
*/
protected $reviewChoice;
/**
* @var string
*
* @Groups({"account:read", "matter_request:read"})
*
* @ORM\Column(name="sortChoice", type="string", nullable=true)
*/
protected $sortChoice;
/**
* @var string
*
* @Groups({"account:read", "matter_request:read"})
*
* @ORM\Column(name="chronologyChoice", type="string", nullable=true)
*
* @Assert\Expression(
* "this.getReviewChoice() !== constant('MedBrief\\MSR\\Entity\\MatterRequest\\Details\\ServiceSelection::REVIEW_CHOICE_MEDBRIEF') or value !== constant('MedBrief\\MSR\\Entity\\MatterRequest\\Details\\ServiceSelection::CHRONOLOGY_CHOICE_YES_SUMMARY')",
* message="Cannot select 'Clinical Summary (Sorted)' as default if MedBrief will already provide a clinical summary prior to sorting.",
* groups={"account-matter-request-defaults"}
* )
*/
protected $chronologyChoice;
/**
* @var string
*
* @Groups({"account:read", "matter_request:read"})
*
* @ORM\Column(name="radiologyChoice", type="string", nullable=true)
*/
protected $radiologyChoice;
/**
* @var string
*
* @Groups({"account:read", "matter_request:read"})
*
* @ORM\Column(name="extraService", type="string", nullable=true)
*/
protected $extraService;
/**
* @var bool
*
* @Groups({"account:read", "matter_request:read"})
*
* @ORM\Column(name="destroyAll", type="boolean")
*/
protected $destroyAll;
/**
* @var array
*
* @Groups({"account:read", "matter_request:read"})
*
* @ORM\Column(name="destroyOptions", type="array")
*/
protected $destroyOptions = [];
/**
* @var array
*
* @Groups({"account:read", "matter_request:read"})
*
* @ORM\Column(name="returnOptions", type="array")
*/
protected $returnOptions = [];
/**
* @var string
*
* @Groups({"account:read", "matter_request:read"})
*
* @ORM\Column(name="sortType", type="string")
*/
protected $sortType;
/**
* @var string
*
* @Groups({"account:read", "matter_request:read"})
*
* @ORM\Column(name="centrePrefix", type="string")
*/
protected $centrePrefix;
/**
* @var string
*
* @Groups({"account:read", "matter_request:read"})
*
* @ORM\Column(name="pagePrefix", type="string")
*/
protected $pagePrefix;
/**
* @var string
*
* @Groups({"account:read", "matter_request:read"})
*
* @ORM\Column(name="paginationRun", type="string")
*/
protected $paginationRun;
/**
* @var string
*
* @Groups({"account:read", "matter_request:read"})
*
* @ORM\Column(name="pageNumberPadding", type="string")
*/
protected $pageNumberPadding;
/**
* @var \DateTimeImmutable
*
* @ORM\Column(name="created", type="datetime_immutable")
*
* @Gedmo\Timestampable(on="create")
*/
protected $created;
/**
* @var \DateTime
*
* @ORM\Column(name="updated", type="datetime")
*
* @Gedmo\Timestampable(on="update")
*/
protected $updated;
/**
* @var Account
*
* @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\Account", inversedBy="matterRequestDefaults")
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="account_id", referencedColumnName="id", unique=true)
* })
*/
protected $account;
/**
* @var array
*
* @Groups({"account:read", "matter_request:read"})
*
* @ORM\Column(name="forceOptionalFields", type="array")
*/
protected $forceOptionalFields = [];
/**
* @var array
*
* @Groups({"account:read", "matter_request:read"})
*
* @ORM\Column(name="forceCompulsoryFields", type="array")
*/
protected $forceCompulsoryFields = [];
/**
* @var bool
*
* @Groups({"account:read", "matter_request:read"})
*
* @ORM\Column(name="matterActiveOnCreation", type="boolean", options={"default"=false})
*/
protected $matterActiveOnCreation = false;
/**
* @var int
*
* @Groups({"account:read", "matter_request:read"})
*
* @ORM\Column(name="pageNumberPositionHorizontal", type="integer", options={"default"="3"})
*/
protected $pageNumberPositionHorizontal = Sort::PAGE_NUMBER_POSITION_HORIZONTAL_RIGHT;
/**
* @var int
*
* @Groups({"account:read", "matter_request:read"})
*
* @ORM\Column(name="pageNumberPositionVertical", type="integer", options={"default"="2"})
*/
protected $pageNumberPositionVertical = Sort::PAGE_NUMBER_POSITION_VERTICAL_BOTTOM;
/**
* @var int
*
* @Groups({"account:read", "matter_request:read"})
*
* @ORM\Column(name="pageNumberSize", type="integer", options={"default"="20"})
*/
protected $pageNumberSize = Sort::PAGE_NUMBER_SIZE_20;
/**
* @var bool
*
* @Groups({"account:read", "matter_request:read"})
*
* @ORM\Column(name="pageNumberBackground", type="boolean", options={"default"=false})
*/
protected $pageNumberBackground = Sort::PAGE_NUMBER_BACKGROUND_NO;
/**
* Constructor
*/
public function __construct()
{
$this->destroyAll = true;
$this->destroyOptions = [];
$this->returnOptions = [];
$this->sortType = Sort::SORT_TYPE_ADMISSION;
$this->centrePrefix = Sort::CENTRE_PREFIX_ALPHA;
$this->pagePrefix = Sort::PAGE_PREFIX_LETTER;
$this->paginationRun = Sort::PAGINATION_CENTRE;
$this->pageNumberPadding = Sort::PADDING_3;
$this->pageNumberPositionHorizontal = Sort::PAGE_NUMBER_POSITION_HORIZONTAL_RIGHT;
$this->pageNumberPositionVertical = Sort::PAGE_NUMBER_POSITION_VERTICAL_BOTTOM;
$this->pageNumberSize = Sort::PAGE_NUMBER_SIZE_20;
$this->pageNumberBackground = Sort::PAGE_NUMBER_BACKGROUND_NO;
$this->forceOptionalFields = [];
$this->forceCompulsoryFields = [];
}
/**
* __toString
*
* @return string
*/
public function __toString(): string
{
return (string) ($this->getId() ?? '');
}
/**
* Get id.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set created.
*
* @param \DateTimeImmutable $created
*
* @return MatterRequestDefaults
*/
public function setCreated($created)
{
$this->created = $created;
return $this;
}
/**
* Get created.
*
* @return \DateTimeImmutable
*/
public function getCreated()
{
return $this->created;
}
/**
* Set updated.
*
* @param \DateTime $updated
*
* @return MatterRequestDefaults
*/
public function setUpdated($updated)
{
$this->updated = $updated;
return $this;
}
/**
* Get updated.
*
* @return \DateTime
*/
public function getUpdated()
{
return $this->updated;
}
/**
* Set selectedServiceGroup.
*
* @param string|null $selectedServiceGroup
*
* @return MatterRequestDefaults
*/
public function setSelectedServiceGroup($selectedServiceGroup = null)
{
$this->selectedServiceGroup = $selectedServiceGroup;
return $this;
}
/**
* Get selectedServiceGroup.
*
* @return string|null
*/
public function getSelectedServiceGroup()
{
return $this->selectedServiceGroup;
}
/**
* Set requestingChoice.
*
* @param string|null $requestingChoice
*
* @return MatterRequestDefaults
*/
public function setRequestingChoice($requestingChoice = null)
{
$this->requestingChoice = $requestingChoice;
return $this;
}
/**
* Get requestingChoice.
*
* @return string|null
*/
public function getRequestingChoice()
{
return $this->requestingChoice;
}
/**
* Set reviewChoice.
*
* @param string|null $reviewChoice
*
* @return MatterRequestDefaults
*/
public function setReviewChoice($reviewChoice = null)
{
$this->reviewChoice = $reviewChoice;
return $this;
}
/**
* Get reviewChoice.
*
* @return string|null
*/
public function getReviewChoice()
{
return $this->reviewChoice;
}
/**
* Set sortChoice.
*
* @param string|null $sortChoice
*
* @return MatterRequestDefaults
*/
public function setSortChoice($sortChoice = null)
{
$this->sortChoice = $sortChoice;
return $this;
}
/**
* Get sortChoice.
*
* @return string|null
*/
public function getSortChoice()
{
return $this->sortChoice;
}
/**
* Set chronologyChoice.
*
* @param string|null $chronologyChoice
*
* @return MatterRequestDefaults
*/
public function setChronologyChoice($chronologyChoice = null)
{
$this->chronologyChoice = $chronologyChoice;
return $this;
}
/**
* Get chronologyChoice.
*
* @return string|null
*/
public function getChronologyChoice()
{
return $this->chronologyChoice;
}
/**
* Set extraService.
*
* @param string|null $extraService
*
* @return MatterRequestDefaults
*/
public function setExtraService($extraService = null)
{
$this->extraService = $extraService;
return $this;
}
/**
* Get extraService.
*
* @return string|null
*/
public function getExtraService()
{
return $this->extraService;
}
/**
* Set destroyAll.
*
* @param bool $destroyAll
*
* @return MatterRequestDefaults
*/
public function setDestroyAll($destroyAll)
{
$this->destroyAll = $destroyAll;
return $this;
}
/**
* Get destroyAll.
*
* @return bool
*/
public function getDestroyAll()
{
return $this->destroyAll;
}
/**
* Set destroyOptions.
*
* @param array $destroyOptions
*
* @return MatterRequestDefaults
*/
public function setDestroyOptions($destroyOptions)
{
$this->destroyOptions = $destroyOptions;
return $this;
}
/**
* Get destroyOptions.
*
* @return array
*/
public function getDestroyOptions()
{
return $this->destroyOptions;
}
/**
* Set returnOptions.
*
* @param array $returnOptions
*
* @return MatterRequestDefaults
*/
public function setReturnOptions($returnOptions)
{
$this->returnOptions = $returnOptions;
return $this;
}
/**
* Get returnOptions.
*
* @return array
*/
public function getReturnOptions()
{
return $this->returnOptions;
}
/**
* Set sortType.
*
* @param string $sortType
*
* @return MatterRequestDefaults
*/
public function setSortType($sortType)
{
$this->sortType = $sortType;
return $this;
}
/**
* Get sortType.
*
* @return string
*/
public function getSortType()
{
return $this->sortType;
}
/**
* Set centrePrefix.
*
* @param string $centrePrefix
*
* @return MatterRequestDefaults
*/
public function setCentrePrefix($centrePrefix)
{
$this->centrePrefix = $centrePrefix;
return $this;
}
/**
* Get centrePrefix.
*
* @return string
*/
public function getCentrePrefix()
{
return $this->centrePrefix;
}
/**
* Set pagePrefix.
*
* @param string $pagePrefix
*
* @return MatterRequestDefaults
*/
public function setPagePrefix($pagePrefix)
{
$this->pagePrefix = $pagePrefix;
return $this;
}
/**
* Get pagePrefix.
*
* @return string
*/
public function getPagePrefix()
{
return $this->pagePrefix;
}
/**
* Set paginationRun.
*
* @param string $paginationRun
*
* @return MatterRequestDefaults
*/
public function setPaginationRun($paginationRun)
{
$this->paginationRun = $paginationRun;
return $this;
}
/**
* Get paginationRun.
*
* @return string
*/
public function getPaginationRun()
{
return $this->paginationRun;
}
/**
* Set pageNumberPadding.
*
* @param string $pageNumberPadding
*
* @return MatterRequestDefaults
*/
public function setPageNumberPadding($pageNumberPadding)
{
$this->pageNumberPadding = $pageNumberPadding;
return $this;
}
/**
* Get pageNumberPadding.
*
* @return string
*/
public function getPageNumberPadding()
{
return $this->pageNumberPadding;
}
/**
* Set account.
*
* @param Account|null $account
*
* @return MatterRequestDefaults
*/
public function setAccount(?Account $account = null)
{
$this->account = $account;
return $this;
}
/**
* Get account.
*
* @return Account|null
*/
public function getAccount()
{
return $this->account;
}
/**
* Set forceOptionalFields.
*
* @param array $forceOptionalFields
*
* @return MatterRequestDefaults
*/
public function setForceOptionalFields($forceOptionalFields)
{
$this->forceOptionalFields = $forceOptionalFields;
return $this;
}
/**
* Get forceOptionalFields.
*
* @return array
*/
public function getForceOptionalFields()
{
if (!$this->forceOptionalFields) {
return [];
}
return $this->forceOptionalFields;
}
/**
* Returns matter creations options as an array, usable as the choices for a form.
*
* @return array
*/
public static function getForceOptionalFieldsOptions(): array
{
$forceOptionalFieldsOptions = self::getConstantsWithLabelsAsChoices('FORCE_OPTIONAL_FIELDS');
return array_flip($forceOptionalFieldsOptions);
}
/**
* Returns true if the field has been forced to be optional.
*
* @param string $fieldName
*
* @return bool
*/
public function isFieldForceOptional(string $fieldName): bool
{
$forceOptionalFieldsValues = self::getConstants('FORCE_OPTIONAL_FIELDS');
if (!in_array($fieldName, $forceOptionalFieldsValues)) {
throw new \InvalidArgumentException(sprintf('Invalid fieldName: %1$s', $fieldName));
}
return in_array($fieldName, $this->getForceOptionalFields());
}
/**
* Set matterActiveOnCreation.
*
* @param bool $matterActiveOnCreation
*
* @return MatterRequestDefaults
*/
public function setMatterActiveOnCreation(bool $matterActiveOnCreation): MatterRequestDefaults
{
$this->matterActiveOnCreation = $matterActiveOnCreation;
return $this;
}
/**
* Get matterActiveOnCreation.
*
* @return bool
*/
public function getMatterActiveOnCreation(): bool
{
return $this->matterActiveOnCreation;
}
/**
* Set radiologyChoice.
*
* @param string|null $radiologyChoice
*
* @return MatterRequestDefaults
*/
public function setRadiologyChoice(?string $radiologyChoice = null): MatterRequestDefaults
{
$this->radiologyChoice = $radiologyChoice;
return $this;
}
/**
* Get radiologyChoice.
*
* @return string|null
*/
public function getRadiologyChoice(): ?string
{
return $this->radiologyChoice;
}
/**
* Get the value of pageNumberPositionHorizontal
*
* @return int
*/
public function getPageNumberPositionHorizontal()
{
return $this->pageNumberPositionHorizontal;
}
/**
* Set the value of pageNumberPositionHorizontal
*
* @param int $pageNumberPositionHorizontal
*
* @return self
*/
public function setPageNumberPositionHorizontal(int $pageNumberPositionHorizontal)
{
$this->pageNumberPositionHorizontal = $pageNumberPositionHorizontal;
return $this;
}
/**
* Get the value of pageNumberPositionVertical
*
* @return int
*/
public function getPageNumberPositionVertical()
{
return $this->pageNumberPositionVertical;
}
/**
* Set the value of pageNumberPositionVertical
*
* @param int $pageNumberPositionVertical
*
* @return self
*/
public function setPageNumberPositionVertical(int $pageNumberPositionVertical)
{
$this->pageNumberPositionVertical = $pageNumberPositionVertical;
return $this;
}
/**
* Get the value of pageNumberSize
*
* @return int
*/
public function getPageNumberSize()
{
return $this->pageNumberSize;
}
/**
* Set the value of pageNumberSize
*
* @param int $pageNumberSize
*
* @return self
*/
public function setPageNumberSize(int $pageNumberSize)
{
$this->pageNumberSize = $pageNumberSize;
return $this;
}
/**
* Get the value of pageNumberBackground
*/
public function getPageNumberBackground()
{
return $this->pageNumberBackground;
}
/**
* Set the value of pageNumberBackground
*
* @param mixed $pageNumberBackground
*
* @return self
*/
public function setPageNumberBackground($pageNumberBackground)
{
$this->pageNumberBackground = $pageNumberBackground;
return $this;
}
/**
* @return string|null
*/
public function getFirmReviewChoice(): ?string
{
return $this->firmReviewChoice;
}
/**
* @param string|null $firmReviewChoice
*
* @return self
*/
public function setFirmReviewChoice(?string $firmReviewChoice = null): self
{
$this->firmReviewChoice = $firmReviewChoice;
return $this;
}
/**
* Set forceCompulsoryFields.
*
* @param array $forceCompulsoryFields
*
* @return MatterRequestDefaults
*/
public function setForceCompulsoryFields(array $forceCompulsoryFields): MatterRequestDefaults
{
$this->forceCompulsoryFields = $forceCompulsoryFields;
return $this;
}
/**
* Get forceCompulsoryFields.
*
* @return array
*/
public function getForceCompulsoryFields(): array
{
if (!$this->forceCompulsoryFields) {
return [];
}
return $this->forceCompulsoryFields;
}
/**
* Returns matter creation options as an array, usable as the choices for a form.
*
* @return array
*/
public static function getForceCompulsoryFieldsOptions(): array
{
$forceCompulsoryFieldsOptions = self::getConstantsWithLabelsAsChoices('FORCE_COMPULSORY_FIELDS');
return array_flip($forceCompulsoryFieldsOptions);
}
/**
* Returns true if the field has been forced to be compulsory.
*
* @param string $fieldName
*
* @return bool
*/
public function isFieldForceCompulsory(string $fieldName): bool
{
$forceCompulsoryFieldsValues = self::getConstants('FORCE_COMPULSORY_FIELDS');
if (!in_array($fieldName, $forceCompulsoryFieldsValues)) {
throw new \InvalidArgumentException(sprintf('Invalid fieldName: %1$s', $fieldName));
}
return in_array($fieldName, $this->getForceCompulsoryFields());
}
}