src/Entity/Project.php line 1597

Open in your IDE?
  1. <?php
  2. namespace MedBrief\MSR\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use DateTime;
  5. use DateTimeInterface;
  6. use DH\Auditor\Provider\Doctrine\Auditing\Annotation as Audit;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection as DoctrineCollection;
  9. use Doctrine\Common\Collections\Criteria;
  10. use Doctrine\ORM\EntityNotFoundException;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use Doctrine\Persistence\Proxy;
  13. use Exception;
  14. use Gedmo\Mapping\Annotation as Gedmo;
  15. use libphonenumber\PhoneNumber;
  16. use MedBrief\MSR\Controller\Project\UpdateRenewalPreferenceAction;
  17. use MedBrief\MSR\Controller\ProjectMatch\ProjectMatchExpertJustificationController;
  18. use MedBrief\MSR\Controller\ProjectMatch\ProjectMatchExpertNameSearchController;
  19. use MedBrief\MSR\Controller\ProjectMatch\ProjectMatchExpertProfileController;
  20. use MedBrief\MSR\Controller\ProjectMatch\ProjectMatchLoAPreviewPdfController;
  21. use MedBrief\MSR\Controller\ProjectMatch\ProjectMatchLoASendPdfController;
  22. use MedBrief\MSR\Controller\ProjectMatch\ProjectMatchMyExpertsController;
  23. use MedBrief\MSR\Controller\ProjectMatch\ProjectMatchRecommendedOptionsController;
  24. use MedBrief\MSR\Controller\ProjectMatch\ProjectMatchSearchController;
  25. use MedBrief\MSR\Controller\ProjectMatch\ProjectMatchShortlistedController;
  26. use MedBrief\MSR\Dto\ClinicalSummaryMatterDto;
  27. use MedBrief\MSR\Dto\Project\RenewalPreferenceOutputDto;
  28. use MedBrief\MSR\Dto\Project\UpdateRenewalPreferenceInputDto;
  29. use MedBrief\MSR\Dto\ProjectMatch\MatchMessagesCta;
  30. use MedBrief\MSR\Entity\MatterRequest\MatterRequest;
  31. use MedBrief\MSR\Entity\MatterRequest\Patient;
  32. use MedBrief\MSR\Entity\Patient as RadiologyPatient;
  33. use MedBrief\MSR\Entity\Serviceable\ServiceableInterface;
  34. use MedBrief\MSR\Repository\ProjectRepository;
  35. use MedBrief\MSR\Service\ClaimCategoryAwareInterface;
  36. use MedBrief\MSR\Service\InterpartyDisclosure\Disclose\DisclosureTargetInterface;
  37. use MedBrief\MSR\Service\MatterTypeAwareInterface;
  38. use MedBrief\MSR\Traits\Disclosure\DisclosureTargetTrait;
  39. use MedBrief\MSR\Traits\FilterableClassConstantsTrait;
  40. use MedBrief\MSR\Traits\ProjectShouldShowAlertTrait;
  41. use Symfony\Component\Serializer\Annotation\Groups;
  42. use Symfony\Component\Validator\Constraints as Assert;
  43. use Symfony\Component\Validator\Context\ExecutionContextInterface;
  44. use Symfony\Component\Validator\Mapping\ClassMetadata;
  45. use Symfony\Component\Validator\Validation;
  46. /**
  47. * 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.
  48. *
  49. * @ApiResource(
  50. * collectionOperations={},
  51. * itemOperations={
  52. * "get"={
  53. * "access_control"="is_granted('READ', object)",
  54. * "normalization_context"={"groups"={"project_closure:read"}, "enable_max_depth"=true}
  55. * },
  56. * "get_clinical_summary_matter"={
  57. * "method"="GET",
  58. * "path"="/projects/{id}/clinical_summary_matter",
  59. * "access_control"="is_granted('READ', object)",
  60. * "normalization_context"={"groups"={"clinical_summary_matter:read"}},
  61. * "output"=ClinicalSummaryMatterDto::class,
  62. * "description"="Resource representing matter details relevant to a clinical summary.",
  63. * },
  64. * "update_renewal_preference"={
  65. * "method"="POST",
  66. * "path"="/projects/{id}/renewal-preference",
  67. * "access_control"="is_granted('UPDATE', object)",
  68. * "controller"=UpdateRenewalPreferenceAction::class,
  69. * "input"=UpdateRenewalPreferenceInputDto::class,
  70. * "output"=RenewalPreferenceOutputDto::class,
  71. * "normalization_context"={"groups"={"renewal_preference:read"}},
  72. * "denormalization_context"={"groups"={"renewal_preference:write"}},
  73. * "validation_groups"={"renewal_preference:write"},
  74. * "openapi_context"={
  75. * "summary"="Update a matter's renewal reminder preference",
  76. * "requestBody"={
  77. * "required"=true,
  78. * "content"={
  79. * "application/json"={
  80. * "schema"={
  81. * "type"="object",
  82. * "required"={"proceedWithRenewal"},
  83. * "properties"={
  84. * "proceedWithRenewal"={"type"="boolean"}
  85. * }
  86. * }
  87. * }
  88. * }
  89. * },
  90. * "responses"={
  91. * "200"={
  92. * "description"="Renewal preference updated",
  93. * "content"={
  94. * "application/json"={
  95. * "schema"={
  96. * "type"="object",
  97. * "properties"={
  98. * "proceedWithRenewal"={"type"="boolean"}
  99. * }
  100. * }
  101. * }
  102. * }
  103. * },
  104. * "409"={
  105. * "description"="The matter is outside the renewal reminder window."
  106. * }
  107. * }
  108. * }
  109. * },
  110. * "get_alert_status"={
  111. * "method"="GET",
  112. * "path"="/match/project/{id}/show-match-alert",
  113. * "access_control"="is_granted('MATCH_VIEW_FIRM', object)",
  114. * "openapi_context"={
  115. * "summary"="Get project alert status",
  116. * "description"="Returns whether an alert should be shown for insufficient matter information"
  117. * },
  118. * "controller"="MedBrief\MSR\Controller\ProjectController::getMatchAlertStatusAction",
  119. * "output"=MedBrief\MSR\Dto\ProjectMatch\MatchAlertStatusOutputDto::class,
  120. * "normalization_context"={"groups"={"project:matchAlert"}}
  121. * },
  122. * "records_insights_chat_sessions"={
  123. * "method"="GET",
  124. * "path"="/project/insights/{id}/records-chat-sessions",
  125. * "access_control"="is_granted('READ', object) and is_granted('VIEW_RECORDS_INSIGHTS', object)",
  126. * "controller"="MedBrief\MSR\Controller\ProjectInsights\ProjectInsightsController::recordInsightsSessionListAction",
  127. * "requirements"={
  128. * "id"="\d+"
  129. * },
  130. * "openapi_context"={
  131. * "summary"="Retrieves chat sessions for a project.",
  132. * "description"="Returns a list of chat sessions with preview information. By default returns the 10 most recent. Use 'all' to retrieve all sessions.",
  133. * "parameters"={
  134. * {
  135. * "name"="id",
  136. * "in"="path",
  137. * "required"=true,
  138. * "description"="Project ID",
  139. * "schema"={"type"="integer"}
  140. * },
  141. * {
  142. * "name"="limit",
  143. * "in"="query",
  144. * "required"=false,
  145. * "description"="Limit of sessions returned. Use 'all' to retrieve all sessions. Defaults to 10.",
  146. * "schema"={"type"="string", "default"="10", "example"="all"}
  147. * }
  148. * },
  149. * "responses"={
  150. * "200"={
  151. * "description"="List of chat sessions with preview information including first query, query count, origin panel, and last query date.",
  152. * }
  153. * }
  154. * }
  155. * },
  156. * "records_insights_chat_session"={
  157. * "method"="GET",
  158. * "path"="/project/insights/{id}/records-chat-session/{sessionId}",
  159. * "access_control"="is_granted('READ', object) and is_granted('VIEW_RECORDS_INSIGHTS', object)",
  160. * "controller"="MedBrief\MSR\Controller\ProjectInsights\ProjectInsightsController::recordInsightsSessionAction",
  161. * "requirements"={
  162. * "id"="\d+",
  163. * "sessionId"="[^/]+"
  164. * },
  165. * "openapi_context"={
  166. * "summary"="Retrieves a records chat session for a given session ID.",
  167. * "description"="Returns the chat session for a specific session within a project.",
  168. * "parameters"={
  169. * {
  170. * "name"="id",
  171. * "in"="path",
  172. * "required"=true,
  173. * "description"="Project ID",
  174. * "schema"={"type"="integer"}
  175. * },
  176. * {
  177. * "name"="sessionId",
  178. * "in"="path",
  179. * "required"=true,
  180. * "description"="Session ID",
  181. * "schema"={"type"="string"}
  182. * }
  183. * },
  184. * "responses"={
  185. * "200"={
  186. * "description"="Chat session for the specified session within the project.",
  187. * }
  188. * }
  189. * }
  190. * },
  191. * "records_insights_chat"={
  192. * "method"="POST",
  193. * "path"="/project/insights/{id}/records-chat",
  194. * "access_control"="is_granted('READ', object) and is_granted('VIEW_RECORDS_INSIGHTS', object)",
  195. * "controller"="MedBrief\MSR\Controller\ProjectInsights\ProjectInsightsController::recordInsightsChatAction",
  196. * "deserialize"=false,
  197. * "requirements"={
  198. * "id"="\d+",
  199. * },
  200. * "openapi_context"={
  201. * "summary"="Record insights chat",
  202. * "description"="Handles chat interactions for project medical records insights.",
  203. * "parameters"={
  204. * {
  205. * "name"="id",
  206. * "in"="path",
  207. * "required"=true,
  208. * "description"="Project ID",
  209. * "schema"={"type"="integer"}
  210. * }
  211. * },
  212. * "requestBody"={
  213. * "required"=true,
  214. * "content"={
  215. * "application/json"={
  216. * "schema"={
  217. * "type"="object",
  218. * "properties"={
  219. * "sessionId"={
  220. * "type"="string",
  221. * "description"="The session ID for the chat session, used to maintain context across multiple messages. Should be passed with every message after the first one."
  222. * },
  223. * "message"={
  224. * "type"="string",
  225. * "description"="The user's message to the chatbot (Max)"
  226. * },
  227. * "filters"={
  228. * "type"="object",
  229. * "description"="Optional filters to narrow the records scope",
  230. * "properties"={
  231. * "dateFrom"={
  232. * "type"="string",
  233. * "description"="From date in ISO format"
  234. * },
  235. * "dateTo"={
  236. * "type"="string",
  237. * "description"="To date in ISO format"
  238. * },
  239. * "location"={
  240. * "type"="object",
  241. * "description"="Location filter specifying a folder or file",
  242. * "properties"={
  243. * "id"={
  244. * "type"="integer",
  245. * "description"="The ID of the folder or file"
  246. * },
  247. * "type"={
  248. * "type"="string",
  249. * "enum"={"folder","file"},
  250. * "description"="Whether the location is a folder or file"
  251. * }
  252. * }
  253. * }
  254. * }
  255. * }
  256. * },
  257. * "required"={"message"}
  258. * },
  259. * "example"={
  260. * "sessionId"=null,
  261. * "message"="What injuries did the patient sustain?",
  262. * "filters"={
  263. * "dateFrom"="2023-01-01",
  264. * "dateTo"="2023-12-31",
  265. * "location"={
  266. * "id"=71,
  267. * "type"="folder"
  268. * }
  269. * }
  270. * }
  271. * }
  272. * }
  273. * },
  274. * "responses"={
  275. * "200"={"description"="Records insights chat response from the chatbot, including the chatbot's message and an updated conversation ID to be used for the next message."},
  276. * "404"={"description"="Project not found"}
  277. * }
  278. * }
  279. * },
  280. * "records_insights_feedback"={
  281. * "method"="POST",
  282. * "path"="/project/insights/{id}/records-feedback",
  283. * "access_control"="is_granted('READ', object)",
  284. * "controller"="MedBrief\MSR\Controller\ProjectInsights\ProjectInsightsController::recordInsightsFeedbackAction",
  285. * "deserialize"=false,
  286. * "requirements"={
  287. * "id"="\d+"
  288. * },
  289. * "openapi_context"={
  290. * "summary"="Record AI feedback for an insights chat response",
  291. * "description"="Stores thumbs up/down feedback (and optional comment) for an Ask Alex chat response.",
  292. * "parameters"={
  293. * {
  294. * "name"="id",
  295. * "in"="path",
  296. * "required"=true,
  297. * "description"="Project ID",
  298. * "schema"={"type"="integer"}
  299. * }
  300. * },
  301. * "requestBody"={
  302. * "required"=true,
  303. * "content"={
  304. * "application/json"={
  305. * "schema"={
  306. * "type"="object",
  307. * "properties"={
  308. * "contentType"={"type"="string", "example"="insights_chat", "description"="The type of content being rated. For Ask Alex chat responses, this should be 'insights_chat'."},
  309. * "contentDetails"={"type"="string", "description"="The assistant response text"},
  310. * "contentId"={"type"="integer", "nullable"=true, "description"="RecordsChatHistory id of the rated AI message"},
  311. * "feedback"={"type"="string", "enum"={"positive","negative"}},
  312. * "comment"={"type"="string", "nullable"=true},
  313. * "filters"={"type"="object", "description"="Filters that produced the response"}
  314. * },
  315. * "required"={"contentType","contentDetails","feedback"}
  316. * },
  317. * "example"={
  318. * "contentType"="insights_chat", "description"="The type of content being rated. For Ask Alex chat responses, this should be 'insights_chat'.",
  319. * "contentDetails"="Here are GP records that contain references to...",
  320. * "contentId"=4567,
  321. * "feedback"="negative",
  322. * "comment"="Missed the March entries.",
  323. * "filters"={"dateFrom"="2023-12-14","dateTo"="2026-03-14","includeUndated"=false}
  324. * }
  325. * }
  326. * }
  327. * },
  328. * "responses"={
  329. * "201"={"description"="Feedback recorded"},
  330. * "400"={"description"="Invalid input"},
  331. * "404"={"description"="Project not found"}
  332. * }
  333. * }
  334. * },
  335. * "records_filter"={
  336. * "method"="POST",
  337. * "path"="/projects/{id}/records-filter",
  338. * "access_control"="is_granted('READ', object)",
  339. * "controller"="MedBrief\MSR\Controller\ProjectMedicalRecordController::filterRecords",
  340. * "deserialize"=false,
  341. * "requirements"={
  342. * "id"="\d+",
  343. * },
  344. * "openapi_context"={
  345. * "summary"="Filter project medical records",
  346. * "description"="Filters the medical records for a project based on the provided criteria.",
  347. * "parameters"={
  348. * {
  349. * "name"="id",
  350. * "in"="path",
  351. * "required"=true,
  352. * "description"="Project ID",
  353. * "schema"={"type"="integer"}
  354. * }
  355. * },
  356. * "requestBody"={
  357. * "required"=true,
  358. * "content"={
  359. * "application/json"={
  360. * "schema"={
  361. * "type"="object",
  362. * "properties"={
  363. * "dateFrom"={
  364. * "type"="string",
  365. * "description"="Date you want to filter from in ISO format"
  366. * },
  367. * "dateTo"={
  368. * "type"="string",
  369. * "description"="Date you want to filter to in ISO format"
  370. * }
  371. * },
  372. * "required"={"dateFrom","dateTo"}
  373. * },
  374. * "example"={
  375. * "dateFrom"="2024-06-01",
  376. * "dateTo"="2024-06-15"
  377. * }
  378. * }
  379. * }
  380. * },
  381. * "responses"={
  382. * "200"={"description"="Records filtered successfully."}
  383. * }
  384. * }
  385. * },
  386. * "records_insights_index"={
  387. * "method"="GET",
  388. * "path"="/project/insights/{id}/records-index/{documentId}",
  389. * "access_control"="is_granted('READ', object) and is_granted('VIEW_RECORDS_INSIGHTS', object)",
  390. * "controller"="MedBrief\MSR\Controller\ProjectInsights\ProjectInsightsController::recordsIndexAction",
  391. * "deserialize"=false,
  392. * "requirements"={
  393. * "id"="\d+",
  394. * "documentId"="\d+"
  395. * },
  396. * "openapi_context"={
  397. * "summary"="Retrieve the AI-generated records index for a specific document",
  398. * "description"="Returns a cached records index if available, otherwise generates it via AI and caches the result.",
  399. * "parameters"={
  400. * {
  401. * "name"="id",
  402. * "in"="path",
  403. * "required"=true,
  404. * "description"="Project ID",
  405. * "schema"={"type"="integer"}
  406. * },
  407. * {
  408. * "name"="documentId",
  409. * "in"="path",
  410. * "required"=true,
  411. * "description"="Document ID",
  412. * "schema"={"type"="integer"}
  413. * }
  414. * },
  415. * "responses"={
  416. * "200"={"description"="Records index retrieved successfully"},
  417. * "204"={"description"="Index unavailable"},
  418. * "404"={"description"="Project or document not found"}
  419. * }
  420. * }
  421. * },
  422. * "records_insights_key_events"={
  423. * "method"="GET",
  424. * "path"="/project/insights/{id}/records-key-events",
  425. * "access_control"="is_granted('READ', object) and is_granted('VIEW_RECORDS_INSIGHTS', object)",
  426. * "controller"="MedBrief\MSR\Controller\ProjectInsights\ProjectInsightsController::recordInsightsKeyEventsAction",
  427. * "requirements"={
  428. * "id"="\d+"
  429. * },
  430. * "openapi_context"={
  431. * "summary"="Retrieves key events timeline for a project.",
  432. * "description"="Returns a chronological timeline of clinically significant events extracted from the project's medical records.",
  433. * "parameters"={
  434. * {
  435. * "name"="id",
  436. * "in"="path",
  437. * "required"=true,
  438. * "description"="Project ID",
  439. * "schema"={"type"="integer"}
  440. * }
  441. * },
  442. * "responses"={
  443. * "200"={"description"="List of key clinical events with source references."},
  444. * "204"={"description"="No key events available for this project."},
  445. * "404"={"description"="Project or document not found"}
  446. * }
  447. * }
  448. * },
  449. * "records_insights_key_events_document_page_labels"={
  450. * "method"="GET",
  451. * "path"="/project/insights/{id}/records-key-events/document-page-labels/{documentId}",
  452. * "access_control"="is_granted('READ', object) and is_granted('VIEW_RECORDS_INSIGHTS', object)",
  453. * "controller"="MedBrief\MSR\Controller\ProjectInsights\ProjectInsightsController::recordInsightsKeyEventsDocumentPageLabelsAction",
  454. * "requirements"={"id"="\d+", "documentId"="\d+"},
  455. * "openapi_context"={
  456. * "summary"="Retrieves the physical-page to bundle-label map for one document.",
  457. * "description"="Returns every indexed physical page of the document mapped to its sorting-session label, so the Key Events editor can display bundle labels for any page of a viewed document.",
  458. * "parameters"={
  459. * {"name"="id", "in"="path", "required"=true, "description"="Project ID", "schema"={"type"="integer"}},
  460. * {"name"="documentId", "in"="path", "required"=true, "description"="Document ID", "schema"={"type"="integer"}}
  461. * },
  462. * "responses"={
  463. * "200"={"description"="Physical-page to label map for the document."},
  464. * "404"={"description"="Document not found in this matter."}
  465. * }
  466. * }
  467. * },
  468. * "records_insights_key_events_page_reference_search"={
  469. * "method"="GET",
  470. * "path"="/project/insights/{id}/records-key-events/page-reference-search/{documentId}",
  471. * "access_control"="is_granted('READ', object) and is_granted('VIEW_RECORDS_INSIGHTS', object)",
  472. * "controller"="MedBrief\MSR\Controller\ProjectInsights\ProjectInsightsController::recordInsightsKeyEventsPageReferenceSearchAction",
  473. * "requirements"={"id"="\d+", "documentId"="\d+"},
  474. * "openapi_context"={
  475. * "summary"="Searches indexed page references for the Key Events editor.",
  476. * "parameters"={
  477. * {"name"="id", "in"="path", "required"=true, "description"="Project ID", "schema"={"type"="integer"}},
  478. * {"name"="documentId", "in"="path", "required"=true, "description"="Document ID", "schema"={"type"="integer"}},
  479. * {"name"="q", "in"="query", "required"=true, "description"="Physical page or index label search term", "schema"={"type"="string"}},
  480. * {"name"="limit", "in"="query", "required"=false, "description"="Maximum number of suggestions", "schema"={"type"="integer", "default"=25}}
  481. * },
  482. * "responses"={
  483. * "200"={"description"="Bounded page-reference suggestions."},
  484. * "404"={"description"="Document not found in this matter."}
  485. * }
  486. * }
  487. * },
  488. * "records_insights_key_events_project_page_reference_search"={
  489. * "method"="GET",
  490. * "path"="/project/insights/{id}/records-key-events/page-reference-search",
  491. * "access_control"="is_granted('READ', object) and is_granted('VIEW_RECORDS_INSIGHTS', object)",
  492. * "controller"="MedBrief\MSR\Controller\ProjectInsights\ProjectInsightsController::recordInsightsKeyEventsProjectPageReferenceSearchAction",
  493. * "requirements"={"id"="\d+"},
  494. * "openapi_context"={
  495. * "summary"="Searches indexed page references across a project's documents.",
  496. * "parameters"={
  497. * {"name"="id", "in"="path", "required"=true, "description"="Project ID", "schema"={"type"="integer"}},
  498. * {"name"="q", "in"="query", "required"=true, "description"="Physical page or index label search term", "schema"={"type"="string"}},
  499. * {"name"="limit", "in"="query", "required"=false, "description"="Maximum number of suggestions", "schema"={"type"="integer", "default"=25}}
  500. * },
  501. * "responses"={"200"={"description"="Bounded page-reference suggestions across the matter."}}
  502. * }
  503. * },
  504. * "records_insights_key_events_create"={
  505. * "method"="POST",
  506. * "path"="/project/insights/{id}/records-key-events",
  507. * "access_control"="is_granted('READ', object) and is_granted('EDIT_RECORDS_INSIGHTS', object)",
  508. * "controller"="MedBrief\MSR\Controller\ProjectInsights\ProjectInsightsController::recordInsightsKeyEventCreateAction",
  509. * "deserialize"=false,
  510. * "requirements"={
  511. * "id"="\d+"
  512. * },
  513. * "openapi_context"={
  514. * "summary"="Create and immediately save a Key Event",
  515. * "requestBody"={
  516. * "required"=true,
  517. * "content"={
  518. * "application/json"={
  519. * "schema"={
  520. * "type"="object",
  521. * "required"={"id"},
  522. * "properties"={
  523. * "id"={"type"="string"},
  524. * "status"={"type"="string"},
  525. * "date"={"type"="string"},
  526. * "title"={"type"="string"},
  527. * "summary"={"type"="string"},
  528. * "categories"={"type"="array", "items"={"type"="string"}},
  529. * "native_files"={"type"="array", "items"={"type"="object"}}
  530. * }
  531. * }
  532. * }
  533. * }
  534. * },
  535. * "responses"={
  536. * "201"={"description"="Key Event saved"},
  537. * "400"={"description"="Invalid Key Event payload"},
  538. * "403"={"description"="Not authorised to edit Key Events"}
  539. * }
  540. * }
  541. * },
  542. * "records_insights_key_events_update"={
  543. * "method"="PUT",
  544. * "path"="/project/insights/{id}/records-key-events/{eventId}",
  545. * "access_control"="is_granted('READ', object) and is_granted('EDIT_RECORDS_INSIGHTS', object)",
  546. * "controller"="MedBrief\MSR\Controller\ProjectInsights\ProjectInsightsController::recordInsightsKeyEventUpdateAction",
  547. * "deserialize"=false,
  548. * "requirements"={"id"="\d+", "eventId"="[^/]+"},
  549. * "openapi_context"={
  550. * "summary"="Update and immediately save a Key Event",
  551. * "requestBody"={
  552. * "required"=true,
  553. * "content"={
  554. * "application/json"={
  555. * "schema"={
  556. * "type"="object",
  557. * "properties"={
  558. * "id"={"type"="string"},
  559. * "status"={"type"="string"},
  560. * "date"={"type"="string"},
  561. * "title"={"type"="string"},
  562. * "summary"={"type"="string"},
  563. * "categories"={"type"="array", "items"={"type"="string"}},
  564. * "native_files"={"type"="array", "items"={"type"="object"}}
  565. * }
  566. * }
  567. * }
  568. * }
  569. * },
  570. * "responses"={"200"={"description"="Key Event saved"}, "400"={"description"="Invalid Key Event payload"}}
  571. * }
  572. * },
  573. * "records_insights_key_events_delete"={
  574. * "method"="DELETE",
  575. * "path"="/project/insights/{id}/records-key-events/{eventId}",
  576. * "access_control"="is_granted('READ', object) and is_granted('EDIT_RECORDS_INSIGHTS', object)",
  577. * "controller"="MedBrief\MSR\Controller\ProjectInsights\ProjectInsightsController::recordInsightsKeyEventDeleteAction",
  578. * "deserialize"=false,
  579. * "requirements"={"id"="\d+", "eventId"="[^/]+"},
  580. * "openapi_context"={
  581. * "summary"="Soft-delete a Key Event",
  582. * "responses"={"204"={"description"="Key Event marked for deletion"}, "400"={"description"="Invalid request"}}
  583. * }
  584. * },
  585. * "records_insights_key_events_restore"={
  586. * "method"="POST",
  587. * "path"="/project/insights/{id}/records-key-events/{eventId}/restore",
  588. * "access_control"="is_granted('READ', object) and is_granted('EDIT_RECORDS_INSIGHTS', object)",
  589. * "controller"="MedBrief\MSR\Controller\ProjectInsights\ProjectInsightsController::recordInsightsKeyEventRestoreAction",
  590. * "deserialize"=false,
  591. * "requirements"={"id"="\d+", "eventId"="[^/]+"},
  592. * "openapi_context"={
  593. * "summary"="Restore a soft-deleted Key Event",
  594. * "responses"={"204"={"description"="Key Event restored"}, "400"={"description"="Invalid request"}}
  595. * }
  596. * },
  597. * "records_insights_key_events_done"={
  598. * "method"="POST",
  599. * "path"="/project/insights/{id}/records-key-events/edit-session/done",
  600. * "access_control"="is_granted('READ', object) and is_granted('EDIT_RECORDS_INSIGHTS', object)",
  601. * "controller"="MedBrief\MSR\Controller\ProjectInsights\ProjectInsightsController::recordInsightsKeyEventsDoneAction",
  602. * "deserialize"=false,
  603. * "requirements"={"id"="\d+"},
  604. * "openapi_context"={
  605. * "summary"="Finalise Key Events edits",
  606. * "parameters"={{"name"="X-Key-Events-Session", "in"="header", "required"=true, "schema"={"type"="string", "format"="uuid"}}},
  607. * "requestBody"={
  608. * "required"=false,
  609. * "content"={
  610. * "application/json"={
  611. * "schema"={
  612. * "type"="object",
  613. * "properties"={
  614. * "eventOrder"={
  615. * "type"="array",
  616. * "nullable"=true,
  617. * "items"={"type"="string", "minLength"=1},
  618. * "uniqueItems"=true,
  619. * "description"="Optional manual order of Key Event IDs. Omitted or null keeps the session's existing saved order; an empty array clears the saved manual order; a non-empty array replaces it. Manual order only applies between events sharing the same date, so chronological order is unaffected. Every ID must be a non-empty string that is not only whitespace, and IDs must not repeat. Unknown IDs are accepted and ignored."
  620. * }
  621. * }
  622. * }
  623. * }
  624. * }
  625. * },
  626. * "responses"={"200"={"description"="Key Events edits finalised"}, "400"={"description"="Invalid edit session or invalid request body"}}
  627. * }
  628. * },
  629. * "records_insights_key_events_start"={
  630. * "method"="POST",
  631. * "path"="/project/insights/{id}/records-key-events/edit-session/start",
  632. * "access_control"="is_granted('READ', object) and is_granted('EDIT_RECORDS_INSIGHTS', object)",
  633. * "controller"="MedBrief\MSR\Controller\ProjectInsights\ProjectInsightsController::recordInsightsKeyEventsStartAction",
  634. * "deserialize"=false,
  635. * "requirements"={"id"="\d+"},
  636. * "openapi_context"={
  637. * "summary"="Start a Key Events edit session",
  638. * "parameters"={{"name"="X-Key-Events-Session", "in"="header", "required"=true, "schema"={"type"="string", "format"="uuid"}}},
  639. * "requestBody"={"required"=false, "content"={"application/json"={"schema"={"type"="object", "properties"={}}}}},
  640. * "responses"={"200"={"description"="Edit session started"}, "409"={"description"="Another user is editing Key Events"}}
  641. * }
  642. * },
  643. * "records_insights_key_events_renew"={
  644. * "method"="POST",
  645. * "path"="/project/insights/{id}/records-key-events/edit-session/renew",
  646. * "access_control"="is_granted('READ', object) and is_granted('EDIT_RECORDS_INSIGHTS', object)",
  647. * "controller"="MedBrief\MSR\Controller\ProjectInsights\ProjectInsightsController::recordInsightsKeyEventsRenewAction",
  648. * "deserialize"=false,
  649. * "requirements"={"id"="\d+"},
  650. * "openapi_context"={
  651. * "summary"="Renew a Key Events edit-session lock",
  652. * "parameters"={{"name"="X-Key-Events-Session", "in"="header", "required"=true, "schema"={"type"="string", "format"="uuid"}}},
  653. * "requestBody"={"required"=false, "content"={"application/json"={"schema"={"type"="object", "properties"={}}}}},
  654. * "responses"={"200"={"description"="Edit-session lock renewed"}}
  655. * }
  656. * },
  657. * "records_insights_key_events_cancel"={
  658. * "method"="POST",
  659. * "path"="/project/insights/{id}/records-key-events/edit-session/cancel",
  660. * "access_control"="is_granted('READ', object) and is_granted('EDIT_RECORDS_INSIGHTS', object)",
  661. * "controller"="MedBrief\MSR\Controller\ProjectInsights\ProjectInsightsController::recordInsightsKeyEventsCancelAction",
  662. * "deserialize"=false,
  663. * "requirements"={"id"="\d+"},
  664. * "openapi_context"={
  665. * "summary"="Cancel a Key Events edit session",
  666. * "parameters"={{"name"="X-Key-Events-Session", "in"="header", "required"=true, "schema"={"type"="string", "format"="uuid"}}},
  667. * "requestBody"={"required"=false, "content"={"application/json"={"schema"={"type"="object", "properties"={}}}}},
  668. * "responses"={"204"={"description"="Edit session cancelled"}}
  669. * }
  670. * },
  671. * "records_insights_key_events_export"={
  672. * "method"="POST",
  673. * "path"="/project/insights/{id}/records-key-events/export",
  674. * "access_control"="is_granted('READ', object) and is_granted('VIEW_RECORDS_INSIGHTS', object)",
  675. * "controller"="MedBrief\MSR\Controller\ProjectInsights\ProjectInsightsController::recordInsightsKeyEventsExportAction",
  676. * "deserialize"=false,
  677. * "requirements"={
  678. * "id"="\d+"
  679. * },
  680. * "openapi_context"={
  681. * "summary"="Export key events timeline as PDF",
  682. * "description"="Generates a PDF export of the key events timeline, optionally password-protected.",
  683. * "parameters"={
  684. * {
  685. * "name"="id",
  686. * "in"="path",
  687. * "required"=true,
  688. * "description"="Project ID",
  689. * "schema"={"type"="integer"}
  690. * }
  691. * },
  692. * "requestBody"={
  693. * "required"=false,
  694. * "content"={
  695. * "application/json"={
  696. * "schema"={
  697. * "type"="object",
  698. * "properties"={
  699. * "password"={
  700. * "type"="string",
  701. * "description"="Optional password to encrypt the PDF"
  702. * }
  703. * }
  704. * }
  705. * }
  706. * }
  707. * },
  708. * "responses"={
  709. * "200"={"description"="PDF file download"},
  710. * "204"={"description"="No key events to export"},
  711. * "500"={"description"="Export generation failed"}
  712. * }
  713. * }
  714. * },
  715. * "match_recommended_options"={
  716. * "method"="GET",
  717. * "path"="/match/project/{id}/recommended-options",
  718. * "access_control"="is_granted('MATCH_VIEW_FIRM', object)",
  719. * "controller"=ProjectMatchRecommendedOptionsController::class,
  720. * "openapi_context"={
  721. * "summary"="Return all Match Recommended Options.",
  722. * "description"="Return all Match Recommended Options for a match search. Including recommended Specialities and Queries",
  723. * "responses"={
  724. * "200"={
  725. * "description"="A list of Match Recommended Options.",
  726. * }
  727. * }
  728. * }
  729. * },
  730. * "get_shortlisted"={
  731. * "method"="GET",
  732. * "path"="/match/project/{id}/shortlisted-expert",
  733. * "access_control"="is_granted('MATCH_VIEW_FIRM', object)",
  734. * "controller"=ProjectMatchShortlistedController::class,
  735. * "openapi_context"={
  736. * "summary"="Return all Match Shortlisted Experts.",
  737. * "description"="Return all Shortlisted Experts for a project.",
  738. * "responses"={
  739. * "200"={
  740. * "description"="A list of Shortlisted Experts with their full data.",
  741. * }
  742. * }
  743. * }
  744. * },
  745. * "get_my_experts"={
  746. * "method"="GET",
  747. * "path"="/match/project/{id}/my-experts",
  748. * "access_control"="is_granted('MATCH_VIEW_FIRM', object) or is_granted('MATCH_VIEW_EXPERT', object)",
  749. * "controller"=ProjectMatchMyExpertsController::class,
  750. * "openapi_context"={
  751. * "summary"="Return all Experts shortlisted and contacted for this project with their message threads.",
  752. * "description"="Return all Experts shortlisted and contacted for this project with their message threads.",
  753. * "responses"={
  754. * "200"={
  755. * "description"="A list of Experts shortlisted and contacted for this project with their message threads.",
  756. * }
  757. * }
  758. * }
  759. * },
  760. * "match_loa_get"={
  761. * "method"="GET",
  762. * "path"="/match/project/{id}/letter-of-approach/{userId}",
  763. * "access_control"="is_granted('MATCH_VIEW_FIRM', object)",
  764. * "controller"="MedBrief\MSR\Controller\ProjectMatch\ProjectMatchLoAController::getLetterOfApproach",
  765. * "requirements"={
  766. * "id"="\d+",
  767. * "userId"="\d+"
  768. * },
  769. * "openapi_context"={
  770. * "summary"="Returns letter of approach data for a specific expert and project.",
  771. * "description"="Given a Project ID and an Expert User ID, returns the letter of approach data for that expert and project.",
  772. * "parameters"={
  773. * {
  774. * "name"="id",
  775. * "in"="path",
  776. * "required"=true,
  777. * "description"="Project ID",
  778. * "schema"={"type"="integer"}
  779. * },
  780. * {
  781. * "name"="userId",
  782. * "in"="path",
  783. * "required"=true,
  784. * "description"="Expert User ID",
  785. * "schema"={"type"="integer"}
  786. * }
  787. * },
  788. * "responses"={
  789. * "200"={
  790. * "description"="Letter of Approach data for the specified expert and project.",
  791. * }
  792. * }
  793. * }
  794. * },
  795. * "match_loa_copy_sources"={
  796. * "method"="GET",
  797. * "path"="/match/project/{id}/letter-of-approach/{userId}/copy-sources",
  798. * "access_control"="is_granted('MATCH_VIEW_FIRM', object)",
  799. * "controller"="MedBrief\MSR\Controller\ProjectMatch\ProjectMatchLoAController::getCopySources",
  800. * "requirements"={
  801. * "id"="\d+",
  802. * "userId"="\d+"
  803. * },
  804. * "openapi_context"={
  805. * "summary"="Returns experts on this project who already have a sent letter of approach, excluding the given expert.",
  806. * "description"="Given a Project ID and a target Expert User ID, returns the list of experts on the project with a sent Letter of Approach (sent, accepted, declined or information required), ordered most recently sent first, for use when copying an existing letter.",
  807. * "parameters"={
  808. * {
  809. * "name"="id",
  810. * "in"="path",
  811. * "required"=true,
  812. * "description"="Project ID",
  813. * "schema"={"type"="integer"}
  814. * },
  815. * {
  816. * "name"="userId",
  817. * "in"="path",
  818. * "required"=true,
  819. * "description"="Target Expert User ID, excluded from the results",
  820. * "schema"={"type"="integer"}
  821. * }
  822. * },
  823. * "responses"={
  824. * "200"={
  825. * "description"="List of experts with a sent Letter of Approach for this project, most recently sent first.",
  826. * }
  827. * }
  828. * }
  829. * },
  830. * "match_loa_candidates"={
  831. * "method"="GET",
  832. * "path"="/match/project/{id}/letter-of-approach/candidates",
  833. * "access_control"="is_granted('MATCH_VIEW_FIRM', object)",
  834. * "controller"="MedBrief\MSR\Controller\ProjectMatch\ProjectMatchLoAController::getMultiSendCandidates",
  835. * "requirements"={"id"="\d+"},
  836. * "openapi_context"={
  837. * "summary"="Returns shortlisted experts eligible for a multi-expert Letter of Approach.",
  838. * "parameters"={
  839. * {
  840. * "name"="sourceExpertUserId",
  841. * "in"="query",
  842. * "required"=true,
  843. * "description"="Source expert user ID",
  844. * "schema"={"type"="integer"}
  845. * }
  846. * }
  847. * }
  848. * },
  849. * "match_loa_copy_preview"={
  850. * "method"="GET",
  851. * "path"="/match/project/{id}/letter-of-approach/{userId}/copy-from/{sourceUserId}",
  852. * "access_control"="is_granted('MATCH_VIEW_FIRM', object)",
  853. * "controller"="MedBrief\MSR\Controller\ProjectMatch\ProjectMatchLoAController::getLetterOfApproachCopiedFrom",
  854. * "requirements"={
  855. * "id"="\d+",
  856. * "userId"="\d+",
  857. * "sourceUserId"="\d+"
  858. * },
  859. * "openapi_context"={
  860. * "summary"="Previews a letter of approach for an expert, populated from another expert's sent letter.",
  861. * "description"="Returns an unsaved preview of the Letter of Approach for the target expert, with content extracted from the source expert's sent letter and rebound to the target. Nothing is persisted; the caller must save the returned payload to keep it. If the target expert already has a letter, their existing letter is returned unchanged.",
  862. * "parameters"={
  863. * {
  864. * "name"="id",
  865. * "in"="path",
  866. * "required"=true,
  867. * "description"="Project ID",
  868. * "schema"={"type"="integer"}
  869. * },
  870. * {
  871. * "name"="userId",
  872. * "in"="path",
  873. * "required"=true,
  874. * "description"="Target Expert User ID the letter is being prepared for",
  875. * "schema"={"type"="integer"}
  876. * },
  877. * {
  878. * "name"="sourceUserId",
  879. * "in"="path",
  880. * "required"=true,
  881. * "description"="Source Expert User ID whose sent Letter of Approach is copied",
  882. * "schema"={"type"="integer"}
  883. * }
  884. * },
  885. * "responses"={
  886. * "200"={
  887. * "description"="Unsaved Letter of Approach preview for the target expert."
  888. * },
  889. * "404"={"description"="Project, target expert or source expert not found"},
  890. * "403"={"description"="Access denied"}
  891. * }
  892. * }
  893. * },
  894. * "match_loa_save"={
  895. * "method"="POST",
  896. * "path"="/match/project/{id}/letter-of-approach/{userId}/save-as-draft",
  897. * "access_control"="is_granted('MATCH_VIEW_FIRM', object)",
  898. * "controller"="MedBrief\MSR\Controller\ProjectMatch\ProjectMatchLoAController::saveLetterOfApproach",
  899. * "deserialize"=false,
  900. * "requirements"={
  901. * "id"="\d+",
  902. * "userId"="\d+"
  903. * },
  904. * "openapi_context"={
  905. * "summary"="Save letter of approach data for a project and expert",
  906. * "description"="Saves the letter of approach (LoA) payload for a project and expert. The payload is an object with top-level keys.",
  907. * "parameters"={
  908. * {
  909. * "name"="id",
  910. * "in"="path",
  911. * "required"=true,
  912. * "description"="Project ID",
  913. * "schema"={"type"="integer"}
  914. * },
  915. * {
  916. * "name"="userId",
  917. * "in"="path",
  918. * "required"=true,
  919. * "description"="Expert User ID",
  920. * "schema"={"type"="integer"}
  921. * }
  922. * },
  923. * "requestBody"={
  924. * "required"=true,
  925. * "content"={
  926. * "application/json"={
  927. * "schema"={
  928. * "type"="object",
  929. * "properties"={
  930. * "matterDetails"={
  931. * "type"="object",
  932. * "description"="Information about the matter and sender details.",
  933. * "additionalProperties"={
  934. * "oneOf"={
  935. * {"type"="string"},
  936. * {"type"="integer"},
  937. * {"type"="boolean"},
  938. * {"type"="number"}
  939. * }
  940. * }
  941. * },
  942. * "LoAData"={
  943. * "type"="object",
  944. * "description"="Main LoA sections. Keys represent sections like head, introduction, etc.",
  945. * "additionalProperties"={
  946. * "type"="object",
  947. * "properties"={
  948. * "order"={"type"="integer"},
  949. * "editable"={"type"="boolean"},
  950. * "data"={"type"="string"}
  951. * }
  952. * }
  953. * },
  954. * "documents"={
  955. * "type"="array",
  956. * "description"="Array of match letter document IDs",
  957. * "items"={"type"="integer"}
  958. * }
  959. * },
  960. * "required"={"matterDetails","LoAData"}
  961. * },
  962. * "example"={
  963. * "matterDetails"={
  964. * "todaysDate"="2024-06-15",
  965. * "expertUserId"=36,
  966. * "expertTitle"="Dr.",
  967. * "expertFirstName"="John",
  968. * "expertLastName"="Doe",
  969. * "matterName"="Lorem -v- Ipsum NHS Trust",
  970. * "matterNumber"="12345",
  971. * "claimantInitials"="LIP",
  972. * "defendantName"="Ipsum NHS Trust",
  973. * "caseSummary"="Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
  974. * "matterManager"="/msr/users/2",
  975. * "senderId"="/msr/users/2",
  976. * "senderPosition"="Solicitor",
  977. * "tradingName"="ACME Trading"
  978. * },
  979. * "LoAData"={
  980. * "head"={
  981. * "order"=1,
  982. * "editable"=false,
  983. * "fieldRequiresUpdate"=false,
  984. * "data"="<p>Matter reference: 12345<br><strong>PRIVATE AND CONFIDENTIAL</strong></p>"
  985. * },
  986. * "introduction"={
  987. * "order"=2,
  988. * "editable"=true,
  989. * "fieldRequiresUpdate"=false,
  990. * "data"="<p>Dear Dr. Doe, Lorem ipsum dolor sit amet...</p>"
  991. * },
  992. * "background"={
  993. * "order"=3,
  994. * "editable"=true,
  995. * "fieldRequiresUpdate"=true,
  996. * "data"="<p>Background lorem ipsum dolor sit amet...</p>"
  997. * },
  998. * "recordsObtained"={
  999. * "order"=4,
  1000. * "editable"=true,
  1001. * "fieldRequiresUpdate"=true,
  1002. * "data"="<p>The following records have been obtained:</p><ul><li>Record 1</li><li>Record 2</li></ul>"
  1003. * },
  1004. * "progressOfLitigation"={
  1005. * "order"=5,
  1006. * "editable"=true,
  1007. * "fieldRequiresUpdate"=true,
  1008. * "data"="<p>Progress of litigation details...</p>"
  1009. * },
  1010. * "informationRequested"={
  1011. * "order"=6,
  1012. * "editable"=false,
  1013. * "fieldRequiresUpdate"=false,
  1014. * "data"="<p>Information requested details...</p>"
  1015. * },
  1016. * "signOff"={
  1017. * "order"=7,
  1018. * "editable"=true,
  1019. * "fieldRequiresUpdate"=true,
  1020. * "data"="<p>Yours sincerely,</p>"
  1021. * }
  1022. * },
  1023. * "documents"={1,2,3}
  1024. * }
  1025. * }
  1026. * }
  1027. * },
  1028. * "responses"={
  1029. * "200"={"description"="Letter of approach saved successfully."}
  1030. * }
  1031. * }
  1032. * },
  1033. * "match_loa_upload_documents"={
  1034. * "method"="POST",
  1035. * "path"="/match/project/{id}/letter-of-approach/{userId}/upload-documents",
  1036. * "access_control"="is_granted('MATCH_VIEW_FIRM', object)",
  1037. * "controller"="MedBrief\MSR\Controller\ProjectMatch\ProjectMatchLoAController::uploadDocuments",
  1038. * "deserialize"=false,
  1039. * "requirements"={
  1040. * "id"="\d+",
  1041. * "userId"="\d+"
  1042. * },
  1043. * "openapi_context"={
  1044. * "summary"="Upload bulk documents to an LoA",
  1045. * "description"="Uploads documents to an LoA",
  1046. * "parameters"={
  1047. * {
  1048. * "name"="id",
  1049. * "in"="path",
  1050. * "required"=true,
  1051. * "description"="Project ID",
  1052. * "schema"={"type"="integer"}
  1053. * },
  1054. * {
  1055. * "name"="userId",
  1056. * "in"="path",
  1057. * "required"=true,
  1058. * "description"="Expert User ID",
  1059. * "schema"={"type"="integer"}
  1060. * }
  1061. * },
  1062. * "requestBody"={
  1063. * "required"=true,
  1064. * "content"={
  1065. * "multipart/form-data"={
  1066. * "schema"={
  1067. * "type"="object",
  1068. * "required"={"documents[]"},
  1069. * "properties"={
  1070. * "documents[]"={
  1071. * "type"="array",
  1072. * "items"={"type"="string", "format"="binary"}
  1073. * }
  1074. * }
  1075. * }
  1076. * }
  1077. * }
  1078. * },
  1079. * "responses"={
  1080. * "200"={"description"="Documents uploaded"},
  1081. * "400"={"description"="Invalid file"},
  1082. * "401"={"description"="Unauthorized"},
  1083. * "403"={"description"="Access denied"}
  1084. * }
  1085. * }
  1086. * },
  1087. * "match_loa_preview_pdf"={
  1088. * "method"="POST",
  1089. * "path"="/match/project/{id}/letter-of-approach/{userId}/preview-pdf",
  1090. * "access_control"="is_granted('MATCH_VIEW_FIRM', object)",
  1091. * "controller"=ProjectMatchLoAPreviewPdfController::class,
  1092. * "deserialize"=false,
  1093. * "requirements"={
  1094. * "id"="\d+",
  1095. * "userId"="\d+"
  1096. * },
  1097. * "openapi_context"={
  1098. * "summary"="Preview the letter of approach pdf for a project and expert",
  1099. * "description"="Saves the letter of approach (LoA) payload for a project and expert, then retrieves a PDF based on the saved data.",
  1100. * "parameters"={
  1101. * {
  1102. * "name"="id",
  1103. * "in"="path",
  1104. * "required"=true,
  1105. * "description"="Project ID",
  1106. * "schema"={"type"="integer"}
  1107. * },
  1108. * {
  1109. * "name"="userId",
  1110. * "in"="path",
  1111. * "required"=true,
  1112. * "description"="Expert User ID",
  1113. * "schema"={"type"="integer"}
  1114. * }
  1115. * },
  1116. * "requestBody"={
  1117. * "required"=true,
  1118. * "content"={
  1119. * "application/json"={
  1120. * "schema"={
  1121. * "type"="object",
  1122. * "properties"={
  1123. * "matterDetails"={
  1124. * "type"="object",
  1125. * "description"="Information about the matter and sender details.",
  1126. * "additionalProperties"={
  1127. * "oneOf"={
  1128. * {"type"="string"},
  1129. * {"type"="integer"},
  1130. * {"type"="boolean"},
  1131. * {"type"="number"}
  1132. * }
  1133. * }
  1134. * },
  1135. * "LoAData"={
  1136. * "type"="object",
  1137. * "description"="Main LoA sections. Keys represent sections like head, introduction, etc.",
  1138. * "additionalProperties"={
  1139. * "type"="object",
  1140. * "properties"={
  1141. * "order"={"type"="integer"},
  1142. * "editable"={"type"="boolean"},
  1143. * "data"={"type"="string"}
  1144. * }
  1145. * }
  1146. * },
  1147. * "documents"={
  1148. * "type"="array",
  1149. * "description"="Array of match letter document IDs",
  1150. * "items"={"type"="integer"}
  1151. * }
  1152. * },
  1153. * "required"={"matterDetails","LoAData"}
  1154. * },
  1155. * "example"={
  1156. * "matterDetails"={
  1157. * "todaysDate"="2024-06-15",
  1158. * "expertUserId"=36,
  1159. * "expertTitle"="Dr.",
  1160. * "expertFirstName"="John",
  1161. * "expertLastName"="Doe",
  1162. * "matterName"="Lorem -v- Ipsum NHS Trust",
  1163. * "matterNumber"="12345",
  1164. * "claimantInitials"="LIP",
  1165. * "defendantName"="Ipsum NHS Trust",
  1166. * "caseSummary"="Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
  1167. * "matterManager"="/msr/users/2",
  1168. * "senderId"="/msr/users/2",
  1169. * "senderPosition"="Solicitor",
  1170. * "tradingName"="ACME Trading"
  1171. * },
  1172. * "LoAData"={
  1173. * "head"={
  1174. * "order"=1,
  1175. * "editable"=false,
  1176. * "fieldRequiresUpdate"=false,
  1177. * "data"="<p>Matter reference: 12345<br><strong>PRIVATE AND CONFIDENTIAL</strong></p>"
  1178. * },
  1179. * "introduction"={
  1180. * "order"=2,
  1181. * "editable"=true,
  1182. * "fieldRequiresUpdate"=false,
  1183. * "data"="<p>Dear Dr. Doe, Lorem ipsum dolor sit amet...</p>"
  1184. * },
  1185. * "background"={
  1186. * "order"=3,
  1187. * "editable"=true,
  1188. * "fieldRequiresUpdate"=true,
  1189. * "data"="<p>Background lorem ipsum dolor sit amet...</p>"
  1190. * },
  1191. * "recordsObtained"={
  1192. * "order"=4,
  1193. * "editable"=true,
  1194. * "fieldRequiresUpdate"=true,
  1195. * "data"="<p>The following records have been obtained:</p><ul><li>Record 1</li><li>Record 2</li></ul>"
  1196. * },
  1197. * "progressOfLitigation"={
  1198. * "order"=5,
  1199. * "editable"=true,
  1200. * "fieldRequiresUpdate"=true,
  1201. * "data"="<p>Progress of litigation details...</p>"
  1202. * },
  1203. * "informationRequested"={
  1204. * "order"=6,
  1205. * "editable"=false,
  1206. * "fieldRequiresUpdate"=false,
  1207. * "data"="<p>Information requested details...</p>"
  1208. * },
  1209. * "signOff"={
  1210. * "order"=7,
  1211. * "editable"=true,
  1212. * "fieldRequiresUpdate"=true,
  1213. * "data"="<p>Yours sincerely,</p>"
  1214. * }
  1215. * },
  1216. * "documents"={1,2,3}
  1217. * }
  1218. * }
  1219. * }
  1220. * },
  1221. * "responses"={
  1222. * "200"={
  1223. * "description"="LoA PDF file",
  1224. * "schema"={"type"="string","format"="binary"}
  1225. * },
  1226. * "404"={"description"="Not found"}
  1227. * }
  1228. * }
  1229. * },
  1230. * "match_loa_send_pdf"={
  1231. * "method"="POST",
  1232. * "path"="/match/project/{id}/letter-of-approach/{userId}/send-pdf",
  1233. * "access_control"="is_granted('MATCH_VIEW_FIRM', object)",
  1234. * "controller"=ProjectMatchLoASendPdfController::class,
  1235. * "deserialize"=false,
  1236. * "requirements"={
  1237. * "id"="\d+",
  1238. * "userId"="\d+"
  1239. * },
  1240. * "openapi_context"={
  1241. * "summary"="Sends letter of approach pdf for a project and expert to the expert via message system",
  1242. * "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.",
  1243. * "parameters"={
  1244. * {
  1245. * "name"="id",
  1246. * "in"="path",
  1247. * "required"=true,
  1248. * "description"="Project ID",
  1249. * "schema"={"type"="integer"}
  1250. * },
  1251. * {
  1252. * "name"="userId",
  1253. * "in"="path",
  1254. * "required"=true,
  1255. * "description"="Expert User ID",
  1256. * "schema"={"type"="integer"}
  1257. * }
  1258. * },
  1259. * "requestBody"={
  1260. * "required"=false,
  1261. * "content"={
  1262. * "application/json"={
  1263. * "schema"={"type"="object","properties"={}}
  1264. * }
  1265. * }
  1266. * },
  1267. * "responses"={
  1268. * "200"={
  1269. * "description"="LoA successfully sent"
  1270. * },
  1271. * "404"={"description"="Not found"}
  1272. * }
  1273. * }
  1274. * },
  1275. * "match_loa_send_multi"={
  1276. * "method"="POST",
  1277. * "path"="/match/project/{id}/letter-of-approach/send-multi",
  1278. * "access_control"="is_granted('MATCH_VIEW_FIRM', object)",
  1279. * "controller"="MedBrief\MSR\Controller\ProjectMatch\ProjectMatchLoAController::sendLetterOfApproachToMultipleExperts",
  1280. * "deserialize"=false,
  1281. * "requirements"={"id"="\d+"},
  1282. * "openapi_context"={
  1283. * "summary"="Sends one Letter of Approach payload to multiple shortlisted experts.",
  1284. * "description"="Materialises and sends the submitted Letter of Approach once per selected expert, returning per-expert sent and failed outcomes.",
  1285. * "requestBody"={
  1286. * "required"=true,
  1287. * "content"={
  1288. * "application/json"={
  1289. * "schema"={
  1290. * "type"="object",
  1291. * "properties"={
  1292. * "sourceExpertUserId"={"type"="integer"},
  1293. * "expertUserIds"={"type"="array","items"={"type"="integer"}},
  1294. * "matterDetails"={"type"="object"},
  1295. * "LoAData"={"type"="object"},
  1296. * "documents"={"type"="array","items"={"type"="integer"}}
  1297. * },
  1298. * "required"={"sourceExpertUserId","expertUserIds","matterDetails","LoAData"}
  1299. * }
  1300. * }
  1301. * }
  1302. * },
  1303. * "responses"={
  1304. * "200"={"description"="LoA sent to one or more experts, with per-expert results."},
  1305. * "400"={"description"="Invalid request or no experts sent."},
  1306. * "409"={"description"="A Letter of Approach has already been sent on this matter."}
  1307. * }
  1308. * }
  1309. * },
  1310. * "match_loa_delete_draft"={
  1311. * "method"="POST",
  1312. * "path"="/match/project/{id}/letter-of-approach/{userId}/delete-draft",
  1313. * "access_control"="is_granted('MATCH_VIEW_FIRM', object)",
  1314. * "controller"="MedBrief\MSR\Controller\ProjectMatch\ProjectMatchLoAController::deleteLetterOfApproachDraft",
  1315. * "deserialize"=false,
  1316. * "requirements"={
  1317. * "id"="\d+",
  1318. * "userId"="\d+"
  1319. * },
  1320. * "openapi_context"={
  1321. * "summary"="Deletes letter of approach draft for a project and expert",
  1322. * "description"="Gets the LoA data for a project and expert, then deletes the draft based on the saved data.",
  1323. * "parameters"={
  1324. * {
  1325. * "name"="id",
  1326. * "in"="path",
  1327. * "required"=true,
  1328. * "description"="Project ID",
  1329. * "schema"={"type"="integer"}
  1330. * },
  1331. * {
  1332. * "name"="userId",
  1333. * "in"="path",
  1334. * "required"=true,
  1335. * "description"="Expert User ID",
  1336. * "schema"={"type"="integer"}
  1337. * }
  1338. * },
  1339. * "requestBody"={
  1340. * "required"=false,
  1341. * "content"={
  1342. * "application/json"={
  1343. * "schema"={"type"="object","properties"={}}
  1344. * }
  1345. * }
  1346. * },
  1347. * "responses"={
  1348. * "200"={
  1349. * "description"="LoA draft successfully deleted"
  1350. * },
  1351. * "404"={"description"="Not found"},
  1352. * "409"={"description"="Conflict"}
  1353. * }
  1354. * }
  1355. * },
  1356. * "update_shortlisted"={
  1357. * "method"="POST",
  1358. * "path"="/match/project/{id}/shortlisted-expert/update",
  1359. * "access_control"="is_granted('MATCH_VIEW_FIRM', object)",
  1360. * "controller"=ProjectMatchShortlistedController::class,
  1361. * "openapi_context"={
  1362. * "summary"="Used to add or remove experts from the shortlisted list for a project",
  1363. * "description"="By passing in a user ID and a boolean value, you can add or remove experts from the shortlisted list for a project.",
  1364. * "requestBody"={
  1365. * "required"=true,
  1366. * "content"={
  1367. * "application/json"={
  1368. * "schema"={
  1369. * "type"="array",
  1370. * "items"={
  1371. * "type"="array",
  1372. * "items"={
  1373. * "type"="object",
  1374. * "properties"={
  1375. * "userId"={"type"="integer"},
  1376. * "shortlisted"={"type"="boolean"}
  1377. * }
  1378. * },
  1379. * "description"="user ID and boolean value indicating whether to add or remove from shortlisted list"
  1380. * }
  1381. * },
  1382. * "example"={
  1383. * "userId"=1,
  1384. * "shortlisted"=true
  1385. * }
  1386. * }
  1387. * }
  1388. * },
  1389. * "responses"={
  1390. * "200"={
  1391. * "description"="Shortlisted expert updated successfully."
  1392. * }
  1393. * }
  1394. * }
  1395. * },
  1396. * "match_expert_profile"={
  1397. * "method"="POST",
  1398. * "path"="/match/project/{id}/profile",
  1399. * "access_control"="is_granted('MATCH_VIEW_FIRM', object)",
  1400. * "controller"=ProjectMatchExpertProfileController::class,
  1401. * "openapi_context"={
  1402. * "summary"="Returns a list of cached expert profiles containing full profile data",
  1403. * "description"="Returns a list of experts that have been cached with all of their profile data. Makes use of ExpertProfileCache to retrieve profiles.",
  1404. * "requestBody"={
  1405. * "required"=true,
  1406. * "content"={
  1407. * "application/json"={
  1408. * "schema"={
  1409. * "type"="array",
  1410. * "items"={
  1411. * {"type"="integer"}
  1412. * }
  1413. * },
  1414. * "example"={1,2,3,4,5}
  1415. * }
  1416. * }
  1417. * },
  1418. * "responses"={
  1419. * "200"={
  1420. * "description"="A list of cached expert profiles."
  1421. * }
  1422. * }
  1423. * }
  1424. * },
  1425. * "match_search"={
  1426. * "method"="POST",
  1427. * "path"="/match/project/{id}/search",
  1428. * "access_control"="is_granted('MATCH_VIEW_FIRM', object)",
  1429. * "controller"=ProjectMatchSearchController::class,
  1430. * "openapi_context"={
  1431. * "summary"="Returns a list of experts that match a provided input.",
  1432. * "description"="Returns a list of experts that match a provided input search query. Calls an AI endpoint to calculate the best fitting experts.",
  1433. * "requestBody"={
  1434. * "required"=true,
  1435. * "content"={
  1436. * "application/json"={
  1437. * "schema"={
  1438. * "type"="object",
  1439. * "properties"={
  1440. * "specialities"={
  1441. * "type"="array",
  1442. * "items"={
  1443. * "type"="object",
  1444. * "properties"={
  1445. * "id"={"type"="integer"},
  1446. * "label"={"type"="string"}
  1447. * }
  1448. * },
  1449. * "description"="Array of speciality objects, each object contains integer id and string label (e.g. id:14, label:General Psychiatry)"
  1450. * },
  1451. * "consultationType"={
  1452. * "type"="string",
  1453. * "description"="Consultation type to fetch preferences for - either breach, causation or both"
  1454. * },
  1455. * "aiSearch"={
  1456. * "type"="string",
  1457. * "description"="AI search query to fetch preferences for"
  1458. * },
  1459. * "expertName"={
  1460. * "type"="string",
  1461. * "description"="Full or partial expert name to search for (optional)."
  1462. * },
  1463. * "expertUserId"={
  1464. * "type"="integer",
  1465. * "description"="User id of an expert picked from the name suggestion list (optional)."
  1466. * }
  1467. * },
  1468. * "required"={"specialities"}
  1469. * },
  1470. * "example"={
  1471. * "specialities"={
  1472. * {"id"=49,"label"="Psychiatry"},
  1473. * {"id"=38,"label"="Neurology"}
  1474. * },
  1475. * "consultationType"="both",
  1476. * "expertName"="Piet",
  1477. * "aiSearch"="please find me experts that will work for my case"
  1478. * }
  1479. * }
  1480. * }
  1481. * },
  1482. * "responses"={
  1483. * "200"={
  1484. * "description"="A list of Experts."
  1485. * }
  1486. * }
  1487. * }
  1488. * },
  1489. * "match_expert_name_search"={
  1490. * "method"="GET",
  1491. * "path"="/match/project/{id}/expert-name-search",
  1492. * "access_control"="is_granted('MATCH_VIEW_FIRM', object)",
  1493. * "controller"=ProjectMatchExpertNameSearchController::class,
  1494. * "openapi_context"={
  1495. * "summary"="Returns expert-name suggestions for the search-form typeahead.",
  1496. * "description"="Returns experts whose first or last name matches the 'name' query parameter, ordered by first then last name.",
  1497. * "parameters"={
  1498. * {
  1499. * "name"="id",
  1500. * "in"="path",
  1501. * "required"=true,
  1502. * "schema"={"type"="integer"},
  1503. * "description"="Project id"
  1504. * },
  1505. * {
  1506. * "name"="name",
  1507. * "in"="query",
  1508. * "required"=true,
  1509. * "schema"={"type"="string"},
  1510. * "description"="Full or partial expert name to search for"
  1511. * }
  1512. * },
  1513. * "responses"={
  1514. * "200"={
  1515. * "description"="A list of matching expert name suggestions."
  1516. * }
  1517. * }
  1518. * }
  1519. * },
  1520. * "match_expert_justifications"={
  1521. * "method"="POST",
  1522. * "path"="/match/project/{id}/expert-justifications",
  1523. * "access_control"="is_granted('MATCH_VIEW_FIRM', object)",
  1524. * "controller"=ProjectMatchExpertJustificationController::class,
  1525. * "openapi_context"={
  1526. * "summary"="Returns justifications for a list of experts based on the project context.",
  1527. * "description"="Calls an AI endpoint to generate justifications explaining why each expert is a good match for the project.",
  1528. * "requestBody"={
  1529. * "required"=true,
  1530. * "content"={
  1531. * "application/json"={
  1532. * "schema"={
  1533. * "type"="object",
  1534. * "properties"={
  1535. * "experts"={
  1536. * "type"="array",
  1537. * "items"={
  1538. * "type"="object",
  1539. * "properties"={
  1540. * "id"={"type"="integer"},
  1541. * "specialty"={"type"="string"}
  1542. * }
  1543. * },
  1544. * "description"="Array of expert objects, each containing integer id and string specialty"
  1545. * },
  1546. * "consultationType"={
  1547. * "type"="string",
  1548. * "description"="Consultation type - either breach, causation or both"
  1549. * },
  1550. * "userQuery"={
  1551. * "type"="string",
  1552. * "description"="Optional user query or search terms used"
  1553. * }
  1554. * },
  1555. * "required"={"experts"}
  1556. * },
  1557. * "example"={
  1558. * "experts"={
  1559. * {"id"=1,"specialty"="Psychiatry"},
  1560. * {"id"=2,"specialty"="Neurology"}
  1561. * },
  1562. * "consultationType"="both",
  1563. * "userQuery"="experts for complex psychiatric case"
  1564. * }
  1565. * }
  1566. * }
  1567. * },
  1568. * "responses"={
  1569. * "200"={
  1570. * "description"="A list of expert justifications."
  1571. * }
  1572. * }
  1573. * }
  1574. * },
  1575. * "put"={"access_control"="is_granted('UPDATE', object)"}
  1576. * },
  1577. * attributes={
  1578. * "normalization_context"={"groups"={"project:read"}},
  1579. * }
  1580. * )
  1581. *
  1582. * @ORM\Table(name="Project", uniqueConstraints={@ORM\UniqueConstraint(name="reference_idx", columns={"account_id", "client_reference", "deletedAt"})})
  1583. *
  1584. * @ORM\Entity(repositoryClass=ProjectRepository::class)
  1585. *
  1586. * @ORM\HasLifecycleCallbacks
  1587. *
  1588. * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
  1589. *
  1590. * @Audit\Auditable
  1591. *
  1592. * @Audit\Security(view={"ROLE_ALLOWED_TO_AUDIT"})
  1593. */
  1594. class Project implements ClaimCategoryAwareInterface, MatterTypeAwareInterface, DisclosureTargetInterface
  1595. {
  1596. use FilterableClassConstantsTrait;
  1597. use DisclosureTargetTrait;
  1598. use ProjectShouldShowAlertTrait;
  1599. public const STATUS_INACTIVE = 1;
  1600. public const STATUS_ACTIVE = 2;
  1601. public const LICENSE_LEVEL_STANDARD = 1;
  1602. public const LICENSE_LEVEL_PROFESSIONAL = 2;
  1603. public const LICENSE_LEVEL_PREMIUM = 3;
  1604. public const LICENSE_LEVEL_BASIC = 4;
  1605. public const ESTIMATED_CLAIM_VALUE_0_25000 = 1;
  1606. public const ESTIMATED_CLAIM_VALUE_25001_50000 = 2;
  1607. public const ESTIMATED_CLAIM_VALUE_50001_100000 = 3;
  1608. public const ESTIMATED_CLAIM_VALUE_100001_250000 = 4;
  1609. public const ESTIMATED_CLAIM_VALUE_250001_500000 = 5;
  1610. public const ESTIMATED_CLAIM_VALUE_500001_1000000 = 6;
  1611. public const ESTIMATED_CLAIM_VALUE_1000001 = 7;
  1612. public const ESTIMATED_CLAIM_VALUE_0_25000__LABEL = '£0 - £25,000';
  1613. public const ESTIMATED_CLAIM_VALUE_25001_50000__LABEL = '£25,001 - £50,000';
  1614. public const ESTIMATED_CLAIM_VALUE_50001_100000__LABEL = '£50,001 - £100,000';
  1615. public const ESTIMATED_CLAIM_VALUE_100001_250000__LABEL = '£100,001 - £250,000';
  1616. public const ESTIMATED_CLAIM_VALUE_250001_500000__LABEL = '£250,001 - £500,000';
  1617. public const ESTIMATED_CLAIM_VALUE_500001_1000000__LABEL = '£500,001 - £1,000,000';
  1618. public const ESTIMATED_CLAIM_VALUE_1000001__LABEL = '£1,000,000 +';
  1619. // These are the Archive statuses of a Project
  1620. public const ARCHIVE_STATUS_PENDING = 1;
  1621. public const ARCHIVE_STATUS_PENDING__LABEL = 'Pending';
  1622. public const ARCHIVE_STATUS_PROCESSING = 2;
  1623. public const ARCHIVE_STATUS_PROCESSING__LABEL = 'Processing';
  1624. public const ARCHIVE_STATUS_COMPLETE = 3;
  1625. public const ARCHIVE_STATUS_COMPLETE__LABEL = 'Complete';
  1626. public const ARCHIVE_STATUS_UNARCHIVE_PROCESSING = 4;
  1627. public const ARCHIVE_STATUS_UNARCHIVE_PROCESSING__LABEL = 'Unarchiving processing';
  1628. // The delete statuses of a Project
  1629. public const DELETE_STATUS_PENDING = 1;
  1630. public const DELETE_STATUS_PENDING__LABEL = 'Pending Deletion';
  1631. public const DELETE_STATUS_REMINDER_SENT = 6;
  1632. public const DELETE_STATUS_REMINDER_SENT__LABEL = 'Reminder Sent';
  1633. public const DELETE_STATUS_PROCESSING = 2;
  1634. public const DELETE_STATUS_PROCESSING__LABEL = 'Processing';
  1635. public const DELETE_STATUS_COMPLETE = 3;
  1636. public const DELETE_STATUS_COMPLETE__LABEL = 'Complete';
  1637. public const DELETE_STATUS_DELETE_FAILED = 4;
  1638. public const DELETE_STATUS_DELETE_FAILED__LABEL = 'Failed';
  1639. public const DELETE_STATUS_ANONYMISE_FAILED = 5;
  1640. public const DELETE_STATUS_ANONYMISE_FAILED__LABEL = 'Anonymise Failed';
  1641. // This status is used to mass set projects to be deleted immediately.
  1642. public const DELETE_STATUS_PENDING_IMMEDIATE = 7;
  1643. public const DELETE_STATUS_PENDING_IMMEDIATE__LABEL = 'Pending Immediate Deletion';
  1644. // The permanent delete status of a Project
  1645. public const PERMANENT_DELETE_STATUS_PENDING = 'pending';
  1646. public const PERMANENT_DELETE_STATUS_INPROGRESS = 'inprogress';
  1647. public const PERMANENT_DELETE_STATUS_COMPLETE = 'complete';
  1648. public const PERMANENT_DELETE_STATUS_FAILED = 'failed';
  1649. // Default role options
  1650. public const DEFAULT_ROLE_EXPERT = 'EXPERT';
  1651. public const DEFAULT_ROLE_EXPERTVIEWER = 'EXPERTVIEWER';
  1652. public const DEFAULT_ROLE_SCANNER = 'SCANNER';
  1653. public const DEFAULT_ROLE_SCANNERDOWNLOAD = 'SCANNERDOWNLOAD';
  1654. public const DEFAULT_ROLE_PROJECTMANAGER = 'PROJECTMANAGER';
  1655. public const REFERENCE_ID_PREFIX = 'MSR-';
  1656. // Case merits analysis options
  1657. public const CASE_MERITS_ANALYSIS_SUPPORTIVE = 'supportive';
  1658. public const CASE_MERITS_ANALYSIS_UNSUPPORTIVE = 'unsupportive';
  1659. public const CASE_MERITS_ANALYSIS_INCONCLUSIVE = 'inconclusive';
  1660. // Type of letter options
  1661. public const TYPE_OF_LETTER_LETTER_OF_CLAIM = 'letter_of_claim';
  1662. public const TYPE_OF_LETTER_LETTER_OF_NOTIFICATION = 'letter_of_notification';
  1663. public const TYPE_OF_LETTER_SUBJECT_ACCESS_REQUEST = 'subject_access_request';
  1664. public const TYPE_OF_LETTER_DISCLOSURE_APPLICATION = 'disclosure_application';
  1665. // Review type options
  1666. public const REVIEW_TYPE_CASE_MERITS_ANALYSIS = 'case_merits_analysis';
  1667. public const REVIEW_TYPE_CHRONOLOGY = 'chronology';
  1668. // The number of hours prior to deletion that a reminder must be sent (currently set to the equivalent of 7 days)
  1669. public const DELETION_REMINDER_OFFSET_HOURS = 168;
  1670. // Firm Records Review Constants
  1671. public const FIRM_RECORDS_REVIEW_STATUS_AWAITING_RECORDS = 'awaiting_records';
  1672. public const FIRM_RECORDS_REVIEW_STATUS_AWAITING_RECORDS__LABEL = 'Awaiting records';
  1673. public const FIRM_RECORDS_REVIEW_STATUS_UPLOADED = 'uploaded';
  1674. public const FIRM_RECORDS_REVIEW_STATUS_UPLOADED__LABEL = 'Uploaded for firm review';
  1675. public const FIRM_RECORDS_REVIEW_STATUS_COMPLETE_PROCEED = 'complete_proceed';
  1676. public const FIRM_RECORDS_REVIEW_STATUS_COMPLETE_PROCEED__LABEL = 'Complete - proceed with services';
  1677. public const FIRM_RECORDS_REVIEW_STATUS_COMPLETE_NO_PROCEED = 'complete_no_proceed';
  1678. public const FIRM_RECORDS_REVIEW_STATUS_COMPLETE_NO_PROCEED__LABEL = 'Complete - do not proceed with services';
  1679. // Clinical Summary Unsorted Constants
  1680. public const CLINICAL_SUMMARY_UNSORTED_STATUS_AWAITING_CONCLUSION = 'awaiting_conclusion';
  1681. public const CLINICAL_SUMMARY_UNSORTED_STATUS_AWAITING_CONCLUSION__LABEL = 'Awaiting conclusion';
  1682. public const CLINICAL_SUMMARY_UNSORTED_STATUS_SUPPORTIVE = 'supportive';
  1683. public const CLINICAL_SUMMARY_UNSORTED_STATUS_SUPPORTIVE__LABEL = 'Supportive - proceed with services';
  1684. public const CLINICAL_SUMMARY_UNSORTED_STATUS_UNSUPPORTIVE = 'unsupportive';
  1685. public const CLINICAL_SUMMARY_UNSORTED_STATUS_UNSUPPORTIVE__LABEL = 'Unsupportive - do not proceed with services';
  1686. public const CLINICAL_SUMMARY_UNSORTED_STATUS_INCONCLUSIVE = 'inconclusive';
  1687. public const CLINICAL_SUMMARY_UNSORTED_STATUS_INCONCLUSIVE__LABEL = 'Inconclusive';
  1688. // Radiology migration statuses
  1689. public const MODERN_RADIOLOGY_MIGRATION_STATUS_PENDING = 'pending';
  1690. public const MODERN_RADIOLOGY_MIGRATION_STATUS_IN_PROGRESS = 'in_progress';
  1691. public const MODERN_RADIOLOGY_MIGRATION_STATUS_COMPLETE = 'complete';
  1692. // Migration is considered failed if a previously active disc is now in a failed state.
  1693. public const MODERN_RADIOLOGY_MIGRATION_STATUS_FAILED = 'failed';
  1694. // 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.
  1695. public const MODERN_RADIOLOGY_MIGRATION_STATUS_SKIPPED = 'skipped';
  1696. // Represents a matter accessible to the firm which is our client
  1697. public const TYPE_MATTER_FIRM = 'firm';
  1698. public const TYPE_MATTER_FIRM__LABEL = 'Matter';
  1699. // Represents a matter that is intended to disclosure records to a third-party.
  1700. public const TYPE_MATTER_DISCLOSURE = 'disclosure';
  1701. public const TYPE_MATTER_DISCLOSURE__LABEL = 'Disclosure';
  1702. /**
  1703. * @var int
  1704. *
  1705. * @Groups({"project_closure:read", "clinical_summary_matter:read"})
  1706. *
  1707. * @ORM\Column(name="id", type="integer")
  1708. *
  1709. * @ORM\Id
  1710. *
  1711. * @ORM\GeneratedValue(strategy="IDENTITY")
  1712. */
  1713. private $id;
  1714. /**
  1715. * @var DateTime|null
  1716. *
  1717. * @ORM\Column(name="deletedAt", type="datetime", nullable=true)
  1718. */
  1719. private $deletedAt;
  1720. /**
  1721. * @var string
  1722. *
  1723. * @Groups({"project_closure:read", "clinical_summary_matter:read"})
  1724. *
  1725. * @ORM\Column(name="name", type="text")
  1726. */
  1727. private $name;
  1728. /**
  1729. * @var string|null
  1730. *
  1731. * @ORM\Column(name="patient_name", type="string", nullable=true)
  1732. */
  1733. private $patient_name;
  1734. /**
  1735. * @var string|null
  1736. *
  1737. * @ORM\Column(name="old_matter_reference", type="string", nullable=true)
  1738. */
  1739. private $old_matter_reference;
  1740. /**
  1741. * @var int|null
  1742. *
  1743. * @ORM\Column(name="pages", type="integer", nullable=true)
  1744. */
  1745. private $pages;
  1746. /**
  1747. * @var int
  1748. *
  1749. * @ORM\Column(name="status", type="integer", nullable=false)
  1750. */
  1751. private $status;
  1752. /**
  1753. * @var string|null
  1754. *
  1755. * @Groups({"project_closure:read", "clinical_summary_matter:read"})
  1756. *
  1757. * @ORM\Column(name="client_reference", type="string", nullable=true)
  1758. */
  1759. private $client_reference;
  1760. /**
  1761. * @var string|null
  1762. *
  1763. * @ORM\Column(name="billing_code", type="string", nullable=true)
  1764. */
  1765. private $billing_code;
  1766. /**
  1767. * @var string|null
  1768. *
  1769. * @ORM\Column(name="background", type="text", nullable=true)
  1770. */
  1771. private $background;
  1772. /**
  1773. * @var string|null
  1774. *
  1775. * @ORM\Column(name="reference", type="string", nullable=true)
  1776. */
  1777. private $reference;
  1778. /**
  1779. * @var string|null
  1780. *
  1781. * @ORM\Column(name="millnet_id", type="string", nullable=true)
  1782. */
  1783. private $millnet_id;
  1784. /**
  1785. * @var int|null
  1786. *
  1787. * @ORM\Column(name="hold_settled", type="integer", nullable=true)
  1788. */
  1789. private $hold_settled;
  1790. /**
  1791. * @var DateTime|null
  1792. *
  1793. * @ORM\Column(name="date_created", type="datetime", nullable=true)
  1794. */
  1795. private $date_created;
  1796. /**
  1797. * @var DateTime|null
  1798. *
  1799. * @ORM\Column(name="date_closed", type="datetime", nullable=true)
  1800. */
  1801. private $date_closed;
  1802. /**
  1803. * @var DateTime|null
  1804. *
  1805. * @ORM\Column(name="forcedRenewalCreated", type="datetime", nullable=true)
  1806. */
  1807. private ?DateTime $forcedRenewalCreated;
  1808. /**
  1809. * @var DateTime|null
  1810. *
  1811. * @ORM\Column(name="patient_date_of_birth", type="date", nullable=true)
  1812. */
  1813. private $patient_date_of_birth;
  1814. /**
  1815. * @var int|null
  1816. *
  1817. * @ORM\Column(name="archive_status", type="integer", nullable=true)
  1818. */
  1819. private $archive_status;
  1820. /**
  1821. * @var DateTime|null
  1822. *
  1823. * @ORM\Column(name="archive_status_updated", type="datetime", nullable=true)
  1824. */
  1825. private $archive_status_updated;
  1826. /**
  1827. * @var int|null
  1828. *
  1829. * @ORM\Column(name="deleteStatus", type="integer", nullable=true)
  1830. */
  1831. private $deleteStatus;
  1832. /**
  1833. * @var DateTime|null
  1834. *
  1835. * @ORM\Column(name="deleteStatusUpdated", type="datetime", nullable=true)
  1836. */
  1837. private $deleteStatusUpdated;
  1838. /**
  1839. * @var DateTime|null
  1840. *
  1841. * @ORM\Column(name="future_deletion_date", type="datetime", nullable=true)
  1842. */
  1843. private $future_deletion_date;
  1844. /**
  1845. * @var string
  1846. *
  1847. * @ORM\Column(name="slug", type="text")
  1848. *
  1849. * @Gedmo\Slug(fields={"name"}, updatable=false, separator="_")
  1850. */
  1851. private $slug;
  1852. /**
  1853. * @var DateTime
  1854. *
  1855. * @ORM\Column(name="created", type="datetime")
  1856. *
  1857. * @Gedmo\Timestampable(on="create")
  1858. *
  1859. */
  1860. private $created;
  1861. /**
  1862. * @var DateTime
  1863. *
  1864. * @ORM\Column(name="updated", type="datetime")
  1865. *
  1866. * @Gedmo\Timestampable(on="update")
  1867. */
  1868. private $updated;
  1869. /**
  1870. * @var string
  1871. *
  1872. * @ORM\Column(name="search_index", type="text", nullable=false)
  1873. */
  1874. private $search_index;
  1875. /**
  1876. * @var int
  1877. *
  1878. * @ORM\Column(name="license_level", type="integer", nullable=false)
  1879. */
  1880. private $license_level;
  1881. /**
  1882. * @var string|null
  1883. *
  1884. * @ORM\Column(name="documents_total_filesize", type="string", nullable=true)
  1885. */
  1886. private $documents_total_filesize;
  1887. /**
  1888. * @var string|null
  1889. *
  1890. * @ORM\Column(name="active_discs_total_archive_filesize", type="string", nullable=true)
  1891. */
  1892. private $active_discs_total_archive_filesize;
  1893. /**
  1894. * @var DateTime|null
  1895. *
  1896. * @ORM\Column(name="limitation_date", type="datetime", nullable=true)
  1897. */
  1898. private $limitation_date;
  1899. /**
  1900. * @var int|null
  1901. *
  1902. * @ORM\Column(name="claim_category", type="integer", nullable=true)
  1903. */
  1904. private $claim_category;
  1905. /**
  1906. * @var int|null
  1907. *
  1908. * @ORM\Column(name="estimated_claim_value", type="integer", nullable=true)
  1909. */
  1910. private $estimated_claim_value;
  1911. /**
  1912. * @var string|null
  1913. *
  1914. * @ORM\Column(name="team", type="string", nullable=true)
  1915. */
  1916. private $team;
  1917. /**
  1918. * @var string|null
  1919. *
  1920. * @ORM\Column(name="default_role", type="string", nullable=true)
  1921. */
  1922. private $default_role;
  1923. /**
  1924. * UserNotifications disabled for this Project
  1925. *
  1926. * @var array|null
  1927. *
  1928. * @ORM\Column(name="disabled_notifications", type="array", nullable=true)
  1929. */
  1930. private $disabled_notifications;
  1931. /**
  1932. * Whether to require the user to enter a password on downloading a document or folder
  1933. *
  1934. * @var bool
  1935. *
  1936. * @ORM\Column(name="require_password_on_download", type="boolean", options={"default"=false})
  1937. */
  1938. private $require_password_on_download = false;
  1939. /**
  1940. * Whether to require the user to enter a password when accepting an invitation to join a project
  1941. *
  1942. * @var bool
  1943. *
  1944. * @ORM\Column(name="inviteUserMustAuthenticate", type="boolean", options={"default"=false})
  1945. */
  1946. private $inviteUserMustAuthenticate = false;
  1947. /**
  1948. * @var string|null
  1949. *
  1950. * @ORM\Column(name="inviteUserPassword", type="string", nullable=true)
  1951. */
  1952. private $inviteUserPassword;
  1953. /**
  1954. * @var string|null
  1955. *
  1956. * @ORM\Column(name="inviteUserContactName", type="string", nullable=true)
  1957. */
  1958. private $inviteUserContactName;
  1959. /**
  1960. * @var string|null
  1961. *
  1962. * @ORM\Column(name="inviteUserContactEmail", type="string", nullable=true)
  1963. */
  1964. private $inviteUserContactEmail;
  1965. /**
  1966. * @var PhoneNumber|null
  1967. *
  1968. * @ORM\Column(name="inviteUserContactPhoneNumber", type="phone_number", nullable=true)
  1969. */
  1970. private $inviteUserContactPhoneNumber;
  1971. /**
  1972. * @var DateTime|null
  1973. *
  1974. * @ORM\Column(name="date_on_letter", type="datetime", nullable=true)
  1975. */
  1976. private $date_on_letter;
  1977. /**
  1978. * @var string|null
  1979. *
  1980. * @ORM\Column(name="case_merits_analysis", type="string", nullable=true)
  1981. */
  1982. private $case_merits_analysis;
  1983. /**
  1984. * @var string|null
  1985. *
  1986. * @ORM\Column(name="claimant_solicitor", type="string", nullable=true)
  1987. */
  1988. private $claimant_solicitor;
  1989. /**
  1990. * @var string|null
  1991. *
  1992. * @ORM\Column(name="type_of_letter", type="string", nullable=true)
  1993. */
  1994. private $type_of_letter;
  1995. /**
  1996. * @var string|null
  1997. *
  1998. * @ORM\Column(name="review_type", type="string", nullable=true)
  1999. */
  2000. private $review_type;
  2001. /**
  2002. * @var DateTime|null
  2003. *
  2004. * @ORM\Column(name="experts_report_date", type="datetime", nullable=true)
  2005. */
  2006. private $experts_report_date;
  2007. /**
  2008. * @var DateTime|null
  2009. *
  2010. * @ORM\Column(name="letter_of_response_and_expert_report_date", type="datetime", nullable=true)
  2011. */
  2012. private $letter_of_response_and_expert_report_date;
  2013. /**
  2014. * @var DateTime|null
  2015. *
  2016. * @ORM\Column(name="letter_of_response_prepared_date", type="datetime", nullable=true)
  2017. */
  2018. private $letter_of_response_prepared_date;
  2019. /**
  2020. * @var DateTime|null
  2021. *
  2022. * @ORM\Column(name="letter_of_response_sent_date", type="datetime", nullable=true)
  2023. */
  2024. private $letter_of_response_sent_date;
  2025. /**
  2026. * @var DateTime|null
  2027. *
  2028. * @ORM\Column(name="dateDeleted", type="datetime", nullable=true)
  2029. */
  2030. private $dateDeleted;
  2031. /**
  2032. * Determines if users with role Expert and Expert - View Only on a Project/Matter can see
  2033. * the Unsorted records folder on the Medical Records Screen.
  2034. *
  2035. * @var bool|null
  2036. *
  2037. * @ORM\Column(name="allowExpertViewUnsortedRecords", type="boolean", nullable=true)
  2038. */
  2039. private $allowExpertViewUnsortedRecords;
  2040. /**
  2041. * @var ProjectDeletionReport
  2042. *
  2043. * @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\ProjectDeletionReport", inversedBy="project")
  2044. *
  2045. * @ORM\JoinColumns({
  2046. *
  2047. * @ORM\JoinColumn(name="projectDeletionReport_id", referencedColumnName="id", unique=true)
  2048. * })
  2049. */
  2050. private $projectDeletionReport;
  2051. /**
  2052. * @var Collection
  2053. *
  2054. * @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\Collection", inversedBy="projectMedicalRecords", cascade={"all"})
  2055. *
  2056. * @ORM\JoinColumns({
  2057. *
  2058. * @ORM\JoinColumn(name="medicalRecordsCollection_id", referencedColumnName="id", unique=true)
  2059. * })
  2060. */
  2061. private $medicalRecordsCollection;
  2062. /**
  2063. * @var Collection
  2064. *
  2065. * @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\Collection", inversedBy="projectUnsortedRecords", cascade={"all"})
  2066. *
  2067. * @ORM\JoinColumns({
  2068. *
  2069. * @ORM\JoinColumn(name="unsortedRecordsCollection_id", referencedColumnName="id", unique=true)
  2070. * })
  2071. */
  2072. private $unsortedRecordsCollection;
  2073. /**
  2074. * @var Collection
  2075. *
  2076. * @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\Collection", inversedBy="projectPrivate", cascade={"all"})
  2077. *
  2078. * @ORM\JoinColumns({
  2079. *
  2080. * @ORM\JoinColumn(name="privateCollection_id", referencedColumnName="id", unique=true)
  2081. * })
  2082. */
  2083. private $privateCollection;
  2084. /**
  2085. * This collection contains collections specific to a user,
  2086. * from which they are free to upload and download Documents.
  2087. *
  2088. * @var Collection
  2089. *
  2090. * @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\Collection", inversedBy="projectPrivateSandbox", cascade={"all"})
  2091. *
  2092. * @ORM\JoinColumns({
  2093. *
  2094. * @ORM\JoinColumn(name="privateSandboxCollection_id", referencedColumnName="id", unique=true)
  2095. * })
  2096. */
  2097. private $privateSandboxCollection;
  2098. /**
  2099. * @var MatterRequest
  2100. *
  2101. * @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\MatterRequest\MatterRequest", mappedBy="matter", cascade={"persist", "remove"})
  2102. */
  2103. private $matterRequest;
  2104. /**
  2105. * @var ProjectClosure
  2106. *
  2107. * @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\ProjectClosure", mappedBy="project", cascade={"persist", "remove"})
  2108. */
  2109. private $projectClosure;
  2110. /**
  2111. * @var DoctrineCollection
  2112. *
  2113. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\Document", mappedBy="project", orphanRemoval=true)
  2114. */
  2115. private $documents;
  2116. /**
  2117. * @var DoctrineCollection
  2118. *
  2119. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\ProjectUser", mappedBy="project", cascade={"all"})
  2120. */
  2121. private $projectUsers;
  2122. /**
  2123. * @var DoctrineCollection
  2124. *
  2125. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\Disc", mappedBy="project", cascade={"all"})
  2126. *
  2127. * @ORM\OrderBy({
  2128. * "created"="ASC"
  2129. * })
  2130. */
  2131. private $discs;
  2132. /**
  2133. * @var DoctrineCollection
  2134. *
  2135. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\RecordsRequest", mappedBy="project", cascade={"all"})
  2136. */
  2137. private $recordsRequests;
  2138. /**
  2139. * @var DoctrineCollection
  2140. *
  2141. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\BatchRequest", mappedBy="project", cascade={"all"})
  2142. */
  2143. private $batchRequests;
  2144. /**
  2145. * @var DoctrineCollection
  2146. *
  2147. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\ChronologyRequest", mappedBy="project", cascade={"all"})
  2148. */
  2149. private $chronologyRequests;
  2150. /**
  2151. * @var DoctrineCollection
  2152. *
  2153. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\ExpertReportRequest", mappedBy="project", cascade={"all"})
  2154. */
  2155. private $expertReportRequests;
  2156. /**
  2157. * @var DoctrineCollection
  2158. *
  2159. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\AdditionalRequest", mappedBy="project", cascade={"all"})
  2160. */
  2161. private $additionalRequests;
  2162. /**
  2163. * @var DoctrineCollection
  2164. *
  2165. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\SortingSession", mappedBy="project", cascade={"all"})
  2166. */
  2167. private $sortingSessions;
  2168. /**
  2169. * @var DoctrineCollection
  2170. *
  2171. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\Patient", mappedBy="project", cascade={"all"})
  2172. */
  2173. private $patients;
  2174. /**
  2175. * @var DoctrineCollection
  2176. *
  2177. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\Study", mappedBy="project", cascade={"all"})
  2178. */
  2179. private $studies;
  2180. /**
  2181. * @var DoctrineCollection
  2182. *
  2183. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\Series", mappedBy="project", cascade={"all"})
  2184. */
  2185. private $series;
  2186. /**
  2187. * @var DoctrineCollection
  2188. *
  2189. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\DiscImportSession", mappedBy="project", cascade={"all"})
  2190. */
  2191. private $discImportSessions;
  2192. /**
  2193. * @var DoctrineCollection
  2194. *
  2195. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\MatterNote", mappedBy="project", cascade={"persist","remove"}, orphanRemoval=true)
  2196. */
  2197. private $matterNotes;
  2198. /**
  2199. * @var DoctrineCollection
  2200. *
  2201. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\MatterCommunication", mappedBy="project", cascade={"all"})
  2202. */
  2203. private $matterCommunications;
  2204. /**
  2205. * @var
  2206. *
  2207. * @Groups({"clinical_summary_matter:read"})
  2208. *
  2209. * @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\Account", inversedBy="projects")
  2210. *
  2211. * @ORM\JoinColumns({
  2212. *
  2213. * @ORM\JoinColumn(name="account_id", referencedColumnName="id", nullable=false)
  2214. * })
  2215. */
  2216. private $account;
  2217. /**
  2218. * @var User
  2219. *
  2220. * @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\User", inversedBy="managedProjects")
  2221. *
  2222. * @ORM\JoinColumns({
  2223. *
  2224. * @ORM\JoinColumn(name="manager_id", referencedColumnName="id", nullable=true)
  2225. * })
  2226. */
  2227. private $manager;
  2228. /**
  2229. * @var DoctrineCollection|null
  2230. *
  2231. * @ORM\ManyToMany(targetEntity="MedBrief\MSR\Entity\User")
  2232. *
  2233. * @ORM\JoinTable(
  2234. * name="project_additional_contacts",
  2235. * joinColumns={@ORM\JoinColumn(name="project_id", referencedColumnName="id", onDelete="CASCADE", nullable=true)},
  2236. * inverseJoinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE", nullable=true)}
  2237. * )
  2238. */
  2239. private $additionalContacts;
  2240. /**
  2241. * @ORM\OneToMany(targetEntity=Instance::class, mappedBy="project")
  2242. */
  2243. private $instances;
  2244. /**
  2245. * @ORM\Column(type="string", nullable=true)
  2246. */
  2247. private ?string $firmRecordsReviewStatus = null;
  2248. /**
  2249. * @ORM\Column(type="datetime", nullable=true)
  2250. */
  2251. private ?DateTime $firmRecordsReviewUpdated = null;
  2252. /**
  2253. * @ORM\Column(type="string", nullable=true)
  2254. */
  2255. private ?string $clinicalSummaryUnsortedStatus = null;
  2256. /**
  2257. * @ORM\Column(type="datetime", nullable=true)
  2258. */
  2259. private ?DateTime $clinicalSummaryUnsortedUpdated = null;
  2260. /**
  2261. * @ORM\OneToMany(targetEntity=InterpartyDisclosure::class, mappedBy="project", orphanRemoval=true, cascade={"persist", "remove"})
  2262. *
  2263. * @ORM\OrderBy({"id"="DESC"})
  2264. */
  2265. private ?DoctrineCollection $interpartyDisclosures;
  2266. /**
  2267. * @ORM\Column(name="matterType", type="string", length=64, nullable=true)
  2268. *
  2269. */
  2270. private ?string $matterType = self::MATTER_TYPE_CLINICAL_NEGLIGENCE;
  2271. /**
  2272. * @ORM\Column(type="string", nullable=true)
  2273. */
  2274. private ?string $modernRadiologyMigrationStatus;
  2275. /**
  2276. * @ORM\Column(type="boolean", nullable=false, options={"default"=false})
  2277. */
  2278. private bool $useModernRadiology = false;
  2279. /**
  2280. * @ORM\Column(type="string", nullable=false, options={"default"=self::TYPE_MATTER_FIRM})
  2281. */
  2282. private ?string $type = self::TYPE_MATTER_FIRM;
  2283. /**
  2284. * @ORM\Column(type="boolean", nullable=false, options={"default"=false})
  2285. */
  2286. private bool $hideFromInvoicing = false;
  2287. /**
  2288. * @ORM\Column(type="datetime", nullable=true)
  2289. */
  2290. private ?DateTime $lastRenewalDate = null;
  2291. /**
  2292. * @ORM\Column(type="datetime", nullable=true)
  2293. */
  2294. private ?DateTime $nextRenewalDate;
  2295. /**
  2296. * @ORM\Column(type="json", nullable=true)
  2297. */
  2298. private ?array $renewalNotificationSent = [];
  2299. /**
  2300. * Suppresses remaining hosting renewal reminders for the current renewal cycle.
  2301. *
  2302. * @ORM\Column(type="boolean", nullable=false, options={"default"=false})
  2303. */
  2304. private bool $proceedWithRenewal = false;
  2305. /**
  2306. * @ORM\OneToMany(targetEntity=MatterLicenceRenewalLog::class, mappedBy="project")
  2307. */
  2308. private ?DoctrineCollection $matterLicenceRenewalLogs;
  2309. /**
  2310. * @ORM\Column(type="string", length=255, nullable=true)
  2311. */
  2312. private ?string $permanentDeleteStatus = null;
  2313. /**
  2314. * @Groups({"clinical_summary_matter:read"})
  2315. *
  2316. * @ORM\OneToOne(targetEntity=ClinicalSummary::class, mappedBy="project", cascade={"persist", "remove"})
  2317. */
  2318. private ?ClinicalSummary $clinicalSummary = null;
  2319. // Unread match messages count for the project
  2320. private ?int $unreadMatchMessages = null;
  2321. // Messages CTA text and count lozenge for the project (see MatchMessagesCta::resolve())
  2322. private ?MatchMessagesCta $matchMessagesCta = null;
  2323. // Conversation status for the project
  2324. private ?string $conversationStatus = null;
  2325. // Conversation status badge type for the project (see ConversationStatusVocabulary::type())
  2326. private ?string $conversationStatusType = null;
  2327. // a limited matter name that can be used in contexts where the full matter name should not be exposed
  2328. private ?string $limitedMatterName = null;
  2329. public function __construct()
  2330. {
  2331. // default status of INACTIVE
  2332. $this->setStatus(self::STATUS_INACTIVE);
  2333. $this->patients = new ArrayCollection();
  2334. $this->studies = new ArrayCollection();
  2335. $this->series = new ArrayCollection();
  2336. $this->discs = new ArrayCollection();
  2337. $this->recordsRequests = new ArrayCollection();
  2338. $this->batchRequests = new ArrayCollection();
  2339. $this->additionalRequests = new ArrayCollection();
  2340. $this->chronologyRequests = new ArrayCollection();
  2341. $this->expertReportRequests = new ArrayCollection();
  2342. $this->sortingSessions = new ArrayCollection();
  2343. $this->matterNotes = new ArrayCollection();
  2344. $this->documents = new ArrayCollection();
  2345. $this->projectUsers = new ArrayCollection();
  2346. $this->discImportSessions = new ArrayCollection();
  2347. $this->matterCommunications = new ArrayCollection();
  2348. $this->instances = new ArrayCollection();
  2349. $this->interpartyDisclosures = new ArrayCollection();
  2350. $this->disclosureSources = new ArrayCollection();
  2351. $this->matterLicenceRenewalLogs = new ArrayCollection();
  2352. $this->medicalRecordsCollection = new Collection();
  2353. $this->medicalRecordsCollection
  2354. ->setName(Collection::DISPLAY_NAME_MEDICAL_RECORDS)
  2355. ->setProjectMedicalRecords($this)
  2356. ;
  2357. $this->unsortedRecordsCollection = new Collection();
  2358. $this->unsortedRecordsCollection
  2359. ->setName(Collection::DISPLAY_NAME_UNSORTED_RECORDS)
  2360. ->setProjectUnsortedRecords($this)
  2361. ;
  2362. // default the date created for matters to the current date
  2363. $this->setDateCreated(new DateTime());
  2364. // All matters default to the standard license
  2365. $this->setLicenseLevel(self::LICENSE_LEVEL_STANDARD);
  2366. $this->require_password_on_download = false;
  2367. $this->setInviteUserMustAuthenticate(false);
  2368. // Set this in the constructor so it only applies to new matters
  2369. $this->setModernRadiologyMigrationStatus(self::MODERN_RADIOLOGY_MIGRATION_STATUS_SKIPPED);
  2370. $this->matterLicenceRenewalLogs = new ArrayCollection();
  2371. $this->additionalContacts = new ArrayCollection();
  2372. }
  2373. public function __toString()
  2374. {
  2375. return $this->getName();
  2376. }
  2377. /**
  2378. * @return int
  2379. */
  2380. public function getId()
  2381. {
  2382. return $this->id;
  2383. }
  2384. /**
  2385. * @param string $name
  2386. *
  2387. * @return Project
  2388. */
  2389. public function setName($name)
  2390. {
  2391. $this->name = $name;
  2392. return $this;
  2393. }
  2394. /**
  2395. * @return string
  2396. */
  2397. public function getName()
  2398. {
  2399. return $this->name;
  2400. }
  2401. /**
  2402. * @param int $pages
  2403. *
  2404. * @return Project
  2405. */
  2406. public function setPages($pages)
  2407. {
  2408. $this->pages = $pages;
  2409. return $this;
  2410. }
  2411. /**
  2412. * @return int
  2413. */
  2414. public function getPages()
  2415. {
  2416. return $this->pages;
  2417. }
  2418. /**
  2419. * @param Account|null $account
  2420. *
  2421. * @return Project
  2422. */
  2423. public function setAccount(?Account $account = null)
  2424. {
  2425. $this->account = $account;
  2426. return $this;
  2427. }
  2428. /**
  2429. * @return Account
  2430. */
  2431. public function getAccount()
  2432. {
  2433. return $this->account;
  2434. }
  2435. /**
  2436. * @param string $slug
  2437. *
  2438. * @return Project
  2439. */
  2440. public function setSlug($slug)
  2441. {
  2442. $this->slug = $slug;
  2443. return $this;
  2444. }
  2445. /**
  2446. * @return string
  2447. */
  2448. public function getSlug()
  2449. {
  2450. return $this->slug;
  2451. }
  2452. /**
  2453. * @param DateTime $created
  2454. *
  2455. * @return Project
  2456. */
  2457. public function setCreated($created)
  2458. {
  2459. $this->created = $created;
  2460. return $this;
  2461. }
  2462. /**
  2463. * @return DateTime
  2464. */
  2465. public function getCreated()
  2466. {
  2467. return $this->created;
  2468. }
  2469. /**
  2470. * @param DateTime $updated
  2471. *
  2472. * @return Project
  2473. */
  2474. public function setUpdated($updated)
  2475. {
  2476. $this->updated = $updated;
  2477. return $this;
  2478. }
  2479. /**
  2480. * @return DateTime
  2481. */
  2482. public function getUpdated()
  2483. {
  2484. return $this->updated;
  2485. }
  2486. /**
  2487. * @param Document $documents
  2488. *
  2489. * @return Project
  2490. */
  2491. public function addDocument(Document $documents)
  2492. {
  2493. $this->documents[] = $documents;
  2494. return $this;
  2495. }
  2496. /**
  2497. * @param Document $documents
  2498. */
  2499. public function removeDocument(Document $documents)
  2500. {
  2501. $this->documents->removeElement($documents);
  2502. }
  2503. /**
  2504. * @return DoctrineCollection|Document[]
  2505. */
  2506. public function getDocuments()
  2507. {
  2508. return $this->documents;
  2509. }
  2510. /**
  2511. * @param Disc $disc
  2512. *
  2513. * @return Project
  2514. */
  2515. public function addDisc(Disc $disc)
  2516. {
  2517. if (!$this->discs->contains($disc)) {
  2518. $this->discs[] = $disc;
  2519. }
  2520. return $this;
  2521. }
  2522. /**
  2523. * @param Disc $discs
  2524. *
  2525. * @return Project
  2526. */
  2527. public function removeDisc(Disc $discs)
  2528. {
  2529. $this->discs->removeElement($discs);
  2530. return $this;
  2531. }
  2532. /**
  2533. * @return DoctrineCollection|Disc[]
  2534. */
  2535. public function getDiscs()
  2536. {
  2537. return $this->discs;
  2538. }
  2539. /**
  2540. * @return bool
  2541. */
  2542. public function isAllDiscsPendingUpload(): bool
  2543. {
  2544. foreach ($this->getDiscs() as $disc) {
  2545. if ($disc->getStatus() !== Disc::STATUS_PENDING_UPLOAD) {
  2546. return false;
  2547. }
  2548. }
  2549. return true;
  2550. }
  2551. /**
  2552. * Gets Discs for a project with a specific status.
  2553. *
  2554. * @param mixed $status
  2555. *
  2556. * @return ArrayCollection | null
  2557. */
  2558. public function getDiscsByStatus($status)
  2559. {
  2560. return $this->discs->filter(function (Disc $disc) use ($status) {
  2561. return $disc->getStatus() === $status;
  2562. });
  2563. }
  2564. /**
  2565. * Get all active Discs for a Project
  2566. *
  2567. * @return ArrayCollection|null
  2568. */
  2569. public function getActiveDiscs()
  2570. {
  2571. return $this->getDiscsByStatus(Disc::STATUS_ACTIVE);
  2572. }
  2573. /**
  2574. * Gets all failed Discs for a Project
  2575. *
  2576. * @return ArrayCollection|null
  2577. */
  2578. public function getFailedDiscs()
  2579. {
  2580. return $this->getDiscs()->filter(function (Disc $disc) {
  2581. // return true if disc failed, however exclude discs with status failed virus
  2582. // Normally we don't need to check for deletedAt, as the softdeletable filter filters it out,
  2583. // but in the case of disclosures, we switch this filter off, to avoid a broken relationship issue.
  2584. return $disc->isFailed([Disc::STATUS_FAILED_VIRUS]) && $disc->getDeletedAt() === null;
  2585. });
  2586. }
  2587. /**
  2588. * @param int $status
  2589. *
  2590. * @return Project
  2591. */
  2592. public function setStatus($status)
  2593. {
  2594. $this->status = $status;
  2595. return $this;
  2596. }
  2597. /**
  2598. * @return int
  2599. */
  2600. public function getStatus()
  2601. {
  2602. return $this->status;
  2603. }
  2604. /**
  2605. * Returns true if the Project is inactive.
  2606. *
  2607. * @return bool
  2608. */
  2609. public function isInactive()
  2610. {
  2611. return $this->getStatus() === self::STATUS_INACTIVE;
  2612. }
  2613. /**
  2614. * @param string $clientReference
  2615. *
  2616. * @return Project
  2617. */
  2618. public function setClientReference($clientReference)
  2619. {
  2620. $this->client_reference = $clientReference;
  2621. // Update the associated matter request as well, if it exists, and if the values are different,
  2622. // to avoid a recursive loop.
  2623. if ($this->getMatterRequest() && $this->getMatterRequest()->getMatterReference() != $this->client_reference) {
  2624. $this->getMatterRequest()->setMatterReference($this->client_reference);
  2625. }
  2626. return $this;
  2627. }
  2628. /**
  2629. * @Groups({"project_closure:read"})
  2630. *
  2631. * @return string
  2632. */
  2633. public function getClientReference()
  2634. {
  2635. return $this->client_reference;
  2636. }
  2637. /**
  2638. * @param string $reference
  2639. *
  2640. * @return Project
  2641. */
  2642. public function setReference($reference)
  2643. {
  2644. $this->reference = $reference;
  2645. return $this;
  2646. }
  2647. /**
  2648. * @return string
  2649. */
  2650. public function getReference()
  2651. {
  2652. return $this->reference;
  2653. }
  2654. /**
  2655. * @param Patient $patients
  2656. *
  2657. * @return Project
  2658. */
  2659. public function addPatient(Patient $patients)
  2660. {
  2661. $this->patients[] = $patients;
  2662. return $this;
  2663. }
  2664. /**
  2665. * @param Patient $patients
  2666. */
  2667. public function removePatient(Patient $patients)
  2668. {
  2669. $this->patients->removeElement($patients);
  2670. }
  2671. /**
  2672. * @return DoctrineCollection|RadiologyPatient[]
  2673. */
  2674. public function getPatients()
  2675. {
  2676. return $this->patients;
  2677. }
  2678. /**
  2679. * @param Study $studies
  2680. *
  2681. * @return Project
  2682. */
  2683. public function addStudy(Study $studies)
  2684. {
  2685. $this->studies[] = $studies;
  2686. return $this;
  2687. }
  2688. /**
  2689. * @param Study $studies
  2690. */
  2691. public function removeStudy(Study $studies)
  2692. {
  2693. $this->studies->removeElement($studies);
  2694. }
  2695. /**
  2696. * @return DoctrineCollection|Study[]
  2697. */
  2698. public function getStudies()
  2699. {
  2700. return $this->studies;
  2701. }
  2702. /**
  2703. * Get Studies with active Discs
  2704. *
  2705. * @return ArrayCollection|null
  2706. */
  2707. public function getStudiesWithActiveDiscs()
  2708. {
  2709. return $this->getStudies()->filter(function (Study $study) {
  2710. return $study->getDiscs()->filter(function (Disc $disc) {
  2711. // Normally we don't need to check for deletedAt, as the softdeletable filter filters it out,
  2712. // but in the case of disclosures, we switch this filter off, to avoid a broken relationship issue.
  2713. // Due to the many-to-many relation between Disc and Study, the check for deletedAt isn't ACTUALLY needed,
  2714. // but for data integrity, we do the check anyway.
  2715. return $disc->isActive() && $disc->getDeletedAt() === null;
  2716. })->count();
  2717. });
  2718. }
  2719. /**
  2720. * @param Series $series
  2721. *
  2722. * @return Project
  2723. */
  2724. public function addSeries(Series $series)
  2725. {
  2726. $this->series[] = $series;
  2727. return $this;
  2728. }
  2729. /**
  2730. * @param Series $series
  2731. */
  2732. public function removeSeries(Series $series)
  2733. {
  2734. $this->series->removeElement($series);
  2735. }
  2736. /**
  2737. * @return DoctrineCollection|Series[]
  2738. */
  2739. public function getSeries()
  2740. {
  2741. return $this->series;
  2742. }
  2743. /**
  2744. * Returns the MedBrief Matter reference number which is essentially the ClientReference
  2745. * of the Project padded with zeros to six figures
  2746. *
  2747. * @return string
  2748. */
  2749. public function getReferenceNumber()
  2750. {
  2751. return str_pad($this->getClientReference(), 6, '0', STR_PAD_LEFT);
  2752. }
  2753. /**
  2754. * @param DateTime $dateCreated
  2755. *
  2756. * @return Project
  2757. */
  2758. public function setDateCreated($dateCreated)
  2759. {
  2760. $this->date_created = $dateCreated;
  2761. return $this;
  2762. }
  2763. /**
  2764. * @return DateTime
  2765. */
  2766. public function getDateCreated()
  2767. {
  2768. return $this->date_created;
  2769. }
  2770. /**
  2771. * @param DateTime $patientDateOfBirth
  2772. *
  2773. * @throws Exception
  2774. *
  2775. * @return Project
  2776. */
  2777. public function setPatientDateOfBirth($patientDateOfBirth)
  2778. {
  2779. $this->patient_date_of_birth = $patientDateOfBirth;
  2780. // Update the matter request's first patient's date of birth, if different from matter date of birth.
  2781. if ($this->getMatterRequest() && $this->getMatterRequest()->getPatients()->count() > 0) {
  2782. /** @var Patient $firstPatient */
  2783. $firstPatient = $this->getMatterRequest()->getPatients()->first();
  2784. if ($firstPatient->getDateOfBirth() != $this->patient_date_of_birth) {
  2785. $dateOfBirthImmutable = null;
  2786. if ($this->patient_date_of_birth instanceof DateTime) {
  2787. $dateOfBirthImmutable = new \DateTimeImmutable($this->patient_date_of_birth->format('Y-m-d'));
  2788. }
  2789. $firstPatient->setDateOfBirth($dateOfBirthImmutable);
  2790. }
  2791. }
  2792. return $this;
  2793. }
  2794. /**
  2795. * @return DateTime
  2796. */
  2797. public function getPatientDateOfBirth()
  2798. {
  2799. return $this->patient_date_of_birth;
  2800. }
  2801. /**
  2802. * @param User|null $manager
  2803. *
  2804. * @return Project
  2805. */
  2806. public function setManager(?User $manager = null)
  2807. {
  2808. $this->manager = $manager;
  2809. // Update the associated matter request as well, if it exists, and if the values are different,
  2810. // to avoid a recursive loop.
  2811. if ($manager && $this->getMatterRequest() && $this->getMatterRequest()->getManager() != $this->manager) {
  2812. $this->getMatterRequest()->setManager($this->manager);
  2813. }
  2814. return $this;
  2815. }
  2816. /**
  2817. * @return Project
  2818. */
  2819. public function unsetManager()
  2820. {
  2821. $this->manager = null;
  2822. return $this;
  2823. }
  2824. /**
  2825. * retrieves the manager of the project
  2826. *
  2827. * @return User|null
  2828. */
  2829. public function getManager(): ?User
  2830. {
  2831. try {
  2832. // If the manager is a Proxy, we need to load it to ensure it is fully initialized.
  2833. if ($this->manager instanceof Proxy) {
  2834. $this->manager->__load();
  2835. }
  2836. return $this->manager;
  2837. } catch (EntityNotFoundException) {
  2838. // If the manager is not found (has been soft deleted), return null.
  2839. return null;
  2840. }
  2841. }
  2842. /**
  2843. * Returns additional contacts for a matter
  2844. *
  2845. * @return DoctrineCollection|null
  2846. */
  2847. public function getAdditionalContacts(): ?DoctrineCollection
  2848. {
  2849. return $this->additionalContacts;
  2850. }
  2851. /**
  2852. * Sets additional contacts for a matter
  2853. *
  2854. * @param DoctrineCollection|null $additionalContacts
  2855. *
  2856. * @return self
  2857. */
  2858. public function setAdditionalContacts(?DoctrineCollection $additionalContacts): self
  2859. {
  2860. $this->additionalContacts = $additionalContacts ?: new ArrayCollection();
  2861. return $this;
  2862. }
  2863. /**
  2864. * @param RecordsRequest $recordsRequests
  2865. *
  2866. * @return Project
  2867. */
  2868. public function addRecordsRequest(RecordsRequest $recordsRequests)
  2869. {
  2870. $this->recordsRequests[] = $recordsRequests;
  2871. return $this;
  2872. }
  2873. /**
  2874. * @param RecordsRequest $recordsRequests
  2875. */
  2876. public function removeRecordsRequest(RecordsRequest $recordsRequests)
  2877. {
  2878. $this->recordsRequests->removeElement($recordsRequests);
  2879. }
  2880. /**
  2881. * @return DoctrineCollection|RecordsRequest[]
  2882. */
  2883. public function getRecordsRequests()
  2884. {
  2885. return $this->recordsRequests;
  2886. }
  2887. /**
  2888. * @return array
  2889. */
  2890. public function getRecordsRequestIdsArray(): array
  2891. {
  2892. // Map the collection of records requests to extract each's ID, then convert it to an array
  2893. return $this->recordsRequests->map(function (RecordsRequest $recordsRequest) {
  2894. return $recordsRequest->getId();
  2895. })->toArray();
  2896. }
  2897. /**
  2898. * Retrieves the counts for RecordsRequests grouped by
  2899. * their serviceRequest status.
  2900. *
  2901. * @param mixed $uninvoicedOnly
  2902. *
  2903. * @return array
  2904. */
  2905. public function getRecordsRequestsCountByServiceRequestStatus($uninvoicedOnly = true)
  2906. {
  2907. return $this->getServiceableCountsByStatus($this->getRecordsRequests()->toArray(), $uninvoicedOnly);
  2908. }
  2909. /**
  2910. * @param Collection|null $medicalRecordsCollection
  2911. *
  2912. * @return Project
  2913. */
  2914. public function setMedicalRecordsCollection(?Collection $medicalRecordsCollection = null)
  2915. {
  2916. $this->medicalRecordsCollection = $medicalRecordsCollection;
  2917. return $this;
  2918. }
  2919. /**
  2920. * @return Collection
  2921. */
  2922. public function getMedicalRecordsCollection()
  2923. {
  2924. return $this->medicalRecordsCollection;
  2925. }
  2926. /**
  2927. * @param string $billingCode
  2928. *
  2929. * @return Project
  2930. */
  2931. public function setBillingCode($billingCode)
  2932. {
  2933. $this->billing_code = $billingCode;
  2934. // Update the associated matter request as well, if it exists, and if the values are different,
  2935. // to avoid a recursive loop.
  2936. if ($this->getMatterRequest() && $this->getMatterRequest()->getBillingCode() != $this->billing_code) {
  2937. $this->getMatterRequest()->setBillingCode($this->billing_code);
  2938. }
  2939. return $this;
  2940. }
  2941. /**
  2942. * @return string
  2943. */
  2944. public function getBillingCode()
  2945. {
  2946. return $this->billing_code;
  2947. }
  2948. /**
  2949. * @param DateTime $deletedAt
  2950. *
  2951. * @return Project
  2952. */
  2953. public function setDeletedAt($deletedAt)
  2954. {
  2955. $this->deletedAt = $deletedAt;
  2956. return $this;
  2957. }
  2958. /**
  2959. * @return DateTime
  2960. */
  2961. public function getDeletedAt()
  2962. {
  2963. return $this->deletedAt;
  2964. }
  2965. /**
  2966. * Add discImportSession
  2967. *
  2968. * @param DiscImportSession $discImportSession
  2969. *
  2970. * @return Project
  2971. */
  2972. public function addDiscImportSession(DiscImportSession $discImportSession)
  2973. {
  2974. $this->discImportSessions[] = $discImportSession;
  2975. return $this;
  2976. }
  2977. /**
  2978. * Remove discImportSession
  2979. *
  2980. * @param DiscImportSession $discImportSession
  2981. */
  2982. public function removeDiscImportSession(DiscImportSession $discImportSession)
  2983. {
  2984. $this->discImportSessions->removeElement($discImportSession);
  2985. }
  2986. /**
  2987. * @return DoctrineCollection
  2988. */
  2989. public function getDiscImportSessions()
  2990. {
  2991. return $this->discImportSessions;
  2992. }
  2993. /**
  2994. * @param string $patientName
  2995. *
  2996. * @return Project
  2997. */
  2998. public function setPatientName($patientName)
  2999. {
  3000. $this->patient_name = $patientName;
  3001. return $this;
  3002. }
  3003. /**
  3004. * @return string
  3005. */
  3006. public function getPatientName()
  3007. {
  3008. return $this->patient_name;
  3009. }
  3010. /**
  3011. * @param string $oldMatterReference
  3012. *
  3013. * @return Project
  3014. */
  3015. public function setOldMatterReference($oldMatterReference)
  3016. {
  3017. $this->old_matter_reference = $oldMatterReference;
  3018. return $this;
  3019. }
  3020. /**
  3021. * @return string
  3022. */
  3023. public function getOldMatterReference()
  3024. {
  3025. return $this->old_matter_reference;
  3026. }
  3027. /**
  3028. * @param string $millnetId
  3029. *
  3030. * @return Project
  3031. */
  3032. public function setMillnetId($millnetId)
  3033. {
  3034. $this->millnet_id = $millnetId;
  3035. return $this;
  3036. }
  3037. /**
  3038. * @return string
  3039. */
  3040. public function getMillnetId()
  3041. {
  3042. return $this->millnet_id;
  3043. }
  3044. /**
  3045. * @param int $holdSettled
  3046. *
  3047. * @return Project
  3048. */
  3049. public function setHoldSettled($holdSettled)
  3050. {
  3051. $this->hold_settled = $holdSettled;
  3052. return $this;
  3053. }
  3054. /**
  3055. * @return int
  3056. */
  3057. public function getHoldSettled()
  3058. {
  3059. return $this->hold_settled;
  3060. }
  3061. /**
  3062. * @param DateTime $dateClosed
  3063. *
  3064. * @return Project
  3065. */
  3066. public function setDateClosed($dateClosed)
  3067. {
  3068. $this->date_closed = $dateClosed;
  3069. return $this;
  3070. }
  3071. /**
  3072. * @return DateTime
  3073. */
  3074. public function getDateClosed()
  3075. {
  3076. return $this->date_closed;
  3077. }
  3078. /**
  3079. * @param DateTime|null $forcedRenewalCreated
  3080. *
  3081. * @return Project
  3082. */
  3083. public function setForcedRenewalCreated(?DateTime $forcedRenewalCreated = null)
  3084. {
  3085. $this->forcedRenewalCreated = $forcedRenewalCreated;
  3086. return $this;
  3087. }
  3088. /**
  3089. * @return DateTime|null
  3090. */
  3091. public function getForcedRenewalCreated(): ?DateTime
  3092. {
  3093. return $this->forcedRenewalCreated;
  3094. }
  3095. /**
  3096. * @param string $searchIndex
  3097. *
  3098. * @return Project
  3099. */
  3100. public function setSearchIndex($searchIndex)
  3101. {
  3102. $this->search_index = $searchIndex;
  3103. return $this;
  3104. }
  3105. /**
  3106. * @return string
  3107. */
  3108. public function getSearchIndex()
  3109. {
  3110. return $this->search_index;
  3111. }
  3112. /**
  3113. * Updates the Search Index field with internal data. The Search Index Field
  3114. * provides an easy way to perform a 'like' query for a generalised search.
  3115. *
  3116. * @ORM\PrePersist
  3117. *
  3118. * @ORM\PreUpdate
  3119. */
  3120. public function updateSearchIndex()
  3121. {
  3122. $searchIndex
  3123. = $this->getName()
  3124. . ' '
  3125. . $this->getClientReference();
  3126. $this->setSearchIndex($searchIndex);
  3127. }
  3128. /**
  3129. * Set licenseLevel
  3130. *
  3131. * @param int $licenseLevel
  3132. *
  3133. * @return Project
  3134. */
  3135. public function setLicenseLevel($licenseLevel)
  3136. {
  3137. $this->license_level = $licenseLevel;
  3138. return $this;
  3139. }
  3140. /**
  3141. * Get licenseLevel
  3142. *
  3143. * @return int
  3144. */
  3145. public function getLicenseLevel()
  3146. {
  3147. return $this->license_level;
  3148. }
  3149. /**
  3150. * Returns an array of permitted values for the license level field and their
  3151. * associated labels,
  3152. *
  3153. * @return array
  3154. */
  3155. public static function getILicenseLevelOptions()
  3156. {
  3157. return [
  3158. self::LICENSE_LEVEL_BASIC => 'Basic',
  3159. self::LICENSE_LEVEL_STANDARD => 'Standard',
  3160. self::LICENSE_LEVEL_PROFESSIONAL => 'Professional',
  3161. self::LICENSE_LEVEL_PREMIUM => 'Premium',
  3162. ];
  3163. }
  3164. /**
  3165. * Returns a human-readable version of the licence level
  3166. *
  3167. * @return string
  3168. */
  3169. public function getLicenseLevelName()
  3170. {
  3171. $options = self::getILicenseLevelOptions();
  3172. return
  3173. $options[$this->getLicenseLevel()] ?? $this->getLicenseLevel();
  3174. }
  3175. /**
  3176. * Returns the Medical Records Collection for this project in a JSTree
  3177. * formatted node tree. Notably, this structure will not include Documents
  3178. * under the top most node that also exist in sub nodes.
  3179. *
  3180. * @param string $replacementRootNodeText
  3181. * @param array $additionalLiAttributes Additional attributes for <li> elements
  3182. * @param mixed $insightsIndexNativeFilenames
  3183. *
  3184. * @return array
  3185. */
  3186. public function getMedicalRecordsAsJsTreeFormattedTree(
  3187. $replacementRootNodeText = null,
  3188. $additionalLiAttributes = [],
  3189. array $insightsIndexNativeFilenames = []
  3190. ) {
  3191. $medicalRecordsCollection = $this->getMedicalRecordsCollection();
  3192. if ($medicalRecordsCollection === null) {
  3193. // Not sure why this Project has no MR Collection so let's create a blank one
  3194. $this->medicalRecordsCollection = new Collection();
  3195. $this->medicalRecordsCollection
  3196. ->setName(Collection::DISPLAY_NAME_MEDICAL_RECORDS)
  3197. ->setProjectMedicalRecords($this)
  3198. ;
  3199. }
  3200. $node = $this->getMedicalRecordsCollection()->getJsTreeFormattedNode(
  3201. $replacementRootNodeText,
  3202. false,
  3203. false,
  3204. $additionalLiAttributes
  3205. );
  3206. // set the children sub array, ready for populating
  3207. $node['children'] = [];
  3208. // order the children alphabetically
  3209. $criteria = Criteria::create()->orderBy(['name' => Criteria::ASC]);
  3210. // add all the sub collections with all their children and document children
  3211. /** @var Collection $childCollection */
  3212. foreach ($this->getMedicalRecordsCollection()->getChildren()->matching($criteria) as $childCollection) {
  3213. $node['children'][] = $childCollection->getJsTreeFormattedNode(
  3214. null,
  3215. true,
  3216. true,
  3217. $additionalLiAttributes,
  3218. $insightsIndexNativeFilenames
  3219. );
  3220. }
  3221. // all document children also get a collection id sent through, so we know what collection
  3222. // the document belongs to
  3223. $additionalLiAttributes['data-collection-id'] = $this->medicalRecordsCollection->getId();
  3224. // loop through all the document children on this main collection
  3225. foreach ($this->getMedicalRecordsCollection()->getDocuments() as $childDocument) {
  3226. // Only if the Document is assigned to one collection inside the MedicalRecords collection (this one)...
  3227. $collectionCount = $childDocument->getCollections()->filter(function (Collection $collection) {
  3228. return $this->getMedicalRecordsCollection()->containsCollectionRecursive($collection);
  3229. })->count();
  3230. if ($collectionCount === 1) {
  3231. $node['children'][] = $childDocument->getJsTreeFormattedNode(
  3232. null,
  3233. $additionalLiAttributes,
  3234. $childDocument->getSortingSessionStack() !== null,
  3235. $childDocument->isCerIndex($insightsIndexNativeFilenames)
  3236. );
  3237. }
  3238. }
  3239. return $node;
  3240. }
  3241. /**
  3242. * Returns the Unsorted Records Collection for this project in a JSTree
  3243. * formatted node tree. Notably, this structure will not include Documents
  3244. * under the top most node that also exist in sub nodes.
  3245. *
  3246. * @param string $replacementRootNodeText
  3247. * @param array $additionalLiAttributes Additional attributes for <li> elements
  3248. *
  3249. * @return array
  3250. */
  3251. public function getUnsortedRecordsAsJsTreeFormattedTree($replacementRootNodeText = null, $additionalLiAttributes = [])
  3252. {
  3253. // first, grab the node with no children
  3254. $node = $this->getUnsortedRecordsCollection()->getJsTreeFormattedNode(
  3255. $replacementRootNodeText,
  3256. false,
  3257. false,
  3258. $additionalLiAttributes
  3259. );
  3260. // set the children sub array, ready for populating
  3261. $node['children'] = [];
  3262. // order the children alphabetically
  3263. $criteria = Criteria::create()
  3264. ->orderBy(['name' => Criteria::ASC])
  3265. ;
  3266. // add all the sub collections with all their children and document children
  3267. foreach ($this->getUnsortedRecordsCollection()->getChildren()->matching($criteria) as $childCollection) {
  3268. $node['children'][] = $childCollection->getJsTreeFormattedNode(null, true, true, $additionalLiAttributes);
  3269. }
  3270. // all document children also get a collection id sent through, so we know what collection
  3271. // the document belongs to
  3272. $additionalLiAttributes['data-collection-id'] = $this->unsortedRecordsCollection->getId();
  3273. // loop through all the document children on this main collection
  3274. foreach ($this->getUnsortedRecordsCollection()->getDocuments() as $childDocument) {
  3275. // Only if the Document is assigned to one collection inside the MedicalRecords collection (this one)...
  3276. $collectionCount = $childDocument->getCollections()->filter(function (Collection $collection) {
  3277. return $this->getUnsortedRecordsCollection()->containsCollectionRecursive($collection);
  3278. })->count();
  3279. // ... do we include it here, else the Document will show twice in Medical Records.
  3280. if ($collectionCount === 1) {
  3281. $node['children'][] = $childDocument->getJsTreeFormattedNode(null, $additionalLiAttributes);
  3282. }
  3283. }
  3284. return $node;
  3285. }
  3286. /**
  3287. * Returns the Medical Records Collection for this project in a JSTree
  3288. * formatted node tree. Notably, this structure will not include Documents
  3289. * under the top most node that also exist in sub nodes.
  3290. *
  3291. * @param string $replacementRootNodeText
  3292. * @param array $additionalLiAttributes
  3293. *
  3294. * @return array
  3295. */
  3296. public function getPrivateCollectionAsJsTreeFormattedTree($replacementRootNodeText = null, $additionalLiAttributes = [])
  3297. {
  3298. // first, grab the node with no children
  3299. // NB! additional attributes MUST be set so that the outer node in the
  3300. // private tree has the data-group "private" or copy and move rules
  3301. // will not work!
  3302. $node = $this->getPrivateCollection()->getJsTreeFormattedNode($replacementRootNodeText, false, false, $additionalLiAttributes);
  3303. // set the children sub array, ready for populating
  3304. $node['children'] = [];
  3305. // order the children alphabetically
  3306. $criteria = Criteria::create()
  3307. ->orderBy(['name' => Criteria::ASC])
  3308. ;
  3309. // add all the sub collections with all their children and document children
  3310. foreach ($this->getPrivateCollection()->getChildren()->matching($criteria) as $childCollection) {
  3311. $node['children'][] = $childCollection->getJsTreeFormattedNode(null, true, true, $additionalLiAttributes);
  3312. }
  3313. // all document children also get a collection id sent through, so we know what collection
  3314. // the document belongs to
  3315. $additionalLiAttributes['data-collection-id'] = $this->getId();
  3316. // loop through all the document children on this main collection
  3317. foreach ($this->getPrivateCollection()->getDocuments() as $childDocument) {
  3318. // Only if the Document is assigned to one collection inside the Private collection (this one)...
  3319. $collectionCount = $childDocument->getCollections()->filter(function (Collection $collection) {
  3320. return $this->getPrivateCollection()->containsCollectionRecursive($collection);
  3321. })->count();
  3322. // ... do we include it here, else the Document will show twice in Medical Records.
  3323. if ($collectionCount === 1) {
  3324. $node['children'][] = $childDocument->getJsTreeFormattedNode(null, $additionalLiAttributes);
  3325. }
  3326. }
  3327. return $node;
  3328. }
  3329. /**
  3330. * Add projectUser
  3331. *
  3332. * @param ProjectUser $projectUser
  3333. *
  3334. * @return Project
  3335. */
  3336. public function addProjectUser(ProjectUser $projectUser)
  3337. {
  3338. $this->projectUsers[] = $projectUser;
  3339. return $this;
  3340. }
  3341. /**
  3342. * Remove projectUser
  3343. *
  3344. * @param ProjectUser $projectUser
  3345. */
  3346. public function removeProjectUser(ProjectUser $projectUser)
  3347. {
  3348. $this->projectUsers->removeElement($projectUser);
  3349. }
  3350. /**
  3351. * Get projectUsers
  3352. *
  3353. * @return DoctrineCollection|ProjectUser[]
  3354. */
  3355. public function getProjectUsers()
  3356. {
  3357. return $this->projectUsers;
  3358. }
  3359. /**
  3360. * Set privateCollection
  3361. *
  3362. * @param Collection|null $privateCollection
  3363. *
  3364. * @return Project
  3365. */
  3366. public function setPrivateCollection(?Collection $privateCollection = null)
  3367. {
  3368. $this->privateCollection = $privateCollection;
  3369. return $this;
  3370. }
  3371. /**
  3372. * Get privateCollection
  3373. *
  3374. * Naming note: this is the project-level root collection displayed in the UI
  3375. * as "Case Documentation" (Collection::DISPLAY_NAME_PRIVATE). The legacy
  3376. * "private" naming predates that label. Do not confuse this project root with
  3377. * ProjectUser::getPrivateCollection(), which is a per-user folder nested
  3378. * beneath this root.
  3379. *
  3380. * @return Collection
  3381. */
  3382. public function getPrivateCollection()
  3383. {
  3384. return $this->privateCollection;
  3385. }
  3386. /**
  3387. * Set background
  3388. *
  3389. * @param string $background
  3390. *
  3391. * @return Project
  3392. */
  3393. public function setBackground($background)
  3394. {
  3395. $this->background = $background;
  3396. // Update the associated matter request as well, if it exists, and if the values are different,
  3397. // to avoid a recursive loop.
  3398. if ($background !== null && $this->getMatterRequest() && $this->getMatterRequest()->getBackground() != $this->background) {
  3399. $this->getMatterRequest()->setBackground($this->background);
  3400. }
  3401. return $this;
  3402. }
  3403. /**
  3404. * Get background
  3405. *
  3406. * @return string
  3407. */
  3408. public function getBackground()
  3409. {
  3410. return $this->background;
  3411. }
  3412. /**
  3413. * Increases the total documents file size for this Project.
  3414. *
  3415. * This value should exclude DICOM files.
  3416. *
  3417. * @param mixed $filesize
  3418. *
  3419. * @return Project
  3420. */
  3421. public function increaseDocumentsTotalFilesize($filesize)
  3422. {
  3423. $this->documents_total_filesize += $filesize;
  3424. return $this;
  3425. }
  3426. /**
  3427. * Decreases the total documents file size for this Project.
  3428. *
  3429. * This value should exclude DICOM files.
  3430. *
  3431. * @param mixed $filesize
  3432. *
  3433. * @return Project
  3434. */
  3435. public function decreaseDocumentsTotalFilesize($filesize)
  3436. {
  3437. $this->documents_total_filesize -= $filesize;
  3438. return $this;
  3439. }
  3440. /**
  3441. * Get documentsTotalFilesize
  3442. *
  3443. * @return string
  3444. */
  3445. public function getDocumentsTotalFilesize()
  3446. {
  3447. return $this->documents_total_filesize;
  3448. }
  3449. /**
  3450. * Set documentsTotalFilesize
  3451. *
  3452. * @param mixed $documents_total_filesize
  3453. *
  3454. * @return Project
  3455. */
  3456. public function setDocumentsTotalFilesize($documents_total_filesize)
  3457. {
  3458. $this->documents_total_filesize = $documents_total_filesize;
  3459. return $this;
  3460. }
  3461. /**
  3462. * Increases the total file size in bytes of active disc archives for
  3463. * this project.
  3464. *
  3465. * @param int $filesize
  3466. *
  3467. * @return Project
  3468. */
  3469. public function increaseActiveDiscsTotalArchiveFilesize($filesize)
  3470. {
  3471. $this->active_discs_total_archive_filesize += $filesize;
  3472. return $this;
  3473. }
  3474. /**
  3475. * Decreases the total file size in bytes of active disc archives for
  3476. * this project.
  3477. *
  3478. * @param int $filesize
  3479. *
  3480. * @return Project
  3481. */
  3482. public function decreaseActiveDiscsTotalArchiveFilesize($filesize)
  3483. {
  3484. $this->active_discs_total_archive_filesize -= $filesize;
  3485. return $this;
  3486. }
  3487. /**
  3488. * Get activeDiscsTotalArchiveFilesize
  3489. *
  3490. * @return string
  3491. */
  3492. public function getActiveDiscsTotalArchiveFilesize()
  3493. {
  3494. return $this->active_discs_total_archive_filesize;
  3495. }
  3496. /**
  3497. * Set activeDiscsTotalArchiveFilesize
  3498. *
  3499. * @param mixed $active_discs_total_archive_filesize
  3500. *
  3501. * @return Project
  3502. */
  3503. public function setActiveDiscsTotalArchiveFilesize($active_discs_total_archive_filesize)
  3504. {
  3505. $this->active_discs_total_archive_filesize = $active_discs_total_archive_filesize;
  3506. return $this;
  3507. }
  3508. /**
  3509. * Get limitationDate
  3510. *
  3511. * @return DateTime
  3512. */
  3513. public function getLimitationDate()
  3514. {
  3515. return $this->limitation_date;
  3516. }
  3517. /**
  3518. * Set limitationDate
  3519. *
  3520. * @param DateTime $limitationDate
  3521. *
  3522. * @return Project
  3523. */
  3524. public function setLimitationDate($limitationDate)
  3525. {
  3526. $this->limitation_date = $limitationDate;
  3527. // Update the associated matter request as well, if it exists, and if the values are different,
  3528. // to avoid a recursive loop.
  3529. if ($this->getMatterRequest() && $this->getMatterRequest()->getLimitationDate() != $this->limitation_date) {
  3530. $this->getMatterRequest()->setLimitationDate($this->limitation_date);
  3531. }
  3532. return $this;
  3533. }
  3534. /**
  3535. * Set claimCategory
  3536. *
  3537. * @param int $claimCategory
  3538. *
  3539. * @return Project
  3540. */
  3541. public function setClaimCategory($claimCategory)
  3542. {
  3543. $this->claim_category = $claimCategory;
  3544. // Update the associated matter request as well, if it exists, and if the values are different,
  3545. // to avoid a recursive loop.
  3546. if ($this->getMatterRequest() && $this->getMatterRequest()->getClaimCategory() != $this->claim_category) {
  3547. $this->getMatterRequest()->setClaimCategory($this->claim_category);
  3548. }
  3549. return $this;
  3550. }
  3551. /**
  3552. * Get claimCategory
  3553. *
  3554. * @return int
  3555. */
  3556. public function getClaimCategory()
  3557. {
  3558. return $this->claim_category;
  3559. }
  3560. /**
  3561. * Returns an array of permitted values for the claim category field and their
  3562. * associated labels.
  3563. *
  3564. * @return array
  3565. */
  3566. public static function getClaimCategoryOptions()
  3567. {
  3568. $claimCategoryOptions = self::getConstantsWithLabelsAsChoices('CLAIM_CATEGORY');
  3569. ksort($claimCategoryOptions);
  3570. return array_flip($claimCategoryOptions);
  3571. }
  3572. /**
  3573. * Returns an array of permitted values for the claim category field and their
  3574. * associated labels, in a verbose array structure.
  3575. *
  3576. * @return array
  3577. */
  3578. public static function getClaimCategoryOptionsWithLabels()
  3579. {
  3580. return self::getConstantsWithLabels('CLAIM_CATEGORY');
  3581. }
  3582. /**
  3583. * Returns a human-readable version of the claim_category
  3584. *
  3585. * @return string
  3586. */
  3587. public function getClaimCategoryName()
  3588. {
  3589. $options = self::getClaimCategoryOptions();
  3590. return $options[$this->getClaimCategory()] ?? 'Other';
  3591. }
  3592. /**
  3593. * Returns an array of Claim Categories that are Birth Injury cases.
  3594. *
  3595. * @TODO: We should update how the constants are handled to include this
  3596. * there.
  3597. *
  3598. * @return array|int[]
  3599. */
  3600. public static function getBirthInjuryClaimCategories(): array
  3601. {
  3602. return [
  3603. self::CLAIM_CATEGORY_OBSTETRICS_RELATING_TO_CHILD,
  3604. self::CLAIM_CATEGORY_OBSTETRICS_BRAIN_INJURY_HIE,
  3605. self::CLAIM_CATEGORY_OBSTETRICS_GBS_SEPSIS,
  3606. self::CLAIM_CATEGORY_OBSTETRICS_KERNICTERUS,
  3607. self::CLAIM_CATEGORY_OBSTETRICS_NEONATAL_DEATH,
  3608. self::CLAIM_CATEGORY_OBSTETRICS_OTHER_CHILD_INJURY,
  3609. self::CLAIM_CATEGORY_OBSTETRICS_SHOULDER_DYSTOCIA,
  3610. self::CLAIM_CATEGORY_OBSTETRICS_STILLBIRTH,
  3611. self::CLAIM_CATEGORY_OBSTETRICS_WRONGFUL_BIRTH,
  3612. ];
  3613. }
  3614. /**
  3615. * Set estimatedClaimValue
  3616. *
  3617. * @param int $estimatedClaimValue
  3618. *
  3619. * @return Project
  3620. */
  3621. public function setEstimatedClaimValue($estimatedClaimValue)
  3622. {
  3623. $this->estimated_claim_value = $estimatedClaimValue;
  3624. // Update the associated matter request as well, if it exists, and if the values are different,
  3625. // to avoid a recursive loop.
  3626. if ($this->getMatterRequest() && $this->getMatterRequest()->getClaimValue() != $this->estimated_claim_value) {
  3627. $this->getMatterRequest()->setClaimValue($this->estimated_claim_value);
  3628. }
  3629. return $this;
  3630. }
  3631. /**
  3632. * Get estimatedClaimValue
  3633. *
  3634. * @return int
  3635. */
  3636. public function getEstimatedClaimValue()
  3637. {
  3638. return $this->estimated_claim_value;
  3639. }
  3640. /**
  3641. * Returns an array of permitted values for the estimated claim value field and their
  3642. * associated labels.
  3643. *
  3644. * @return array
  3645. */
  3646. public static function getEstimatedClaimValueOptions()
  3647. {
  3648. return [
  3649. self::ESTIMATED_CLAIM_VALUE_0_25000 => self::ESTIMATED_CLAIM_VALUE_0_25000__LABEL,
  3650. self::ESTIMATED_CLAIM_VALUE_25001_50000 => self::ESTIMATED_CLAIM_VALUE_25001_50000__LABEL,
  3651. self::ESTIMATED_CLAIM_VALUE_50001_100000 => self::ESTIMATED_CLAIM_VALUE_50001_100000__LABEL,
  3652. self::ESTIMATED_CLAIM_VALUE_100001_250000 => self::ESTIMATED_CLAIM_VALUE_100001_250000__LABEL,
  3653. self::ESTIMATED_CLAIM_VALUE_250001_500000 => self::ESTIMATED_CLAIM_VALUE_250001_500000__LABEL,
  3654. self::ESTIMATED_CLAIM_VALUE_500001_1000000 => self::ESTIMATED_CLAIM_VALUE_500001_1000000__LABEL,
  3655. self::ESTIMATED_CLAIM_VALUE_1000001 => self::ESTIMATED_CLAIM_VALUE_1000001__LABEL,
  3656. ];
  3657. }
  3658. /**
  3659. * Returns an array of permitted values for the estimated claim value field and their
  3660. * associated labels, in a verbose array structure.
  3661. *
  3662. * @return array
  3663. */
  3664. public static function getEstimatedClaimValueOptionsWithLabels()
  3665. {
  3666. return self::getConstantsWithLabels('ESTIMATED_CLAIM_VALUE');
  3667. }
  3668. /**
  3669. * Returns a human-readable version of the estimated_claim_value
  3670. *
  3671. * @return string
  3672. */
  3673. public function getEstimatedClaimValueName()
  3674. {
  3675. $options = self::getEstimatedClaimValueOptions();
  3676. return $options[$this->getEstimatedClaimValue()] ?? $this->getEstimatedClaimValue();
  3677. }
  3678. /**
  3679. * Set archiveStatus
  3680. *
  3681. * @param int|null $archiveStatus
  3682. *
  3683. * @return Project
  3684. */
  3685. public function setArchiveStatus(?int $archiveStatus = null)
  3686. {
  3687. $this->archive_status = $archiveStatus;
  3688. // DisclosureProjects are directly associated with their Parent Project
  3689. // As a Project may have multiple DisclosureTargets/Projects, update their archiveStatus as well
  3690. // To ensure they are included in the archive logic
  3691. foreach ($this->getInterpartyDisclosures() as $disclosure) {
  3692. if ($disclosure->getDisclosureTarget() !== null) {
  3693. $disclosure->getDisclosureTarget()->setArchiveStatus($archiveStatus);
  3694. }
  3695. }
  3696. return $this;
  3697. }
  3698. /**
  3699. * Get archiveStatus
  3700. *
  3701. * @return int
  3702. */
  3703. public function getArchiveStatus()
  3704. {
  3705. return $this->archive_status;
  3706. }
  3707. /**
  3708. * Set archiveStatusUpdated
  3709. *
  3710. * @param DateTime|null $archiveStatusUpdated
  3711. *
  3712. * @return Project
  3713. */
  3714. public function setArchiveStatusUpdated(?DateTime $archiveStatusUpdated = null)
  3715. {
  3716. $this->archive_status_updated = $archiveStatusUpdated;
  3717. // DisclosureProjects are directly associated with their Parent Project
  3718. // As a Project may have multiple DisclosureTargets, update their archiveStatusUpdated as well
  3719. // To ensure they are included in the archive logic
  3720. foreach ($this->getInterpartyDisclosures() as $disclosure) {
  3721. if ($disclosure->getDisclosureTarget() !== null) {
  3722. $disclosure->getDisclosureTarget()->setArchiveStatusUpdated($archiveStatusUpdated);
  3723. }
  3724. }
  3725. return $this;
  3726. }
  3727. /**
  3728. * Get archiveStatusUpdated
  3729. *
  3730. * @return DateTime
  3731. */
  3732. public function getArchiveStatusUpdated()
  3733. {
  3734. return $this->archive_status_updated;
  3735. }
  3736. /**
  3737. * Set futureDeletionDate
  3738. *
  3739. * @param DateTime $futureDeletionDate
  3740. *
  3741. * @return Project
  3742. */
  3743. public function setFutureDeletionDate($futureDeletionDate)
  3744. {
  3745. $this->future_deletion_date = $futureDeletionDate;
  3746. return $this;
  3747. }
  3748. /**
  3749. * Get futureDeletionDate
  3750. *
  3751. * @return DateTime
  3752. */
  3753. public function getFutureDeletionDate()
  3754. {
  3755. return $this->future_deletion_date;
  3756. }
  3757. /**
  3758. * Set privateSandboxCollection
  3759. *
  3760. * @param Collection|null $privateSandboxCollection
  3761. *
  3762. * @return Project
  3763. */
  3764. public function setPrivateSandboxCollection(?Collection $privateSandboxCollection = null)
  3765. {
  3766. $this->privateSandboxCollection = $privateSandboxCollection;
  3767. return $this;
  3768. }
  3769. /**
  3770. * Get privateSandboxCollection
  3771. *
  3772. * Naming note: this is the project-level root collection displayed in the UI
  3773. * as "Private Folders" (Collection::DISPLAY_NAME_PRIVATE_SANDBOX). The legacy
  3774. * "private sandbox" naming predates that label. Do not confuse this project
  3775. * root with ProjectUser::getPrivateSandboxCollection(), which is a per-user
  3776. * folder nested beneath this root.
  3777. *
  3778. * @return Collection
  3779. */
  3780. public function getPrivateSandboxCollection()
  3781. {
  3782. // If no privateSandboxCollection exists, create a new one.
  3783. // We do this here, instead of the constructor, so we only create a new
  3784. // Collection entity if none already exists.
  3785. if ($this->privateSandboxCollection === null) {
  3786. $privateSandboxCollection = new Collection();
  3787. $privateSandboxCollection->setName('Private Sandbox Folders');
  3788. $this->setPrivateSandboxCollection($privateSandboxCollection);
  3789. }
  3790. return $this->privateSandboxCollection;
  3791. }
  3792. /**
  3793. * Returns the PrivateSandboxCollection for this project in a JSTree
  3794. * formatted node tree. Notably, this structure will not include Documents
  3795. * under the top most node that also exist in sub nodes.
  3796. *
  3797. * @param string $replacementRootNodeText
  3798. * @param array $additionalLiAttributes
  3799. *
  3800. * @return array
  3801. */
  3802. public function getPrivateSandboxCollectionAsJsTreeFormattedTree($replacementRootNodeText = null, $additionalLiAttributes = [])
  3803. {
  3804. $node = $this->getPrivateSandboxCollection()->getJsTreeFormattedNode($replacementRootNodeText, false, false, $additionalLiAttributes);
  3805. // set the children sub array, ready for populating
  3806. $node['children'] = [];
  3807. // order the children alphabetically
  3808. $criteria = Criteria::create()
  3809. ->orderBy(['name' => Criteria::ASC])
  3810. ;
  3811. // add all the sub collections with all their children and document children
  3812. foreach ($this->getPrivateSandboxCollection()->getChildren()->matching($criteria) as $childCollection) {
  3813. $node['children'][] = $childCollection->getJsTreeFormattedNode(null, true, true, $additionalLiAttributes);
  3814. }
  3815. // all document children also get a collection id sent through, so we know what collection
  3816. // the document belongs to
  3817. $additionalLiAttributes['data-collection-id'] = $this->getId();
  3818. // loop through all the document children on this main collection
  3819. foreach ($this->getPrivateSandboxCollection()->getDocuments() as $childDocument) {
  3820. // Only if the Document is assigned to one collection inside the Private Sandbox collection (this one)...
  3821. $collectionCount = $childDocument->getCollections()->filter(function (Collection $collection) {
  3822. return $this->getPrivateSandboxCollection()->containsCollectionRecursive($collection);
  3823. })->count();
  3824. // ... do we include it here, else the Document will show twice in Medical Records.
  3825. if ($collectionCount === 1) {
  3826. $node['children'][] = $childDocument->getJsTreeFormattedNode(null, $additionalLiAttributes);
  3827. }
  3828. }
  3829. return $node;
  3830. }
  3831. /**
  3832. * Add batchRequest
  3833. *
  3834. * @param BatchRequest $batchRequest
  3835. *
  3836. * @return Project
  3837. */
  3838. public function addBatchRequest(BatchRequest $batchRequest)
  3839. {
  3840. $this->batchRequests[] = $batchRequest;
  3841. return $this;
  3842. }
  3843. /**
  3844. * Remove batchRequest
  3845. *
  3846. * @param BatchRequest $batchRequest
  3847. */
  3848. public function removeBatchRequest(BatchRequest $batchRequest)
  3849. {
  3850. $this->batchRequests->removeElement($batchRequest);
  3851. }
  3852. /**
  3853. * Get batchRequests
  3854. *
  3855. * @return DoctrineCollection|BatchRequest[]
  3856. */
  3857. public function getBatchRequests()
  3858. {
  3859. return $this->batchRequests;
  3860. }
  3861. /**
  3862. * Retrieves the counts for BatchRequests grouped by
  3863. * their serviceRequest status.
  3864. *
  3865. * @param mixed $uninvoicedOnly
  3866. *
  3867. * @return array
  3868. */
  3869. public function getBatchRequestsCountByServiceRequestStatus($uninvoicedOnly = true)
  3870. {
  3871. return $this->getServiceableCountsByStatus($this->getBatchRequests()->toArray(), $uninvoicedOnly);
  3872. }
  3873. /**
  3874. * Add additionalRequest
  3875. *
  3876. * @param AdditionalRequest $additionalRequest
  3877. *
  3878. * @return Project
  3879. */
  3880. public function addAdditionalRequest(AdditionalRequest $additionalRequest)
  3881. {
  3882. $this->additionalRequests[] = $additionalRequest;
  3883. return $this;
  3884. }
  3885. /**
  3886. * Remove additionalRequest
  3887. *
  3888. * @param AdditionalRequest $additionalRequest
  3889. */
  3890. public function removeAdditionalRequest(AdditionalRequest $additionalRequest)
  3891. {
  3892. $this->additionalRequests->removeElement($additionalRequest);
  3893. }
  3894. /**
  3895. * Get additionalRequests
  3896. *
  3897. * @return DoctrineCollection|AdditionalRequest[]
  3898. */
  3899. public function getAdditionalRequests()
  3900. {
  3901. return $this->additionalRequests;
  3902. }
  3903. /**
  3904. * Retrieves the counts for AdditionalRequests grouped by
  3905. * their serviceRequest status
  3906. *
  3907. * @param mixed $uninvoicedOnly
  3908. *
  3909. * @return array
  3910. */
  3911. public function getAdditionalRequestsCountByServiceRequestStatus($uninvoicedOnly = true)
  3912. {
  3913. return $this->getServiceableCountsByStatus($this->getAdditionalRequests()->toArray(), $uninvoicedOnly);
  3914. }
  3915. /**
  3916. * Add chronologyRequest
  3917. *
  3918. * @param ChronologyRequest $chronologyRequest
  3919. *
  3920. * @return Project
  3921. */
  3922. public function addChronologyRequest(ChronologyRequest $chronologyRequest)
  3923. {
  3924. $this->chronologyRequests[] = $chronologyRequest;
  3925. return $this;
  3926. }
  3927. /**
  3928. * Remove chronologyRequest
  3929. *
  3930. * @param ChronologyRequest $chronologyRequest
  3931. */
  3932. public function removeChronologyRequest(ChronologyRequest $chronologyRequest)
  3933. {
  3934. $this->chronologyRequests->removeElement($chronologyRequest);
  3935. }
  3936. /**
  3937. * Get chronologyRequests
  3938. *
  3939. * @return ArrayCollection|ChronologyRequest[]
  3940. */
  3941. public function getChronologyRequests()
  3942. {
  3943. return $this->chronologyRequests;
  3944. }
  3945. /**
  3946. * Retrieves the counts for ChronologyRequests grouped by
  3947. * their serviceRequest status
  3948. *
  3949. * @param bool $uninvoicedOnly
  3950. *
  3951. * @return array
  3952. */
  3953. public function getChronologyRequestsCountByServiceRequestStatus($uninvoicedOnly = true)
  3954. {
  3955. return $this->getServiceableCountsByStatus($this->getChronologyRequests()->toArray(), $uninvoicedOnly);
  3956. }
  3957. /**
  3958. * @param ExpertReportRequest $expertReportRequest
  3959. *
  3960. * @return Project
  3961. */
  3962. public function addExpertReportRequest(ExpertReportRequest $expertReportRequest)
  3963. {
  3964. $this->expertReportRequests[] = $expertReportRequest;
  3965. return $this;
  3966. }
  3967. /**
  3968. * @param ExpertReportRequest $expertReportRequest
  3969. */
  3970. public function removeExpertReportRequest(ExpertReportRequest $expertReportRequest)
  3971. {
  3972. $this->expertReportRequests->removeElement($expertReportRequest);
  3973. }
  3974. /**
  3975. * @return ArrayCollection|ExpertReportRequest[]
  3976. */
  3977. public function getExpertReportRequests()
  3978. {
  3979. return $this->expertReportRequests;
  3980. }
  3981. /**
  3982. * @param bool $uninvoicedOnly
  3983. *
  3984. * @return array
  3985. */
  3986. public function getExpertReportRequestsCountByServiceRequestStatus($uninvoicedOnly = true)
  3987. {
  3988. return $this->getServiceableCountsByStatus($this->getExpertReportRequests()->toArray(), $uninvoicedOnly);
  3989. }
  3990. /**
  3991. * @return array
  3992. */
  3993. public function getExpertReportRequestCountsByStatus()
  3994. {
  3995. $serviceables = $this->getExpertReportRequests()->toArray();
  3996. return $this->getServiceableCountsByStatus($serviceables);
  3997. }
  3998. /**
  3999. * Retrieve a sum of ServiceRequest statuses for all Serviceable entities attached to this Project.
  4000. *
  4001. * @param bool $uninvoicedOnly
  4002. *
  4003. * @return array
  4004. */
  4005. public function getTotalServiceRequestCountsByStatus($uninvoicedOnly = true)
  4006. {
  4007. return $this->getServiceableCountsByStatus($this->getServiceables(), $uninvoicedOnly);
  4008. }
  4009. /**
  4010. * @return array
  4011. */
  4012. public function getServiceables(): array
  4013. {
  4014. $serviceables = [];
  4015. // Combine all Serviceable entities on this Project into a single array.
  4016. $serviceables = array_merge(
  4017. $this->getRecordsRequests()->toArray(),
  4018. $this->getBatchRequests()->toArray(),
  4019. $this->getChronologyRequests()->toArray(),
  4020. $this->getAdditionalRequests()->toArray(),
  4021. $this->getExpertReportRequests()->toArray()
  4022. );
  4023. return $serviceables;
  4024. }
  4025. /**
  4026. * Gets the total number of ServiceRequest that are in status On Hold.
  4027. *
  4028. * @return int
  4029. */
  4030. public function getTotalServiceRequestCountsOnHold()
  4031. {
  4032. $totals = $this->getTotalServiceRequestCountsByStatus();
  4033. return isset($totals[ServiceRequest::STATUS_ON_HOLD]) ? $totals[ServiceRequest::STATUS_ON_HOLD]['count'] : 0;
  4034. }
  4035. /**
  4036. * Gets the total number of ServiceRequest that are in status In Progress.
  4037. *
  4038. * @return int
  4039. */
  4040. public function getTotalServiceRequestCountsInProgress()
  4041. {
  4042. $totals = $this->getTotalServiceRequestCountsByStatus();
  4043. $inProgressCount = $totals[ServiceRequest::STATUS_IN_PROGRESS]['count'] ?? 0;
  4044. $instructedCount = $totals[ServiceRequest::STATUS_INSTRUCTED]['count'] ?? 0;
  4045. return $inProgressCount + $instructedCount;
  4046. }
  4047. /**
  4048. * Gets the total number of ServiceRequest that are in status Complete.
  4049. *
  4050. * @return int
  4051. */
  4052. public function getTotalServiceRequestCountsComplete()
  4053. {
  4054. $totals = $this->getTotalServiceRequestCountsByStatus();
  4055. $completeTotal = 0;
  4056. $completeTotal += $totals[ServiceRequest::STATUS_COMPLETE]['count'] ?? 0;
  4057. $completeTotal += $totals[ServiceRequest::STATUS_BACK_TO_CLIENT]['count'] ?? 0;
  4058. $completeTotal += $totals[ServiceRequest::STATUS_RELEASED_TO_CLIENT]['count'] ?? 0;
  4059. return $completeTotal;
  4060. }
  4061. /**
  4062. * Gets the total number of ServiceRequest that are in status Awaiting Records.
  4063. *
  4064. * @return int
  4065. */
  4066. public function getTotalServiceRequestCountsAwaitingRecords()
  4067. {
  4068. $totals = $this->getTotalServiceRequestCountsByStatus();
  4069. /**
  4070. * Combine awaiting records and awaiting records arrival into one total, as they are similar but have slightly
  4071. * different meanings for different service requests.
  4072. * {@see ServiceRequest::getStatusOptionsBatchRequest} and {@see ServiceRequest::getStatusOptionsChronologyRequest}
  4073. */
  4074. $awaitingRecordsTotal = isset($totals[ServiceRequest::STATUS_AWAITING_RECORDS]) ? $totals[ServiceRequest::STATUS_AWAITING_RECORDS]['count'] : 0;
  4075. $awaitingRecordsArrivalTotal = isset($totals[ServiceRequest::STATUS_AWAITING_RECORDS_ARRIVAL]) ? $totals[ServiceRequest::STATUS_AWAITING_RECORDS_ARRIVAL]['count'] : 0;
  4076. $awaitingQuoteApprovalTotal = isset($totals[ServiceRequest::STATUS_AWAITING_QUOTE_APPROVAL]) ? $totals[ServiceRequest::STATUS_AWAITING_QUOTE_APPROVAL]['count'] : 0;
  4077. return $awaitingRecordsTotal + $awaitingRecordsArrivalTotal + $awaitingQuoteApprovalTotal;
  4078. }
  4079. /**
  4080. * Gets the amount of Records Requests grouped by their respective statuses
  4081. *
  4082. * @return array
  4083. */
  4084. public function getRecordsRequestCountsByStatus()
  4085. {
  4086. $serviceables = $this->getRecordsRequests()->toArray();
  4087. return $this->getServiceableCountsByStatus($serviceables);
  4088. }
  4089. /**
  4090. * Gets the amount of Batch Requests grouped by their respective statuses
  4091. *
  4092. * @return array
  4093. */
  4094. public function getBatchRequestCountsByStatus()
  4095. {
  4096. $serviceables = $this->getBatchRequests()->toArray();
  4097. return $this->getServiceableCountsByStatus($serviceables);
  4098. }
  4099. /**
  4100. * Gets the amount of Chronology Requests grouped by their respective statuses
  4101. *
  4102. * @return array
  4103. */
  4104. public function getChronologyRequestCountsByStatus()
  4105. {
  4106. $serviceables = $this->getChronologyRequests()->toArray();
  4107. return $this->getServiceableCountsByStatus($serviceables);
  4108. }
  4109. /**
  4110. * Gets the amount of Additional Requests grouped by their respective statuses
  4111. *
  4112. * @return array
  4113. */
  4114. public function getAdditionalRequestCountsByStatus()
  4115. {
  4116. $serviceables = $this->getAdditionalRequests()->toArray();
  4117. return $this->getServiceableCountsByStatus($serviceables);
  4118. }
  4119. /**
  4120. * Gets the total of all records request status' with status STATUS_COMPLETE and STATUS_BACK_TO_CLIENT
  4121. *
  4122. * @return int
  4123. */
  4124. public function getRecordsRequestCompleteReturnCount()
  4125. {
  4126. $recordsRequestByStatus = $this->getRecordsRequestCountsByStatus();
  4127. $count = 0;
  4128. $arrayKeys = array_keys($recordsRequestByStatus);
  4129. if (in_array(ServiceRequest::STATUS_BACK_TO_CLIENT, $arrayKeys, true)) {
  4130. $count += $recordsRequestByStatus[ServiceRequest::STATUS_BACK_TO_CLIENT]['count'];
  4131. }
  4132. if (in_array(ServiceRequest::STATUS_COMPLETE, $arrayKeys, true)) {
  4133. $count += $recordsRequestByStatus[ServiceRequest::STATUS_COMPLETE]['count'];
  4134. }
  4135. return $count;
  4136. }
  4137. /**
  4138. * Gets the ServiceRequest counts grouped by their respective statuses and types
  4139. *
  4140. * @return array
  4141. */
  4142. public function getServiceRequestStatusCountsByType()
  4143. {
  4144. return [
  4145. 'Records Requests' => $this->getRecordsRequestCountsByStatus(),
  4146. 'Batch Requests' => $this->getBatchRequestCountsByStatus(),
  4147. 'Chronology Requests' => $this->getChronologyRequestCountsByStatus(),
  4148. 'Additional Requests' => $this->getAdditionalRequestCountsByStatus(),
  4149. 'Expert Reports' => $this->getExpertReportRequestCountsByStatus(),
  4150. ];
  4151. }
  4152. // @todo The below functions could probably all be rolled up in to one easy catchall
  4153. // like ::getServiceRequestCountByTypeAndStatus( $type, $status ) but only
  4154. // thought of it too late ┐('~`;)┌
  4155. /**
  4156. * Gets a count of all completed ServiceRequests given a specific Type
  4157. *
  4158. * @param $service_request_type
  4159. *
  4160. * @throws Exception
  4161. *
  4162. * @return int|mixed
  4163. */
  4164. public function getCompleteServiceRequestCountsByType($service_request_type)
  4165. {
  4166. switch ($service_request_type) {
  4167. case ServiceRequest::TYPE_RECORDS_REQUEST:
  4168. $serviceables = $this->getRecordsRequestsCountByServiceRequestStatus(false);
  4169. break;
  4170. case ServiceRequest::TYPE_BATCH_REQUEST:
  4171. $serviceables = $this->getBatchRequestsCountByServiceRequestStatus(false);
  4172. break;
  4173. case ServiceRequest::TYPE_CHRONOLOGY_REQUEST:
  4174. $serviceables = $this->getChronologyRequestsCountByServiceRequestStatus(false);
  4175. break;
  4176. case ServiceRequest::TYPE_ADDITIONAL_REQUEST:
  4177. $serviceables = $this->getAdditionalRequestsCountByServiceRequestStatus(false);
  4178. break;
  4179. case ServiceRequest::TYPE_EXPERT_REPORT:
  4180. $serviceables = $this->getExpertReportRequestsCountByServiceRequestStatus(false);
  4181. break;
  4182. default:
  4183. throw new Exception('Invalid Service Request Type.');
  4184. }
  4185. $complete = isset($serviceables[ServiceRequest::STATUS_COMPLETE]) ? $serviceables[ServiceRequest::STATUS_COMPLETE]['count'] : 0;
  4186. $releasedToClient = isset($serviceables[ServiceRequest::STATUS_RELEASED_TO_CLIENT]) ? $serviceables[ServiceRequest::STATUS_RELEASED_TO_CLIENT]['count'] : 0;
  4187. return $complete + $releasedToClient;
  4188. }
  4189. /**
  4190. * Gets a count of all in progress ServiceRequests given a specific Type
  4191. *
  4192. * @param $service_request_type
  4193. *
  4194. * @throws Exception
  4195. *
  4196. * @return int|mixed
  4197. */
  4198. public function getInProgressServiceRequestCountsByType($service_request_type)
  4199. {
  4200. switch ($service_request_type) {
  4201. case ServiceRequest::TYPE_RECORDS_REQUEST:
  4202. $serviceables = $this->getRecordsRequestsCountByServiceRequestStatus(false);
  4203. break;
  4204. case ServiceRequest::TYPE_BATCH_REQUEST:
  4205. $serviceables = $this->getBatchRequestsCountByServiceRequestStatus(false);
  4206. break;
  4207. case ServiceRequest::TYPE_CHRONOLOGY_REQUEST:
  4208. $serviceables = $this->getChronologyRequestsCountByServiceRequestStatus(false);
  4209. break;
  4210. case ServiceRequest::TYPE_ADDITIONAL_REQUEST:
  4211. $serviceables = $this->getAdditionalRequestsCountByServiceRequestStatus(false);
  4212. break;
  4213. case ServiceRequest::TYPE_EXPERT_REPORT:
  4214. $serviceables = $this->getExpertReportRequestsCountByServiceRequestStatus(false);
  4215. break;
  4216. default:
  4217. throw new Exception('Invalid Service Request Type.');
  4218. }
  4219. return isset($serviceables[ServiceRequest::STATUS_IN_PROGRESS]) ? $serviceables[ServiceRequest::STATUS_IN_PROGRESS]['count'] : 0;
  4220. }
  4221. /**
  4222. * Gets a count of all on hold ServiceRequests given a specific Type
  4223. *
  4224. * @param $service_request_type
  4225. *
  4226. * @throws Exception
  4227. *
  4228. * @return int|mixed
  4229. */
  4230. public function getOnHoldServiceRequestCountsByType($service_request_type)
  4231. {
  4232. switch ($service_request_type) {
  4233. case ServiceRequest::TYPE_RECORDS_REQUEST:
  4234. $serviceables = $this->getRecordsRequestsCountByServiceRequestStatus(false);
  4235. break;
  4236. case ServiceRequest::TYPE_BATCH_REQUEST:
  4237. $serviceables = $this->getBatchRequestsCountByServiceRequestStatus(false);
  4238. break;
  4239. case ServiceRequest::TYPE_CHRONOLOGY_REQUEST:
  4240. $serviceables = $this->getChronologyRequestsCountByServiceRequestStatus(false);
  4241. break;
  4242. case ServiceRequest::TYPE_ADDITIONAL_REQUEST:
  4243. $serviceables = $this->getAdditionalRequestsCountByServiceRequestStatus(false);
  4244. break;
  4245. case ServiceRequest::TYPE_EXPERT_REPORT:
  4246. $serviceables = $this->getExpertReportRequestsCountByServiceRequestStatus(false);
  4247. break;
  4248. default:
  4249. throw new Exception('Invalid Service Request Type.');
  4250. }
  4251. return isset($serviceables[ServiceRequest::STATUS_ON_HOLD]) ? $serviceables[ServiceRequest::STATUS_ON_HOLD]['count'] : 0;
  4252. }
  4253. /**
  4254. * Gets a count of all ServiceRequests awaiting records given a specific Type
  4255. *
  4256. * @param $service_request_type
  4257. *
  4258. * @throws Exception
  4259. *
  4260. * @return int|mixed
  4261. */
  4262. public function getPendingServiceRequestCountsByType($service_request_type)
  4263. {
  4264. switch ($service_request_type) {
  4265. case ServiceRequest::TYPE_RECORDS_REQUEST:
  4266. $serviceables = $this->getRecordsRequestsCountByServiceRequestStatus(false);
  4267. break;
  4268. case ServiceRequest::TYPE_BATCH_REQUEST:
  4269. $serviceables = $this->getBatchRequestsCountByServiceRequestStatus(false);
  4270. break;
  4271. case ServiceRequest::TYPE_CHRONOLOGY_REQUEST:
  4272. $serviceables = $this->getChronologyRequestsCountByServiceRequestStatus(false);
  4273. break;
  4274. case ServiceRequest::TYPE_ADDITIONAL_REQUEST:
  4275. $serviceables = $this->getAdditionalRequestsCountByServiceRequestStatus(false);
  4276. break;
  4277. case ServiceRequest::TYPE_EXPERT_REPORT:
  4278. $serviceables = $this->getExpertReportRequestsCountByServiceRequestStatus(false);
  4279. break;
  4280. default:
  4281. throw new Exception('Invalid Service Request Type.');
  4282. }
  4283. return isset($serviceables[ServiceRequest::STATUS_AWAITING_RECORDS]) ? $serviceables[ServiceRequest::STATUS_AWAITING_RECORDS]['count'] : 0;
  4284. }
  4285. /**
  4286. * Gets a count of all cancelled ServiceRequests given a specific Type
  4287. *
  4288. * @param $service_request_type
  4289. *
  4290. * @throws Exception
  4291. *
  4292. * @return int|mixed
  4293. */
  4294. public function getCancelledServiceRequestCountsByType($service_request_type)
  4295. {
  4296. switch ($service_request_type) {
  4297. case ServiceRequest::TYPE_RECORDS_REQUEST:
  4298. $serviceables = $this->getRecordsRequestsCountByServiceRequestStatus(false);
  4299. break;
  4300. case ServiceRequest::TYPE_BATCH_REQUEST:
  4301. $serviceables = $this->getBatchRequestsCountByServiceRequestStatus(false);
  4302. break;
  4303. case ServiceRequest::TYPE_CHRONOLOGY_REQUEST:
  4304. $serviceables = $this->getChronologyRequestsCountByServiceRequestStatus(false);
  4305. break;
  4306. case ServiceRequest::TYPE_ADDITIONAL_REQUEST:
  4307. $serviceables = $this->getAdditionalRequestsCountByServiceRequestStatus(false);
  4308. break;
  4309. case ServiceRequest::TYPE_EXPERT_REPORT:
  4310. $serviceables = $this->getExpertReportRequestsCountByServiceRequestStatus(false);
  4311. break;
  4312. default:
  4313. throw new Exception('Invalid Service Request Type.');
  4314. }
  4315. return isset($serviceables[ServiceRequest::STATUS_CANCELLED]) ? $serviceables[ServiceRequest::STATUS_CANCELLED]['count'] : 0;
  4316. }
  4317. /**
  4318. * Set team
  4319. *
  4320. * @param string $team
  4321. *
  4322. * @return Project
  4323. */
  4324. public function setTeam($team)
  4325. {
  4326. $this->team = $team;
  4327. // Update the associated matter request as well, if it exists, and if the values are different,
  4328. // to avoid a recursive loop.
  4329. if ($this->getMatterRequest() && $this->getMatterRequest()->getTeam() != $this->team) {
  4330. $this->getMatterRequest()->setTeam($this->team);
  4331. }
  4332. return $this;
  4333. }
  4334. /**
  4335. * Get team
  4336. *
  4337. * @return string
  4338. */
  4339. public function getTeam()
  4340. {
  4341. return $this->team;
  4342. }
  4343. /**
  4344. * Set defaultRole
  4345. *
  4346. * @param string $defaultRole
  4347. *
  4348. * @return Project
  4349. */
  4350. public function setDefaultRole($defaultRole)
  4351. {
  4352. $this->default_role = $defaultRole;
  4353. return $this;
  4354. }
  4355. /**
  4356. * Get defaultRole
  4357. *
  4358. * @return string
  4359. */
  4360. public function getDefaultRole()
  4361. {
  4362. return $this->default_role;
  4363. }
  4364. /**
  4365. * Get defaultRoleOptions
  4366. *
  4367. * @return array
  4368. */
  4369. public static function getDefaultRoleOptions()
  4370. {
  4371. return [
  4372. self::DEFAULT_ROLE_EXPERT => 'Expert',
  4373. self::DEFAULT_ROLE_EXPERTVIEWER => 'Expert - View Only',
  4374. self::DEFAULT_ROLE_SCANNER => 'Scanner',
  4375. self::DEFAULT_ROLE_SCANNERDOWNLOAD => 'Scanner - Download Enabled',
  4376. self::DEFAULT_ROLE_PROJECTMANAGER => 'Project Manager',
  4377. ];
  4378. }
  4379. /**
  4380. * Get DefaultRoleLabel
  4381. *
  4382. * @return int
  4383. */
  4384. public function getDefaultRoleLabel()
  4385. {
  4386. $options = self::getDefaultRoleOptions();
  4387. return $options[$this->getDefaultRole()] ?? '';
  4388. }
  4389. /**
  4390. * Get DefaultRoleLabel
  4391. *
  4392. * @return string
  4393. */
  4394. public function getDefaultRoleAsRole()
  4395. {
  4396. if (!$this->getDefaultRole()) {
  4397. return '';
  4398. }
  4399. return 'ROLE_PROJECT_' . $this->getId() . '_' . $this->getDefaultRole();
  4400. }
  4401. /**
  4402. * Get the disabled UserNotification types
  4403. *
  4404. * @return array
  4405. */
  4406. public function getDisabledNotifications()
  4407. {
  4408. return $this->disabled_notifications ?: [];
  4409. }
  4410. /**
  4411. * @param array $disabled_notifications
  4412. *
  4413. * @return Project
  4414. */
  4415. public function setDisabledNotifications($disabled_notifications): Project
  4416. {
  4417. $this->disabled_notifications = $disabled_notifications;
  4418. return $this;
  4419. }
  4420. /**
  4421. * Disable a notification
  4422. *
  4423. * @param $notification_type
  4424. *
  4425. * @return Project
  4426. */
  4427. public function disableNotification($notification_type): Project
  4428. {
  4429. $this->disabled_notifications[] = $notification_type;
  4430. return $this;
  4431. }
  4432. /**
  4433. * Function to determine if the specific UserNotification is disabled for this Entity
  4434. *
  4435. * @param $notification_type
  4436. *
  4437. * @return bool
  4438. */
  4439. public function isNotificationDisabled($notification_type)
  4440. {
  4441. if (!$this->disabled_notifications || count($this->disabled_notifications) == 0) {
  4442. return false;
  4443. }
  4444. return in_array($notification_type, $this->disabled_notifications) ? true : false;
  4445. }
  4446. /**
  4447. * Add sortingSession
  4448. *
  4449. * @param SortingSession $sortingSession
  4450. *
  4451. * @return Project
  4452. */
  4453. public function addSortingSession(SortingSession $sortingSession)
  4454. {
  4455. $this->sortingSessions[] = $sortingSession;
  4456. return $this;
  4457. }
  4458. /**
  4459. * Remove sortingSession
  4460. *
  4461. * @param SortingSession $sortingSession
  4462. */
  4463. public function removeSortingSession(SortingSession $sortingSession)
  4464. {
  4465. $this->sortingSessions->removeElement($sortingSession);
  4466. }
  4467. /**
  4468. * Get sortingSessions
  4469. *
  4470. * @return DoctrineCollection|SortingSession[]
  4471. */
  4472. public function getSortingSessions()
  4473. {
  4474. return $this->sortingSessions;
  4475. }
  4476. /**
  4477. * Get completedSortingSessions
  4478. *
  4479. * @return ArrayCollection|DoctrineCollection|Collection
  4480. */
  4481. public function getCompletedSortingSessions()
  4482. {
  4483. return $this->getSortingSessions()->filter(
  4484. function ($sortingSession) {
  4485. return $sortingSession->hasBeenCompleted();
  4486. }
  4487. );
  4488. }
  4489. /**
  4490. * @return bool
  4491. */
  4492. public function hasIncompleteSortingSessions(): bool
  4493. {
  4494. foreach ($this->getSortingSessions() as $sortingSession) {
  4495. if (!$sortingSession->hasBeenCompleted() && !$sortingSession->isSortStatusDownloaded()) {
  4496. return true;
  4497. }
  4498. }
  4499. return false;
  4500. }
  4501. /**
  4502. * Returns true if there are any incomplete serviceables on the project.
  4503. * This is used to block a project from being archived or deleted when work is still on-going.
  4504. *
  4505. * @return bool
  4506. */
  4507. public function hasIncompleteServiceables(): bool
  4508. {
  4509. foreach ($this->getRecordsRequests() as $recordsRequest) {
  4510. $incompleteStatuses = [
  4511. ServiceRequest::STATUS_IN_PROGRESS,
  4512. ServiceRequest::STATUS_ON_HOLD,
  4513. ];
  4514. if ($recordsRequest->getServiceRequest() && in_array($recordsRequest->getServiceRequest()->getStatus(), $incompleteStatuses)) {
  4515. return true;
  4516. }
  4517. }
  4518. foreach ($this->getBatchRequests() as $batchRequest) {
  4519. $incompleteStatuses = [
  4520. ServiceRequest::STATUS_IN_PROGRESS,
  4521. ServiceRequest::STATUS_AWAITING_RECORDS,
  4522. ServiceRequest::STATUS_ON_HOLD,
  4523. ];
  4524. if ($batchRequest->getServiceRequest() && in_array($batchRequest->getServiceRequest()->getStatus(), $incompleteStatuses)) {
  4525. return true;
  4526. }
  4527. }
  4528. foreach ($this->getChronologyRequests() as $chronologyRequest) {
  4529. $incompleteStatuses = [
  4530. ServiceRequest::STATUS_INSTRUCTED,
  4531. ServiceRequest::STATUS_IN_PROGRESS,
  4532. ServiceRequest::STATUS_ON_HOLD,
  4533. ];
  4534. if ($chronologyRequest->getServiceRequest() && in_array($chronologyRequest->getServiceRequest()->getStatus(), $incompleteStatuses)) {
  4535. return true;
  4536. }
  4537. }
  4538. foreach ($this->getExpertReportRequests() as $expertReportRequest) {
  4539. $incompleteStatuses = [
  4540. ServiceRequest::STATUS_INSTRUCTED,
  4541. ServiceRequest::STATUS_IN_PROGRESS,
  4542. ServiceRequest::STATUS_ON_HOLD,
  4543. ];
  4544. if ($expertReportRequest->getServiceRequest() && in_array($expertReportRequest->getServiceRequest()->getStatus(), $incompleteStatuses)) {
  4545. return true;
  4546. }
  4547. }
  4548. foreach ($this->getAdditionalRequests() as $additionalRequest) {
  4549. $incompleteStatuses = [
  4550. ServiceRequest::STATUS_IN_PROGRESS,
  4551. ServiceRequest::STATUS_ON_HOLD,
  4552. ];
  4553. if ($additionalRequest->getServiceRequest() && in_array($additionalRequest->getServiceRequest()->getStatus(), $incompleteStatuses)) {
  4554. return true;
  4555. }
  4556. }
  4557. // Finally, we check if there are incomplete sorting sessions.
  4558. return $this->hasIncompleteSortingSessions();
  4559. }
  4560. /**
  4561. * Add matterNote
  4562. *
  4563. * @param MatterNote $matterNote
  4564. *
  4565. * @return Project
  4566. */
  4567. public function addMatterNote(MatterNote $matterNote)
  4568. {
  4569. $this->matterNotes[] = $matterNote;
  4570. $matterNote->setProject($this);
  4571. return $this;
  4572. }
  4573. /**
  4574. * Remove matterNote
  4575. *
  4576. * @param MatterNote $matterNote
  4577. */
  4578. public function removeMatterNote(MatterNote $matterNote)
  4579. {
  4580. $this->matterNotes->removeElement($matterNote);
  4581. }
  4582. /**
  4583. * Get matterNotes
  4584. *
  4585. * @return DoctrineCollection|MatterNote[]
  4586. */
  4587. public function getMatterNotes()
  4588. {
  4589. return $this->matterNotes;
  4590. }
  4591. /**
  4592. * @return array
  4593. */
  4594. public function getNoteCounts(): array
  4595. {
  4596. $noteCounts = [];
  4597. foreach ($this->getMatterNotes() as $note) {
  4598. if (!isset($noteCounts[$note->getType()])) {
  4599. $noteCounts[$note->getType()] = 0;
  4600. }
  4601. $noteCounts[$note->getType()]++;
  4602. }
  4603. return $noteCounts;
  4604. }
  4605. /**
  4606. * Set unsortedRecordsCollection.
  4607. *
  4608. * @param Collection|null $unsortedRecordsCollection
  4609. *
  4610. * @return Project
  4611. */
  4612. public function setUnsortedRecordsCollection(?Collection $unsortedRecordsCollection = null)
  4613. {
  4614. $this->unsortedRecordsCollection = $unsortedRecordsCollection;
  4615. return $this;
  4616. }
  4617. /**
  4618. * Set requirePasswordOnDownload.
  4619. *
  4620. * @param bool $requirePasswordOnDownload
  4621. *
  4622. * @return Project
  4623. */
  4624. public function setRequirePasswordOnDownload($requirePasswordOnDownload)
  4625. {
  4626. $this->require_password_on_download = $requirePasswordOnDownload;
  4627. return $this;
  4628. }
  4629. /**
  4630. * Get unsortedRecordsCollection.
  4631. *
  4632. * @return Collection|null
  4633. */
  4634. public function getUnsortedRecordsCollection()
  4635. {
  4636. return $this->unsortedRecordsCollection;
  4637. }
  4638. /**
  4639. * Get requirePasswordOnDownload.
  4640. *
  4641. * @return bool
  4642. */
  4643. public function getRequirePasswordOnDownload()
  4644. {
  4645. return $this->require_password_on_download;
  4646. }
  4647. /**
  4648. * Set inviteUserMustAuthenticate.
  4649. *
  4650. * @param bool $inviteUserMustAuthenticate
  4651. *
  4652. * @return Project
  4653. */
  4654. public function setInviteUserMustAuthenticate($inviteUserMustAuthenticate)
  4655. {
  4656. $this->inviteUserMustAuthenticate = $inviteUserMustAuthenticate;
  4657. return $this;
  4658. }
  4659. /**
  4660. * Get inviteUserMustAuthenticate.
  4661. *
  4662. * @return bool
  4663. */
  4664. public function getInviteUserMustAuthenticate()
  4665. {
  4666. return $this->inviteUserMustAuthenticate;
  4667. }
  4668. /**
  4669. * Set inviteUserPassword.
  4670. *
  4671. * @param string $inviteUserPassword
  4672. *
  4673. * @return Project
  4674. */
  4675. public function setInviteUserPassword($inviteUserPassword)
  4676. {
  4677. $this->inviteUserPassword = $inviteUserPassword;
  4678. return $this;
  4679. }
  4680. /**
  4681. * Get inviteUserPassword.
  4682. *
  4683. * @return string
  4684. */
  4685. public function getInviteUserPassword()
  4686. {
  4687. return $this->inviteUserPassword;
  4688. }
  4689. /**
  4690. * Set inviteUserContactName.
  4691. *
  4692. * @param string|null $inviteUserContactName
  4693. *
  4694. * @return Project
  4695. */
  4696. public function setInviteUserContactName($inviteUserContactName = null)
  4697. {
  4698. $this->inviteUserContactName = $inviteUserContactName;
  4699. return $this;
  4700. }
  4701. /**
  4702. * Get inviteUserContactName.
  4703. *
  4704. * @return string|null
  4705. */
  4706. public function getInviteUserContactName()
  4707. {
  4708. return $this->inviteUserContactName;
  4709. }
  4710. /**
  4711. * Set inviteUserContactEmail.
  4712. *
  4713. * @param string|null $inviteUserContactEmail
  4714. *
  4715. * @return Project
  4716. */
  4717. public function setInviteUserContactEmail($inviteUserContactEmail = null)
  4718. {
  4719. $this->inviteUserContactEmail = $inviteUserContactEmail;
  4720. return $this;
  4721. }
  4722. /**
  4723. * Get inviteUserContactEmail.
  4724. *
  4725. * @return string|null
  4726. */
  4727. public function getInviteUserContactEmail()
  4728. {
  4729. return $this->inviteUserContactEmail;
  4730. }
  4731. /**
  4732. * Set inviteUserContactPhoneNumber.
  4733. *
  4734. * @param string|null $inviteUserContactPhoneNumber
  4735. *
  4736. * @return Project
  4737. */
  4738. public function setInviteUserContactPhoneNumber($inviteUserContactPhoneNumber = null)
  4739. {
  4740. $this->inviteUserContactPhoneNumber = $inviteUserContactPhoneNumber;
  4741. return $this;
  4742. }
  4743. /**
  4744. * Get inviteUserContactPhoneNumber.
  4745. *
  4746. * @return string|null
  4747. */
  4748. public function getInviteUserContactPhoneNumber()
  4749. {
  4750. return $this->inviteUserContactPhoneNumber;
  4751. }
  4752. /**
  4753. * Tells if the contact type is Email.
  4754. *
  4755. * @return bool
  4756. */
  4757. public function isInviteUserContactTypeEmail()
  4758. {
  4759. return !is_null($this->getInviteUserContactEmail());
  4760. }
  4761. /**
  4762. * Tells if the contact type is Phone.
  4763. *
  4764. * @return bool
  4765. */
  4766. public function isInviteUserContactTypePhone()
  4767. {
  4768. return !is_null($this->getInviteUserContactPhoneNumber());
  4769. }
  4770. /**
  4771. * Set dateOnLetter.
  4772. *
  4773. * @param DateTime|null $dateOnLetter
  4774. *
  4775. * @return Project
  4776. */
  4777. public function setDateOnLetter($dateOnLetter = null)
  4778. {
  4779. $this->date_on_letter = $dateOnLetter;
  4780. return $this;
  4781. }
  4782. /**
  4783. * Get dateOnLetter.
  4784. *
  4785. * @return DateTime|null
  4786. */
  4787. public function getDateOnLetter()
  4788. {
  4789. return $this->date_on_letter;
  4790. }
  4791. /**
  4792. * Set caseMeritsAnalysis.
  4793. *
  4794. * @param string|null $caseMeritsAnalysis
  4795. *
  4796. * @return Project
  4797. */
  4798. public function setCaseMeritsAnalysis($caseMeritsAnalysis = null)
  4799. {
  4800. $this->case_merits_analysis = $caseMeritsAnalysis;
  4801. return $this;
  4802. }
  4803. /**
  4804. * Get caseMeritsAnalysis.
  4805. *
  4806. * @return string|null
  4807. */
  4808. public function getCaseMeritsAnalysis()
  4809. {
  4810. return $this->case_merits_analysis;
  4811. }
  4812. /**
  4813. * Returns an array of permitted values for the case_merits_analysis field and their
  4814. * associated labels.
  4815. *
  4816. * @return array
  4817. */
  4818. public static function getCaseMeritsAnalysisOptions()
  4819. {
  4820. return [
  4821. self::CASE_MERITS_ANALYSIS_SUPPORTIVE => 'Supportive',
  4822. self::CASE_MERITS_ANALYSIS_UNSUPPORTIVE => 'Unsupportive',
  4823. self::CASE_MERITS_ANALYSIS_INCONCLUSIVE => 'Inconclusive',
  4824. ];
  4825. }
  4826. /**
  4827. * Returns a human-readable version of the case_merits_analysis
  4828. *
  4829. * @return string
  4830. */
  4831. public function getCaseMeritsAnalysisName()
  4832. {
  4833. $options = self::getCaseMeritsAnalysisOptions();
  4834. return
  4835. $options[$this->getCaseMeritsAnalysis()] ?? $this->getCaseMeritsAnalysis();
  4836. }
  4837. /**
  4838. * Set claimantSolicitor.
  4839. *
  4840. * @param string|null $claimantSolicitor
  4841. *
  4842. * @return Project
  4843. */
  4844. public function setClaimantSolicitor($claimantSolicitor = null)
  4845. {
  4846. $this->claimant_solicitor = $claimantSolicitor;
  4847. return $this;
  4848. }
  4849. /**
  4850. * Get claimantSolicitor.
  4851. *
  4852. * @return string|null
  4853. */
  4854. public function getClaimantSolicitor()
  4855. {
  4856. return $this->claimant_solicitor;
  4857. }
  4858. /**
  4859. * Set typeOfLetter.
  4860. *
  4861. * @param string|null $typeOfLetter
  4862. *
  4863. * @return Project
  4864. */
  4865. public function setTypeOfLetter($typeOfLetter = null)
  4866. {
  4867. $this->type_of_letter = $typeOfLetter;
  4868. return $this;
  4869. }
  4870. /**
  4871. * Get typeOfLetter.
  4872. *
  4873. * @return string|null
  4874. */
  4875. public function getTypeOfLetter()
  4876. {
  4877. return $this->type_of_letter;
  4878. }
  4879. /**
  4880. * Returns an array of permitted values for the type_of_letter field and their
  4881. * associated labels.
  4882. *
  4883. * @return array
  4884. */
  4885. public static function getTypeOfLetterOptions()
  4886. {
  4887. return [
  4888. self::TYPE_OF_LETTER_LETTER_OF_CLAIM => 'Letter of claim',
  4889. self::TYPE_OF_LETTER_LETTER_OF_NOTIFICATION => 'Letter of notification',
  4890. self::TYPE_OF_LETTER_SUBJECT_ACCESS_REQUEST => 'Subject access request',
  4891. self::TYPE_OF_LETTER_DISCLOSURE_APPLICATION => 'Disclosure application',
  4892. ];
  4893. }
  4894. /**
  4895. * Returns a human-readable version of the type_of_letter
  4896. *
  4897. * @return string
  4898. */
  4899. public function getTypeOfLetterName()
  4900. {
  4901. $options = self::getTypeOfLetterOptions();
  4902. return
  4903. $options[$this->getTypeOfLetter()] ?? $this->getTypeOfLetter();
  4904. }
  4905. /**
  4906. * Set reviewType.
  4907. *
  4908. * @param string|null $reviewType
  4909. *
  4910. * @return Project
  4911. */
  4912. public function setReviewType($reviewType = null)
  4913. {
  4914. $this->review_type = $reviewType;
  4915. return $this;
  4916. }
  4917. /**
  4918. * Get reviewType.
  4919. *
  4920. * @return string|null
  4921. */
  4922. public function getReviewType()
  4923. {
  4924. return $this->review_type;
  4925. }
  4926. /**
  4927. * Returns an array of permitted values for the review_type field and their
  4928. * associated labels.
  4929. *
  4930. * @return array
  4931. */
  4932. public static function getReviewTypeOptions()
  4933. {
  4934. return [
  4935. self::REVIEW_TYPE_CASE_MERITS_ANALYSIS => 'Case merits analysis',
  4936. self::REVIEW_TYPE_CHRONOLOGY => 'Chronology',
  4937. ];
  4938. }
  4939. /**
  4940. * Returns a human-readable version of the review_type
  4941. *
  4942. * @return string
  4943. */
  4944. public function getReviewTypeName()
  4945. {
  4946. $options = self::getReviewTypeOptions();
  4947. return
  4948. $options[$this->getReviewType()] ?? $this->getReviewType();
  4949. }
  4950. /**
  4951. * Set expertsReportDate.
  4952. *
  4953. * @param DateTime|null $expertsReportDate
  4954. *
  4955. * @return Project
  4956. */
  4957. public function setExpertsReportDate($expertsReportDate = null)
  4958. {
  4959. $this->experts_report_date = $expertsReportDate;
  4960. return $this;
  4961. }
  4962. /**
  4963. * Get expertsReportDate.
  4964. *
  4965. * @return DateTime|null
  4966. */
  4967. public function getExpertsReportDate()
  4968. {
  4969. return $this->experts_report_date;
  4970. }
  4971. /**
  4972. * Set letterOfResponseAndExpertReportRequestDate.
  4973. *
  4974. * @param DateTime|null $letterOfResponseAndExpertReportRequestDate
  4975. *
  4976. * @return Project
  4977. */
  4978. public function setLetterOfResponseAndExpertReportRequestDate($letterOfResponseAndExpertReportRequestDate = null)
  4979. {
  4980. $this->letter_of_response_and_expert_report_date = $letterOfResponseAndExpertReportRequestDate;
  4981. return $this;
  4982. }
  4983. /**
  4984. * Get letterOfResponseAndExpertReportRequestDate.
  4985. *
  4986. * @return DateTime|null
  4987. */
  4988. public function getLetterOfResponseAndExpertReportRequestDate()
  4989. {
  4990. return $this->letter_of_response_and_expert_report_date;
  4991. }
  4992. /**
  4993. * Set letterOfResponsePreparedDate.
  4994. *
  4995. * @param DateTime|null $letterOfResponsePreparedDate
  4996. *
  4997. * @return Project
  4998. */
  4999. public function setLetterOfResponsePreparedDate($letterOfResponsePreparedDate = null)
  5000. {
  5001. $this->letter_of_response_prepared_date = $letterOfResponsePreparedDate;
  5002. return $this;
  5003. }
  5004. /**
  5005. * Get letterOfResponsePreparedDate.
  5006. *
  5007. * @return DateTime|null
  5008. */
  5009. public function getLetterOfResponsePreparedDate()
  5010. {
  5011. return $this->letter_of_response_prepared_date;
  5012. }
  5013. /**
  5014. * Set letterOfResponseSentDate.
  5015. *
  5016. * @param DateTime|null $letterOfResponseSentDate
  5017. *
  5018. * @return Project
  5019. */
  5020. public function setLetterOfResponseSentDate($letterOfResponseSentDate = null)
  5021. {
  5022. $this->letter_of_response_sent_date = $letterOfResponseSentDate;
  5023. return $this;
  5024. }
  5025. /**
  5026. * Get letterOfResponseSentDate.
  5027. *
  5028. * @return DateTime|null
  5029. */
  5030. public function getLetterOfResponseSentDate()
  5031. {
  5032. return $this->letter_of_response_sent_date;
  5033. }
  5034. public static function loadValidatorMetadata(ClassMetadata $metadata)
  5035. {
  5036. $metadata->addConstraint(new Assert\Callback('validate'));
  5037. }
  5038. public function validate(ExecutionContextInterface $context, $payload)
  5039. {
  5040. if ($this->getInviteUserMustAuthenticate()) {
  5041. $password = $this->getinviteUserPassword();
  5042. // If the password has not already been set, validate the plainPassword.
  5043. if (is_null($password)) {
  5044. $plainPassword = $this->getinviteUserPlainPassword();
  5045. $constraints = [
  5046. new Assert\Regex([
  5047. 'pattern' => '/(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[\d])(?=.*[\W]).{8,}/',
  5048. '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.',
  5049. ]),
  5050. new Assert\NotBlank([]),
  5051. new Assert\Length([
  5052. 'min' => 8,
  5053. 'max' => 255,
  5054. 'minMessage' => 'Your password must have at least {{ limit }} characters.',
  5055. 'maxMessage' => 'The password is too long.',
  5056. ]),
  5057. ];
  5058. $validator = Validation::createValidator();
  5059. foreach ($constraints as $constraint) {
  5060. $errors = $validator->validate(
  5061. $plainPassword,
  5062. $constraint
  5063. );
  5064. if (0 !== count($errors)) {
  5065. $errorMessage = $errors[0]->getMessage();
  5066. $context->buildViolation($errorMessage)
  5067. ->atPath('inviteUserPlainPassword')
  5068. ->addViolation()
  5069. ;
  5070. }
  5071. }
  5072. }
  5073. if (is_null($this->getInviteUserContactName())) {
  5074. $errorMessage = 'Contact name required.';
  5075. $context->buildViolation($errorMessage)
  5076. ->atPath('inviteUserContactName')
  5077. ->addViolation()
  5078. ;
  5079. }
  5080. if (is_null($this->getInviteUserContactEmail())
  5081. && is_null($this->getInviteUserContactPhoneNumber())
  5082. ) {
  5083. $errorMessage = 'Contact email address or phone number required.';
  5084. $context->buildViolation($errorMessage)
  5085. ->atPath('inviteUserContactEmail')
  5086. ->addViolation()
  5087. ;
  5088. $context->buildViolation($errorMessage)
  5089. ->atPath('inviteUserContactPhoneNumber')
  5090. ->addViolation()
  5091. ;
  5092. }
  5093. }
  5094. }
  5095. /**
  5096. * Set matterRequest.
  5097. *
  5098. * @param MatterRequest|null $matterRequest
  5099. *
  5100. * @return Project
  5101. */
  5102. public function setMatterRequest(?MatterRequest $matterRequest = null)
  5103. {
  5104. $this->matterRequest = $matterRequest;
  5105. return $this;
  5106. }
  5107. /**
  5108. * Get matterRequest.
  5109. *
  5110. * @return MatterRequest|null
  5111. */
  5112. public function getMatterRequest()
  5113. {
  5114. return $this->matterRequest;
  5115. }
  5116. /**
  5117. * Returns a radiology schedule array grouped by study of all related radiology on a project.
  5118. *
  5119. * @return array
  5120. */
  5121. public function getRadiologyScheduleArray()
  5122. {
  5123. $data = [];
  5124. $serieses = $this->getSeries();
  5125. /** @var Series $series */
  5126. foreach ($serieses as $series) {
  5127. // Grab the Study this Series is in
  5128. $study = $series->getStudy();
  5129. if ($study) {
  5130. // Skip studies that have no active (non-deleted) discs
  5131. $activeDiscs = $study->getDiscs()->filter(function (Disc $disc) {
  5132. return $disc->isActive() && $disc->getDeletedAt() === null;
  5133. });
  5134. if ($activeDiscs->isEmpty()) {
  5135. continue;
  5136. }
  5137. // Having named keys here isn't really necessary but we might want them later for something
  5138. // If we have Discs, we can fill out the `source` and `number` fields
  5139. $data[$study->getId()] = [
  5140. 'id' => $study->getId(),
  5141. 'matter' => $this->getClientReference(),
  5142. 'patient' => $study->getPatient()->getDicomPatientName(),
  5143. 'date' => $study->getStudyDate(),
  5144. 'description' => $study->getStudyDescription(),
  5145. 'centre' => $study->getStudyInstituteName(),
  5146. 'discs' => $study->getDiscs(),
  5147. 'longDescription' => $study->__toString(),
  5148. ];
  5149. }
  5150. }
  5151. usort($data, function ($a, $b) {
  5152. return strcmp($a['longDescription'], $b['longDescription']);
  5153. });
  5154. return $data;
  5155. }
  5156. /**
  5157. * Add matterCommunication.
  5158. *
  5159. * @param MatterCommunication $matterCommunication
  5160. *
  5161. * @return Project
  5162. */
  5163. public function addMatterCommunication(MatterCommunication $matterCommunication)
  5164. {
  5165. $this->matterCommunications[] = $matterCommunication;
  5166. return $this;
  5167. }
  5168. /**
  5169. * Remove matterCommunication.
  5170. *
  5171. * @param MatterCommunication $matterCommunication
  5172. *
  5173. * @return bool TRUE if this collection contained the specified element, FALSE otherwise.
  5174. */
  5175. public function removeMatterCommunication(MatterCommunication $matterCommunication)
  5176. {
  5177. return $this->matterCommunications->removeElement($matterCommunication);
  5178. }
  5179. /**
  5180. * Get matterCommunications.
  5181. *
  5182. * @return DoctrineCollection|MatterCommunication[]
  5183. */
  5184. public function getMatterCommunications()
  5185. {
  5186. return $this->matterCommunications;
  5187. }
  5188. /**
  5189. * Set deleteStatus
  5190. *
  5191. * @param int $deleteStatus
  5192. *
  5193. * @return Project
  5194. */
  5195. public function setDeleteStatus(?int $deleteStatus = null)
  5196. {
  5197. if ($this->deleteStatus !== $deleteStatus) {
  5198. $this->setDeleteStatusUpdated(new DateTime());
  5199. }
  5200. $this->deleteStatus = $deleteStatus;
  5201. return $this;
  5202. }
  5203. /**
  5204. * Get deleteStatus
  5205. *
  5206. * @return int
  5207. */
  5208. public function getDeleteStatus()
  5209. {
  5210. return $this->deleteStatus;
  5211. }
  5212. /**
  5213. * Return true if deletestatus is equal to the constants below
  5214. *
  5215. * @return bool
  5216. */
  5217. public function hasDeleteStatus()
  5218. {
  5219. $statuses = [
  5220. self::DELETE_STATUS_PENDING,
  5221. self::DELETE_STATUS_REMINDER_SENT,
  5222. self::DELETE_STATUS_PROCESSING,
  5223. self::DELETE_STATUS_COMPLETE,
  5224. ];
  5225. return in_array($this->getDeleteStatus(), $statuses);
  5226. }
  5227. /**
  5228. * Set deleteStatusUpdated
  5229. *
  5230. * @param DateTime $deleteStatusUpdated
  5231. *
  5232. * @return Project
  5233. */
  5234. public function setDeleteStatusUpdated(?DateTime $deleteStatusUpdated = null)
  5235. {
  5236. $this->deleteStatusUpdated = $deleteStatusUpdated;
  5237. return $this;
  5238. }
  5239. /**
  5240. * Get deleteStatusUpdated
  5241. *
  5242. * @return DateTime
  5243. */
  5244. public function getDeleteStatusUpdated()
  5245. {
  5246. return $this->deleteStatusUpdated;
  5247. }
  5248. /**
  5249. * Get archiveStatus as Label
  5250. *
  5251. * @return string
  5252. */
  5253. public function getArchiveStatusLabel()
  5254. {
  5255. $archiveStatusOptions = array_flip(static::getConstantsWithLabelsAsChoices('ARCHIVE_STATUS'));
  5256. return $archiveStatusOptions[$this->getArchiveStatus()] ?? '';
  5257. }
  5258. /**
  5259. * @return array
  5260. */
  5261. public static function getArchiveStatusChoices()
  5262. {
  5263. return static::getConstantsWithLabelsAsChoices('ARCHIVE_STATUS');
  5264. }
  5265. /**
  5266. * @return array
  5267. */
  5268. public static function getDeleteStatusChoices()
  5269. {
  5270. return static::getConstantsWithLabelsAsChoices('DELETE_STATUS');
  5271. }
  5272. /**
  5273. * Return true if matter is in the process of being deleted/archived, or is deleted or archived
  5274. *
  5275. * @return bool
  5276. */
  5277. public function isCloseInProgressOrComplete()
  5278. {
  5279. $archiveStatuses = [
  5280. self::ARCHIVE_STATUS_PENDING,
  5281. self::ARCHIVE_STATUS_PROCESSING,
  5282. self::ARCHIVE_STATUS_UNARCHIVE_PROCESSING,
  5283. self::ARCHIVE_STATUS_COMPLETE,
  5284. ];
  5285. $deleteStatuses = [
  5286. self::DELETE_STATUS_PENDING,
  5287. self::DELETE_STATUS_REMINDER_SENT,
  5288. self::DELETE_STATUS_PROCESSING,
  5289. self::DELETE_STATUS_COMPLETE,
  5290. self::DELETE_STATUS_DELETE_FAILED,
  5291. self::DELETE_STATUS_ANONYMISE_FAILED,
  5292. ];
  5293. return in_array($this->getArchiveStatus(), $archiveStatuses, true) || in_array($this->getDeleteStatus(), $deleteStatuses, true);
  5294. }
  5295. /**
  5296. * Return true if project status is active
  5297. *
  5298. * @return bool
  5299. */
  5300. public function isStatusActive()
  5301. {
  5302. return $this->getStatus() === self::STATUS_ACTIVE;
  5303. }
  5304. /**
  5305. * Return true if project archive status is pending
  5306. *
  5307. * @return bool
  5308. */
  5309. public function isArchiveStatusPending()
  5310. {
  5311. return $this->getArchiveStatus() === self::ARCHIVE_STATUS_PENDING;
  5312. }
  5313. /**
  5314. * Return true if project archive status is processing
  5315. *
  5316. * @return bool
  5317. */
  5318. public function isArchiveStatusProcessing()
  5319. {
  5320. return $this->getArchiveStatus() === self::ARCHIVE_STATUS_PROCESSING;
  5321. }
  5322. /**
  5323. * Return true if project archive status is complete
  5324. *
  5325. * @return bool
  5326. */
  5327. public function isArchiveStatusComplete()
  5328. {
  5329. return $this->getArchiveStatus() === self::ARCHIVE_STATUS_COMPLETE;
  5330. }
  5331. /**
  5332. * Return true if project archive status is unarchive in process
  5333. *
  5334. * @return bool
  5335. */
  5336. public function isArchiveStatusUnarchiveProcessing()
  5337. {
  5338. return $this->getArchiveStatus() === self::ARCHIVE_STATUS_UNARCHIVE_PROCESSING;
  5339. }
  5340. /**
  5341. * Return true if matter is in the process of being deleted/archived
  5342. *
  5343. * @return bool
  5344. */
  5345. public function isQueuedForArchiveOrDeletion(): bool
  5346. {
  5347. $archiveStatuses = [
  5348. self::ARCHIVE_STATUS_PENDING,
  5349. self::ARCHIVE_STATUS_PROCESSING,
  5350. self::ARCHIVE_STATUS_UNARCHIVE_PROCESSING,
  5351. ];
  5352. $deleteStatuses = [
  5353. self::DELETE_STATUS_PENDING,
  5354. self::DELETE_STATUS_REMINDER_SENT,
  5355. self::DELETE_STATUS_PROCESSING,
  5356. ];
  5357. return in_array($this->getArchiveStatus(), $archiveStatuses, true) || in_array($this->getDeleteStatus(), $deleteStatuses, true);
  5358. }
  5359. /**
  5360. * Return true if archive status is equal to the constants below
  5361. *
  5362. * @return bool
  5363. */
  5364. public function hasArchiveStatus(): bool
  5365. {
  5366. $statuses = [
  5367. self::ARCHIVE_STATUS_PENDING,
  5368. self::ARCHIVE_STATUS_PROCESSING,
  5369. self::ARCHIVE_STATUS_COMPLETE,
  5370. self::ARCHIVE_STATUS_UNARCHIVE_PROCESSING,
  5371. ];
  5372. return in_array($this->getArchiveStatus(), $statuses);
  5373. }
  5374. /**
  5375. * Get deleteStatus as Label
  5376. *
  5377. * @return string
  5378. */
  5379. public function getDeleteStatusLabel()
  5380. {
  5381. $deleteStatusOptions = array_flip(static::getConstantsWithLabelsAsChoices('DELETE_STATUS'));
  5382. return $deleteStatusOptions[$this->getDeleteStatus()] ?? '';
  5383. }
  5384. /**
  5385. * Return true if project delete status is pending
  5386. *
  5387. * @return bool
  5388. */
  5389. public function isDeleteStatusPending()
  5390. {
  5391. return $this->getDeleteStatus() === self::DELETE_STATUS_PENDING;
  5392. }
  5393. /**
  5394. * Return true if project delete status is pending immediate deletion.
  5395. *
  5396. * @return bool
  5397. */
  5398. public function isDeleteStatusPendingImmediate()
  5399. {
  5400. return $this->getDeleteStatus() === self::DELETE_STATUS_PENDING_IMMEDIATE;
  5401. }
  5402. /**
  5403. * Return true if project delete status is reminder sent
  5404. *
  5405. * @return bool
  5406. */
  5407. public function isDeleteStatusReminderSent()
  5408. {
  5409. return $this->getDeleteStatus() === self::DELETE_STATUS_REMINDER_SENT;
  5410. }
  5411. /**
  5412. * Return true if project delete status is processing
  5413. *
  5414. * @return bool
  5415. */
  5416. public function isDeleteStatusProcessing()
  5417. {
  5418. return $this->getDeleteStatus() === self::DELETE_STATUS_PROCESSING;
  5419. }
  5420. /**
  5421. * Return true if project delete status is complete
  5422. *
  5423. * @return bool
  5424. */
  5425. public function isDeleteStatusComplete()
  5426. {
  5427. return $this->getDeleteStatus() === self::DELETE_STATUS_COMPLETE;
  5428. }
  5429. /**
  5430. * Return true if project delete status is failed
  5431. *
  5432. * @return bool
  5433. */
  5434. public function isDeleteStatusFailed()
  5435. {
  5436. return $this->getDeleteStatus() === self::DELETE_STATUS_DELETE_FAILED;
  5437. }
  5438. /**
  5439. * Return true if the Project can be deleted.
  5440. *
  5441. * @return bool
  5442. */
  5443. public function canBeDeleted(): bool
  5444. {
  5445. return $this->isDeleteStatusReminderSent() || $this->isDeleteStatusProcessing();
  5446. }
  5447. /**
  5448. * Returns true if the project is queued for deletion.
  5449. *
  5450. * @return bool
  5451. */
  5452. public function isQueuedForDeletion(): bool
  5453. {
  5454. return $this->isDeleteStatusPending() || $this->isDeleteStatusReminderSent() || $this->isDeleteStatusPendingImmediate();
  5455. }
  5456. /**
  5457. * Return true if matter is in the process of being deleted/archived, and is not in the queue to be closed
  5458. *
  5459. * @return bool
  5460. */
  5461. public function isCloseInProgress()
  5462. {
  5463. $archiveStatuses = [
  5464. self::ARCHIVE_STATUS_PROCESSING,
  5465. self::ARCHIVE_STATUS_UNARCHIVE_PROCESSING,
  5466. ];
  5467. $deleteStatuses = [
  5468. self::DELETE_STATUS_PROCESSING,
  5469. ];
  5470. return in_array($this->getArchiveStatus(), $archiveStatuses, true) || in_array($this->getDeleteStatus(), $deleteStatuses, true);
  5471. }
  5472. /**
  5473. * Return true if matter deletion is complete
  5474. *
  5475. * @return bool
  5476. */
  5477. public function isDeleteComplete()
  5478. {
  5479. return $this->getDeleteStatus() === self::DELETE_STATUS_COMPLETE;
  5480. }
  5481. /**
  5482. * Returns the User that requested the deletion.
  5483. *
  5484. * @return User
  5485. */
  5486. public function getDeletionRequestedBy(): ?User
  5487. {
  5488. return $this->getProjectClosure() ? $this->getProjectClosure()->getClosedBy() : null;
  5489. }
  5490. /**
  5491. * getAllowExpertViewUnsortedRecords
  5492. *
  5493. * @return bool
  5494. */
  5495. public function getAllowExpertViewUnsortedRecords(): ?bool
  5496. {
  5497. return $this->allowExpertViewUnsortedRecords;
  5498. }
  5499. /**
  5500. * setAllowExpertViewUnsortedRecords
  5501. *
  5502. * @param bool $allowExpertViewUnsortedRecords
  5503. *
  5504. * @return self
  5505. */
  5506. public function setAllowExpertViewUnsortedRecords(?bool $allowExpertViewUnsortedRecords = null): self
  5507. {
  5508. $this->allowExpertViewUnsortedRecords = $allowExpertViewUnsortedRecords;
  5509. return $this;
  5510. }
  5511. /**
  5512. * Get the value of dateDeleted
  5513. *
  5514. * @return DateTime
  5515. */
  5516. public function getDateDeleted()
  5517. {
  5518. return $this->dateDeleted;
  5519. }
  5520. /**
  5521. * Set the value of dateDeleted
  5522. *
  5523. * @param DateTime|null $dateDeleted
  5524. *
  5525. * @return self
  5526. */
  5527. public function setDateDeleted(?DateTime $dateDeleted)
  5528. {
  5529. $this->dateDeleted = $dateDeleted;
  5530. return $this;
  5531. }
  5532. /**
  5533. * Get the value of projectDeletionReport
  5534. */
  5535. public function getProjectDeletionReport()
  5536. {
  5537. return $this->projectDeletionReport;
  5538. }
  5539. /**
  5540. * Set the value of projectDeletionReport
  5541. *
  5542. * @param ProjectDeletionReport|null $projectDeletionReport
  5543. *
  5544. * @return self
  5545. */
  5546. public function setProjectDeletionReport(?ProjectDeletionReport $projectDeletionReport)
  5547. {
  5548. $this->projectDeletionReport = $projectDeletionReport;
  5549. return $this;
  5550. }
  5551. /**
  5552. * Transforms matter Request entity into a usable array structure
  5553. *
  5554. * @return array
  5555. */
  5556. public function getDeletionSummaryArray(): array
  5557. {
  5558. $deletionReport = $this->getProjectDeletionReport();
  5559. if ($deletionReport === null) {
  5560. throw new Exception('Project deletion report has not been stored.');
  5561. }
  5562. return [
  5563. 'project' => $this,
  5564. 'patientDob' => $deletionReport->getPatientDateOfBirth(),
  5565. 'userWhoCompletedClosureWizard' => $this->getDeletionRequestedBy() ? $this->getDeletionRequestedBy()->getFullName() : '',
  5566. 'dateDeletionCompleted' => $deletionReport->getCreated(),
  5567. 'documents' => $deletionReport->getDocuments(),
  5568. ];
  5569. }
  5570. /**
  5571. * Sets the project delete status to failed.
  5572. *
  5573. * @return self
  5574. */
  5575. public function setDeleteStatusFailed(): self
  5576. {
  5577. $this->setDeleteStatus(self::DELETE_STATUS_DELETE_FAILED);
  5578. return $this;
  5579. }
  5580. /**
  5581. * Sets the project delete status to anonymise failed.
  5582. *
  5583. * @return self
  5584. */
  5585. public function setDeleteStatusAnonymiseFailed(): self
  5586. {
  5587. $this->setDeleteStatus(self::DELETE_STATUS_ANONYMISE_FAILED);
  5588. return $this;
  5589. }
  5590. /**
  5591. * Sets the project delete status to complete.
  5592. *
  5593. * @return self
  5594. */
  5595. public function setDeleteStatusComplete(): self
  5596. {
  5597. $this->setDeleteStatus(self::DELETE_STATUS_COMPLETE);
  5598. return $this;
  5599. }
  5600. /**
  5601. * Sets the project delete status to complete.
  5602. *
  5603. * @return self
  5604. */
  5605. public function setDeleteStatusProcessing(): self
  5606. {
  5607. $this->setDeleteStatus(self::DELETE_STATUS_PROCESSING);
  5608. return $this;
  5609. }
  5610. /**
  5611. * @return ProjectClosure|null
  5612. */
  5613. public function getProjectClosure(): ?ProjectClosure
  5614. {
  5615. return $this->projectClosure;
  5616. }
  5617. /**
  5618. * @param ProjectClosure|null $projectClosure
  5619. *
  5620. * @return self
  5621. */
  5622. public function setProjectClosure(?ProjectClosure $projectClosure): self
  5623. {
  5624. // unset the owning side of the relation if necessary
  5625. if ($projectClosure === null && $this->projectClosure !== null) {
  5626. $this->projectClosure->setProject(null);
  5627. }
  5628. // set the owning side of the relation if necessary
  5629. if ($projectClosure !== null && $projectClosure->getProject() !== $this) {
  5630. $projectClosure->setProject($this);
  5631. }
  5632. $this->projectClosure = $projectClosure;
  5633. return $this;
  5634. }
  5635. /**
  5636. * Returns all the root collections for a project. These are the root folders on the MedicalRecords page.
  5637. *
  5638. * @return Collection[]
  5639. */
  5640. public function getRootCollections(): array
  5641. {
  5642. $rootCollections = [];
  5643. if ($this->getMedicalRecordsCollection()) {
  5644. $rootCollections[] = $this->getMedicalRecordsCollection();
  5645. }
  5646. if ($this->getPrivateCollection()) {
  5647. $rootCollections[] = $this->getPrivateCollection();
  5648. }
  5649. if ($this->getPrivateSandboxCollection()) {
  5650. $rootCollections[] = $this->getPrivateSandboxCollection();
  5651. }
  5652. if ($this->getUnsortedRecordsCollection()) {
  5653. $rootCollections[] = $this->getUnsortedRecordsCollection();
  5654. }
  5655. return $rootCollections;
  5656. }
  5657. /**
  5658. * Return true if deleteStatus is PROCESSING or COMPLETE
  5659. *
  5660. * @return bool
  5661. */
  5662. public function isDeleteProcessingOrComplete()
  5663. {
  5664. $statuses = [
  5665. self::DELETE_STATUS_PROCESSING,
  5666. self::DELETE_STATUS_COMPLETE,
  5667. ];
  5668. return in_array($this->getDeleteStatus(), $statuses);
  5669. }
  5670. /**
  5671. * @Groups({"project_closure:read"})
  5672. *
  5673. * @return bool
  5674. */
  5675. public function getClosureQuestionsOptional(): bool
  5676. {
  5677. return $this->getAccount()->getMatterClosureQuestionsOptional();
  5678. }
  5679. /**
  5680. * @return string|null
  5681. */
  5682. public function getClosureStatusLabel(): ?string
  5683. {
  5684. if ($this->getArchiveStatus()) {
  5685. return 'Archived';
  5686. }
  5687. if ($this->getDeleteStatus()) {
  5688. return 'Deleted';
  5689. }
  5690. return null;
  5691. }
  5692. /**
  5693. * @return string|null
  5694. */
  5695. public function getFirmRecordsReviewStatus(): ?string
  5696. {
  5697. return $this->firmRecordsReviewStatus;
  5698. }
  5699. /**
  5700. * @param string|null $firmRecordsReviewStatus
  5701. *
  5702. * @return self
  5703. */
  5704. public function setFirmRecordsReviewStatus(?string $firmRecordsReviewStatus): self
  5705. {
  5706. if ($this->firmRecordsReviewStatus !== $firmRecordsReviewStatus) {
  5707. $this->setFirmRecordsReviewUpdated(new DateTime());
  5708. }
  5709. $this->firmRecordsReviewStatus = $firmRecordsReviewStatus;
  5710. return $this;
  5711. }
  5712. /**
  5713. * @return array
  5714. */
  5715. public static function getFirmRecordsReviewStatusOptions(): array
  5716. {
  5717. return static::getConstantsWithLabelsAsChoices('FIRM_RECORDS_REVIEW_STATUS');
  5718. }
  5719. /**
  5720. * @return string
  5721. */
  5722. public function getFirmRecordsReviewStatusLabel(): string
  5723. {
  5724. $options = array_flip($this->getFirmRecordsReviewStatusOptions());
  5725. return $options[$this->firmRecordsReviewStatus] ?? '';
  5726. }
  5727. /**
  5728. * @return bool
  5729. */
  5730. public function showFirmRecordsReviewAdditionalInstruction(): bool
  5731. {
  5732. $statuses = [
  5733. self::FIRM_RECORDS_REVIEW_STATUS_AWAITING_RECORDS,
  5734. self::FIRM_RECORDS_REVIEW_STATUS_UPLOADED,
  5735. ];
  5736. return in_array($this->getFirmRecordsReviewStatus(), $statuses);
  5737. }
  5738. /**
  5739. * @return DateTimeInterface|null
  5740. */
  5741. public function getFirmRecordsReviewUpdated(): ?DateTimeInterface
  5742. {
  5743. return $this->firmRecordsReviewUpdated;
  5744. }
  5745. /**
  5746. * @param DateTimeInterface|null $firmRecordsReviewUpdated
  5747. *
  5748. * @return self
  5749. */
  5750. public function setFirmRecordsReviewUpdated(?DateTimeInterface $firmRecordsReviewUpdated): self
  5751. {
  5752. $this->firmRecordsReviewUpdated = $firmRecordsReviewUpdated;
  5753. return $this;
  5754. }
  5755. /**
  5756. * @return string|null
  5757. */
  5758. public function getClinicalSummaryUnsortedStatus(): ?string
  5759. {
  5760. return $this->clinicalSummaryUnsortedStatus;
  5761. }
  5762. /**
  5763. * @param string|null $clinicalSummaryUnsortedStatus
  5764. *
  5765. * @return self
  5766. */
  5767. public function setClinicalSummaryUnsortedStatus(?string $clinicalSummaryUnsortedStatus): self
  5768. {
  5769. if ($this->clinicalSummaryUnsortedStatus !== $clinicalSummaryUnsortedStatus) {
  5770. $this->setClinicalSummaryUnsortedUpdated(new DateTime());
  5771. }
  5772. $this->clinicalSummaryUnsortedStatus = $clinicalSummaryUnsortedStatus;
  5773. return $this;
  5774. }
  5775. /**
  5776. * @return array
  5777. */
  5778. public static function getClinicalSummaryUnsortedStatusOptions(): array
  5779. {
  5780. return static::getConstantsWithLabelsAsChoices('CLINICAL_SUMMARY_UNSORTED_STATUS');
  5781. }
  5782. /**
  5783. * @return string
  5784. */
  5785. public function getClinicalSummaryUnsortedStatusLabel(): string
  5786. {
  5787. $options = array_flip($this->getClinicalSummaryUnsortedStatusOptions());
  5788. return $options[$this->clinicalSummaryUnsortedStatus] ?? '';
  5789. }
  5790. /**
  5791. * @return DateTimeInterface|null
  5792. */
  5793. public function getClinicalSummaryUnsortedUpdated(): ?DateTimeInterface
  5794. {
  5795. return $this->clinicalSummaryUnsortedUpdated;
  5796. }
  5797. /**
  5798. * @param DateTimeInterface|null $clinicalSummaryUnsortedUpdated
  5799. *
  5800. * @return self
  5801. */
  5802. public function setClinicalSummaryUnsortedUpdated(?DateTimeInterface $clinicalSummaryUnsortedUpdated): self
  5803. {
  5804. $this->clinicalSummaryUnsortedUpdated = $clinicalSummaryUnsortedUpdated;
  5805. return $this;
  5806. }
  5807. /**
  5808. * @return bool
  5809. */
  5810. public function showClinicalSummaryUnsortedAdditionalInstruction(): bool
  5811. {
  5812. $statuses = [
  5813. self::CLINICAL_SUMMARY_UNSORTED_STATUS_AWAITING_CONCLUSION,
  5814. self::CLINICAL_SUMMARY_UNSORTED_STATUS_INCONCLUSIVE,
  5815. ];
  5816. return in_array($this->getClinicalSummaryUnsortedStatus(), $statuses);
  5817. }
  5818. /**
  5819. * @param Instance $instance
  5820. *
  5821. * @return $this
  5822. */
  5823. public function addInstance(Instance $instance): Project
  5824. {
  5825. if (!$this->instances->contains($instance)) {
  5826. $this->instances[] = $instance;
  5827. }
  5828. return $this;
  5829. }
  5830. /**
  5831. * @param Instance $instance
  5832. *
  5833. * @return $this
  5834. */
  5835. public function removeInstance(Instance $instance): Project
  5836. {
  5837. $this->instances->removeElement($instance);
  5838. return $this;
  5839. }
  5840. /**
  5841. * @return DoctrineCollection<int, InterpartyDisclosure>
  5842. */
  5843. public function getInterpartyDisclosures(): DoctrineCollection
  5844. {
  5845. return $this->interpartyDisclosures;
  5846. }
  5847. /**
  5848. * This function name is no longer very descriptive as we include drafts that
  5849. * were saved intentionally as drafts for review.
  5850. *
  5851. * @return DoctrineCollection<int, InterpartyDisclosure>
  5852. */
  5853. public function getNonDraftInterpartyDisclosures(): DoctrineCollection
  5854. {
  5855. return $this->interpartyDisclosures->filter(function (InterpartyDisclosure $disclosure) {
  5856. return ($disclosure->isStatusDraft() === false || $disclosure->getSavedAsDraft() === true) && $disclosure->isCurrentHeadOfChain() === true;
  5857. });
  5858. }
  5859. /**
  5860. * Returns a unique array of matter numbers that have already been used as recipient firm
  5861. * matter numbers for disclosures on this project.
  5862. *
  5863. * @param ?InterpartyDisclosure $excludeDisclosure - Optionally exclude a specific disclosure from the list.
  5864. * @param bool $excludePreviousVersions
  5865. *
  5866. * @return array
  5867. */
  5868. public function getInterpartyDisclosureRecipientMatterNumbers(?InterpartyDisclosure $excludeDisclosure = null, bool $excludePreviousVersions = false): array
  5869. {
  5870. $matterNumbers = [];
  5871. foreach ($this->getInterpartyDisclosures() as $disclosure) {
  5872. if (
  5873. $excludeDisclosure === $disclosure
  5874. || ($excludePreviousVersions === true && $disclosure->isDisclosurePreviousVersionOf($excludeDisclosure))
  5875. || $disclosure->isStatusDraft()
  5876. || $disclosure->isStatusRevoked()
  5877. || $disclosure->isStatusFailed()
  5878. ) {
  5879. continue;
  5880. }
  5881. foreach ($disclosure->getRecipientFirms() as $recipientFirm) {
  5882. $matterNumbers[] = $recipientFirm->getMatterNumber();
  5883. }
  5884. }
  5885. // Don't call array unique here as it messes with the keys of the array.
  5886. return $matterNumbers;
  5887. }
  5888. /**
  5889. * @return bool
  5890. */
  5891. public function hasActiveInterpartyDisclosures(): bool
  5892. {
  5893. foreach ($this->getInterpartyDisclosures() as $disclosure) {
  5894. if ($disclosure->isStatusActive()) {
  5895. return true;
  5896. }
  5897. }
  5898. return false;
  5899. }
  5900. /**
  5901. * @return bool
  5902. */
  5903. public function hasExpiredInterpartyDisclosures(): bool
  5904. {
  5905. foreach ($this->getInterpartyDisclosures() as $disclosure) {
  5906. if ($disclosure->isStatusExpired()) {
  5907. return true;
  5908. }
  5909. }
  5910. return false;
  5911. }
  5912. /**
  5913. * @param InterpartyDisclosure $interpartyDisclosure
  5914. *
  5915. * @return self
  5916. */
  5917. public function addInterpartyDisclosure(InterpartyDisclosure $interpartyDisclosure): self
  5918. {
  5919. if (!$this->interpartyDisclosures->contains($interpartyDisclosure)) {
  5920. $this->interpartyDisclosures[] = $interpartyDisclosure;
  5921. $interpartyDisclosure->setProject($this);
  5922. }
  5923. return $this;
  5924. }
  5925. /**
  5926. * @param InterpartyDisclosure $interpartyDisclosure
  5927. *
  5928. * @return self
  5929. */
  5930. public function removeInterpartyDisclosure(InterpartyDisclosure $interpartyDisclosure): self
  5931. {
  5932. if ($this->interpartyDisclosures->removeElement($interpartyDisclosure)) {
  5933. // set the owning side to null (unless already changed)
  5934. if ($interpartyDisclosure->getProject() === $this) {
  5935. $interpartyDisclosure->setProject(null);
  5936. }
  5937. }
  5938. return $this;
  5939. }
  5940. /**
  5941. * Return the count of active disclosures relating to the current project.
  5942. *
  5943. * @return int
  5944. */
  5945. public function getActiveDisclosuresCount(): int
  5946. {
  5947. $interpartyDisclosuresArray = $this->getInterpartyDisclosures()->toArray();
  5948. $activeCount = array_reduce(
  5949. $interpartyDisclosuresArray,
  5950. function ($activeTotal, $disclosure) {
  5951. return $activeTotal + $disclosure->isStatusActive();
  5952. },
  5953. 0
  5954. );
  5955. return $activeCount;
  5956. }
  5957. /**
  5958. * @return string|null
  5959. *
  5960. */
  5961. public function getMatterType(): ?string
  5962. {
  5963. return $this->matterType;
  5964. }
  5965. /**
  5966. * @param string|null $matterType
  5967. *
  5968. * @return self
  5969. */
  5970. public function setMatterType(?string $matterType): self
  5971. {
  5972. $this->matterType = $matterType;
  5973. return $this;
  5974. }
  5975. /**
  5976. * @return array
  5977. */
  5978. public static function getMatterTypeOptions(): array
  5979. {
  5980. return self::getConstantsWithLabelsAsChoices('MATTER_TYPE');
  5981. }
  5982. /**
  5983. * @return string
  5984. */
  5985. public function getMatterTypeLabel(): string
  5986. {
  5987. if ($this->getMatterType() === null) {
  5988. return '';
  5989. }
  5990. $options = array_flip(self::getMatterTypeOptions());
  5991. return $options[$this->getMatterType()] ?? '';
  5992. }
  5993. /**
  5994. * @return bool
  5995. */
  5996. public function isClinicalNegligenceMatterType(): bool
  5997. {
  5998. return $this->getMatterType() === self::MATTER_TYPE_CLINICAL_NEGLIGENCE;
  5999. }
  6000. /**
  6001. * Get the value of useModernRadiology
  6002. */
  6003. public function getUseModernRadiology(): ?bool
  6004. {
  6005. return $this->useModernRadiology;
  6006. }
  6007. /**
  6008. * Set the value of useModernRadiology
  6009. *
  6010. * @param bool|null $useModernRadiology
  6011. *
  6012. * @return self
  6013. */
  6014. public function setUseModernRadiology(?bool $useModernRadiology)
  6015. {
  6016. $this->useModernRadiology = $useModernRadiology;
  6017. return $this;
  6018. }
  6019. /**
  6020. * Get the value of modernRadiologyMigrationStatus
  6021. */
  6022. public function getModernRadiologyMigrationStatus(): ?string
  6023. {
  6024. return $this->modernRadiologyMigrationStatus;
  6025. }
  6026. /**
  6027. * Set the value of modernRadiologyMigrationStatus
  6028. *
  6029. * @param mixed $modernRadiologyMigrationStatus
  6030. *
  6031. * @return self
  6032. */
  6033. public function setModernRadiologyMigrationStatus(?string $modernRadiologyMigrationStatus)
  6034. {
  6035. $this->modernRadiologyMigrationStatus = $modernRadiologyMigrationStatus;
  6036. // Once the migration completes, flick the switch that we should now use modern radiology.
  6037. if ($modernRadiologyMigrationStatus === self::MODERN_RADIOLOGY_MIGRATION_STATUS_COMPLETE
  6038. || $modernRadiologyMigrationStatus === self::MODERN_RADIOLOGY_MIGRATION_STATUS_SKIPPED) {
  6039. $this->setUseModernRadiology(true);
  6040. }
  6041. return $this;
  6042. }
  6043. /**
  6044. * @return bool
  6045. */
  6046. public function isModernRadiologyMigrationInProgress(): bool
  6047. {
  6048. return $this->getModernRadiologyMigrationStatus() === self::MODERN_RADIOLOGY_MIGRATION_STATUS_IN_PROGRESS;
  6049. }
  6050. /**
  6051. * @return string|null
  6052. */
  6053. public function getType(): ?string
  6054. {
  6055. return $this->type;
  6056. }
  6057. /**
  6058. * @param string|null $type
  6059. *
  6060. * @return self
  6061. */
  6062. public function setType(?string $type): self
  6063. {
  6064. $this->type = $type;
  6065. return $this;
  6066. }
  6067. /**
  6068. * @return bool
  6069. */
  6070. public function isTypeDisclosure(): bool
  6071. {
  6072. return $this->type === self::TYPE_MATTER_DISCLOSURE;
  6073. }
  6074. /**
  6075. * Returns an array of permitted values for the Matter Type field and their
  6076. * associated labels.
  6077. *
  6078. * @return array
  6079. */
  6080. public static function getTypeOptions()
  6081. {
  6082. $typeOptions = self::getConstantsWithLabelsAsChoices('TYPE_MATTER');
  6083. return $typeOptions;
  6084. }
  6085. /**
  6086. * Returns a human readable version of the type
  6087. *
  6088. * @return string
  6089. */
  6090. public function getTypeLabel()
  6091. {
  6092. return self::getConstantsWithLabels('TYPE_MATTER');
  6093. }
  6094. /**
  6095. * @return bool
  6096. */
  6097. public function hasNoRecordsForDisclosure(): bool
  6098. {
  6099. if ($this->getMedicalRecordsCollection() === null) {
  6100. return false;
  6101. }
  6102. return $this->getMedicalRecordsCollection()->getDocuments()->isEmpty() && $this->getUnsortedRecordsCollection()->getDocuments()->isEmpty();
  6103. }
  6104. /**
  6105. * @return bool
  6106. */
  6107. public function hasNoRadiologyForDisclosure(): bool
  6108. {
  6109. // Get failed discs too for this consideration, as you can disclose failed discs.
  6110. return $this->getFailedDiscs()->isEmpty() && $this->getActiveDiscs()->isEmpty() && $this->getStudies()->isEmpty();
  6111. }
  6112. /**
  6113. * Returns true if the project has no items for disclosure (records and radiology)
  6114. *
  6115. * @return bool
  6116. */
  6117. public function hasNoItemsForDisclosure(): bool
  6118. {
  6119. $hasNoRecords = $this->hasNoRecordsForDisclosure();
  6120. $hasNoRadiology = $this->hasNoRadiologyForDisclosure();
  6121. return $hasNoRecords === true && $hasNoRadiology === true;
  6122. }
  6123. /**
  6124. * Returns true if one of the project's discs does not have the same status as it had pre-migration.
  6125. *
  6126. * @return bool
  6127. */
  6128. public function hasProjectFailedDiscMigration(): bool
  6129. {
  6130. foreach ($this->getDiscs() as $disc) {
  6131. if ($disc->hasDiscFailedMigration()) {
  6132. return true;
  6133. }
  6134. }
  6135. return false;
  6136. }
  6137. /**
  6138. * @return bool|null
  6139. */
  6140. public function getHideFromInvoicing(): ?bool
  6141. {
  6142. return $this->hideFromInvoicing;
  6143. }
  6144. /**
  6145. * @param bool|null $hideFromInvoicing
  6146. *
  6147. * @return self
  6148. */
  6149. public function setHideFromInvoicing(?bool $hideFromInvoicing): self
  6150. {
  6151. $this->hideFromInvoicing = $hideFromInvoicing;
  6152. return $this;
  6153. }
  6154. /**
  6155. * @return DateTimeInterface|null
  6156. */
  6157. public function getLastRenewalDate(): ?DateTimeInterface
  6158. {
  6159. return $this->lastRenewalDate;
  6160. }
  6161. /**
  6162. * @param DateTimeInterface|null $lastRenewalDate
  6163. *
  6164. * @return self
  6165. */
  6166. public function setLastRenewalDate(?DateTimeInterface $lastRenewalDate): self
  6167. {
  6168. $this->lastRenewalDate = $lastRenewalDate;
  6169. return $this;
  6170. }
  6171. /**
  6172. * @return DateTimeInterface|null
  6173. */
  6174. public function getNextRenewalDate(): ?DateTimeInterface
  6175. {
  6176. return $this->nextRenewalDate;
  6177. }
  6178. /**
  6179. * @param DateTimeInterface|null $nextRenewalDate
  6180. *
  6181. * @return self
  6182. */
  6183. public function setNextRenewalDate(?DateTimeInterface $nextRenewalDate): self
  6184. {
  6185. $this->nextRenewalDate = $nextRenewalDate;
  6186. return $this;
  6187. }
  6188. /**
  6189. * @return array|null
  6190. */
  6191. public function getRenewalNotificationSent(): ?array
  6192. {
  6193. return $this->renewalNotificationSent;
  6194. }
  6195. /**
  6196. * @param array|null $renewalNotificationSent
  6197. *
  6198. * @return self
  6199. */
  6200. public function setRenewalNotificationSent(?array $renewalNotificationSent): self
  6201. {
  6202. $this->renewalNotificationSent = $renewalNotificationSent;
  6203. return $this;
  6204. }
  6205. /**
  6206. * Returns whether remaining hosting renewal reminders are suppressed.
  6207. *
  6208. * @return bool
  6209. */
  6210. public function isProceedWithRenewal(): bool
  6211. {
  6212. return $this->proceedWithRenewal;
  6213. }
  6214. /**
  6215. * Set the current-cycle hosting renewal reminder preference.
  6216. *
  6217. * @param bool $proceedWithRenewal
  6218. */
  6219. public function setProceedWithRenewal(bool $proceedWithRenewal): self
  6220. {
  6221. $this->proceedWithRenewal = $proceedWithRenewal;
  6222. return $this;
  6223. }
  6224. /**
  6225. * @return DoctrineCollection<int, MatterLicenceRenewalLog>
  6226. */
  6227. public function getMatterLicenceRenewalLogs(): DoctrineCollection
  6228. {
  6229. return $this->matterLicenceRenewalLogs;
  6230. }
  6231. /**
  6232. * @param MatterLicenceRenewalLog $matterLicenceRenewalLog
  6233. *
  6234. * @return self
  6235. */
  6236. public function addMatterLicenceRenewalLog(MatterLicenceRenewalLog $matterLicenceRenewalLog): self
  6237. {
  6238. if (!$this->matterLicenceRenewalLogs->contains($matterLicenceRenewalLog)) {
  6239. $this->matterLicenceRenewalLogs[] = $matterLicenceRenewalLog;
  6240. $matterLicenceRenewalLog->setProject($this);
  6241. }
  6242. return $this;
  6243. }
  6244. /**
  6245. * @param MatterLicenceRenewalLog $matterLicenceRenewalLog
  6246. *
  6247. * @return self
  6248. */
  6249. public function removeMatterLicenceRenewalLog(MatterLicenceRenewalLog $matterLicenceRenewalLog): self
  6250. {
  6251. if ($this->matterLicenceRenewalLogs->removeElement($matterLicenceRenewalLog)) {
  6252. // set the owning side to null (unless already changed)
  6253. if ($matterLicenceRenewalLog->getProject() === $this) {
  6254. $matterLicenceRenewalLog->setProject(null);
  6255. }
  6256. }
  6257. return $this;
  6258. }
  6259. /**
  6260. * Get a valid Licence Renewal Term belonging to the Project
  6261. * For a term to be valid the Project's created date must fall between the effective renewal date and effective renewal end date
  6262. *
  6263. * @return LicenceRenewalTerm|null
  6264. */
  6265. public function getLicenceRenewalTerm(): ?LicenceRenewalTerm
  6266. {
  6267. $terms = $this->getAccount()->getLicenceRenewalTerms();
  6268. // if the Account doesn't have any associated terms return
  6269. if (empty($terms)) {
  6270. return null;
  6271. }
  6272. // find only the applicable term for this project
  6273. foreach ($terms as $term) {
  6274. // If we have an artificial created date to slot it into the renewal period, use that instead.
  6275. if ($this->getForcedRenewalCreated()) {
  6276. $validStartCriteria = $this->getForcedRenewalCreated() >= $term->getEffectiveDate();
  6277. $validEndCriteria = $term->getEffectiveEndDate() === null || ($this->getForcedRenewalCreated() <= $term->getEffectiveEndDate());
  6278. } else {
  6279. $validStartCriteria = $this->getCreated() >= $term->getEffectiveDate();
  6280. $validEndCriteria = $term->getEffectiveEndDate() === null || ($this->getCreated() <= $term->getEffectiveEndDate());
  6281. }
  6282. // return the qualifying term, effectiveEndDate of null indicates the last term, thus a recurring term
  6283. if ($validStartCriteria && $validEndCriteria) {
  6284. return $term;
  6285. }
  6286. };
  6287. return null;
  6288. }
  6289. /**
  6290. * @return string|null
  6291. */
  6292. public function getPermanentDeleteStatus(): ?string
  6293. {
  6294. return $this->permanentDeleteStatus;
  6295. }
  6296. /**
  6297. * @param string|null $permanentDeleteStatus
  6298. *
  6299. * @return self
  6300. */
  6301. public function setPermanentDeleteStatus(?string $permanentDeleteStatus): self
  6302. {
  6303. $this->permanentDeleteStatus = $permanentDeleteStatus;
  6304. return $this;
  6305. }
  6306. /**
  6307. * If there is a renewal date, it calculates the difference in days between it and today's date.
  6308. *
  6309. * @return int|null Number of days until renewal, or null if there's no renewal date.
  6310. */
  6311. public function getNumberOfDaysTillRenewal(): ?int
  6312. {
  6313. $nextRenewalDate = $this->getNextRenewalDate();
  6314. if ($nextRenewalDate !== null) {
  6315. $currentDate = (new DateTime())->setTime(0, 0, 0);
  6316. // Calculate the difference in days
  6317. $dueForRenewalInDays = $nextRenewalDate->diff($currentDate, false)->days;
  6318. $dueForRenewalInDays = max(0, $dueForRenewalInDays);
  6319. return $dueForRenewalInDays;
  6320. }
  6321. return null;
  6322. }
  6323. /**
  6324. * @return ClinicalSummary|null
  6325. */
  6326. public function getClinicalSummary(): ?ClinicalSummary
  6327. {
  6328. return $this->clinicalSummary;
  6329. }
  6330. /**
  6331. * @param ClinicalSummary|null $clinicalSummary
  6332. *
  6333. * @return self
  6334. */
  6335. public function setClinicalSummary(?ClinicalSummary $clinicalSummary): self
  6336. {
  6337. $this->clinicalSummary = $clinicalSummary;
  6338. return $this;
  6339. }
  6340. /**
  6341. * Returns an array of service request groups for this project.
  6342. *
  6343. * @return array
  6344. */
  6345. public function getServiceRequestGroups(): array
  6346. {
  6347. // If you have a property or logic for service request groups, return it here.
  6348. // Otherwise, return an empty array to avoid errors.
  6349. return [];
  6350. }
  6351. /**
  6352. * Sets the number of unread match messages for this project.
  6353. * Defaults to -1 if null is provided (no messages in thread/project at all)
  6354. *
  6355. * @param int|null $unreadMatchMessages
  6356. *
  6357. * @return self
  6358. */
  6359. public function setUnreadMatchMessages(?int $unreadMatchMessages): self
  6360. {
  6361. $this->unreadMatchMessages = $unreadMatchMessages ?? -1;
  6362. return $this;
  6363. }
  6364. /**
  6365. * Sets the Messages CTA text and count lozenge for this project.
  6366. *
  6367. * @param MatchMessagesCta|null $matchMessagesCta
  6368. *
  6369. * @return self
  6370. */
  6371. public function setMatchMessagesCta(?MatchMessagesCta $matchMessagesCta): self
  6372. {
  6373. $this->matchMessagesCta = $matchMessagesCta;
  6374. return $this;
  6375. }
  6376. /**
  6377. * Gets the Messages CTA for this project, defaulting to "View messages" without a count.
  6378. *
  6379. * @return MatchMessagesCta
  6380. */
  6381. public function getMatchMessagesCta(): MatchMessagesCta
  6382. {
  6383. return $this->matchMessagesCta ?? MatchMessagesCta::resolve(0);
  6384. }
  6385. /**
  6386. * Sets the conversation status for this project.
  6387. *
  6388. * @param string|null $conversationStatus
  6389. *
  6390. * @return self
  6391. */
  6392. public function setConversationStatus(?string $conversationStatus): self
  6393. {
  6394. $this->conversationStatus = $conversationStatus;
  6395. return $this;
  6396. }
  6397. /**
  6398. * Gets the conversation status for this project.
  6399. *
  6400. * @return string|null
  6401. */
  6402. public function getConversationStatus(): ?string
  6403. {
  6404. return $this->conversationStatus;
  6405. }
  6406. /**
  6407. * Gets the conversation status badge type for this project.
  6408. *
  6409. * @return string|null
  6410. */
  6411. public function getConversationStatusType(): ?string
  6412. {
  6413. return $this->conversationStatusType;
  6414. }
  6415. /**
  6416. * Sets the conversation status badge type for this project.
  6417. *
  6418. * @param string|null $conversationStatusType
  6419. *
  6420. * @return self
  6421. */
  6422. public function setConversationStatusType(?string $conversationStatusType): self
  6423. {
  6424. $this->conversationStatusType = $conversationStatusType;
  6425. return $this;
  6426. }
  6427. /**
  6428. * Gets the limited matter name for this project, which is used in the context of matters where the full matter name can not be exposed
  6429. *
  6430. * @return string|null
  6431. */
  6432. public function getLimitedMatterName(): ?string
  6433. {
  6434. return $this->limitedMatterName ?? null;
  6435. }
  6436. /**
  6437. * Sets the limited matter name for this project, which is used in the context of matters where the full matter name can not be exposed
  6438. *
  6439. * @param string|null $limitedMatterName
  6440. *
  6441. * @return self
  6442. */
  6443. public function setLimitedMatterName(?string $limitedMatterName): self
  6444. {
  6445. $this->limitedMatterName = $limitedMatterName;
  6446. return $this;
  6447. }
  6448. /**
  6449. * Returns the number of unread match messages for this project.
  6450. * Defaults to -1 if null is provided (no messages in thread/project at all)
  6451. *
  6452. * @return int
  6453. */
  6454. public function getUnreadMatchMessages(): int
  6455. {
  6456. return $this->unreadMatchMessages ?? -1;
  6457. }
  6458. /**
  6459. * Retrieves the counts of an array of Serviceable entities, grouped by their ServiceRequest status.
  6460. *
  6461. * @param array $serviceables
  6462. * @param bool $uninvoicedOnly
  6463. *
  6464. * @return array
  6465. */
  6466. private function getServiceableCountsByStatus(array $serviceables, $uninvoicedOnly = true)
  6467. {
  6468. $serviceableCounts = [];
  6469. // Go through each serviceable entity
  6470. foreach ($serviceables as $serviceable) {
  6471. // Check that it is in fact a Serviceable entity, and that it has a ServiceRequest
  6472. // attached to it.
  6473. if ($serviceable instanceof ServiceableInterface && $serviceable->getServiceRequest()) {
  6474. // If we are only looking for uninvoiced, and this serviceable entity has been billed for,
  6475. // continue to next element of the array.
  6476. if ($uninvoicedOnly && $serviceable->isBilled()) {
  6477. continue;
  6478. }
  6479. // Use the status integer as the key
  6480. $key = $serviceable->getServiceRequest()->getStatus();
  6481. // If the array element does not already exist, setup the defaults for it.
  6482. if (!isset($serviceableCounts[$key])) {
  6483. // Place the count and label as two separate elements of the array
  6484. // so we can easily access them using the status integer key
  6485. $serviceableCounts[$key] = [
  6486. 'label' => $serviceable->getServiceRequest()->getStatusLabel(),
  6487. 'count' => 0,
  6488. ];
  6489. }
  6490. // Increment the count for the status
  6491. $serviceableCounts[$key]['count']++;
  6492. }
  6493. }
  6494. // Sort the elements by key (status)
  6495. ksort($serviceableCounts);
  6496. return $serviceableCounts;
  6497. }
  6498. }