aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/treatmentmatching.scala
blob: 35aa5ef7110426a60e4e981912169113b9992d98 (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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
package xyz.driver.pdsuidomain.fakes.entities

import xyz.driver.entities.labels.Label
import xyz.driver.fakes
import xyz.driver.pdsuicommon.domain.{LongId, StringId, User}
import xyz.driver.pdsuidomain.entities._
import xyz.driver.pdsuidomain.services.PatientCriterionService.{DraftPatientCriterion, RichPatientCriterion}
import xyz.driver.pdsuidomain.services.PatientEligibleTrialService.RichPatientEligibleTrial
import xyz.driver.pdsuidomain.services.PatientHypothesisService.RichPatientHypothesis
import xyz.driver.pdsuidomain.services.PatientLabelService.RichPatientLabel

object treatmentmatching {
  import common._
  import xyz.driver.core.generators

  def nextPatientOrderId: PatientOrderId = PatientOrderId(generators.nextUuid())

  def nextPatientAction: PatientHistory.Action =
    generators.oneOf[PatientHistory.Action](PatientHistory.Action.All)

  def nextPatientState: PatientHistory.State =
    generators.oneOf[PatientHistory.State](PatientHistory.State.All)

  def nextPatient(): Patient = Patient(
    id = nextUuidId[Patient],
    status = nextPatientStatus,
    name = nextFullName[Patient],
    dob = nextLocalDate,
    assignee = generators.nextOption(nextStringId[User]),
    previousStatus = generators.nextOption(nextPatientStatus),
    previousAssignee = generators.nextOption(nextStringId[User]),
    lastActiveUserId = generators.nextOption(nextStringId[User]),
    isUpdateRequired = generators.nextBoolean(),
    disease = nextCancerType,
    orderId = nextPatientOrderId,
    lastUpdate = nextLocalDateTime
  )

  def nextPatientLabel(): PatientLabel = PatientLabel(
    id = nextLongId[PatientLabel],
    patientId = nextUuidId[Patient],
    labelId = nextLongId[Label],
    score = generators.nextInt(100),
    primaryValue = generators.nextOption(fakes.entities.labels.nextLabelValue()),
    verifiedPrimaryValue = generators.nextOption(fakes.entities.labels.nextLabelValue()),
    isImplicitMatch = generators.nextBoolean(),
    isVisible = generators.nextBoolean()
  )

  def nextRichPatientLabel(): RichPatientLabel = RichPatientLabel(
    patientLabel = nextPatientLabel(),
    isVerified = generators.nextBoolean()
  )

  def nextPatientCriterion(): PatientCriterion = PatientCriterion(
    id = nextLongId[PatientCriterion],
    patientLabelId = nextLongId[PatientLabel],
    trialId = generators.nextInt(Int.MaxValue).toLong,
    nctId = nextStringId[Trial],
    criterionId = nextLongId[Criterion],
    criterionText = generators.nextString(),
    criterionValue = generators.nextOption(generators.nextBoolean()),
    criterionIsDefining = generators.nextBoolean(),
    eligibilityStatus = generators.nextOption(fakes.entities.labels.nextLabelValue()),
    verifiedEligibilityStatus = generators.nextOption(fakes.entities.labels.nextLabelValue()),
    isVerified = generators.nextBoolean(),
    isVisible = generators.nextBoolean(),
    lastUpdate = nextLocalDateTime
  )

  def nextDraftPatientCriterion(): DraftPatientCriterion = DraftPatientCriterion(
    id = nextLongId[PatientCriterion],
    eligibilityStatus = generators.nextOption(fakes.entities.labels.nextLabelValue()),
    isVerified = generators.nextOption(generators.nextBoolean())
  )

  def nextPatientCriterionArm(criterionId: LongId[PatientCriterion]): PatientCriterionArm = PatientCriterionArm(
    patientCriterionId = criterionId,
    armId = nextLongId[Arm],
    armName = generators.nextString()
  )

  def nextRichPatientCriterion(): RichPatientCriterion = {
    val patientCriterion = nextPatientCriterion()
    RichPatientCriterion(
      patientCriterion = patientCriterion,
      labelId = nextLongId[Label],
      armList = List(
        nextPatientCriterionArm(patientCriterion.id),
        nextPatientCriterionArm(patientCriterion.id),
        nextPatientCriterionArm(patientCriterion.id)
      )
    )
  }

  def nextPatientLabelEvidenceView(): PatientLabelEvidenceView = PatientLabelEvidenceView(
    id = nextLongId[PatientLabelEvidence],
    value = fakes.entities.labels.nextLabelValue(),
    evidenceText = generators.nextString(),
    documentId = generators.nextOption(nextLongId[Document]),
    evidenceId = generators.nextOption(nextLongId[ExtractedData]),
    reportId = generators.nextOption(nextUuidId[DirectReport]),
    documentType = nextDocumentType(),
    date = generators.nextOption(nextLocalDate),
    providerType = nextProviderType(),
    patientId = nextUuidId[Patient],
    labelId = nextLongId[Label],
    isImplicitMatch = generators.nextBoolean()
  )

  def nextPatientTrialArmGroupView(trialId: StringId[Trial]): PatientTrialArmGroupView = PatientTrialArmGroupView(
    id = nextLongId[PatientTrialArmGroup],
    patientId = nextUuidId[Patient],
    trialId = trialId,
    hypothesisId = nextUuidId[Hypothesis],
    eligibilityStatus = generators.nextOption(fakes.entities.labels.nextLabelValue()),
    verifiedEligibilityStatus = generators.nextOption(fakes.entities.labels.nextLabelValue()),
    isVerified = generators.nextBoolean()
  )

  def nextRichPatientEligibleTrial(): RichPatientEligibleTrial = {
    val patientCriterionId = nextLongId[PatientCriterion]
    val trial              = trialcuration.nextTrial()
    RichPatientEligibleTrial(
      trial = trial,
      group = nextPatientTrialArmGroupView(trial.id),
      arms = List(
        nextPatientCriterionArm(patientCriterionId),
        nextPatientCriterionArm(patientCriterionId),
        nextPatientCriterionArm(patientCriterionId)
      )
    )
  }

  def nextPatientHypothesis(): PatientHypothesis = PatientHypothesis(
    id = nextUuidId[PatientHypothesis],
    patientId = nextUuidId[Patient],
    hypothesisId = nextUuidId[Hypothesis],
    rationale = Option(generators.nextString()),
    matchedTrials = generators.nextInt(Int.MaxValue).toLong
  )

  def nextRichPatientHypothesis(): RichPatientHypothesis = RichPatientHypothesis(
    patientHypothesis = nextPatientHypothesis(),
    isRequired = generators.nextBoolean()
  )

  def nextPatientIssue(): PatientIssue = PatientIssue(
    id = nextLongId[PatientIssue],
    userId = nextStringId[User],
    patientId = nextUuidId[Patient],
    lastUpdate = nextLocalDateTime,
    isDraft = generators.nextBoolean(),
    text = generators.nextString(),
    archiveRequired = generators.nextBoolean()
  )

  def nextPatientHistory(): PatientHistory = PatientHistory(
    id = nextLongId[PatientHistory],
    executor = nextStringId[User],
    patientId = nextUuidId[Patient],
    state = nextPatientState,
    action = nextPatientAction,
    created = nextLocalDateTime
  )

}