<?php
namespace MedBrief\MSR\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use DateTime;
use DateTimeInterface;
use DH\Auditor\Provider\Doctrine\Auditing\Annotation as Audit;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection as DoctrineCollection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\EntityNotFoundException;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Persistence\Proxy;
use Exception;
use Gedmo\Mapping\Annotation as Gedmo;
use libphonenumber\PhoneNumber;
use MedBrief\MSR\Controller\ProjectMatch\ProjectMatchExpertProfileController;
use MedBrief\MSR\Controller\ProjectMatch\ProjectMatchLoAController;
use MedBrief\MSR\Controller\ProjectMatch\ProjectMatchLoAPreviewPdfController;
use MedBrief\MSR\Controller\ProjectMatch\ProjectMatchLoASendPdfController;
use MedBrief\MSR\Controller\ProjectMatch\ProjectMatchMyExpertsController;
use MedBrief\MSR\Controller\ProjectMatch\ProjectMatchRecommendedOptionsController;
use MedBrief\MSR\Controller\ProjectMatch\ProjectMatchSearchController;
use MedBrief\MSR\Controller\ProjectMatch\ProjectMatchShortlistedController;
use MedBrief\MSR\Dto\ClinicalSummaryMatterDto;
use MedBrief\MSR\Entity\MatterRequest\MatterRequest;
use MedBrief\MSR\Entity\MatterRequest\Patient;
use MedBrief\MSR\Entity\Patient as RadiologyPatient;
use MedBrief\MSR\Entity\Serviceable\ServiceableInterface;
use MedBrief\MSR\Repository\ProjectRepository;
use MedBrief\MSR\Service\ClaimCategoryAwareInterface;
use MedBrief\MSR\Service\InterpartyDisclosure\Disclose\DisclosureTargetInterface;
use MedBrief\MSR\Service\MatterTypeAwareInterface;
use MedBrief\MSR\Traits\Disclosure\DisclosureTargetTrait;
use MedBrief\MSR\Traits\FilterableClassConstantsTrait;
use MedBrief\MSR\Traits\ProjectShouldShowAlertTrait;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Validation;
/**
* Note: When using ApiResource groups, if the variable you want to get is snake_case you will need to add the group as an annotation to the getter.
*
* @ApiResource(
* collectionOperations={},
* itemOperations={
* "get"={
* "access_control"="is_granted('READ', object)",
* "normalization_context"={"groups"={"project_closure:read"}, "enable_max_depth"=true}
* },
* "get_clinical_summary_matter"={
* "method"="GET",
* "path"="/projects/{id}/clinical_summary_matter",
* "access_control"="is_granted('READ', object)",
* "normalization_context"={"groups"={"clinical_summary_matter:read"}},
* "output"=ClinicalSummaryMatterDto::class,
* "description"="Resource representing matter details relevant to a clinical summary.",
* },
* "get_alert_status"={
* "method"="GET",
* "path"="/match/project/{id}/show-match-alert",
* "access_control"="is_granted('MATCH_VIEW_FIRM', object)",
* "openapi_context"={
* "summary"="Get project alert status",
* "description"="Returns whether an alert should be shown for insufficient matter information"
* },
* "controller"="MedBrief\MSR\Controller\ProjectController::getMatchAlertStatusAction",
* "output"=MedBrief\MSR\Dto\ProjectMatch\MatchAlertStatusOutputDto::class,
* "normalization_context"={"groups"={"project:matchAlert"}}
* },
* "match_recommended_options"={
* "method"="GET",
* "path"="/match/project/{id}/recommended-options",
* "access_control"="is_granted('MATCH_VIEW_FIRM', object)",
* "controller"=ProjectMatchRecommendedOptionsController::class,
* "openapi_context"={
* "summary"="Return all Match Recommended Options.",
* "description"="Return all Match Recommended Options for a match search. Including recommended Specialities and Queries",
* "responses"={
* "200"={
* "description"="A list of Match Recommended Options.",
* }
* }
* }
* },
* "get_shortlisted"={
* "method"="GET",
* "path"="/match/project/{id}/shortlisted-expert",
* "access_control"="is_granted('MATCH_VIEW_FIRM', object)",
* "controller"=ProjectMatchShortlistedController::class,
* "openapi_context"={
* "summary"="Return all Match Shortlisted Experts.",
* "description"="Return all Shortlisted Experts for a project.",
* "responses"={
* "200"={
* "description"="A list of Shortlisted Experts with their full data.",
* }
* }
* }
* },
* "get_my_experts"={
* "method"="GET",
* "path"="/match/project/{id}/my-experts",
* "access_control"="is_granted('MATCH_VIEW_FIRM', object) or is_granted('MATCH_VIEW_EXPERT', object)",
* "controller"=ProjectMatchMyExpertsController::class,
* "openapi_context"={
* "summary"="Return all Experts shortlisted and contacted for this project with their message threads.",
* "description"="Return all Experts shortlisted and contacted for this project with their message threads.",
* "responses"={
* "200"={
* "description"="A list of Experts shortlisted and contacted for this project with their message threads.",
* }
* }
* }
* },
* "match_loa_get"={
* "method"="GET",
* "path"="/match/project/{id}/letter-of-approach/{userId}",
* "access_control"="is_granted('MATCH_VIEW_FIRM', object)",
* "controller"=ProjectMatchLoAController::class,
* "requirements"={
* "id"="\d+",
* "userId"="\d+"
* },
* "openapi_context"={
* "summary"="Returns letter of approach data for a specific expert and project.",
* "description"="Given a Project ID and an Expert User ID, returns the letter of approach data for that expert and project.",
* "parameters"={
* {
* "name"="id",
* "in"="path",
* "required"=true,
* "description"="Project ID",
* "schema"={"type"="integer"}
* },
* {
* "name"="userId",
* "in"="path",
* "required"=true,
* "description"="Expert User ID",
* "schema"={"type"="integer"}
* }
* },
* "responses"={
* "200"={
* "description"="Letter of Approach data for the specified expert and project.",
* }
* }
* }
* },
* "match_loa_save"={
* "method"="POST",
* "path"="/match/project/{id}/letter-of-approach/{userId}/save-as-draft",
* "access_control"="is_granted('MATCH_VIEW_FIRM', object)",
* "controller"=ProjectMatchLoAController::class,
* "requirements"={
* "id"="\d+",
* "userId"="\d+"
* },
* "openapi_context"={
* "summary"="Save letter of approach data for a project and expert",
* "description"="Saves the letter of approach (LoA) payload for a project and expert. The payload is an object with top-level keys.",
* "parameters"={
* {
* "name"="id",
* "in"="path",
* "required"=true,
* "description"="Project ID",
* "schema"={"type"="integer"}
* },
* {
* "name"="userId",
* "in"="path",
* "required"=true,
* "description"="Expert User ID",
* "schema"={"type"="integer"}
* }
* },
* "requestBody"={
* "required"=true,
* "content"={
* "application/json"={
* "schema"={
* "type"="object",
* "properties"={
* "matterDetails"={
* "type"="object",
* "description"="Information about the matter and sender details.",
* "additionalProperties"={
* "oneOf"={
* {"type"="string"},
* {"type"="integer"},
* {"type"="boolean"},
* {"type"="number"}
* }
* }
* },
* "LoAData"={
* "type"="object",
* "description"="Main LoA sections. Keys represent sections like head, introduction, etc.",
* "additionalProperties"={
* "type"="object",
* "properties"={
* "order"={"type"="integer"},
* "editable"={"type"="boolean"},
* "data"={"type"="string"}
* }
* }
* }
* },
* "required"={"matterDetails","LoAData"}
* },
* "example"={
* "matterDetails"={
* "todaysDate"="2024-06-15",
* "expertUserId"=36,
* "expertTitle"="Dr.",
* "expertFirstName"="John",
* "expertLastName"="Doe",
* "matterName"="Lorem -v- Ipsum NHS Trust",
* "matterNumber"="12345",
* "claimantInitials"="LIP",
* "defendantName"="Ipsum NHS Trust",
* "caseSummary"="Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
* "matterManager"="Jane Smith",
* "senderId"="/msr/users/2",
* "senderPosition"="Solicitor"
* },
* "LoAData"={
* "head"={
* "order"=1,
* "editable"=false,
* "fieldRequiresUpdate"=false,
* "data"="<p>Matter reference: 12345<br><strong>PRIVATE AND CONFIDENTIAL</strong></p>"
* },
* "introduction"={
* "order"=2,
* "editable"=true,
* "fieldRequiresUpdate"=false,
* "data"="<p>Dear Dr. Doe, Lorem ipsum dolor sit amet...</p>"
* },
* "background"={
* "order"=3,
* "editable"=true,
* "fieldRequiresUpdate"=true,
* "data"="<p>Background lorem ipsum dolor sit amet...</p>"
* },
* "recordsObtained"={
* "order"=4,
* "editable"=true,
* "fieldRequiresUpdate"=true,
* "data"="<p>The following records have been obtained:</p><ul><li>Record 1</li><li>Record 2</li></ul>"
* },
* "progressOfLitigation"={
* "order"=5,
* "editable"=true,
* "fieldRequiresUpdate"=true,
* "data"="<p>Progress of litigation details...</p>"
* },
* "informationRequested"={
* "order"=6,
* "editable"=false,
* "fieldRequiresUpdate"=false,
* "data"="<p>Information requested details...</p>"
* },
* "signOff"={
* "order"=7,
* "editable"=true,
* "fieldRequiresUpdate"=true,
* "data"="<p>Yours sincerely,</p>"
* }
* }
* }
* }
* }
* },
* "responses"={
* "200"={"description"="Letter of approach saved successfully."}
* }
* }
* },
* "match_loa_preview_pdf"={
* "method"="POST",
* "path"="/match/project/{id}/letter-of-approach/{userId}/preview-pdf",
* "access_control"="is_granted('MATCH_VIEW_FIRM', object)",
* "controller"=ProjectMatchLoAPreviewPdfController::class,
* "requirements"={
* "id"="\d+",
* "userId"="\d+"
* },
* "openapi_context"={
* "summary"="Preview the letter of approach pdf for a project and expert",
* "description"="Saves the letter of approach (LoA) payload for a project and expert, then retrieves a PDF based on the saved data.",
* "parameters"={
* {
* "name"="id",
* "in"="path",
* "required"=true,
* "description"="Project ID",
* "schema"={"type"="integer"}
* },
* {
* "name"="userId",
* "in"="path",
* "required"=true,
* "description"="Expert User ID",
* "schema"={"type"="integer"}
* }
* },
* "requestBody"={
* "required"=true,
* "content"={
* "application/json"={
* "schema"={
* "type"="object",
* "properties"={
* "matterDetails"={
* "type"="object",
* "description"="Information about the matter and sender details.",
* "additionalProperties"={
* "oneOf"={
* {"type"="string"},
* {"type"="integer"},
* {"type"="boolean"},
* {"type"="number"}
* }
* }
* },
* "LoAData"={
* "type"="object",
* "description"="Main LoA sections. Keys represent sections like head, introduction, etc.",
* "additionalProperties"={
* "type"="object",
* "properties"={
* "order"={"type"="integer"},
* "editable"={"type"="boolean"},
* "data"={"type"="string"}
* }
* }
* }
* },
* "required"={"matterDetails","LoAData"}
* },
* "example"={
* "matterDetails"={
* "todaysDate"="2024-06-15",
* "expertUserId"=36,
* "expertTitle"="Dr.",
* "expertFirstName"="John",
* "expertLastName"="Doe",
* "matterName"="Lorem -v- Ipsum NHS Trust",
* "matterNumber"="12345",
* "claimantInitials"="LIP",
* "defendantName"="Ipsum NHS Trust",
* "caseSummary"="Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
* "matterManager"="Jane Smith",
* "senderId"="/msr/users/2",
* "senderPosition"="Solicitor"
* },
* "LoAData"={
* "head"={
* "order"=1,
* "editable"=false,
* "fieldRequiresUpdate"=false,
* "data"="<p>Matter reference: 12345<br><strong>PRIVATE AND CONFIDENTIAL</strong></p>"
* },
* "introduction"={
* "order"=2,
* "editable"=true,
* "fieldRequiresUpdate"=false,
* "data"="<p>Dear Dr. Doe, Lorem ipsum dolor sit amet...</p>"
* },
* "background"={
* "order"=3,
* "editable"=true,
* "fieldRequiresUpdate"=true,
* "data"="<p>Background lorem ipsum dolor sit amet...</p>"
* },
* "recordsObtained"={
* "order"=4,
* "editable"=true,
* "fieldRequiresUpdate"=true,
* "data"="<p>The following records have been obtained:</p><ul><li>Record 1</li><li>Record 2</li></ul>"
* },
* "progressOfLitigation"={
* "order"=5,
* "editable"=true,
* "fieldRequiresUpdate"=true,
* "data"="<p>Progress of litigation details...</p>"
* },
* "informationRequested"={
* "order"=6,
* "editable"=false,
* "fieldRequiresUpdate"=false,
* "data"="<p>Information requested details...</p>"
* },
* "signOff"={
* "order"=7,
* "editable"=true,
* "fieldRequiresUpdate"=true,
* "data"="<p>Yours sincerely,</p>"
* }
* }
* }
* }
* }
* },
* "responses"={
* "200"={
* "description"="LoA PDF file",
* "schema"={"type"="string","format"="binary"}
* },
* "404"={"description"="Not found"}
* }
* }
* },
* "match_loa_send_pdf"={
* "method"="POST",
* "path"="/match/project/{id}/letter-of-approach/{userId}/send-pdf",
* "access_control"="is_granted('MATCH_VIEW_FIRM', object)",
* "controller"=ProjectMatchLoASendPdfController::class,
* "deserialize"=false,
* "requirements"={
* "id"="\d+",
* "userId"="\d+"
* },
* "openapi_context"={
* "summary"="Sends letter of approach pdf for a project and expert to the expert via message system",
* "description"="Gets the LoA data for a project and expert, then generates a PDF based on the saved data and sends it to the expected recipients.",
* "parameters"={
* {
* "name"="id",
* "in"="path",
* "required"=true,
* "description"="Project ID",
* "schema"={"type"="integer"}
* },
* {
* "name"="userId",
* "in"="path",
* "required"=true,
* "description"="Expert User ID",
* "schema"={"type"="integer"}
* }
* },
* "requestBody"={
* "required"=false,
* "content"={
* "application/json"={
* "schema"={"type"="object","properties"={}}
* }
* }
* },
* "responses"={
* "200"={
* "description"="LoA successfully sent"
* },
* "404"={"description"="Not found"}
* }
* }
* },
* "update_shortlisted"={
* "method"="POST",
* "path"="/match/project/{id}/shortlisted-expert/update",
* "access_control"="is_granted('MATCH_VIEW_FIRM', object)",
* "controller"=ProjectMatchShortlistedController::class,
* "openapi_context"={
* "summary"="Used to add or remove experts from the shortlisted list for a project",
* "description"="By passing in a user ID and a boolean value, you can add or remove experts from the shortlisted list for a project.",
* "requestBody"={
* "required"=true,
* "content"={
* "application/json"={
* "schema"={
* "type"="array",
* "items"={
* "type"="array",
* "items"={
* "type"="object",
* "properties"={
* "userId"={"type"="integer"},
* "shortlisted"={"type"="boolean"}
* }
* },
* "description"="user ID and boolean value indicating whether to add or remove from shortlisted list"
* }
* },
* "example"={
* "userId"=1,
* "shortlisted"=true
* }
* }
* }
* },
* "responses"={
* "200"={
* "description"="Shortlisted expert updated successfully."
* }
* }
* }
* },
* "match_expert_profile"={
* "method"="POST",
* "path"="/match/project/{id}/profile",
* "access_control"="is_granted('MATCH_VIEW_FIRM', object)",
* "controller"=ProjectMatchExpertProfileController::class,
* "openapi_context"={
* "summary"="Returns a list of cached expert profiles containing full profile data",
* "description"="Returns a list of experts that have been cached with all of their profile data. Makes use of ExpertProfileCache to retrieve profiles.",
* "requestBody"={
* "required"=true,
* "content"={
* "application/json"={
* "schema"={
* "type"="array",
* "items"={
* {"type"="integer"}
* }
* },
* "example"={1,2,3,4,5}
* }
* }
* },
* "responses"={
* "200"={
* "description"="A list of cached expert profiles."
* }
* }
* }
* },
* "match_search"={
* "method"="POST",
* "path"="/match/project/{id}/search",
* "access_control"="is_granted('MATCH_VIEW_FIRM', object)",
* "controller"=ProjectMatchSearchController::class,
* "openapi_context"={
* "summary"="Returns a list of experts that match a provided input.",
* "description"="Returns a list of experts that match a provided input search query. Calls an AI endpoint to calculate the best fitting experts.",
* "requestBody"={
* "required"=true,
* "content"={
* "application/json"={
* "schema"={
* "type"="object",
* "properties"={
* "specialities"={
* "type"="array",
* "items"={
* "type"="object",
* "properties"={
* "id"={"type"="integer"},
* "label"={"type"="string"}
* }
* },
* "description"="Array of speciality objects, each object contains integer id and string label (e.g. id:14, label:General Psychiatry)"
* },
* "consultationType"={
* "type"="string",
* "description"="Consultation type to fetch preferences for - either breach, causation or both"
* },
* "aiSearch"={
* "type"="string",
* "description"="AI search query to fetch preferences for"
* }
* },
* "required"={"specialities"}
* },
* "example"={
* "specialities"={
* {"id"=14,"label"="Psychiatry"},
* {"id"=5,"label"="Neurology"}
* },
* "consultationType"="both",
* "aiSearch"="please find me experts that will work for my case"
* }
* }
* }
* },
* "responses"={
* "200"={
* "description"="A list of Experts."
* }
* }
* }
* },
* "put"={"access_control"="is_granted('UPDATE', object)"}
* },
* attributes={
* "normalization_context"={"groups"={"project:read"}},
* }
* )
*
* @ORM\Table(name="Project", uniqueConstraints={@ORM\UniqueConstraint(name="reference_idx", columns={"account_id", "client_reference", "deletedAt"})})
*
* @ORM\Entity(repositoryClass=ProjectRepository::class)
*
* @ORM\HasLifecycleCallbacks
*
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
*
* @Audit\Auditable
*
* @Audit\Security(view={"ROLE_ALLOWED_TO_AUDIT"})
*/
class Project implements ClaimCategoryAwareInterface, MatterTypeAwareInterface, DisclosureTargetInterface
{
use FilterableClassConstantsTrait;
use DisclosureTargetTrait;
use ProjectShouldShowAlertTrait;
public const STATUS_INACTIVE = 1;
public const STATUS_ACTIVE = 2;
public const LICENSE_LEVEL_STANDARD = 1;
public const LICENSE_LEVEL_PROFESSIONAL = 2;
public const LICENSE_LEVEL_PREMIUM = 3;
public const LICENSE_LEVEL_BASIC = 4;
public const ESTIMATED_CLAIM_VALUE_0_25000 = 1;
public const ESTIMATED_CLAIM_VALUE_25001_50000 = 2;
public const ESTIMATED_CLAIM_VALUE_50001_100000 = 3;
public const ESTIMATED_CLAIM_VALUE_100001_250000 = 4;
public const ESTIMATED_CLAIM_VALUE_250001_500000 = 5;
public const ESTIMATED_CLAIM_VALUE_500001_1000000 = 6;
public const ESTIMATED_CLAIM_VALUE_1000001 = 7;
public const ESTIMATED_CLAIM_VALUE_0_25000__LABEL = '£0 - £25,000';
public const ESTIMATED_CLAIM_VALUE_25001_50000__LABEL = '£25,001 - £50,000';
public const ESTIMATED_CLAIM_VALUE_50001_100000__LABEL = '£50,001 - £100,000';
public const ESTIMATED_CLAIM_VALUE_100001_250000__LABEL = '£100,001 - £250,000';
public const ESTIMATED_CLAIM_VALUE_250001_500000__LABEL = '£250,001 - £500,000';
public const ESTIMATED_CLAIM_VALUE_500001_1000000__LABEL = '£500,001 - £1,000,000';
public const ESTIMATED_CLAIM_VALUE_1000001__LABEL = '£1,000,000 +';
// These are the Archive statuses of a Project
public const ARCHIVE_STATUS_PENDING = 1;
public const ARCHIVE_STATUS_PENDING__LABEL = 'Pending';
public const ARCHIVE_STATUS_PROCESSING = 2;
public const ARCHIVE_STATUS_PROCESSING__LABEL = 'Processing';
public const ARCHIVE_STATUS_COMPLETE = 3;
public const ARCHIVE_STATUS_COMPLETE__LABEL = 'Complete';
public const ARCHIVE_STATUS_UNARCHIVE_PROCESSING = 4;
public const ARCHIVE_STATUS_UNARCHIVE_PROCESSING__LABEL = 'Unarchiving processing';
// The delete statuses of a Project
public const DELETE_STATUS_PENDING = 1;
public const DELETE_STATUS_PENDING__LABEL = 'Pending Deletion';
public const DELETE_STATUS_REMINDER_SENT = 6;
public const DELETE_STATUS_REMINDER_SENT__LABEL = 'Reminder Sent';
public const DELETE_STATUS_PROCESSING = 2;
public const DELETE_STATUS_PROCESSING__LABEL = 'Processing';
public const DELETE_STATUS_COMPLETE = 3;
public const DELETE_STATUS_COMPLETE__LABEL = 'Complete';
public const DELETE_STATUS_DELETE_FAILED = 4;
public const DELETE_STATUS_DELETE_FAILED__LABEL = 'Failed';
public const DELETE_STATUS_ANONYMISE_FAILED = 5;
public const DELETE_STATUS_ANONYMISE_FAILED__LABEL = 'Anonymise Failed';
// This status is used to mass set projects to be deleted immediately.
public const DELETE_STATUS_PENDING_IMMEDIATE = 7;
public const DELETE_STATUS_PENDING_IMMEDIATE__LABEL = 'Pending Immediate Deletion';
// The permanent delete status of a Project
public const PERMANENT_DELETE_STATUS_PENDING = 'pending';
public const PERMANENT_DELETE_STATUS_INPROGRESS = 'inprogress';
public const PERMANENT_DELETE_STATUS_COMPLETE = 'complete';
public const PERMANENT_DELETE_STATUS_FAILED = 'failed';
// Default role options
public const DEFAULT_ROLE_EXPERT = 'EXPERT';
public const DEFAULT_ROLE_EXPERTVIEWER = 'EXPERTVIEWER';
public const DEFAULT_ROLE_SCANNER = 'SCANNER';
public const DEFAULT_ROLE_SCANNERDOWNLOAD = 'SCANNERDOWNLOAD';
public const DEFAULT_ROLE_PROJECTMANAGER = 'PROJECTMANAGER';
public const REFERENCE_ID_PREFIX = 'MSR-';
// Case merits analysis options
public const CASE_MERITS_ANALYSIS_SUPPORTIVE = 'supportive';
public const CASE_MERITS_ANALYSIS_UNSUPPORTIVE = 'unsupportive';
public const CASE_MERITS_ANALYSIS_INCONCLUSIVE = 'inconclusive';
// Type of letter options
public const TYPE_OF_LETTER_LETTER_OF_CLAIM = 'letter_of_claim';
public const TYPE_OF_LETTER_LETTER_OF_NOTIFICATION = 'letter_of_notification';
public const TYPE_OF_LETTER_SUBJECT_ACCESS_REQUEST = 'subject_access_request';
public const TYPE_OF_LETTER_DISCLOSURE_APPLICATION = 'disclosure_application';
// Review type options
public const REVIEW_TYPE_CASE_MERITS_ANALYSIS = 'case_merits_analysis';
public const REVIEW_TYPE_CHRONOLOGY = 'chronology';
// The number of hours prior to deletion that a reminder must be sent (currently set to the equivalent of 7 days)
public const DELETION_REMINDER_OFFSET_HOURS = 168;
// Firm Records Review Constants
public const FIRM_RECORDS_REVIEW_STATUS_AWAITING_RECORDS = 'awaiting_records';
public const FIRM_RECORDS_REVIEW_STATUS_AWAITING_RECORDS__LABEL = 'Awaiting records';
public const FIRM_RECORDS_REVIEW_STATUS_UPLOADED = 'uploaded';
public const FIRM_RECORDS_REVIEW_STATUS_UPLOADED__LABEL = 'Uploaded for firm review';
public const FIRM_RECORDS_REVIEW_STATUS_COMPLETE_PROCEED = 'complete_proceed';
public const FIRM_RECORDS_REVIEW_STATUS_COMPLETE_PROCEED__LABEL = 'Complete - proceed with services';
public const FIRM_RECORDS_REVIEW_STATUS_COMPLETE_NO_PROCEED = 'complete_no_proceed';
public const FIRM_RECORDS_REVIEW_STATUS_COMPLETE_NO_PROCEED__LABEL = 'Complete - do not proceed with services';
// Clinical Summary Unsorted Constants
public const CLINICAL_SUMMARY_UNSORTED_STATUS_AWAITING_CONCLUSION = 'awaiting_conclusion';
public const CLINICAL_SUMMARY_UNSORTED_STATUS_AWAITING_CONCLUSION__LABEL = 'Awaiting conclusion';
public const CLINICAL_SUMMARY_UNSORTED_STATUS_SUPPORTIVE = 'supportive';
public const CLINICAL_SUMMARY_UNSORTED_STATUS_SUPPORTIVE__LABEL = 'Supportive - proceed with services';
public const CLINICAL_SUMMARY_UNSORTED_STATUS_UNSUPPORTIVE = 'unsupportive';
public const CLINICAL_SUMMARY_UNSORTED_STATUS_UNSUPPORTIVE__LABEL = 'Unsupportive - do not proceed with services';
public const CLINICAL_SUMMARY_UNSORTED_STATUS_INCONCLUSIVE = 'inconclusive';
public const CLINICAL_SUMMARY_UNSORTED_STATUS_INCONCLUSIVE__LABEL = 'Inconclusive';
// Radiology migration statuses
public const MODERN_RADIOLOGY_MIGRATION_STATUS_PENDING = 'pending';
public const MODERN_RADIOLOGY_MIGRATION_STATUS_IN_PROGRESS = 'in_progress';
public const MODERN_RADIOLOGY_MIGRATION_STATUS_COMPLETE = 'complete';
// Migration is considered failed if a previously active disc is now in a failed state.
public const MODERN_RADIOLOGY_MIGRATION_STATUS_FAILED = 'failed';
// We use the skipped status to indicate projects that had no discs to migrate, or that were newly created and did not need to be migrated.
public const MODERN_RADIOLOGY_MIGRATION_STATUS_SKIPPED = 'skipped';
// Represents a matter accessible to the firm which is our client
public const TYPE_MATTER_FIRM = 'firm';
public const TYPE_MATTER_FIRM__LABEL = 'Matter';
// Represents a matter that is intended to disclosure records to a third-party.
public const TYPE_MATTER_DISCLOSURE = 'disclosure';
public const TYPE_MATTER_DISCLOSURE__LABEL = 'Disclosure';
/**
* @var int
*
* @Groups({"project_closure:read", "clinical_summary_matter:read"})
*
* @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
*
* @Groups({"project_closure:read", "clinical_summary_matter:read"})
*
* @ORM\Column(name="name", type="text")
*/
private $name;
/**
* @var string|null
*
* @ORM\Column(name="patient_name", type="string", nullable=true)
*/
private $patient_name;
/**
* @var string|null
*
* @ORM\Column(name="old_matter_reference", type="string", nullable=true)
*/
private $old_matter_reference;
/**
* @var int|null
*
* @ORM\Column(name="pages", type="integer", nullable=true)
*/
private $pages;
/**
* @var int
*
* @ORM\Column(name="status", type="integer", nullable=false)
*/
private $status;
/**
* @var string|null
*
* @Groups({"project_closure:read", "clinical_summary_matter:read"})
*
* @ORM\Column(name="client_reference", type="string", nullable=true)
*/
private $client_reference;
/**
* @var string|null
*
* @ORM\Column(name="billing_code", type="string", nullable=true)
*/
private $billing_code;
/**
* @var string|null
*
* @ORM\Column(name="background", type="text", nullable=true)
*/
private $background;
/**
* @var string|null
*
* @ORM\Column(name="reference", type="string", nullable=true)
*/
private $reference;
/**
* @var string|null
*
* @ORM\Column(name="millnet_id", type="string", nullable=true)
*/
private $millnet_id;
/**
* @var int|null
*
* @ORM\Column(name="hold_settled", type="integer", nullable=true)
*/
private $hold_settled;
/**
* @var DateTime|null
*
* @ORM\Column(name="date_created", type="datetime", nullable=true)
*/
private $date_created;
/**
* @var DateTime|null
*
* @ORM\Column(name="date_closed", type="datetime", nullable=true)
*/
private $date_closed;
/**
* @var DateTime|null
*
* @ORM\Column(name="forcedRenewalCreated", type="datetime", nullable=true)
*/
private ?DateTime $forcedRenewalCreated;
/**
* @var DateTime|null
*
* @ORM\Column(name="patient_date_of_birth", type="date", nullable=true)
*/
private $patient_date_of_birth;
/**
* @var int|null
*
* @ORM\Column(name="archive_status", type="integer", nullable=true)
*/
private $archive_status;
/**
* @var DateTime|null
*
* @ORM\Column(name="archive_status_updated", type="datetime", nullable=true)
*/
private $archive_status_updated;
/**
* @var int|null
*
* @ORM\Column(name="deleteStatus", type="integer", nullable=true)
*/
private $deleteStatus;
/**
* @var DateTime|null
*
* @ORM\Column(name="deleteStatusUpdated", type="datetime", nullable=true)
*/
private $deleteStatusUpdated;
/**
* @var DateTime|null
*
* @ORM\Column(name="future_deletion_date", type="datetime", nullable=true)
*/
private $future_deletion_date;
/**
* @var string
*
* @ORM\Column(name="slug", type="text")
*
* @Gedmo\Slug(fields={"name"}, updatable=false, separator="_")
*/
private $slug;
/**
* @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 string
*
* @ORM\Column(name="search_index", type="text", nullable=false)
*/
private $search_index;
/**
* @var int
*
* @ORM\Column(name="license_level", type="integer", nullable=false)
*/
private $license_level;
/**
* @var string|null
*
* @ORM\Column(name="documents_total_filesize", type="string", nullable=true)
*/
private $documents_total_filesize;
/**
* @var string|null
*
* @ORM\Column(name="active_discs_total_archive_filesize", type="string", nullable=true)
*/
private $active_discs_total_archive_filesize;
/**
* @var DateTime|null
*
* @ORM\Column(name="limitation_date", type="datetime", nullable=true)
*/
private $limitation_date;
/**
* @var int|null
*
* @ORM\Column(name="claim_category", type="integer", nullable=true)
*/
private $claim_category;
/**
* @var int|null
*
* @ORM\Column(name="estimated_claim_value", type="integer", nullable=true)
*/
private $estimated_claim_value;
/**
* @var string|null
*
* @ORM\Column(name="team", type="string", nullable=true)
*/
private $team;
/**
* @var string|null
*
* @ORM\Column(name="default_role", type="string", nullable=true)
*/
private $default_role;
/**
* UserNotifications disabled for this Project
*
* @var array|null
*
* @ORM\Column(name="disabled_notifications", type="array", nullable=true)
*/
private $disabled_notifications;
/**
* Whether to require the user to enter a password on downloading a document or folder
*
* @var bool
*
* @ORM\Column(name="require_password_on_download", type="boolean", options={"default"=false})
*/
private $require_password_on_download = false;
/**
* Whether to require the user to enter a password when accepting an invitation to join a project
*
* @var bool
*
* @ORM\Column(name="inviteUserMustAuthenticate", type="boolean", options={"default"=false})
*/
private $inviteUserMustAuthenticate = false;
/**
* @var string|null
*
* @ORM\Column(name="inviteUserPassword", type="string", nullable=true)
*/
private $inviteUserPassword;
/**
* @var string|null
*
* @ORM\Column(name="inviteUserContactName", type="string", nullable=true)
*/
private $inviteUserContactName;
/**
* @var string|null
*
* @ORM\Column(name="inviteUserContactEmail", type="string", nullable=true)
*/
private $inviteUserContactEmail;
/**
* @var PhoneNumber|null
*
* @ORM\Column(name="inviteUserContactPhoneNumber", type="phone_number", nullable=true)
*/
private $inviteUserContactPhoneNumber;
/**
* @var DateTime|null
*
* @ORM\Column(name="date_on_letter", type="datetime", nullable=true)
*/
private $date_on_letter;
/**
* @var string|null
*
* @ORM\Column(name="case_merits_analysis", type="string", nullable=true)
*/
private $case_merits_analysis;
/**
* @var string|null
*
* @ORM\Column(name="claimant_solicitor", type="string", nullable=true)
*/
private $claimant_solicitor;
/**
* @var string|null
*
* @ORM\Column(name="type_of_letter", type="string", nullable=true)
*/
private $type_of_letter;
/**
* @var string|null
*
* @ORM\Column(name="review_type", type="string", nullable=true)
*/
private $review_type;
/**
* @var DateTime|null
*
* @ORM\Column(name="experts_report_date", type="datetime", nullable=true)
*/
private $experts_report_date;
/**
* @var DateTime|null
*
* @ORM\Column(name="letter_of_response_and_expert_report_date", type="datetime", nullable=true)
*/
private $letter_of_response_and_expert_report_date;
/**
* @var DateTime|null
*
* @ORM\Column(name="letter_of_response_prepared_date", type="datetime", nullable=true)
*/
private $letter_of_response_prepared_date;
/**
* @var DateTime|null
*
* @ORM\Column(name="letter_of_response_sent_date", type="datetime", nullable=true)
*/
private $letter_of_response_sent_date;
/**
* @var DateTime|null
*
* @ORM\Column(name="dateDeleted", type="datetime", nullable=true)
*/
private $dateDeleted;
/**
* Determines if users with role Expert and Expert - View Only on a Project/Matter can see
* the Unsorted records folder on the Medical Records Screen.
*
* @var bool|null
*
* @ORM\Column(name="allowExpertViewUnsortedRecords", type="boolean", nullable=true)
*/
private $allowExpertViewUnsortedRecords;
/**
* @var ProjectDeletionReport
*
* @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\ProjectDeletionReport", inversedBy="project")
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="projectDeletionReport_id", referencedColumnName="id", unique=true)
* })
*/
private $projectDeletionReport;
/**
* @var Collection
*
* @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\Collection", inversedBy="projectMedicalRecords", cascade={"all"})
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="medicalRecordsCollection_id", referencedColumnName="id", unique=true)
* })
*/
private $medicalRecordsCollection;
/**
* @var Collection
*
* @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\Collection", inversedBy="projectUnsortedRecords", cascade={"all"})
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="unsortedRecordsCollection_id", referencedColumnName="id", unique=true)
* })
*/
private $unsortedRecordsCollection;
/**
* @var Collection
*
* @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\Collection", inversedBy="projectPrivate", cascade={"all"})
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="privateCollection_id", referencedColumnName="id", unique=true)
* })
*/
private $privateCollection;
/**
* This collection contains collections specific to a user,
* from which they are free to upload and download Documents.
*
* @var Collection
*
* @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\Collection", inversedBy="projectPrivateSandbox", cascade={"all"})
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="privateSandboxCollection_id", referencedColumnName="id", unique=true)
* })
*/
private $privateSandboxCollection;
/**
* @var MatterRequest
*
* @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\MatterRequest\MatterRequest", mappedBy="matter", cascade={"persist", "remove"})
*/
private $matterRequest;
/**
* @var ProjectClosure
*
* @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\ProjectClosure", mappedBy="project", cascade={"persist", "remove"})
*/
private $projectClosure;
/**
* @var DoctrineCollection
*
* @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\Document", mappedBy="project", orphanRemoval=true)
*/
private $documents;
/**
* @var DoctrineCollection
*
* @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\ProjectUser", mappedBy="project", cascade={"all"})
*/
private $projectUsers;
/**
* @var DoctrineCollection
*
* @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\Disc", mappedBy="project", cascade={"all"})
*
* @ORM\OrderBy({
* "created"="ASC"
* })
*/
private $discs;
/**
* @var DoctrineCollection
*
* @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\RecordsRequest", mappedBy="project", cascade={"all"})
*/
private $recordsRequests;
/**
* @var DoctrineCollection
*
* @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\BatchRequest", mappedBy="project", cascade={"all"})
*/
private $batchRequests;
/**
* @var DoctrineCollection
*
* @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\ChronologyRequest", mappedBy="project", cascade={"all"})
*/
private $chronologyRequests;
/**
* @var DoctrineCollection
*
* @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\AdditionalRequest", mappedBy="project", cascade={"all"})
*/
private $additionalRequests;
/**
* @var DoctrineCollection
*
* @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\SortingSession", mappedBy="project", cascade={"all"})
*/
private $sortingSessions;
/**
* @var DoctrineCollection
*
* @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\Patient", mappedBy="project", cascade={"all"})
*/
private $patients;
/**
* @var DoctrineCollection
*
* @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\Study", mappedBy="project", cascade={"all"})
*/
private $studies;
/**
* @var DoctrineCollection
*
* @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\Series", mappedBy="project", cascade={"all"})
*/
private $series;
/**
* @var DoctrineCollection
*
* @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\DiscImportSession", mappedBy="project", cascade={"all"})
*/
private $discImportSessions;
/**
* @var DoctrineCollection
*
* @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\MatterNote", mappedBy="project", cascade={"persist","remove"}, orphanRemoval=true)
*/
private $matterNotes;
/**
* @var DoctrineCollection
*
* @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\MatterCommunication", mappedBy="project", cascade={"all"})
*/
private $matterCommunications;
/**
* @var
*
* @Groups({"clinical_summary_matter:read"})
*
* @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\Account", inversedBy="projects")
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="account_id", referencedColumnName="id", nullable=false)
* })
*/
private $account;
/**
* @var User
*
* @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\User", inversedBy="managedProjects")
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="manager_id", referencedColumnName="id", nullable=true)
* })
*/
private $manager;
/**
* @var DoctrineCollection|null
*
* @ORM\ManyToMany(targetEntity="MedBrief\MSR\Entity\User")
*
* @ORM\JoinTable(
* name="project_additional_contacts",
* joinColumns={@ORM\JoinColumn(name="project_id", referencedColumnName="id", onDelete="CASCADE", nullable=true)},
* inverseJoinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE", nullable=true)}
* )
*/
private $additionalContacts;
/**
* @ORM\OneToMany(targetEntity=Instance::class, mappedBy="project")
*/
private $instances;
/**
* @ORM\Column(type="string", nullable=true)
*/
private ?string $firmRecordsReviewStatus = null;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?DateTime $firmRecordsReviewUpdated = null;
/**
* @ORM\Column(type="string", nullable=true)
*/
private ?string $clinicalSummaryUnsortedStatus = null;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?DateTime $clinicalSummaryUnsortedUpdated = null;
/**
* @ORM\OneToMany(targetEntity=InterpartyDisclosure::class, mappedBy="project", orphanRemoval=true, cascade={"persist", "remove"})
*
* @ORM\OrderBy({"id"="DESC"})
*/
private ?DoctrineCollection $interpartyDisclosures;
/**
* @ORM\Column(name="matterType", type="string", length=64, nullable=true)
*
*/
private ?string $matterType = self::MATTER_TYPE_CLINICAL_NEGLIGENCE;
/**
* @ORM\Column(type="string", nullable=true)
*/
private ?string $modernRadiologyMigrationStatus;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default"=false})
*/
private bool $useModernRadiology = false;
/**
* @ORM\Column(type="string", nullable=false, options={"default"=self::TYPE_MATTER_FIRM})
*/
private ?string $type = self::TYPE_MATTER_FIRM;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default"=false})
*/
private bool $hideFromInvoicing = false;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?DateTime $lastRenewalDate = null;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?DateTime $nextRenewalDate;
/**
* @ORM\Column(type="json", nullable=true)
*/
private ?array $renewalNotificationSent = [];
/**
* @ORM\OneToMany(targetEntity=MatterLicenceRenewalLog::class, mappedBy="project")
*/
private ?DoctrineCollection $matterLicenceRenewalLogs;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $permanentDeleteStatus = null;
/**
* @Groups({"clinical_summary_matter:read"})
*
* @ORM\OneToOne(targetEntity=ClinicalSummary::class, mappedBy="project", cascade={"persist", "remove"})
*/
private ?ClinicalSummary $clinicalSummary;
public function __construct()
{
// default status of INACTIVE
$this->setStatus(self::STATUS_INACTIVE);
$this->patients = new ArrayCollection();
$this->studies = new ArrayCollection();
$this->series = new ArrayCollection();
$this->discs = new ArrayCollection();
$this->recordsRequests = new ArrayCollection();
$this->batchRequests = new ArrayCollection();
$this->additionalRequests = new ArrayCollection();
$this->chronologyRequests = new ArrayCollection();
$this->sortingSessions = new ArrayCollection();
$this->matterNotes = new ArrayCollection();
$this->documents = new ArrayCollection();
$this->projectUsers = new ArrayCollection();
$this->discImportSessions = new ArrayCollection();
$this->matterCommunications = new ArrayCollection();
$this->instances = new ArrayCollection();
$this->interpartyDisclosures = new ArrayCollection();
$this->disclosureSources = new ArrayCollection();
$this->matterLicenceRenewalLogs = new ArrayCollection();
$this->medicalRecordsCollection = new Collection();
$this->medicalRecordsCollection
->setName(Collection::DISPLAY_NAME_MEDICAL_RECORDS)
->setProjectMedicalRecords($this)
;
$this->unsortedRecordsCollection = new Collection();
$this->unsortedRecordsCollection
->setName(Collection::DISPLAY_NAME_UNSORTED_RECORDS)
->setProjectUnsortedRecords($this)
;
// default the date created for matters to the current date
$this->setDateCreated(new DateTime());
// All matters default to the standard license
$this->setLicenseLevel(self::LICENSE_LEVEL_STANDARD);
$this->require_password_on_download = false;
$this->setInviteUserMustAuthenticate(false);
// Set this in the constructor so it only applies to new matters
$this->setModernRadiologyMigrationStatus(self::MODERN_RADIOLOGY_MIGRATION_STATUS_SKIPPED);
$this->matterLicenceRenewalLogs = new ArrayCollection();
$this->additionalContacts = new ArrayCollection();
}
public function __toString()
{
return $this->getName();
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @param string $name
*
* @return Project
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param int $pages
*
* @return Project
*/
public function setPages($pages)
{
$this->pages = $pages;
return $this;
}
/**
* @return int
*/
public function getPages()
{
return $this->pages;
}
/**
* @param Account|null $account
*
* @return Project
*/
public function setAccount(?Account $account = null)
{
$this->account = $account;
return $this;
}
/**
* @return Account
*/
public function getAccount()
{
return $this->account;
}
/**
* @param string $slug
*
* @return Project
*/
public function setSlug($slug)
{
$this->slug = $slug;
return $this;
}
/**
* @return string
*/
public function getSlug()
{
return $this->slug;
}
/**
* @param DateTime $created
*
* @return Project
*/
public function setCreated($created)
{
$this->created = $created;
return $this;
}
/**
* @return DateTime
*/
public function getCreated()
{
return $this->created;
}
/**
* @param DateTime $updated
*
* @return Project
*/
public function setUpdated($updated)
{
$this->updated = $updated;
return $this;
}
/**
* @return DateTime
*/
public function getUpdated()
{
return $this->updated;
}
/**
* @param Document $documents
*
* @return Project
*/
public function addDocument(Document $documents)
{
$this->documents[] = $documents;
return $this;
}
/**
* @param Document $documents
*/
public function removeDocument(Document $documents)
{
$this->documents->removeElement($documents);
}
/**
* @return DoctrineCollection|Document[]
*/
public function getDocuments()
{
return $this->documents;
}
/**
* @param Disc $disc
*
* @return Project
*/
public function addDisc(Disc $disc)
{
if (!$this->discs->contains($disc)) {
$this->discs[] = $disc;
}
return $this;
}
/**
* @param Disc $discs
*
* @return Project
*/
public function removeDisc(Disc $discs)
{
$this->discs->removeElement($discs);
return $this;
}
/**
* @return DoctrineCollection|Disc[]
*/
public function getDiscs()
{
return $this->discs;
}
/**
* @return bool
*/
public function isAllDiscsPendingUpload(): bool
{
foreach ($this->getDiscs() as $disc) {
if ($disc->getStatus() !== Disc::STATUS_PENDING_UPLOAD) {
return false;
}
}
return true;
}
/**
* Gets Discs for a project with a specific status.
*
* @param mixed $status
*
* @return ArrayCollection | null
*/
public function getDiscsByStatus($status)
{
return $this->discs->filter(function (Disc $disc) use ($status) {
return $disc->getStatus() === $status;
});
}
/**
* Get all active Discs for a Project
*
* @return ArrayCollection|null
*/
public function getActiveDiscs()
{
return $this->getDiscsByStatus(Disc::STATUS_ACTIVE);
}
/**
* Gets all failed Discs for a Project
*
* @return ArrayCollection|null
*/
public function getFailedDiscs()
{
return $this->getDiscs()->filter(function (Disc $disc) {
// return true if disc failed, however exclude discs with status failed virus
// Normally we don't need to check for deletedAt, as the softdeletable filter filters it out,
// but in the case of disclosures, we switch this filter off, to avoid a broken relationship issue.
return $disc->isFailed([Disc::STATUS_FAILED_VIRUS]) && $disc->getDeletedAt() === null;
});
}
/**
* @param int $status
*
* @return Project
*/
public function setStatus($status)
{
$this->status = $status;
return $this;
}
/**
* @return int
*/
public function getStatus()
{
return $this->status;
}
/**
* Returns true if the Project is inactive.
*
* @return bool
*/
public function isInactive()
{
return $this->getStatus() === self::STATUS_INACTIVE;
}
/**
* @param string $clientReference
*
* @return Project
*/
public function setClientReference($clientReference)
{
$this->client_reference = $clientReference;
// Update the associated matter request as well, if it exists, and if the values are different,
// to avoid a recursive loop.
if ($this->getMatterRequest() && $this->getMatterRequest()->getMatterReference() != $this->client_reference) {
$this->getMatterRequest()->setMatterReference($this->client_reference);
}
return $this;
}
/**
* @Groups({"project_closure:read"})
*
* @return string
*/
public function getClientReference()
{
return $this->client_reference;
}
/**
* @param string $reference
*
* @return Project
*/
public function setReference($reference)
{
$this->reference = $reference;
return $this;
}
/**
* @return string
*/
public function getReference()
{
return $this->reference;
}
/**
* @param Patient $patients
*
* @return Project
*/
public function addPatient(Patient $patients)
{
$this->patients[] = $patients;
return $this;
}
/**
* @param Patient $patients
*/
public function removePatient(Patient $patients)
{
$this->patients->removeElement($patients);
}
/**
* @return DoctrineCollection|RadiologyPatient[]
*/
public function getPatients()
{
return $this->patients;
}
/**
* @param Study $studies
*
* @return Project
*/
public function addStudy(Study $studies)
{
$this->studies[] = $studies;
return $this;
}
/**
* @param Study $studies
*/
public function removeStudy(Study $studies)
{
$this->studies->removeElement($studies);
}
/**
* @return DoctrineCollection|Study[]
*/
public function getStudies()
{
return $this->studies;
}
/**
* Get Studies with active Discs
*
* @return ArrayCollection|null
*/
public function getStudiesWithActiveDiscs()
{
return $this->getStudies()->filter(function (Study $study) {
return $study->getDiscs()->filter(function (Disc $disc) {
// Normally we don't need to check for deletedAt, as the softdeletable filter filters it out,
// but in the case of disclosures, we switch this filter off, to avoid a broken relationship issue.
// Due to the many-to-many relation between Disc and Study, the check for deletedAt isn't ACTUALLY needed,
// but for data integrity, we do the check anyway.
return $disc->isActive() && $disc->getDeletedAt() === null;
})->count();
});
}
/**
* @param Series $series
*
* @return Project
*/
public function addSeries(Series $series)
{
$this->series[] = $series;
return $this;
}
/**
* @param Series $series
*/
public function removeSeries(Series $series)
{
$this->series->removeElement($series);
}
/**
* @return DoctrineCollection|Series[]
*/
public function getSeries()
{
return $this->series;
}
/**
* Returns the MedBrief Matter reference number which is essentially the ClientReference
* of the Project padded with zeros to six figures
*
* @return string
*/
public function getReferenceNumber()
{
return str_pad($this->getClientReference(), 6, '0', STR_PAD_LEFT);
}
/**
* @param DateTime $dateCreated
*
* @return Project
*/
public function setDateCreated($dateCreated)
{
$this->date_created = $dateCreated;
return $this;
}
/**
* @return DateTime
*/
public function getDateCreated()
{
return $this->date_created;
}
/**
* @param DateTime $patientDateOfBirth
*
* @throws Exception
*
* @return Project
*/
public function setPatientDateOfBirth($patientDateOfBirth)
{
$this->patient_date_of_birth = $patientDateOfBirth;
// Update the matter request's first patient's date of birth, if different from matter date of birth.
if ($this->getMatterRequest() && $this->getMatterRequest()->getPatients()->count() > 0) {
/** @var Patient $firstPatient */
$firstPatient = $this->getMatterRequest()->getPatients()->first();
if ($firstPatient->getDateOfBirth() != $this->patient_date_of_birth) {
$dateOfBirthImmutable = null;
if ($this->patient_date_of_birth instanceof DateTime) {
$dateOfBirthImmutable = new \DateTimeImmutable($this->patient_date_of_birth->format('Y-m-d'));
}
$firstPatient->setDateOfBirth($dateOfBirthImmutable);
}
}
return $this;
}
/**
* @return DateTime
*/
public function getPatientDateOfBirth()
{
return $this->patient_date_of_birth;
}
/**
* @param User|null $manager
*
* @return Project
*/
public function setManager(?User $manager = null)
{
$this->manager = $manager;
// Update the associated matter request as well, if it exists, and if the values are different,
// to avoid a recursive loop.
if ($manager && $this->getMatterRequest() && $this->getMatterRequest()->getManager() != $this->manager) {
$this->getMatterRequest()->setManager($this->manager);
}
return $this;
}
/**
* @return Project
*/
public function unsetManager()
{
$this->manager = null;
return $this;
}
/**
* retrieves the manager of the project
*
* @return User|null
*/
public function getManager(): ?User
{
try {
// If the manager is a Proxy, we need to load it to ensure it is fully initialized.
if ($this->manager instanceof Proxy) {
$this->manager->__load();
}
return $this->manager;
} catch (EntityNotFoundException) {
// If the manager is not found (has been soft deleted), return null.
return null;
}
}
/**
* Returns additional contacts for a matter
*
* @return DoctrineCollection|null
*/
public function getAdditionalContacts(): ?DoctrineCollection
{
return $this->additionalContacts;
}
/**
* Sets additional contacts for a matter
*
* @param DoctrineCollection|null $additionalContacts
*
* @return self
*/
public function setAdditionalContacts(?DoctrineCollection $additionalContacts): self
{
$this->additionalContacts = $additionalContacts ?: new ArrayCollection();
return $this;
}
/**
* @param RecordsRequest $recordsRequests
*
* @return Project
*/
public function addRecordsRequest(RecordsRequest $recordsRequests)
{
$this->recordsRequests[] = $recordsRequests;
return $this;
}
/**
* @param RecordsRequest $recordsRequests
*/
public function removeRecordsRequest(RecordsRequest $recordsRequests)
{
$this->recordsRequests->removeElement($recordsRequests);
}
/**
* @return DoctrineCollection|RecordsRequest[]
*/
public function getRecordsRequests()
{
return $this->recordsRequests;
}
/**
* @return array
*/
public function getRecordsRequestIdsArray(): array
{
// Map the collection of records requests to extract each's ID, then convert it to an array
return $this->recordsRequests->map(function (RecordsRequest $recordsRequest) {
return $recordsRequest->getId();
})->toArray();
}
/**
* Retrieves the counts for RecordsRequests grouped by
* their serviceRequest status.
*
* @param mixed $uninvoicedOnly
*
* @return array
*/
public function getRecordsRequestsCountByServiceRequestStatus($uninvoicedOnly = true)
{
return $this->getServiceableCountsByStatus($this->getRecordsRequests()->toArray(), $uninvoicedOnly);
}
/**
* @param Collection|null $medicalRecordsCollection
*
* @return Project
*/
public function setMedicalRecordsCollection(?Collection $medicalRecordsCollection = null)
{
$this->medicalRecordsCollection = $medicalRecordsCollection;
return $this;
}
/**
* @return Collection
*/
public function getMedicalRecordsCollection()
{
return $this->medicalRecordsCollection;
}
/**
* @param string $billingCode
*
* @return Project
*/
public function setBillingCode($billingCode)
{
$this->billing_code = $billingCode;
// Update the associated matter request as well, if it exists, and if the values are different,
// to avoid a recursive loop.
if ($this->getMatterRequest() && $this->getMatterRequest()->getBillingCode() != $this->billing_code) {
$this->getMatterRequest()->setBillingCode($this->billing_code);
}
return $this;
}
/**
* @return string
*/
public function getBillingCode()
{
return $this->billing_code;
}
/**
* @param DateTime $deletedAt
*
* @return Project
*/
public function setDeletedAt($deletedAt)
{
$this->deletedAt = $deletedAt;
return $this;
}
/**
* @return DateTime
*/
public function getDeletedAt()
{
return $this->deletedAt;
}
/**
* Add discImportSession
*
* @param DiscImportSession $discImportSession
*
* @return Project
*/
public function addDiscImportSession(DiscImportSession $discImportSession)
{
$this->discImportSessions[] = $discImportSession;
return $this;
}
/**
* Remove discImportSession
*
* @param DiscImportSession $discImportSession
*/
public function removeDiscImportSession(DiscImportSession $discImportSession)
{
$this->discImportSessions->removeElement($discImportSession);
}
/**
* @return DoctrineCollection
*/
public function getDiscImportSessions()
{
return $this->discImportSessions;
}
/**
* @param string $patientName
*
* @return Project
*/
public function setPatientName($patientName)
{
$this->patient_name = $patientName;
return $this;
}
/**
* @return string
*/
public function getPatientName()
{
return $this->patient_name;
}
/**
* @param string $oldMatterReference
*
* @return Project
*/
public function setOldMatterReference($oldMatterReference)
{
$this->old_matter_reference = $oldMatterReference;
return $this;
}
/**
* @return string
*/
public function getOldMatterReference()
{
return $this->old_matter_reference;
}
/**
* @param string $millnetId
*
* @return Project
*/
public function setMillnetId($millnetId)
{
$this->millnet_id = $millnetId;
return $this;
}
/**
* @return string
*/
public function getMillnetId()
{
return $this->millnet_id;
}
/**
* @param int $holdSettled
*
* @return Project
*/
public function setHoldSettled($holdSettled)
{
$this->hold_settled = $holdSettled;
return $this;
}
/**
* @return int
*/
public function getHoldSettled()
{
return $this->hold_settled;
}
/**
* @param DateTime $dateClosed
*
* @return Project
*/
public function setDateClosed($dateClosed)
{
$this->date_closed = $dateClosed;
return $this;
}
/**
* @return DateTime
*/
public function getDateClosed()
{
return $this->date_closed;
}
/**
* @param DateTime|null $forcedRenewalCreated
*
* @return Project
*/
public function setForcedRenewalCreated(?DateTime $forcedRenewalCreated = null)
{
$this->forcedRenewalCreated = $forcedRenewalCreated;
return $this;
}
/**
* @return DateTime|null
*/
public function getForcedRenewalCreated(): ?DateTime
{
return $this->forcedRenewalCreated;
}
/**
* @param string $searchIndex
*
* @return Project
*/
public function setSearchIndex($searchIndex)
{
$this->search_index = $searchIndex;
return $this;
}
/**
* @return string
*/
public function getSearchIndex()
{
return $this->search_index;
}
/**
* Updates the Search Index field with internal data. The Search Index Field
* provides an easy way to perform a 'like' query for a generalised search.
*
* @ORM\PrePersist
*
* @ORM\PreUpdate
*/
public function updateSearchIndex()
{
$searchIndex
= $this->getName()
. ' '
. $this->getClientReference();
$this->setSearchIndex($searchIndex);
}
/**
* Set licenseLevel
*
* @param int $licenseLevel
*
* @return Project
*/
public function setLicenseLevel($licenseLevel)
{
$this->license_level = $licenseLevel;
return $this;
}
/**
* Get licenseLevel
*
* @return int
*/
public function getLicenseLevel()
{
return $this->license_level;
}
/**
* Returns an array of permitted values for the license level field and their
* associated labels,
*
* @return array
*/
public static function getILicenseLevelOptions()
{
return [
self::LICENSE_LEVEL_BASIC => 'Basic',
self::LICENSE_LEVEL_STANDARD => 'Standard',
self::LICENSE_LEVEL_PROFESSIONAL => 'Professional',
self::LICENSE_LEVEL_PREMIUM => 'Premium',
];
}
/**
* Returns a human-readable version of the licence level
*
* @return string
*/
public function getLicenseLevelName()
{
$options = self::getILicenseLevelOptions();
return
$options[$this->getLicenseLevel()] ?? $this->getLicenseLevel();
}
/**
* Returns the Medical Records Collection for this project in a JSTree
* formatted node tree. Notably, this structure will not include Documents
* under the top most node that also exist in sub nodes.
*
* @param string $replacementRootNodeText
* @param array $additionalLiAttributes Additional attributes for <li> elements
*
* @return array
*/
public function getMedicalRecordsAsJsTreeFormattedTree($replacementRootNodeText = null, $additionalLiAttributes = [])
{
$medicalRecordsCollection = $this->getMedicalRecordsCollection();
if ($medicalRecordsCollection === null) {
// Not sure why this Project has no MR Collection so let's create a blank one
$this->medicalRecordsCollection = new Collection();
$this->medicalRecordsCollection
->setName(Collection::DISPLAY_NAME_MEDICAL_RECORDS)
->setProjectMedicalRecords($this)
;
}
// first, grab the node with no children
$node = $this->getMedicalRecordsCollection()
->getJsTreeFormattedNode(
$replacementRootNodeText,
false,
false,
$additionalLiAttributes
)
;
// set the children sub array, ready for populating
$node['children'] = [];
// order the children alphabetically
$criteria = Criteria::create()
->orderBy(['name' => Criteria::ASC])
;
// add all the sub collections with all their children and document children
/** @var Collection $childCollection */
foreach ($this->getMedicalRecordsCollection()->getChildren()->matching($criteria) as $childCollection) {
$node['children'][] = $childCollection->getJsTreeFormattedNode(null, true, true, $additionalLiAttributes);
}
// all document children also get a collection id sent through, so we know what collection
// the document belongs to
$additionalLiAttributes['data-collection-id'] = $this->medicalRecordsCollection->getId();
// loop through all the document children on this main collection
foreach ($this->getMedicalRecordsCollection()->getDocuments() as $childDocument) {
// Only if the Document is assigned to one collection inside the MedicalRecords collection (this one)...
$collectionCount = $childDocument->getCollections()->filter(function (Collection $collection) {
return $this->getMedicalRecordsCollection()->containsCollectionRecursive($collection);
})->count();
// ... do we include it here, else the Document will show twice in Medical Records.
if ($collectionCount === 1) {
$node['children'][] = $childDocument->getJsTreeFormattedNode(null, $additionalLiAttributes);
}
}
return $node;
}
/**
* Returns the Unsorted Records Collection for this project in a JSTree
* formatted node tree. Notably, this structure will not include Documents
* under the top most node that also exist in sub nodes.
*
* @param string $replacementRootNodeText
* @param array $additionalLiAttributes Additional attributes for <li> elements
*
* @return array
*/
public function getUnsortedRecordsAsJsTreeFormattedTree($replacementRootNodeText = null, $additionalLiAttributes = [])
{
// first, grab the node with no children
$node = $this->getUnsortedRecordsCollection()->getJsTreeFormattedNode(
$replacementRootNodeText,
false,
false,
$additionalLiAttributes
);
// set the children sub array, ready for populating
$node['children'] = [];
// order the children alphabetically
$criteria = Criteria::create()
->orderBy(['name' => Criteria::ASC])
;
// add all the sub collections with all their children and document children
foreach ($this->getUnsortedRecordsCollection()->getChildren()->matching($criteria) as $childCollection) {
$node['children'][] = $childCollection->getJsTreeFormattedNode(null, true, true, $additionalLiAttributes);
}
// all document children also get a collection id sent through, so we know what collection
// the document belongs to
$additionalLiAttributes['data-collection-id'] = $this->unsortedRecordsCollection->getId();
// loop through all the document children on this main collection
foreach ($this->getUnsortedRecordsCollection()->getDocuments() as $childDocument) {
// Only if the Document is assigned to one collection inside the MedicalRecords collection (this one)...
$collectionCount = $childDocument->getCollections()->filter(function (Collection $collection) {
return $this->getUnsortedRecordsCollection()->containsCollectionRecursive($collection);
})->count();
// ... do we include it here, else the Document will show twice in Medical Records.
if ($collectionCount === 1) {
$node['children'][] = $childDocument->getJsTreeFormattedNode(null, $additionalLiAttributes);
}
}
return $node;
}
/**
* Returns the Medical Records Collection for this project in a JSTree
* formatted node tree. Notably, this structure will not include Documents
* under the top most node that also exist in sub nodes.
*
* @param string $replacementRootNodeText
* @param array $additionalLiAttributes
*
* @return array
*/
public function getPrivateCollectionAsJsTreeFormattedTree($replacementRootNodeText = null, $additionalLiAttributes = [])
{
// first, grab the node with no children
// NB! additional attributes MUST be set so that the outer node in the
// private tree has the data-group "private" or copy and move rules
// will not work!
$node = $this->getPrivateCollection()->getJsTreeFormattedNode($replacementRootNodeText, false, false, $additionalLiAttributes);
// set the children sub array, ready for populating
$node['children'] = [];
// order the children alphabetically
$criteria = Criteria::create()
->orderBy(['name' => Criteria::ASC])
;
// add all the sub collections with all their children and document children
foreach ($this->getPrivateCollection()->getChildren()->matching($criteria) as $childCollection) {
$node['children'][] = $childCollection->getJsTreeFormattedNode(null, true, true, $additionalLiAttributes);
}
// all document children also get a collection id sent through, so we know what collection
// the document belongs to
$additionalLiAttributes['data-collection-id'] = $this->getId();
// loop through all the document children on this main collection
foreach ($this->getPrivateCollection()->getDocuments() as $childDocument) {
// Only if the Document is assigned to one collection inside the Private collection (this one)...
$collectionCount = $childDocument->getCollections()->filter(function (Collection $collection) {
return $this->getPrivateCollection()->containsCollectionRecursive($collection);
})->count();
// ... do we include it here, else the Document will show twice in Medical Records.
if ($collectionCount === 1) {
$node['children'][] = $childDocument->getJsTreeFormattedNode(null, $additionalLiAttributes);
}
}
return $node;
}
/**
* Add projectUser
*
* @param ProjectUser $projectUser
*
* @return Project
*/
public function addProjectUser(ProjectUser $projectUser)
{
$this->projectUsers[] = $projectUser;
return $this;
}
/**
* Remove projectUser
*
* @param ProjectUser $projectUser
*/
public function removeProjectUser(ProjectUser $projectUser)
{
$this->projectUsers->removeElement($projectUser);
}
/**
* Get projectUsers
*
* @return DoctrineCollection|ProjectUser[]
*/
public function getProjectUsers()
{
return $this->projectUsers;
}
/**
* Set privateCollection
*
* @param Collection|null $privateCollection
*
* @return Project
*/
public function setPrivateCollection(?Collection $privateCollection = null)
{
$this->privateCollection = $privateCollection;
return $this;
}
/**
* Get privateCollection
*
* @return Collection
*/
public function getPrivateCollection()
{
return $this->privateCollection;
}
/**
* Set background
*
* @param string $background
*
* @return Project
*/
public function setBackground($background)
{
$this->background = $background;
// Update the associated matter request as well, if it exists, and if the values are different,
// to avoid a recursive loop.
if ($background !== null && $this->getMatterRequest() && $this->getMatterRequest()->getBackground() != $this->background) {
$this->getMatterRequest()->setBackground($this->background);
}
return $this;
}
/**
* Get background
*
* @return string
*/
public function getBackground()
{
return $this->background;
}
/**
* Increases the total documents file size for this Project.
*
* This value should exclude DICOM files.
*
* @param mixed $filesize
*
* @return Project
*/
public function increaseDocumentsTotalFilesize($filesize)
{
$this->documents_total_filesize += $filesize;
return $this;
}
/**
* Decreases the total documents file size for this Project.
*
* This value should exclude DICOM files.
*
* @param mixed $filesize
*
* @return Project
*/
public function decreaseDocumentsTotalFilesize($filesize)
{
$this->documents_total_filesize -= $filesize;
return $this;
}
/**
* Get documentsTotalFilesize
*
* @return string
*/
public function getDocumentsTotalFilesize()
{
return $this->documents_total_filesize;
}
/**
* Set documentsTotalFilesize
*
* @param mixed $documents_total_filesize
*
* @return Project
*/
public function setDocumentsTotalFilesize($documents_total_filesize)
{
$this->documents_total_filesize = $documents_total_filesize;
return $this;
}
/**
* Increases the total file size in bytes of active disc archives for
* this project.
*
* @param int $filesize
*
* @return Project
*/
public function increaseActiveDiscsTotalArchiveFilesize($filesize)
{
$this->active_discs_total_archive_filesize += $filesize;
return $this;
}
/**
* Decreases the total file size in bytes of active disc archives for
* this project.
*
* @param int $filesize
*
* @return Project
*/
public function decreaseActiveDiscsTotalArchiveFilesize($filesize)
{
$this->active_discs_total_archive_filesize -= $filesize;
return $this;
}
/**
* Get activeDiscsTotalArchiveFilesize
*
* @return string
*/
public function getActiveDiscsTotalArchiveFilesize()
{
return $this->active_discs_total_archive_filesize;
}
/**
* Set activeDiscsTotalArchiveFilesize
*
* @param mixed $active_discs_total_archive_filesize
*
* @return Project
*/
public function setActiveDiscsTotalArchiveFilesize($active_discs_total_archive_filesize)
{
$this->active_discs_total_archive_filesize = $active_discs_total_archive_filesize;
return $this;
}
/**
* Get limitationDate
*
* @return DateTime
*/
public function getLimitationDate()
{
return $this->limitation_date;
}
/**
* Set limitationDate
*
* @param DateTime $limitationDate
*
* @return Project
*/
public function setLimitationDate($limitationDate)
{
$this->limitation_date = $limitationDate;
// Update the associated matter request as well, if it exists, and if the values are different,
// to avoid a recursive loop.
if ($this->getMatterRequest() && $this->getMatterRequest()->getLimitationDate() != $this->limitation_date) {
$this->getMatterRequest()->setLimitationDate($this->limitation_date);
}
return $this;
}
/**
* Set claimCategory
*
* @param int $claimCategory
*
* @return Project
*/
public function setClaimCategory($claimCategory)
{
$this->claim_category = $claimCategory;
// Update the associated matter request as well, if it exists, and if the values are different,
// to avoid a recursive loop.
if ($this->getMatterRequest() && $this->getMatterRequest()->getClaimCategory() != $this->claim_category) {
$this->getMatterRequest()->setClaimCategory($this->claim_category);
}
return $this;
}
/**
* Get claimCategory
*
* @return int
*/
public function getClaimCategory()
{
return $this->claim_category;
}
/**
* Returns an array of permitted values for the claim category field and their
* associated labels.
*
* @return array
*/
public static function getClaimCategoryOptions()
{
$claimCategoryOptions = self::getConstantsWithLabelsAsChoices('CLAIM_CATEGORY');
ksort($claimCategoryOptions);
return array_flip($claimCategoryOptions);
}
/**
* Returns an array of permitted values for the claim category field and their
* associated labels, in a verbose array structure.
*
* @return array
*/
public static function getClaimCategoryOptionsWithLabels()
{
return self::getConstantsWithLabels('CLAIM_CATEGORY');
}
/**
* Returns a human-readable version of the claim_category
*
* @return string
*/
public function getClaimCategoryName()
{
$options = self::getClaimCategoryOptions();
return $options[$this->getClaimCategory()] ?? 'Other';
}
/**
* Returns an array of Claim Categories that are Birth Injury cases.
*
* @TODO: We should update how the constants are handled to include this
* there.
*
* @return array|int[]
*/
public static function getBirthInjuryClaimCategories(): array
{
return [
self::CLAIM_CATEGORY_OBSTETRICS_RELATING_TO_CHILD,
self::CLAIM_CATEGORY_OBSTETRICS_BRAIN_INJURY_HIE,
self::CLAIM_CATEGORY_OBSTETRICS_GBS_SEPSIS,
self::CLAIM_CATEGORY_OBSTETRICS_KERNICTERUS,
self::CLAIM_CATEGORY_OBSTETRICS_NEONATAL_DEATH,
self::CLAIM_CATEGORY_OBSTETRICS_OTHER_CHILD_INJURY,
self::CLAIM_CATEGORY_OBSTETRICS_SHOULDER_DYSTOCIA,
self::CLAIM_CATEGORY_OBSTETRICS_STILLBIRTH,
self::CLAIM_CATEGORY_OBSTETRICS_WRONGFUL_BIRTH,
];
}
/**
* Set estimatedClaimValue
*
* @param int $estimatedClaimValue
*
* @return Project
*/
public function setEstimatedClaimValue($estimatedClaimValue)
{
$this->estimated_claim_value = $estimatedClaimValue;
// Update the associated matter request as well, if it exists, and if the values are different,
// to avoid a recursive loop.
if ($this->getMatterRequest() && $this->getMatterRequest()->getClaimValue() != $this->estimated_claim_value) {
$this->getMatterRequest()->setClaimValue($this->estimated_claim_value);
}
return $this;
}
/**
* Get estimatedClaimValue
*
* @return int
*/
public function getEstimatedClaimValue()
{
return $this->estimated_claim_value;
}
/**
* Returns an array of permitted values for the estimated claim value field and their
* associated labels.
*
* @return array
*/
public static function getEstimatedClaimValueOptions()
{
return [
self::ESTIMATED_CLAIM_VALUE_0_25000 => self::ESTIMATED_CLAIM_VALUE_0_25000__LABEL,
self::ESTIMATED_CLAIM_VALUE_25001_50000 => self::ESTIMATED_CLAIM_VALUE_25001_50000__LABEL,
self::ESTIMATED_CLAIM_VALUE_50001_100000 => self::ESTIMATED_CLAIM_VALUE_50001_100000__LABEL,
self::ESTIMATED_CLAIM_VALUE_100001_250000 => self::ESTIMATED_CLAIM_VALUE_100001_250000__LABEL,
self::ESTIMATED_CLAIM_VALUE_250001_500000 => self::ESTIMATED_CLAIM_VALUE_250001_500000__LABEL,
self::ESTIMATED_CLAIM_VALUE_500001_1000000 => self::ESTIMATED_CLAIM_VALUE_500001_1000000__LABEL,
self::ESTIMATED_CLAIM_VALUE_1000001 => self::ESTIMATED_CLAIM_VALUE_1000001__LABEL,
];
}
/**
* Returns an array of permitted values for the estimated claim value field and their
* associated labels, in a verbose array structure.
*
* @return array
*/
public static function getEstimatedClaimValueOptionsWithLabels()
{
return self::getConstantsWithLabels('ESTIMATED_CLAIM_VALUE');
}
/**
* Returns a human-readable version of the estimated_claim_value
*
* @return string
*/
public function getEstimatedClaimValueName()
{
$options = self::getEstimatedClaimValueOptions();
return $options[$this->getEstimatedClaimValue()] ?? $this->getEstimatedClaimValue();
}
/**
* Set archiveStatus
*
* @param int|null $archiveStatus
*
* @return Project
*/
public function setArchiveStatus(?int $archiveStatus = null)
{
$this->archive_status = $archiveStatus;
// DisclosureProjects are directly associated with their Parent Project
// As a Project may have multiple DisclosureTargets/Projects, update their archiveStatus as well
// To ensure they are included in the archive logic
foreach ($this->getInterpartyDisclosures() as $disclosure) {
if ($disclosure->getDisclosureTarget() !== null) {
$disclosure->getDisclosureTarget()->setArchiveStatus($archiveStatus);
}
}
return $this;
}
/**
* Get archiveStatus
*
* @return int
*/
public function getArchiveStatus()
{
return $this->archive_status;
}
/**
* Set archiveStatusUpdated
*
* @param DateTime|null $archiveStatusUpdated
*
* @return Project
*/
public function setArchiveStatusUpdated(?DateTime $archiveStatusUpdated = null)
{
$this->archive_status_updated = $archiveStatusUpdated;
// DisclosureProjects are directly associated with their Parent Project
// As a Project may have multiple DisclosureTargets, update their archiveStatusUpdated as well
// To ensure they are included in the archive logic
foreach ($this->getInterpartyDisclosures() as $disclosure) {
if ($disclosure->getDisclosureTarget() !== null) {
$disclosure->getDisclosureTarget()->setArchiveStatusUpdated($archiveStatusUpdated);
}
}
return $this;
}
/**
* Get archiveStatusUpdated
*
* @return DateTime
*/
public function getArchiveStatusUpdated()
{
return $this->archive_status_updated;
}
/**
* Set futureDeletionDate
*
* @param DateTime $futureDeletionDate
*
* @return Project
*/
public function setFutureDeletionDate($futureDeletionDate)
{
$this->future_deletion_date = $futureDeletionDate;
return $this;
}
/**
* Get futureDeletionDate
*
* @return DateTime
*/
public function getFutureDeletionDate()
{
return $this->future_deletion_date;
}
/**
* Set privateSandboxCollection
*
* @param Collection|null $privateSandboxCollection
*
* @return Project
*/
public function setPrivateSandboxCollection(?Collection $privateSandboxCollection = null)
{
$this->privateSandboxCollection = $privateSandboxCollection;
return $this;
}
/**
* Get privateSandboxCollection
*
* @return Collection
*/
public function getPrivateSandboxCollection()
{
// If no privateSandboxCollection exists, create a new one.
// We do this here, instead of the constructor, so we only create a new
// Collection entity if none already exists.
if ($this->privateSandboxCollection === null) {
$privateSandboxCollection = new Collection();
$privateSandboxCollection->setName('Private Sandbox Folders');
$this->setPrivateSandboxCollection($privateSandboxCollection);
}
return $this->privateSandboxCollection;
}
/**
* Returns the PrivateSandboxCollection for this project in a JSTree
* formatted node tree. Notably, this structure will not include Documents
* under the top most node that also exist in sub nodes.
*
* @param string $replacementRootNodeText
* @param array $additionalLiAttributes
*
* @return array
*/
public function getPrivateSandboxCollectionAsJsTreeFormattedTree($replacementRootNodeText = null, $additionalLiAttributes = [])
{
$node = $this->getPrivateSandboxCollection()->getJsTreeFormattedNode($replacementRootNodeText, false, false, $additionalLiAttributes);
// set the children sub array, ready for populating
$node['children'] = [];
// order the children alphabetically
$criteria = Criteria::create()
->orderBy(['name' => Criteria::ASC])
;
// add all the sub collections with all their children and document children
foreach ($this->getPrivateSandboxCollection()->getChildren()->matching($criteria) as $childCollection) {
$node['children'][] = $childCollection->getJsTreeFormattedNode(null, true, true, $additionalLiAttributes);
}
// all document children also get a collection id sent through, so we know what collection
// the document belongs to
$additionalLiAttributes['data-collection-id'] = $this->getId();
// loop through all the document children on this main collection
foreach ($this->getPrivateSandboxCollection()->getDocuments() as $childDocument) {
// Only if the Document is assigned to one collection inside the Private Sandbox collection (this one)...
$collectionCount = $childDocument->getCollections()->filter(function (Collection $collection) {
return $this->getPrivateSandboxCollection()->containsCollectionRecursive($collection);
})->count();
// ... do we include it here, else the Document will show twice in Medical Records.
if ($collectionCount === 1) {
$node['children'][] = $childDocument->getJsTreeFormattedNode(null, $additionalLiAttributes);
}
}
return $node;
}
/**
* Add batchRequest
*
* @param BatchRequest $batchRequest
*
* @return Project
*/
public function addBatchRequest(BatchRequest $batchRequest)
{
$this->batchRequests[] = $batchRequest;
return $this;
}
/**
* Remove batchRequest
*
* @param BatchRequest $batchRequest
*/
public function removeBatchRequest(BatchRequest $batchRequest)
{
$this->batchRequests->removeElement($batchRequest);
}
/**
* Get batchRequests
*
* @return DoctrineCollection|BatchRequest[]
*/
public function getBatchRequests()
{
return $this->batchRequests;
}
/**
* Retrieves the counts for BatchRequests grouped by
* their serviceRequest status.
*
* @param mixed $uninvoicedOnly
*
* @return array
*/
public function getBatchRequestsCountByServiceRequestStatus($uninvoicedOnly = true)
{
return $this->getServiceableCountsByStatus($this->getBatchRequests()->toArray(), $uninvoicedOnly);
}
/**
* Add additionalRequest
*
* @param AdditionalRequest $additionalRequest
*
* @return Project
*/
public function addAdditionalRequest(AdditionalRequest $additionalRequest)
{
$this->additionalRequests[] = $additionalRequest;
return $this;
}
/**
* Remove additionalRequest
*
* @param AdditionalRequest $additionalRequest
*/
public function removeAdditionalRequest(AdditionalRequest $additionalRequest)
{
$this->additionalRequests->removeElement($additionalRequest);
}
/**
* Get additionalRequests
*
* @return DoctrineCollection|AdditionalRequest[]
*/
public function getAdditionalRequests()
{
return $this->additionalRequests;
}
/**
* Retrieves the counts for AdditionalRequests grouped by
* their serviceRequest status
*
* @param mixed $uninvoicedOnly
*
* @return array
*/
public function getAdditionalRequestsCountByServiceRequestStatus($uninvoicedOnly = true)
{
return $this->getServiceableCountsByStatus($this->getAdditionalRequests()->toArray(), $uninvoicedOnly);
}
/**
* Add chronologyRequest
*
* @param ChronologyRequest $chronologyRequest
*
* @return Project
*/
public function addChronologyRequest(ChronologyRequest $chronologyRequest)
{
$this->chronologyRequests[] = $chronologyRequest;
return $this;
}
/**
* Remove chronologyRequest
*
* @param ChronologyRequest $chronologyRequest
*/
public function removeChronologyRequest(ChronologyRequest $chronologyRequest)
{
$this->chronologyRequests->removeElement($chronologyRequest);
}
/**
* Get chronologyRequests
*
* @return ArrayCollection|ChronologyRequest[]
*/
public function getChronologyRequests()
{
return $this->chronologyRequests;
}
/**
* Retrieves the counts for ChronologyRequests grouped by
* their serviceRequest status
*
* @param bool $uninvoicedOnly
*
* @return array
*/
public function getChronologyRequestsCountByServiceRequestStatus($uninvoicedOnly = true)
{
return $this->getServiceableCountsByStatus($this->getChronologyRequests()->toArray(), $uninvoicedOnly);
}
/**
* Retrieve a sum of ServiceRequest statuses for all Serviceable entities attached to this Project.
*
* @param bool $uninvoicedOnly
*
* @return array
*/
public function getTotalServiceRequestCountsByStatus($uninvoicedOnly = true)
{
return $this->getServiceableCountsByStatus($this->getServiceables(), $uninvoicedOnly);
}
/**
* @return array
*/
public function getServiceables(): array
{
$serviceables = [];
// Combine all Serviceable entities on this Project into a single array.
$serviceables = array_merge(
$this->getRecordsRequests()->toArray(),
$this->getBatchRequests()->toArray(),
$this->getChronologyRequests()->toArray(),
$this->getAdditionalRequests()->toArray()
);
return $serviceables;
}
/**
* Gets the total number of ServiceRequest that are in status On Hold.
*
* @return int
*/
public function getTotalServiceRequestCountsOnHold()
{
$totals = $this->getTotalServiceRequestCountsByStatus();
return isset($totals[ServiceRequest::STATUS_ON_HOLD]) ? $totals[ServiceRequest::STATUS_ON_HOLD]['count'] : 0;
}
/**
* Gets the total number of ServiceRequest that are in status In Progress.
*
* @return int
*/
public function getTotalServiceRequestCountsInProgress()
{
$totals = $this->getTotalServiceRequestCountsByStatus();
$inProgressCount = $totals[ServiceRequest::STATUS_IN_PROGRESS]['count'] ?? 0;
$instructedCount = $totals[ServiceRequest::STATUS_INSTRUCTED]['count'] ?? 0;
return $inProgressCount + $instructedCount;
}
/**
* Gets the total number of ServiceRequest that are in status Complete.
*
* @return int
*/
public function getTotalServiceRequestCountsComplete()
{
$totals = $this->getTotalServiceRequestCountsByStatus();
$completeTotal = 0;
$completeTotal += $totals[ServiceRequest::STATUS_COMPLETE]['count'] ?? 0;
$completeTotal += $totals[ServiceRequest::STATUS_BACK_TO_CLIENT]['count'] ?? 0;
$completeTotal += $totals[ServiceRequest::STATUS_RELEASED_TO_CLIENT]['count'] ?? 0;
return $completeTotal;
}
/**
* Gets the total number of ServiceRequest that are in status Awaiting Records.
*
* @return int
*/
public function getTotalServiceRequestCountsAwaitingRecords()
{
$totals = $this->getTotalServiceRequestCountsByStatus();
/**
* Combine awaiting records and awaiting records arrival into one total, as they are similar but have slightly
* different meanings for different service requests.
* {@see ServiceRequest::getStatusOptionsBatchRequest} and {@see ServiceRequest::getStatusOptionsChronologyRequest}
*/
$awaitingRecordsTotal = isset($totals[ServiceRequest::STATUS_AWAITING_RECORDS]) ? $totals[ServiceRequest::STATUS_AWAITING_RECORDS]['count'] : 0;
$awaitingRecordsArrivalTotal = isset($totals[ServiceRequest::STATUS_AWAITING_RECORDS_ARRIVAL]) ? $totals[ServiceRequest::STATUS_AWAITING_RECORDS_ARRIVAL]['count'] : 0;
$awaitingQuoteApprovalTotal = isset($totals[ServiceRequest::STATUS_AWAITING_QUOTE_APPROVAL]) ? $totals[ServiceRequest::STATUS_AWAITING_QUOTE_APPROVAL]['count'] : 0;
return $awaitingRecordsTotal + $awaitingRecordsArrivalTotal + $awaitingQuoteApprovalTotal;
}
/**
* Gets the amount of Records Requests grouped by their respective statuses
*
* @return array
*/
public function getRecordsRequestCountsByStatus()
{
$serviceables = $this->getRecordsRequests()->toArray();
return $this->getServiceableCountsByStatus($serviceables);
}
/**
* Gets the amount of Batch Requests grouped by their respective statuses
*
* @return array
*/
public function getBatchRequestCountsByStatus()
{
$serviceables = $this->getBatchRequests()->toArray();
return $this->getServiceableCountsByStatus($serviceables);
}
/**
* Gets the amount of Chronology Requests grouped by their respective statuses
*
* @return array
*/
public function getChronologyRequestCountsByStatus()
{
$serviceables = $this->getChronologyRequests()->toArray();
return $this->getServiceableCountsByStatus($serviceables);
}
/**
* Gets the amount of Additional Requests grouped by their respective statuses
*
* @return array
*/
public function getAdditionalRequestCountsByStatus()
{
$serviceables = $this->getAdditionalRequests()->toArray();
return $this->getServiceableCountsByStatus($serviceables);
}
/**
* Gets the total of all records request status' with status STATUS_COMPLETE and STATUS_BACK_TO_CLIENT
*
* @return int
*/
public function getRecordsRequestCompleteReturnCount()
{
$recordsRequestByStatus = $this->getRecordsRequestCountsByStatus();
$count = 0;
$arrayKeys = array_keys($recordsRequestByStatus);
if (in_array(ServiceRequest::STATUS_BACK_TO_CLIENT, $arrayKeys, true)) {
$count += $recordsRequestByStatus[ServiceRequest::STATUS_BACK_TO_CLIENT]['count'];
}
if (in_array(ServiceRequest::STATUS_COMPLETE, $arrayKeys, true)) {
$count += $recordsRequestByStatus[ServiceRequest::STATUS_COMPLETE]['count'];
}
return $count;
}
/**
* Gets the ServiceRequest counts grouped by their respective statuses and types
*
* @return array
*/
public function getServiceRequestStatusCountsByType()
{
return [
'Records Requests' => $this->getRecordsRequestCountsByStatus(),
'Batch Requests' => $this->getBatchRequestCountsByStatus(),
'Chronology Requests' => $this->getChronologyRequestCountsByStatus(),
'Additional Requests' => $this->getAdditionalRequestCountsByStatus(),
];
}
// @todo The below functions could probably all be rolled up in to one easy catchall
// like ::getServiceRequestCountByTypeAndStatus( $type, $status ) but only
// thought of it too late ┐('~`;)┌
/**
* Gets a count of all completed ServiceRequests given a specific Type
*
* @param $service_request_type
*
* @throws Exception
*
* @return int|mixed
*/
public function getCompleteServiceRequestCountsByType($service_request_type)
{
switch ($service_request_type) {
case ServiceRequest::TYPE_RECORDS_REQUEST:
$serviceables = $this->getRecordsRequestsCountByServiceRequestStatus(false);
break;
case ServiceRequest::TYPE_BATCH_REQUEST:
$serviceables = $this->getBatchRequestsCountByServiceRequestStatus(false);
break;
case ServiceRequest::TYPE_CHRONOLOGY_REQUEST:
$serviceables = $this->getChronologyRequestsCountByServiceRequestStatus(false);
break;
case ServiceRequest::TYPE_ADDITIONAL_REQUEST:
$serviceables = $this->getAdditionalRequestsCountByServiceRequestStatus(false);
break;
default:
throw new Exception('Invalid Service Request Type.');
}
$complete = isset($serviceables[ServiceRequest::STATUS_COMPLETE]) ? $serviceables[ServiceRequest::STATUS_COMPLETE]['count'] : 0;
$releasedToClient = isset($serviceables[ServiceRequest::STATUS_RELEASED_TO_CLIENT]) ? $serviceables[ServiceRequest::STATUS_RELEASED_TO_CLIENT]['count'] : 0;
return $complete + $releasedToClient;
}
/**
* Gets a count of all in progress ServiceRequests given a specific Type
*
* @param $service_request_type
*
* @throws Exception
*
* @return int|mixed
*/
public function getInProgressServiceRequestCountsByType($service_request_type)
{
switch ($service_request_type) {
case ServiceRequest::TYPE_RECORDS_REQUEST:
$serviceables = $this->getRecordsRequestsCountByServiceRequestStatus(false);
break;
case ServiceRequest::TYPE_BATCH_REQUEST:
$serviceables = $this->getBatchRequestsCountByServiceRequestStatus(false);
break;
case ServiceRequest::TYPE_CHRONOLOGY_REQUEST:
$serviceables = $this->getChronologyRequestsCountByServiceRequestStatus(false);
break;
case ServiceRequest::TYPE_ADDITIONAL_REQUEST:
$serviceables = $this->getAdditionalRequestsCountByServiceRequestStatus(false);
break;
default:
throw new Exception('Invalid Service Request Type.');
}
return isset($serviceables[ServiceRequest::STATUS_IN_PROGRESS]) ? $serviceables[ServiceRequest::STATUS_IN_PROGRESS]['count'] : 0;
}
/**
* Gets a count of all on hold ServiceRequests given a specific Type
*
* @param $service_request_type
*
* @throws Exception
*
* @return int|mixed
*/
public function getOnHoldServiceRequestCountsByType($service_request_type)
{
switch ($service_request_type) {
case ServiceRequest::TYPE_RECORDS_REQUEST:
$serviceables = $this->getRecordsRequestsCountByServiceRequestStatus(false);
break;
case ServiceRequest::TYPE_BATCH_REQUEST:
$serviceables = $this->getBatchRequestsCountByServiceRequestStatus(false);
break;
case ServiceRequest::TYPE_CHRONOLOGY_REQUEST:
$serviceables = $this->getChronologyRequestsCountByServiceRequestStatus(false);
break;
case ServiceRequest::TYPE_ADDITIONAL_REQUEST:
$serviceables = $this->getAdditionalRequestsCountByServiceRequestStatus(false);
break;
default:
throw new Exception('Invalid Service Request Type.');
}
return isset($serviceables[ServiceRequest::STATUS_ON_HOLD]) ? $serviceables[ServiceRequest::STATUS_ON_HOLD]['count'] : 0;
}
/**
* Gets a count of all ServiceRequests awaiting records given a specific Type
*
* @param $service_request_type
*
* @throws Exception
*
* @return int|mixed
*/
public function getPendingServiceRequestCountsByType($service_request_type)
{
switch ($service_request_type) {
case ServiceRequest::TYPE_RECORDS_REQUEST:
$serviceables = $this->getRecordsRequestsCountByServiceRequestStatus(false);
break;
case ServiceRequest::TYPE_BATCH_REQUEST:
$serviceables = $this->getBatchRequestsCountByServiceRequestStatus(false);
break;
case ServiceRequest::TYPE_CHRONOLOGY_REQUEST:
$serviceables = $this->getChronologyRequestsCountByServiceRequestStatus(false);
break;
case ServiceRequest::TYPE_ADDITIONAL_REQUEST:
$serviceables = $this->getAdditionalRequestsCountByServiceRequestStatus(false);
break;
default:
throw new Exception('Invalid Service Request Type.');
}
return isset($serviceables[ServiceRequest::STATUS_AWAITING_RECORDS]) ? $serviceables[ServiceRequest::STATUS_AWAITING_RECORDS]['count'] : 0;
}
/**
* Gets a count of all cancelled ServiceRequests given a specific Type
*
* @param $service_request_type
*
* @throws Exception
*
* @return int|mixed
*/
public function getCancelledServiceRequestCountsByType($service_request_type)
{
switch ($service_request_type) {
case ServiceRequest::TYPE_RECORDS_REQUEST:
$serviceables = $this->getRecordsRequestsCountByServiceRequestStatus(false);
break;
case ServiceRequest::TYPE_BATCH_REQUEST:
$serviceables = $this->getBatchRequestsCountByServiceRequestStatus(false);
break;
case ServiceRequest::TYPE_CHRONOLOGY_REQUEST:
$serviceables = $this->getChronologyRequestsCountByServiceRequestStatus(false);
break;
case ServiceRequest::TYPE_ADDITIONAL_REQUEST:
$serviceables = $this->getAdditionalRequestsCountByServiceRequestStatus(false);
break;
default:
throw new Exception('Invalid Service Request Type.');
}
return isset($serviceables[ServiceRequest::STATUS_CANCELLED]) ? $serviceables[ServiceRequest::STATUS_CANCELLED]['count'] : 0;
}
/**
* Set team
*
* @param string $team
*
* @return Project
*/
public function setTeam($team)
{
$this->team = $team;
// Update the associated matter request as well, if it exists, and if the values are different,
// to avoid a recursive loop.
if ($this->getMatterRequest() && $this->getMatterRequest()->getTeam() != $this->team) {
$this->getMatterRequest()->setTeam($this->team);
}
return $this;
}
/**
* Get team
*
* @return string
*/
public function getTeam()
{
return $this->team;
}
/**
* Set defaultRole
*
* @param string $defaultRole
*
* @return Project
*/
public function setDefaultRole($defaultRole)
{
$this->default_role = $defaultRole;
return $this;
}
/**
* Get defaultRole
*
* @return string
*/
public function getDefaultRole()
{
return $this->default_role;
}
/**
* Get defaultRoleOptions
*
* @return array
*/
public static function getDefaultRoleOptions()
{
return [
self::DEFAULT_ROLE_EXPERT => 'Expert',
self::DEFAULT_ROLE_EXPERTVIEWER => 'Expert - View Only',
self::DEFAULT_ROLE_SCANNER => 'Scanner',
self::DEFAULT_ROLE_SCANNERDOWNLOAD => 'Scanner - Download Enabled',
self::DEFAULT_ROLE_PROJECTMANAGER => 'Project Manager',
];
}
/**
* Get DefaultRoleLabel
*
* @return int
*/
public function getDefaultRoleLabel()
{
$options = self::getDefaultRoleOptions();
return $options[$this->getDefaultRole()] ?? '';
}
/**
* Get DefaultRoleLabel
*
* @return string
*/
public function getDefaultRoleAsRole()
{
if (!$this->getDefaultRole()) {
return '';
}
return 'ROLE_PROJECT_' . $this->getId() . '_' . $this->getDefaultRole();
}
/**
* Get the disabled UserNotification types
*
* @return array
*/
public function getDisabledNotifications()
{
return $this->disabled_notifications ?: [];
}
/**
* @param array $disabled_notifications
*
* @return Project
*/
public function setDisabledNotifications($disabled_notifications): Project
{
$this->disabled_notifications = $disabled_notifications;
return $this;
}
/**
* Disable a notification
*
* @param $notification_type
*
* @return Project
*/
public function disableNotification($notification_type): Project
{
$this->disabled_notifications[] = $notification_type;
return $this;
}
/**
* Function to determine if the specific UserNotification is disabled for this Entity
*
* @param $notification_type
*
* @return bool
*/
public function isNotificationDisabled($notification_type)
{
if (!$this->disabled_notifications || count($this->disabled_notifications) == 0) {
return false;
}
return in_array($notification_type, $this->disabled_notifications) ? true : false;
}
/**
* Add sortingSession
*
* @param SortingSession $sortingSession
*
* @return Project
*/
public function addSortingSession(SortingSession $sortingSession)
{
$this->sortingSessions[] = $sortingSession;
return $this;
}
/**
* Remove sortingSession
*
* @param SortingSession $sortingSession
*/
public function removeSortingSession(SortingSession $sortingSession)
{
$this->sortingSessions->removeElement($sortingSession);
}
/**
* Get sortingSessions
*
* @return DoctrineCollection|SortingSession[]
*/
public function getSortingSessions()
{
return $this->sortingSessions;
}
/**
* Get completedSortingSessions
*
* @return ArrayCollection|DoctrineCollection|Collection
*/
public function getCompletedSortingSessions()
{
return $this->getSortingSessions()->filter(
function ($sortingSession) {
return $sortingSession->hasBeenCompleted();
}
);
}
/**
* @return bool
*/
public function hasIncompleteSortingSessions(): bool
{
foreach ($this->getSortingSessions() as $sortingSession) {
if (!$sortingSession->hasBeenCompleted() && !$sortingSession->isSortStatusDownloaded()) {
return true;
}
}
return false;
}
/**
* Returns true if there are any incomplete serviceables on the project.
* This is used to block a project from being archived or deleted when work is still on-going.
*
* @return bool
*/
public function hasIncompleteServiceables(): bool
{
foreach ($this->getRecordsRequests() as $recordsRequest) {
$incompleteStatuses = [
ServiceRequest::STATUS_IN_PROGRESS,
ServiceRequest::STATUS_ON_HOLD,
];
if ($recordsRequest->getServiceRequest() && in_array($recordsRequest->getServiceRequest()->getStatus(), $incompleteStatuses)) {
return true;
}
}
foreach ($this->getBatchRequests() as $batchRequest) {
$incompleteStatuses = [
ServiceRequest::STATUS_IN_PROGRESS,
ServiceRequest::STATUS_AWAITING_RECORDS,
ServiceRequest::STATUS_ON_HOLD,
];
if ($batchRequest->getServiceRequest() && in_array($batchRequest->getServiceRequest()->getStatus(), $incompleteStatuses)) {
return true;
}
}
foreach ($this->getChronologyRequests() as $chronologyRequest) {
$incompleteStatuses = [
ServiceRequest::STATUS_INSTRUCTED,
ServiceRequest::STATUS_IN_PROGRESS,
ServiceRequest::STATUS_ON_HOLD,
];
if ($chronologyRequest->getServiceRequest() && in_array($chronologyRequest->getServiceRequest()->getStatus(), $incompleteStatuses)) {
return true;
}
}
foreach ($this->getAdditionalRequests() as $additionalRequest) {
$incompleteStatuses = [
ServiceRequest::STATUS_IN_PROGRESS,
ServiceRequest::STATUS_ON_HOLD,
];
if ($additionalRequest->getServiceRequest() && in_array($additionalRequest->getServiceRequest()->getStatus(), $incompleteStatuses)) {
return true;
}
}
// Finally, we check if there are incomplete sorting sessions.
return $this->hasIncompleteSortingSessions();
}
/**
* Add matterNote
*
* @param MatterNote $matterNote
*
* @return Project
*/
public function addMatterNote(MatterNote $matterNote)
{
$this->matterNotes[] = $matterNote;
$matterNote->setProject($this);
return $this;
}
/**
* Remove matterNote
*
* @param MatterNote $matterNote
*/
public function removeMatterNote(MatterNote $matterNote)
{
$this->matterNotes->removeElement($matterNote);
}
/**
* Get matterNotes
*
* @return DoctrineCollection|MatterNote[]
*/
public function getMatterNotes()
{
return $this->matterNotes;
}
/**
* @return array
*/
public function getNoteCounts(): array
{
$noteCounts = [];
foreach ($this->getMatterNotes() as $note) {
if (!isset($noteCounts[$note->getType()])) {
$noteCounts[$note->getType()] = 0;
}
$noteCounts[$note->getType()]++;
}
return $noteCounts;
}
/**
* Set unsortedRecordsCollection.
*
* @param Collection|null $unsortedRecordsCollection
*
* @return Project
*/
public function setUnsortedRecordsCollection(?Collection $unsortedRecordsCollection = null)
{
$this->unsortedRecordsCollection = $unsortedRecordsCollection;
return $this;
}
/**
* Set requirePasswordOnDownload.
*
* @param bool $requirePasswordOnDownload
*
* @return Project
*/
public function setRequirePasswordOnDownload($requirePasswordOnDownload)
{
$this->require_password_on_download = $requirePasswordOnDownload;
return $this;
}
/**
* Get unsortedRecordsCollection.
*
* @return Collection|null
*/
public function getUnsortedRecordsCollection()
{
return $this->unsortedRecordsCollection;
}
/**
* Get requirePasswordOnDownload.
*
* @return bool
*/
public function getRequirePasswordOnDownload()
{
return $this->require_password_on_download;
}
/**
* Set inviteUserMustAuthenticate.
*
* @param bool $inviteUserMustAuthenticate
*
* @return Project
*/
public function setInviteUserMustAuthenticate($inviteUserMustAuthenticate)
{
$this->inviteUserMustAuthenticate = $inviteUserMustAuthenticate;
return $this;
}
/**
* Get inviteUserMustAuthenticate.
*
* @return bool
*/
public function getInviteUserMustAuthenticate()
{
return $this->inviteUserMustAuthenticate;
}
/**
* Set inviteUserPassword.
*
* @param string $inviteUserPassword
*
* @return Project
*/
public function setInviteUserPassword($inviteUserPassword)
{
$this->inviteUserPassword = $inviteUserPassword;
return $this;
}
/**
* Get inviteUserPassword.
*
* @return string
*/
public function getInviteUserPassword()
{
return $this->inviteUserPassword;
}
/**
* Set inviteUserContactName.
*
* @param string|null $inviteUserContactName
*
* @return Project
*/
public function setInviteUserContactName($inviteUserContactName = null)
{
$this->inviteUserContactName = $inviteUserContactName;
return $this;
}
/**
* Get inviteUserContactName.
*
* @return string|null
*/
public function getInviteUserContactName()
{
return $this->inviteUserContactName;
}
/**
* Set inviteUserContactEmail.
*
* @param string|null $inviteUserContactEmail
*
* @return Project
*/
public function setInviteUserContactEmail($inviteUserContactEmail = null)
{
$this->inviteUserContactEmail = $inviteUserContactEmail;
return $this;
}
/**
* Get inviteUserContactEmail.
*
* @return string|null
*/
public function getInviteUserContactEmail()
{
return $this->inviteUserContactEmail;
}
/**
* Set inviteUserContactPhoneNumber.
*
* @param string|null $inviteUserContactPhoneNumber
*
* @return Project
*/
public function setInviteUserContactPhoneNumber($inviteUserContactPhoneNumber = null)
{
$this->inviteUserContactPhoneNumber = $inviteUserContactPhoneNumber;
return $this;
}
/**
* Get inviteUserContactPhoneNumber.
*
* @return string|null
*/
public function getInviteUserContactPhoneNumber()
{
return $this->inviteUserContactPhoneNumber;
}
/**
* Tells if the contact type is Email.
*
* @return bool
*/
public function isInviteUserContactTypeEmail()
{
return !is_null($this->getInviteUserContactEmail());
}
/**
* Tells if the contact type is Phone.
*
* @return bool
*/
public function isInviteUserContactTypePhone()
{
return !is_null($this->getInviteUserContactPhoneNumber());
}
/**
* Set dateOnLetter.
*
* @param DateTime|null $dateOnLetter
*
* @return Project
*/
public function setDateOnLetter($dateOnLetter = null)
{
$this->date_on_letter = $dateOnLetter;
return $this;
}
/**
* Get dateOnLetter.
*
* @return DateTime|null
*/
public function getDateOnLetter()
{
return $this->date_on_letter;
}
/**
* Set caseMeritsAnalysis.
*
* @param string|null $caseMeritsAnalysis
*
* @return Project
*/
public function setCaseMeritsAnalysis($caseMeritsAnalysis = null)
{
$this->case_merits_analysis = $caseMeritsAnalysis;
return $this;
}
/**
* Get caseMeritsAnalysis.
*
* @return string|null
*/
public function getCaseMeritsAnalysis()
{
return $this->case_merits_analysis;
}
/**
* Returns an array of permitted values for the case_merits_analysis field and their
* associated labels.
*
* @return array
*/
public static function getCaseMeritsAnalysisOptions()
{
return [
self::CASE_MERITS_ANALYSIS_SUPPORTIVE => 'Supportive',
self::CASE_MERITS_ANALYSIS_UNSUPPORTIVE => 'Unsupportive',
self::CASE_MERITS_ANALYSIS_INCONCLUSIVE => 'Inconclusive',
];
}
/**
* Returns a human-readable version of the case_merits_analysis
*
* @return string
*/
public function getCaseMeritsAnalysisName()
{
$options = self::getCaseMeritsAnalysisOptions();
return
$options[$this->getCaseMeritsAnalysis()] ?? $this->getCaseMeritsAnalysis();
}
/**
* Set claimantSolicitor.
*
* @param string|null $claimantSolicitor
*
* @return Project
*/
public function setClaimantSolicitor($claimantSolicitor = null)
{
$this->claimant_solicitor = $claimantSolicitor;
return $this;
}
/**
* Get claimantSolicitor.
*
* @return string|null
*/
public function getClaimantSolicitor()
{
return $this->claimant_solicitor;
}
/**
* Set typeOfLetter.
*
* @param string|null $typeOfLetter
*
* @return Project
*/
public function setTypeOfLetter($typeOfLetter = null)
{
$this->type_of_letter = $typeOfLetter;
return $this;
}
/**
* Get typeOfLetter.
*
* @return string|null
*/
public function getTypeOfLetter()
{
return $this->type_of_letter;
}
/**
* Returns an array of permitted values for the type_of_letter field and their
* associated labels.
*
* @return array
*/
public static function getTypeOfLetterOptions()
{
return [
self::TYPE_OF_LETTER_LETTER_OF_CLAIM => 'Letter of claim',
self::TYPE_OF_LETTER_LETTER_OF_NOTIFICATION => 'Letter of notification',
self::TYPE_OF_LETTER_SUBJECT_ACCESS_REQUEST => 'Subject access request',
self::TYPE_OF_LETTER_DISCLOSURE_APPLICATION => 'Disclosure application',
];
}
/**
* Returns a human-readable version of the type_of_letter
*
* @return string
*/
public function getTypeOfLetterName()
{
$options = self::getTypeOfLetterOptions();
return
$options[$this->getTypeOfLetter()] ?? $this->getTypeOfLetter();
}
/**
* Set reviewType.
*
* @param string|null $reviewType
*
* @return Project
*/
public function setReviewType($reviewType = null)
{
$this->review_type = $reviewType;
return $this;
}
/**
* Get reviewType.
*
* @return string|null
*/
public function getReviewType()
{
return $this->review_type;
}
/**
* Returns an array of permitted values for the review_type field and their
* associated labels.
*
* @return array
*/
public static function getReviewTypeOptions()
{
return [
self::REVIEW_TYPE_CASE_MERITS_ANALYSIS => 'Case merits analysis',
self::REVIEW_TYPE_CHRONOLOGY => 'Chronology',
];
}
/**
* Returns a human-readable version of the review_type
*
* @return string
*/
public function getReviewTypeName()
{
$options = self::getReviewTypeOptions();
return
$options[$this->getReviewType()] ?? $this->getReviewType();
}
/**
* Set expertsReportDate.
*
* @param DateTime|null $expertsReportDate
*
* @return Project
*/
public function setExpertsReportDate($expertsReportDate = null)
{
$this->experts_report_date = $expertsReportDate;
return $this;
}
/**
* Get expertsReportDate.
*
* @return DateTime|null
*/
public function getExpertsReportDate()
{
return $this->experts_report_date;
}
/**
* Set letterOfResponseAndExpertReportDate.
*
* @param DateTime|null $letterOfResponseAndExpertReportDate
*
* @return Project
*/
public function setLetterOfResponseAndExpertReportDate($letterOfResponseAndExpertReportDate = null)
{
$this->letter_of_response_and_expert_report_date = $letterOfResponseAndExpertReportDate;
return $this;
}
/**
* Get letterOfResponseAndExpertReportDate.
*
* @return DateTime|null
*/
public function getLetterOfResponseAndExpertReportDate()
{
return $this->letter_of_response_and_expert_report_date;
}
/**
* Set letterOfResponsePreparedDate.
*
* @param DateTime|null $letterOfResponsePreparedDate
*
* @return Project
*/
public function setLetterOfResponsePreparedDate($letterOfResponsePreparedDate = null)
{
$this->letter_of_response_prepared_date = $letterOfResponsePreparedDate;
return $this;
}
/**
* Get letterOfResponsePreparedDate.
*
* @return DateTime|null
*/
public function getLetterOfResponsePreparedDate()
{
return $this->letter_of_response_prepared_date;
}
/**
* Set letterOfResponseSentDate.
*
* @param DateTime|null $letterOfResponseSentDate
*
* @return Project
*/
public function setLetterOfResponseSentDate($letterOfResponseSentDate = null)
{
$this->letter_of_response_sent_date = $letterOfResponseSentDate;
return $this;
}
/**
* Get letterOfResponseSentDate.
*
* @return DateTime|null
*/
public function getLetterOfResponseSentDate()
{
return $this->letter_of_response_sent_date;
}
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addConstraint(new Assert\Callback('validate'));
}
public function validate(ExecutionContextInterface $context, $payload)
{
if ($this->getInviteUserMustAuthenticate()) {
$password = $this->getinviteUserPassword();
// If the password has not already been set, validate the plainPassword.
if (is_null($password)) {
$plainPassword = $this->getinviteUserPlainPassword();
$constraints = [
new Assert\Regex([
'pattern' => '/(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[\d])(?=.*[\W]).{8,}/',
'message' => 'Please ensure you use a strong password of at least 8 characters, including at least one each of the following: lowercase, uppercase, number, symbol.',
]),
new Assert\NotBlank([]),
new Assert\Length([
'min' => 8,
'max' => 255,
'minMessage' => 'Your password must have at least {{ limit }} characters.',
'maxMessage' => 'The password is too long.',
]),
];
$validator = Validation::createValidator();
foreach ($constraints as $constraint) {
$errors = $validator->validate(
$plainPassword,
$constraint
);
if (0 !== count($errors)) {
$errorMessage = $errors[0]->getMessage();
$context->buildViolation($errorMessage)
->atPath('inviteUserPlainPassword')
->addViolation()
;
}
}
}
if (is_null($this->getInviteUserContactName())) {
$errorMessage = 'Contact name required.';
$context->buildViolation($errorMessage)
->atPath('inviteUserContactName')
->addViolation()
;
}
if (is_null($this->getInviteUserContactEmail())
&& is_null($this->getInviteUserContactPhoneNumber())
) {
$errorMessage = 'Contact email address or phone number required.';
$context->buildViolation($errorMessage)
->atPath('inviteUserContactEmail')
->addViolation()
;
$context->buildViolation($errorMessage)
->atPath('inviteUserContactPhoneNumber')
->addViolation()
;
}
}
}
/**
* Set matterRequest.
*
* @param MatterRequest|null $matterRequest
*
* @return Project
*/
public function setMatterRequest(?MatterRequest $matterRequest = null)
{
$this->matterRequest = $matterRequest;
return $this;
}
/**
* Get matterRequest.
*
* @return MatterRequest|null
*/
public function getMatterRequest()
{
return $this->matterRequest;
}
/**
* Returns a radiology schedule array grouped by study of all related radiology on a project.
*
* @return array
*/
public function getRadiologyScheduleArray()
{
$data = [];
$serieses = $this->getSeries();
/** @var Series $series */
foreach ($serieses as $series) {
// Grab the Study this Series is in
$study = $series->getStudy();
if ($study) {
// Having named keys here isn't really necessary but we might want them later for something
// If we have Discs, we can fill out the `source` and `number` fields
$data[$study->getId()] = [
'id' => $study->getId(),
'matter' => $this->getClientReference(),
'patient' => $study->getPatient()->getDicomPatientName(),
'date' => $study->getStudyDate(),
'description' => $study->getStudyDescription(),
'centre' => $study->getStudyInstituteName(),
'discs' => $study->getDiscs(),
'longDescription' => $study->__toString(),
];
}
}
usort($data, function ($a, $b) {
return strcmp($a['longDescription'], $b['longDescription']);
});
return $data;
}
/**
* Add matterCommunication.
*
* @param MatterCommunication $matterCommunication
*
* @return Project
*/
public function addMatterCommunication(MatterCommunication $matterCommunication)
{
$this->matterCommunications[] = $matterCommunication;
return $this;
}
/**
* Remove matterCommunication.
*
* @param MatterCommunication $matterCommunication
*
* @return bool TRUE if this collection contained the specified element, FALSE otherwise.
*/
public function removeMatterCommunication(MatterCommunication $matterCommunication)
{
return $this->matterCommunications->removeElement($matterCommunication);
}
/**
* Get matterCommunications.
*
* @return DoctrineCollection|MatterCommunication[]
*/
public function getMatterCommunications()
{
return $this->matterCommunications;
}
/**
* Set deleteStatus
*
* @param int $deleteStatus
*
* @return Project
*/
public function setDeleteStatus(?int $deleteStatus = null)
{
if ($this->deleteStatus !== $deleteStatus) {
$this->setDeleteStatusUpdated(new DateTime());
}
$this->deleteStatus = $deleteStatus;
return $this;
}
/**
* Get deleteStatus
*
* @return int
*/
public function getDeleteStatus()
{
return $this->deleteStatus;
}
/**
* Return true if deletestatus is equal to the constants below
*
* @return bool
*/
public function hasDeleteStatus()
{
$statuses = [
self::DELETE_STATUS_PENDING,
self::DELETE_STATUS_REMINDER_SENT,
self::DELETE_STATUS_PROCESSING,
self::DELETE_STATUS_COMPLETE,
];
return in_array($this->getDeleteStatus(), $statuses);
}
/**
* Set deleteStatusUpdated
*
* @param DateTime $deleteStatusUpdated
*
* @return Project
*/
public function setDeleteStatusUpdated(?DateTime $deleteStatusUpdated = null)
{
$this->deleteStatusUpdated = $deleteStatusUpdated;
return $this;
}
/**
* Get deleteStatusUpdated
*
* @return DateTime
*/
public function getDeleteStatusUpdated()
{
return $this->deleteStatusUpdated;
}
/**
* Get archiveStatus as Label
*
* @return string
*/
public function getArchiveStatusLabel()
{
$archiveStatusOptions = array_flip(static::getConstantsWithLabelsAsChoices('ARCHIVE_STATUS'));
return $archiveStatusOptions[$this->getArchiveStatus()] ?? '';
}
/**
* @return array
*/
public static function getArchiveStatusChoices()
{
return static::getConstantsWithLabelsAsChoices('ARCHIVE_STATUS');
}
/**
* @return array
*/
public static function getDeleteStatusChoices()
{
return static::getConstantsWithLabelsAsChoices('DELETE_STATUS');
}
/**
* Return true if matter is in the process of being deleted/archived, or is deleted or archived
*
* @return bool
*/
public function isCloseInProgressOrComplete()
{
$archiveStatuses = [
self::ARCHIVE_STATUS_PENDING,
self::ARCHIVE_STATUS_PROCESSING,
self::ARCHIVE_STATUS_UNARCHIVE_PROCESSING,
self::ARCHIVE_STATUS_COMPLETE,
];
$deleteStatuses = [
self::DELETE_STATUS_PENDING,
self::DELETE_STATUS_REMINDER_SENT,
self::DELETE_STATUS_PROCESSING,
self::DELETE_STATUS_COMPLETE,
self::DELETE_STATUS_DELETE_FAILED,
self::DELETE_STATUS_ANONYMISE_FAILED,
];
return in_array($this->getArchiveStatus(), $archiveStatuses, true) || in_array($this->getDeleteStatus(), $deleteStatuses, true);
}
/**
* Return true if project status is active
*
* @return bool
*/
public function isStatusActive()
{
return $this->getStatus() === self::STATUS_ACTIVE;
}
/**
* Return true if project archive status is pending
*
* @return bool
*/
public function isArchiveStatusPending()
{
return $this->getArchiveStatus() === self::ARCHIVE_STATUS_PENDING;
}
/**
* Return true if project archive status is processing
*
* @return bool
*/
public function isArchiveStatusProcessing()
{
return $this->getArchiveStatus() === self::ARCHIVE_STATUS_PROCESSING;
}
/**
* Return true if project archive status is complete
*
* @return bool
*/
public function isArchiveStatusComplete()
{
return $this->getArchiveStatus() === self::ARCHIVE_STATUS_COMPLETE;
}
/**
* Return true if project archive status is unarchive in process
*
* @return bool
*/
public function isArchiveStatusUnarchiveProcessing()
{
return $this->getArchiveStatus() === self::ARCHIVE_STATUS_UNARCHIVE_PROCESSING;
}
/**
* Return true if matter is in the process of being deleted/archived
*
* @return bool
*/
public function isQueuedForArchiveOrDeletion(): bool
{
$archiveStatuses = [
self::ARCHIVE_STATUS_PENDING,
self::ARCHIVE_STATUS_PROCESSING,
self::ARCHIVE_STATUS_UNARCHIVE_PROCESSING,
];
$deleteStatuses = [
self::DELETE_STATUS_PENDING,
self::DELETE_STATUS_REMINDER_SENT,
self::DELETE_STATUS_PROCESSING,
];
return in_array($this->getArchiveStatus(), $archiveStatuses, true) || in_array($this->getDeleteStatus(), $deleteStatuses, true);
}
/**
* Return true if archive status is equal to the constants below
*
* @return bool
*/
public function hasArchiveStatus(): bool
{
$statuses = [
self::ARCHIVE_STATUS_PENDING,
self::ARCHIVE_STATUS_PROCESSING,
self::ARCHIVE_STATUS_COMPLETE,
self::ARCHIVE_STATUS_UNARCHIVE_PROCESSING,
];
return in_array($this->getArchiveStatus(), $statuses);
}
/**
* Get deleteStatus as Label
*
* @return string
*/
public function getDeleteStatusLabel()
{
$deleteStatusOptions = array_flip(static::getConstantsWithLabelsAsChoices('DELETE_STATUS'));
return $deleteStatusOptions[$this->getDeleteStatus()] ?? '';
}
/**
* Return true if project delete status is pending
*
* @return bool
*/
public function isDeleteStatusPending()
{
return $this->getDeleteStatus() === self::DELETE_STATUS_PENDING;
}
/**
* Return true if project delete status is pending immediate deletion.
*
* @return bool
*/
public function isDeleteStatusPendingImmediate()
{
return $this->getDeleteStatus() === self::DELETE_STATUS_PENDING_IMMEDIATE;
}
/**
* Return true if project delete status is reminder sent
*
* @return bool
*/
public function isDeleteStatusReminderSent()
{
return $this->getDeleteStatus() === self::DELETE_STATUS_REMINDER_SENT;
}
/**
* Return true if project delete status is processing
*
* @return bool
*/
public function isDeleteStatusProcessing()
{
return $this->getDeleteStatus() === self::DELETE_STATUS_PROCESSING;
}
/**
* Return true if project delete status is complete
*
* @return bool
*/
public function isDeleteStatusComplete()
{
return $this->getDeleteStatus() === self::DELETE_STATUS_COMPLETE;
}
/**
* Return true if project delete status is failed
*
* @return bool
*/
public function isDeleteStatusFailed()
{
return $this->getDeleteStatus() === self::DELETE_STATUS_DELETE_FAILED;
}
/**
* Return true if the Project can be deleted.
*
* @return bool
*/
public function canBeDeleted(): bool
{
return $this->isDeleteStatusReminderSent() || $this->isDeleteStatusProcessing();
}
/**
* Returns true if the project is queued for deletion.
*
* @return bool
*/
public function isQueuedForDeletion(): bool
{
return $this->isDeleteStatusPending() || $this->isDeleteStatusReminderSent() || $this->isDeleteStatusPendingImmediate();
}
/**
* Return true if matter is in the process of being deleted/archived, and is not in the queue to be closed
*
* @return bool
*/
public function isCloseInProgress()
{
$archiveStatuses = [
self::ARCHIVE_STATUS_PROCESSING,
self::ARCHIVE_STATUS_UNARCHIVE_PROCESSING,
];
$deleteStatuses = [
self::DELETE_STATUS_PROCESSING,
];
return in_array($this->getArchiveStatus(), $archiveStatuses, true) || in_array($this->getDeleteStatus(), $deleteStatuses, true);
}
/**
* Return true if matter deletion is complete
*
* @return bool
*/
public function isDeleteComplete()
{
return $this->getDeleteStatus() === self::DELETE_STATUS_COMPLETE;
}
/**
* Returns the User that requested the deletion.
*
* @return User
*/
public function getDeletionRequestedBy(): ?User
{
return $this->getProjectClosure() ? $this->getProjectClosure()->getClosedBy() : null;
}
/**
* getAllowExpertViewUnsortedRecords
*
* @return bool
*/
public function getAllowExpertViewUnsortedRecords(): ?bool
{
return $this->allowExpertViewUnsortedRecords;
}
/**
* setAllowExpertViewUnsortedRecords
*
* @param bool $allowExpertViewUnsortedRecords
*
* @return self
*/
public function setAllowExpertViewUnsortedRecords(?bool $allowExpertViewUnsortedRecords = null): self
{
$this->allowExpertViewUnsortedRecords = $allowExpertViewUnsortedRecords;
return $this;
}
/**
* Get the value of dateDeleted
*
* @return DateTime
*/
public function getDateDeleted()
{
return $this->dateDeleted;
}
/**
* Set the value of dateDeleted
*
* @param DateTime|null $dateDeleted
*
* @return self
*/
public function setDateDeleted(?DateTime $dateDeleted)
{
$this->dateDeleted = $dateDeleted;
return $this;
}
/**
* Get the value of projectDeletionReport
*/
public function getProjectDeletionReport()
{
return $this->projectDeletionReport;
}
/**
* Set the value of projectDeletionReport
*
* @param ProjectDeletionReport|null $projectDeletionReport
*
* @return self
*/
public function setProjectDeletionReport(?ProjectDeletionReport $projectDeletionReport)
{
$this->projectDeletionReport = $projectDeletionReport;
return $this;
}
/**
* Transforms matter Request entity into a usable array structure
*
* @return array
*/
public function getDeletionSummaryArray(): array
{
$deletionReport = $this->getProjectDeletionReport();
if ($deletionReport === null) {
throw new Exception('Project deletion report has not been stored.');
}
return [
'project' => $this,
'patientDob' => $deletionReport->getPatientDateOfBirth(),
'userWhoCompletedClosureWizard' => $this->getDeletionRequestedBy() ? $this->getDeletionRequestedBy()->getFullName() : '',
'dateDeletionCompleted' => $deletionReport->getCreated(),
'documents' => $deletionReport->getDocuments(),
];
}
/**
* Sets the project delete status to failed.
*
* @return self
*/
public function setDeleteStatusFailed(): self
{
$this->setDeleteStatus(self::DELETE_STATUS_DELETE_FAILED);
return $this;
}
/**
* Sets the project delete status to anonymise failed.
*
* @return self
*/
public function setDeleteStatusAnonymiseFailed(): self
{
$this->setDeleteStatus(self::DELETE_STATUS_ANONYMISE_FAILED);
return $this;
}
/**
* Sets the project delete status to complete.
*
* @return self
*/
public function setDeleteStatusComplete(): self
{
$this->setDeleteStatus(self::DELETE_STATUS_COMPLETE);
return $this;
}
/**
* Sets the project delete status to complete.
*
* @return self
*/
public function setDeleteStatusProcessing(): self
{
$this->setDeleteStatus(self::DELETE_STATUS_PROCESSING);
return $this;
}
/**
* @return ProjectClosure|null
*/
public function getProjectClosure(): ?ProjectClosure
{
return $this->projectClosure;
}
/**
* @param ProjectClosure|null $projectClosure
*
* @return self
*/
public function setProjectClosure(?ProjectClosure $projectClosure): self
{
// unset the owning side of the relation if necessary
if ($projectClosure === null && $this->projectClosure !== null) {
$this->projectClosure->setProject(null);
}
// set the owning side of the relation if necessary
if ($projectClosure !== null && $projectClosure->getProject() !== $this) {
$projectClosure->setProject($this);
}
$this->projectClosure = $projectClosure;
return $this;
}
/**
* Returns all the root collections for a project. These are the root folders on the MedicalRecords page.
*
* @return Collection[]
*/
public function getRootCollections(): array
{
$rootCollections = [];
if ($this->getMedicalRecordsCollection()) {
$rootCollections[] = $this->getMedicalRecordsCollection();
}
if ($this->getPrivateCollection()) {
$rootCollections[] = $this->getPrivateCollection();
}
if ($this->getPrivateSandboxCollection()) {
$rootCollections[] = $this->getPrivateSandboxCollection();
}
if ($this->getUnsortedRecordsCollection()) {
$rootCollections[] = $this->getUnsortedRecordsCollection();
}
return $rootCollections;
}
/**
* Return true if deleteStatus is PROCESSING or COMPLETE
*
* @return bool
*/
public function isDeleteProcessingOrComplete()
{
$statuses = [
self::DELETE_STATUS_PROCESSING,
self::DELETE_STATUS_COMPLETE,
];
return in_array($this->getDeleteStatus(), $statuses);
}
/**
* @Groups({"project_closure:read"})
*
* @return bool
*/
public function getClosureQuestionsOptional(): bool
{
return $this->getAccount()->getMatterClosureQuestionsOptional();
}
/**
* @return string|null
*/
public function getClosureStatusLabel(): ?string
{
if ($this->getArchiveStatus()) {
return 'Archived';
}
if ($this->getDeleteStatus()) {
return 'Deleted';
}
return null;
}
/**
* @return string|null
*/
public function getFirmRecordsReviewStatus(): ?string
{
return $this->firmRecordsReviewStatus;
}
/**
* @param string|null $firmRecordsReviewStatus
*
* @return self
*/
public function setFirmRecordsReviewStatus(?string $firmRecordsReviewStatus): self
{
if ($this->firmRecordsReviewStatus !== $firmRecordsReviewStatus) {
$this->setFirmRecordsReviewUpdated(new DateTime());
}
$this->firmRecordsReviewStatus = $firmRecordsReviewStatus;
return $this;
}
/**
* @return array
*/
public static function getFirmRecordsReviewStatusOptions(): array
{
return static::getConstantsWithLabelsAsChoices('FIRM_RECORDS_REVIEW_STATUS');
}
/**
* @return string
*/
public function getFirmRecordsReviewStatusLabel(): string
{
$options = array_flip($this->getFirmRecordsReviewStatusOptions());
return $options[$this->firmRecordsReviewStatus] ?? '';
}
/**
* @return bool
*/
public function showFirmRecordsReviewAdditionalInstruction(): bool
{
$statuses = [
self::FIRM_RECORDS_REVIEW_STATUS_AWAITING_RECORDS,
self::FIRM_RECORDS_REVIEW_STATUS_UPLOADED,
];
return in_array($this->getFirmRecordsReviewStatus(), $statuses);
}
/**
* @return DateTimeInterface|null
*/
public function getFirmRecordsReviewUpdated(): ?DateTimeInterface
{
return $this->firmRecordsReviewUpdated;
}
/**
* @param DateTimeInterface|null $firmRecordsReviewUpdated
*
* @return self
*/
public function setFirmRecordsReviewUpdated(?DateTimeInterface $firmRecordsReviewUpdated): self
{
$this->firmRecordsReviewUpdated = $firmRecordsReviewUpdated;
return $this;
}
/**
* @return string|null
*/
public function getClinicalSummaryUnsortedStatus(): ?string
{
return $this->clinicalSummaryUnsortedStatus;
}
/**
* @param string|null $clinicalSummaryUnsortedStatus
*
* @return self
*/
public function setClinicalSummaryUnsortedStatus(?string $clinicalSummaryUnsortedStatus): self
{
if ($this->clinicalSummaryUnsortedStatus !== $clinicalSummaryUnsortedStatus) {
$this->setClinicalSummaryUnsortedUpdated(new DateTime());
}
$this->clinicalSummaryUnsortedStatus = $clinicalSummaryUnsortedStatus;
return $this;
}
/**
* @return array
*/
public static function getClinicalSummaryUnsortedStatusOptions(): array
{
return static::getConstantsWithLabelsAsChoices('CLINICAL_SUMMARY_UNSORTED_STATUS');
}
/**
* @return string
*/
public function getClinicalSummaryUnsortedStatusLabel(): string
{
$options = array_flip($this->getClinicalSummaryUnsortedStatusOptions());
return $options[$this->clinicalSummaryUnsortedStatus] ?? '';
}
/**
* @return DateTimeInterface|null
*/
public function getClinicalSummaryUnsortedUpdated(): ?DateTimeInterface
{
return $this->clinicalSummaryUnsortedUpdated;
}
/**
* @param DateTimeInterface|null $clinicalSummaryUnsortedUpdated
*
* @return self
*/
public function setClinicalSummaryUnsortedUpdated(?DateTimeInterface $clinicalSummaryUnsortedUpdated): self
{
$this->clinicalSummaryUnsortedUpdated = $clinicalSummaryUnsortedUpdated;
return $this;
}
/**
* @return bool
*/
public function showClinicalSummaryUnsortedAdditionalInstruction(): bool
{
$statuses = [
self::CLINICAL_SUMMARY_UNSORTED_STATUS_AWAITING_CONCLUSION,
self::CLINICAL_SUMMARY_UNSORTED_STATUS_INCONCLUSIVE,
];
return in_array($this->getClinicalSummaryUnsortedStatus(), $statuses);
}
/**
* @param Instance $instance
*
* @return $this
*/
public function addInstance(Instance $instance): Project
{
if (!$this->instances->contains($instance)) {
$this->instances[] = $instance;
}
return $this;
}
/**
* @param Instance $instance
*
* @return $this
*/
public function removeInstance(Instance $instance): Project
{
$this->instances->removeElement($instance);
return $this;
}
/**
* @return DoctrineCollection<int, InterpartyDisclosure>
*/
public function getInterpartyDisclosures(): DoctrineCollection
{
return $this->interpartyDisclosures;
}
/**
* This function name is no longer very descriptive as we include drafts that
* were saved intentionally as drafts for review.
*
* @return DoctrineCollection<int, InterpartyDisclosure>
*/
public function getNonDraftInterpartyDisclosures(): DoctrineCollection
{
return $this->interpartyDisclosures->filter(function (InterpartyDisclosure $disclosure) {
return ($disclosure->isStatusDraft() === false || $disclosure->getSavedAsDraft() === true) && $disclosure->isCurrentHeadOfChain() === true;
});
}
/**
* Returns a unique array of matter numbers that have already been used as recipient firm
* matter numbers for disclosures on this project.
*
* @param ?InterpartyDisclosure $excludeDisclosure - Optionally exclude a specific disclosure from the list.
* @param bool $excludePreviousVersions
*
* @return array
*/
public function getInterpartyDisclosureRecipientMatterNumbers(?InterpartyDisclosure $excludeDisclosure = null, bool $excludePreviousVersions = false): array
{
$matterNumbers = [];
foreach ($this->getInterpartyDisclosures() as $disclosure) {
if (
$excludeDisclosure === $disclosure
|| ($excludePreviousVersions === true && $disclosure->isDisclosurePreviousVersionOf($excludeDisclosure))
|| $disclosure->isStatusDraft()
|| $disclosure->isStatusRevoked()
|| $disclosure->isStatusFailed()
) {
continue;
}
foreach ($disclosure->getRecipientFirms() as $recipientFirm) {
$matterNumbers[] = $recipientFirm->getMatterNumber();
}
}
// Don't call array unique here as it messes with the keys of the array.
return $matterNumbers;
}
/**
* @return bool
*/
public function hasActiveInterpartyDisclosures(): bool
{
foreach ($this->getInterpartyDisclosures() as $disclosure) {
if ($disclosure->isStatusActive()) {
return true;
}
}
return false;
}
/**
* @return bool
*/
public function hasExpiredInterpartyDisclosures(): bool
{
foreach ($this->getInterpartyDisclosures() as $disclosure) {
if ($disclosure->isStatusExpired()) {
return true;
}
}
return false;
}
/**
* @param InterpartyDisclosure $interpartyDisclosure
*
* @return self
*/
public function addInterpartyDisclosure(InterpartyDisclosure $interpartyDisclosure): self
{
if (!$this->interpartyDisclosures->contains($interpartyDisclosure)) {
$this->interpartyDisclosures[] = $interpartyDisclosure;
$interpartyDisclosure->setProject($this);
}
return $this;
}
/**
* @param InterpartyDisclosure $interpartyDisclosure
*
* @return self
*/
public function removeInterpartyDisclosure(InterpartyDisclosure $interpartyDisclosure): self
{
if ($this->interpartyDisclosures->removeElement($interpartyDisclosure)) {
// set the owning side to null (unless already changed)
if ($interpartyDisclosure->getProject() === $this) {
$interpartyDisclosure->setProject(null);
}
}
return $this;
}
/**
* Return the count of active disclosures relating to the current project.
*
* @return int
*/
public function getActiveDisclosuresCount(): int
{
$interpartyDisclosuresArray = $this->getInterpartyDisclosures()->toArray();
$activeCount = array_reduce(
$interpartyDisclosuresArray,
function ($activeTotal, $disclosure) {
return $activeTotal + $disclosure->isStatusActive();
},
0
);
return $activeCount;
}
/**
* @return string|null
*
*/
public function getMatterType(): ?string
{
return $this->matterType;
}
/**
* @param string|null $matterType
*
* @return self
*/
public function setMatterType(?string $matterType): self
{
$this->matterType = $matterType;
return $this;
}
/**
* @return array
*/
public static function getMatterTypeOptions(): array
{
return self::getConstantsWithLabelsAsChoices('MATTER_TYPE');
}
/**
* @return string
*/
public function getMatterTypeLabel(): string
{
if ($this->getMatterType() === null) {
return '';
}
$options = array_flip(self::getMatterTypeOptions());
return $options[$this->getMatterType()] ?? '';
}
/**
* @return bool
*/
public function isClinicalNegligenceMatterType(): bool
{
return $this->getMatterType() === self::MATTER_TYPE_CLINICAL_NEGLIGENCE;
}
/**
* Get the value of useModernRadiology
*/
public function getUseModernRadiology(): ?bool
{
return $this->useModernRadiology;
}
/**
* Set the value of useModernRadiology
*
* @param bool|null $useModernRadiology
*
* @return self
*/
public function setUseModernRadiology(?bool $useModernRadiology)
{
$this->useModernRadiology = $useModernRadiology;
return $this;
}
/**
* Get the value of modernRadiologyMigrationStatus
*/
public function getModernRadiologyMigrationStatus(): ?string
{
return $this->modernRadiologyMigrationStatus;
}
/**
* Set the value of modernRadiologyMigrationStatus
*
* @param mixed $modernRadiologyMigrationStatus
*
* @return self
*/
public function setModernRadiologyMigrationStatus(?string $modernRadiologyMigrationStatus)
{
$this->modernRadiologyMigrationStatus = $modernRadiologyMigrationStatus;
// Once the migration completes, flick the switch that we should now use modern radiology.
if ($modernRadiologyMigrationStatus === self::MODERN_RADIOLOGY_MIGRATION_STATUS_COMPLETE
|| $modernRadiologyMigrationStatus === self::MODERN_RADIOLOGY_MIGRATION_STATUS_SKIPPED) {
$this->setUseModernRadiology(true);
}
return $this;
}
/**
* @return bool
*/
public function isModernRadiologyMigrationInProgress(): bool
{
return $this->getModernRadiologyMigrationStatus() === self::MODERN_RADIOLOGY_MIGRATION_STATUS_IN_PROGRESS;
}
/**
* @return string|null
*/
public function getType(): ?string
{
return $this->type;
}
/**
* @param string|null $type
*
* @return self
*/
public function setType(?string $type): self
{
$this->type = $type;
return $this;
}
/**
* @return bool
*/
public function isTypeDisclosure(): bool
{
return $this->type === self::TYPE_MATTER_DISCLOSURE;
}
/**
* Returns an array of permitted values for the Matter Type field and their
* associated labels.
*
* @return array
*/
public static function getTypeOptions()
{
$typeOptions = self::getConstantsWithLabelsAsChoices('TYPE_MATTER');
return $typeOptions;
}
/**
* Returns a human readable version of the type
*
* @return string
*/
public function getTypeLabel()
{
return self::getConstantsWithLabels('TYPE_MATTER');
}
/**
* @return bool
*/
public function hasNoRecordsForDisclosure(): bool
{
if ($this->getMedicalRecordsCollection() === null) {
return false;
}
return $this->getMedicalRecordsCollection()->getDocuments()->isEmpty() && $this->getUnsortedRecordsCollection()->getDocuments()->isEmpty();
}
/**
* @return bool
*/
public function hasNoRadiologyForDisclosure(): bool
{
// Get failed discs too for this consideration, as you can disclose failed discs.
return $this->getFailedDiscs()->isEmpty() && $this->getActiveDiscs()->isEmpty() && $this->getStudies()->isEmpty();
}
/**
* Returns true if the project has no items for disclosure (records and radiology)
*
* @return bool
*/
public function hasNoItemsForDisclosure(): bool
{
$hasNoRecords = $this->hasNoRecordsForDisclosure();
$hasNoRadiology = $this->hasNoRadiologyForDisclosure();
return $hasNoRecords === true && $hasNoRadiology === true;
}
/**
* Returns true if one of the project's discs does not have the same status as it had pre-migration.
*
* @return bool
*/
public function hasProjectFailedDiscMigration(): bool
{
foreach ($this->getDiscs() as $disc) {
if ($disc->hasDiscFailedMigration()) {
return true;
}
}
return false;
}
/**
* @return bool|null
*/
public function getHideFromInvoicing(): ?bool
{
return $this->hideFromInvoicing;
}
/**
* @param bool|null $hideFromInvoicing
*
* @return self
*/
public function setHideFromInvoicing(?bool $hideFromInvoicing): self
{
$this->hideFromInvoicing = $hideFromInvoicing;
return $this;
}
/**
* @return DateTimeInterface|null
*/
public function getLastRenewalDate(): ?DateTimeInterface
{
return $this->lastRenewalDate;
}
/**
* @param DateTimeInterface|null $lastRenewalDate
*
* @return self
*/
public function setLastRenewalDate(?DateTimeInterface $lastRenewalDate): self
{
$this->lastRenewalDate = $lastRenewalDate;
return $this;
}
/**
* @return DateTimeInterface|null
*/
public function getNextRenewalDate(): ?DateTimeInterface
{
return $this->nextRenewalDate;
}
/**
* @param DateTimeInterface|null $nextRenewalDate
*
* @return self
*/
public function setNextRenewalDate(?DateTimeInterface $nextRenewalDate): self
{
$this->nextRenewalDate = $nextRenewalDate;
return $this;
}
/**
* @return array|null
*/
public function getRenewalNotificationSent(): ?array
{
return $this->renewalNotificationSent;
}
/**
* @param array|null $renewalNotificationSent
*
* @return self
*/
public function setRenewalNotificationSent(?array $renewalNotificationSent): self
{
$this->renewalNotificationSent = $renewalNotificationSent;
return $this;
}
/**
* @return DoctrineCollection<int, MatterLicenceRenewalLog>
*/
public function getMatterLicenceRenewalLogs(): DoctrineCollection
{
return $this->matterLicenceRenewalLogs;
}
/**
* @param MatterLicenceRenewalLog $matterLicenceRenewalLog
*
* @return self
*/
public function addMatterLicenceRenewalLog(MatterLicenceRenewalLog $matterLicenceRenewalLog): self
{
if (!$this->matterLicenceRenewalLogs->contains($matterLicenceRenewalLog)) {
$this->matterLicenceRenewalLogs[] = $matterLicenceRenewalLog;
$matterLicenceRenewalLog->setProject($this);
}
return $this;
}
/**
* @param MatterLicenceRenewalLog $matterLicenceRenewalLog
*
* @return self
*/
public function removeMatterLicenceRenewalLog(MatterLicenceRenewalLog $matterLicenceRenewalLog): self
{
if ($this->matterLicenceRenewalLogs->removeElement($matterLicenceRenewalLog)) {
// set the owning side to null (unless already changed)
if ($matterLicenceRenewalLog->getProject() === $this) {
$matterLicenceRenewalLog->setProject(null);
}
}
return $this;
}
/**
* Get a valid Licence Renewal Term belonging to the Project
* For a term to be valid the Project's created date must fall between the effective renewal date and effective renewal end date
*
* @return LicenceRenewalTerm|null
*/
public function getLicenceRenewalTerm(): ?LicenceRenewalTerm
{
$terms = $this->getAccount()->getLicenceRenewalTerms();
// if the Account doesn't have any associated terms return
if (empty($terms)) {
return null;
}
// find only the applicable term for this project
foreach ($terms as $term) {
$validStartCriteria = $this->getCreated() >= $term->getEffectiveDate();
$validEndCriteria = $term->getEffectiveEndDate() === null || ($this->getCreated() <= $term->getEffectiveEndDate());
// return the qualifying term, effectiveEndDate of null indicates the last term, thus a recurring term
if ($validStartCriteria && $validEndCriteria) {
return $term;
}
};
return null;
}
/**
* @return string|null
*/
public function getPermanentDeleteStatus(): ?string
{
return $this->permanentDeleteStatus;
}
/**
* @param string|null $permanentDeleteStatus
*
* @return self
*/
public function setPermanentDeleteStatus(?string $permanentDeleteStatus): self
{
$this->permanentDeleteStatus = $permanentDeleteStatus;
return $this;
}
/**
* If there is a renewal date, it calculates the difference in days between it and today's date.
*
* @return int|null Number of days until renewal, or null if there's no renewal date.
*/
public function getNumberOfDaysTillRenewal(): ?int
{
$nextRenewalDate = $this->getNextRenewalDate();
if ($nextRenewalDate !== null) {
$currentDate = (new DateTime())->setTime(0, 0, 0);
// Calculate the difference in days
$dueForRenewalInDays = $nextRenewalDate->diff($currentDate, false)->days;
$dueForRenewalInDays = max(0, $dueForRenewalInDays);
return $dueForRenewalInDays;
}
return null;
}
/**
* @return ClinicalSummary|null
*/
public function getClinicalSummary(): ?ClinicalSummary
{
return $this->clinicalSummary;
}
/**
* @param ClinicalSummary|null $clinicalSummary
*
* @return self
*/
public function setClinicalSummary(?ClinicalSummary $clinicalSummary): self
{
$this->clinicalSummary = $clinicalSummary;
return $this;
}
/**
* Returns an array of service request groups for this project.
*
* @return array
*/
public function getServiceRequestGroups(): array
{
// If you have a property or logic for service request groups, return it here.
// Otherwise, return an empty array to avoid errors.
return [];
}
/**
* Retrieves the counts of an array of Serviceable entities, grouped by their ServiceRequest status.
*
* @param array $serviceables
* @param bool $uninvoicedOnly
*
* @return array
*/
private function getServiceableCountsByStatus(array $serviceables, $uninvoicedOnly = true)
{
$serviceableCounts = [];
// Go through each serviceable entity
foreach ($serviceables as $serviceable) {
// Check that it is in fact a Serviceable entity, and that it has a ServiceRequest
// attached to it.
if ($serviceable instanceof ServiceableInterface && $serviceable->getServiceRequest()) {
// If we are only looking for uninvoiced, and this serviceable entity has been billed for,
// continue to next element of the array.
if ($uninvoicedOnly && $serviceable->isBilled()) {
continue;
}
// Use the status integer as the key
$key = $serviceable->getServiceRequest()->getStatus();
// If the array element does not already exist, setup the defaults for it.
if (!isset($serviceableCounts[$key])) {
// Place the count and label as two separate elements of the array
// so we can easily access them using the status integer key
$serviceableCounts[$key] = [
'label' => $serviceable->getServiceRequest()->getStatusLabel(),
'count' => 0,
];
}
// Increment the count for the status
$serviceableCounts[$key]['count']++;
}
}
// Sort the elements by key (status)
ksort($serviceableCounts);
return $serviceableCounts;
}
}