aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/trialcuration.scala
blob: fcd833a9d3549d2281058d728934f1fc89da8088 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
package xyz.driver.pdsuidomain.fakes.entities

import xyz.driver.entities.labels.{Label, LabelCategory}
import xyz.driver.pdsuicommon.domain.{LongId, User}
import xyz.driver.pdsuidomain.entities._
import xyz.driver.pdsuidomain.services.CriterionService.RichCriterion

object trialcuration {
  import xyz.driver.core.generators
  import common._
  import xyz.driver.pdsuidomain.entities.InterventionType._

  def nextTrial(): Trial = Trial(
    id = nextStringId[Trial],
    externalId = nextUuidId[Trial],
    status = nextTrialStatus,
    assignee = Option(nextStringId[User]),
    previousStatus = Option(nextPreviousTrialStatus),
    previousAssignee = Option(nextStringId[User]),
    lastActiveUserId = Option(nextStringId[User]),
    lastUpdate = nextLocalDateTime,
    condition = nextCondition,
    phase = generators.nextString(),
    hypothesisId = Option(nextUuidId[Hypothesis]),
    studyDesignId = Option(nextLongId[StudyDesign]),
    originalStudyDesign = Option(generators.nextString()),
    isPartner = generators.nextBoolean(),
    overview = Option(generators.nextString()),
    overviewTemplate = generators.nextString(),
    isUpdated = generators.nextBoolean(),
    title = generators.nextString(),
    originalTitle = generators.nextString()
  )

  def nextArm(): Arm = Arm(
    id = nextLongId[Arm],
    name = generators.nextString(),
    originalName = generators.nextString(),
    trialId = nextStringId[Trial],
    deleted = Option(nextLocalDateTime)
  )

  def nextCriterion(): Criterion = Criterion(
    id = nextLongId[Criterion],
    trialId = nextStringId[Trial],
    text = Option(generators.nextString()),
    isCompound = generators.nextBoolean(),
    meta = generators.nextString()
  )

  def nextCriterionLabel(criterionId: LongId[Criterion]): CriterionLabel = CriterionLabel(
    id = nextLongId[CriterionLabel],
    labelId = Option(nextLongId[Label]),
    criterionId = criterionId,
    categoryId = Option(nextLongId[LabelCategory]),
    value = Option(generators.nextBoolean()),
    isDefining = generators.nextBoolean()
  )

  def nextRichCriterion(): RichCriterion = {
    val criterion = nextCriterion()
    RichCriterion(
      criterion = criterion,
      armIds = Seq(nextLongId[Arm], nextLongId[Arm]),
      labels = Seq(
        nextCriterionLabel(criterion.id),
        nextCriterionLabel(criterion.id)
      )
    )
  }

  def nextIntervention(): Intervention = Intervention(
    id = nextLongId[Intervention],
    trialId = nextStringId[Trial],
    name = generators.nextString(),
    originalName = generators.nextString(),
    typeId = Option(nextLongId[InterventionType]),
    originalType = Option(generators.nextString()),
    dosage = generators.nextString(),
    originalDosage = generators.nextString(),
    isActive = generators.nextBoolean(),
    deliveryMethod = Option(generators.nextString())
  )

  def nextInterventionArm(interventionId: LongId[Intervention]): InterventionArm = InterventionArm(
    interventionId = interventionId,
    armId = nextLongId[Arm]
  )

  def nextInterventionWithArms(): InterventionWithArms = {
    val intervention = nextIntervention()
    InterventionWithArms(
      intervention = intervention,
      arms = List(
        nextInterventionArm(intervention.id),
        nextInterventionArm(intervention.id),
        nextInterventionArm(intervention.id)
      )
    )
  }

  def nextTrialIssue(): TrialIssue = TrialIssue(
    id = nextLongId[TrialIssue],
    userId = nextStringId[User],
    trialId = nextStringId[Trial],
    lastUpdate = nextLocalDateTime,
    isDraft = generators.nextBoolean(),
    text = generators.nextString(),
    evidence = generators.nextString(),
    archiveRequired = generators.nextBoolean(),
    meta = generators.nextString()
  )

  def nextTrialHistory(): TrialHistory = TrialHistory(
    id = nextLongId[TrialHistory],
    executor = nextStringId[User],
    trialId = nextStringId[Trial],
    state = nextTrialState,
    action = nextTrialAction,
    created = nextLocalDateTime
  )

  def nextHypothesis(): Hypothesis = Hypothesis(
    id = nextUuidId[Hypothesis],
    name = generators.nextString(),
    treatmentType = generators.nextString(),
    description = generators.nextString()
  )

  def nextStudyDesign(): StudyDesign = StudyDesign(
    id = nextLongId[StudyDesign],
    name = generators.nextString()
  )

  def nextInterventionType(): InterventionType = generators.oneOf[InterventionType](
    RadiationTherapy,
    Chemotherapy,
    TargetedTherapy,
    Immunotherapy,
    Surgery,
    HormoneTherapy,
    Other,
    Radiation,
    SurgeryProcedure
  )

}