aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuidomain/ListResponse.scala
blob: b0effdd9b3ae29e3ad0acb6711de8d6e7de1b104 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package xyz.driver.pdsuidomain

import java.time.LocalDateTime

import xyz.driver.pdsuicommon.concurrent.BridgeUploadQueue
import xyz.driver.pdsuicommon.db.Pagination
import xyz.driver.pdsuidomain.entities._
import xyz.driver.pdsuidomain.services.CriterionService.RichCriterion
import xyz.driver.pdsuidomain.services.ExtractedDataService.RichExtractedData
import xyz.driver.pdsuidomain.services.PatientCriterionService.RichPatientCriterion
import xyz.driver.pdsuidomain.services.PatientEligibleTrialService.RichPatientEligibleTrial
import xyz.driver.pdsuidomain.services.PatientHypothesisService.RichPatientHypothesis
import xyz.driver.pdsuidomain.services.PatientLabelService.RichPatientLabel

@SuppressWarnings(Array("org.wartremover.warts.FinalCaseClass"))
case class ListResponse[+T](items: Seq[T], meta: ListResponse.Meta)

object ListResponse {

  final case class Meta(itemsCount: Int, pageNumber: Int, pageSize: Int, lastUpdate: Option[LocalDateTime])

  object Meta {
    def apply(itemsCount: Int, pagination: Pagination, lastUpdate: Option[LocalDateTime]): Meta = {
      Meta(
        itemsCount,
        pagination.pageNumber,
        pagination.pageSize,
        lastUpdate
      )
    }
  }

  trait MedicalRecordListResponse        extends ListResponse[MedicalRecord]
  trait MedicalRecordIssueListResponse   extends ListResponse[MedicalRecordIssue]
  trait MedicalRecordHistoryListResponse extends ListResponse[MedicalRecordHistory]
  trait DocumentListResponse             extends ListResponse[Document]
  trait DocumentIssueListResponse        extends ListResponse[DocumentIssue]
  trait DocumentHistoryListResponse      extends ListResponse[DocumentHistory]
  trait RichExtractedDataListResponse    extends ListResponse[RichExtractedData]
  trait DocumentTypeListResponse         extends ListResponse[DocumentType]
  trait ProviderTypeListResponse         extends ListResponse[ProviderType]

  trait TrialListResponse                      extends ListResponse[Trial]
  trait TrialIssueListResponse                 extends ListResponse[TrialIssue]
  trait TrialHistoryListResponse               extends ListResponse[TrialHistory]
  trait ArmListResponse                        extends ListResponse[Arm]
  trait InterventionWithArmsListResponse       extends ListResponse[InterventionWithArms]
  trait EligibilityArmWithDiseasesListResponse extends ListResponse[EligibilityArmWithDiseases]
  trait SlotArmListResponse                    extends ListResponse[SlotArm]
  trait RichCriterionListResponse              extends ListResponse[RichCriterion]
  trait InterventionTypeListResponse           extends ListResponse[InterventionType]
  trait StudyDesignListResponse                extends ListResponse[StudyDesign]
  trait HypothesisListResponse                 extends ListResponse[Hypothesis]

  trait PatientListResponse                  extends ListResponse[Patient]
  trait PatientIssueListResponse             extends ListResponse[PatientIssue]
  trait PatientHistoryListResponse           extends ListResponse[PatientHistory]
  trait PatientLabelListResponse             extends ListResponse[PatientLabel]
  trait RichPatientLabelListResponse         extends ListResponse[RichPatientLabel]
  trait RichPatientCriterionListResponse     extends ListResponse[RichPatientCriterion]
  trait RichPatientEligibleTrialListResponse extends ListResponse[RichPatientEligibleTrial]
  trait RichPatientHypothesisListResponse    extends ListResponse[RichPatientHypothesis]
  trait PatientLabelEvidenceViewListResponse extends ListResponse[PatientLabelEvidenceView]

  trait QueueUploadItemListResponse extends ListResponse[BridgeUploadQueue.Item]

}