aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/MedicalRecordMetaGen.scala
blob: 1536c654e99ed12016354443d0d33e582e8fc681 (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
package xyz.driver.pdsuidomain.fakes.entities.rep

import xyz.driver.pdsuidomain.entities.MedicalRecord
import xyz.driver.core.generators
import xyz.driver.core.generators._

object MedicalRecordMetaGen {
  private val maxItemsInCollectionNumber = 50
  private val pageMaxNumber = 1000

  private val medicalRecordMetas = {
    Set(
      () => nextMedicalRecordMetaReorder,
      () => nextMedicalRecordMetaDuplicate,
      () => nextMedicalRecordMetaRotation
    )
  }


  def nextMedicalRecordMetaReorder: MedicalRecord.Meta.Reorder = {
    val itemsNumber =
      maxItemsInCollectionNumber
    val items = scala.util.Random
      .shuffle(Seq.tabulate(itemsNumber)(identity))

    MedicalRecord.Meta.Reorder(
      predicted = nextOption(nextBoolean),
      items = items
    )
  }


  def nextMedicalRecordMetaDuplicate: MedicalRecord.Meta.Duplicate = {
    val startPageGen =
      nextInt(pageMaxNumber, minValue = 0)
    val endPageGen =
      nextInt(pageMaxNumber, startPageGen)

    MedicalRecord.Meta.Duplicate(
      predicted = nextOption(nextBoolean),
      startPage = startPageGen.toDouble,
      endPage = endPageGen.toDouble,
      startOriginalPage = startPageGen.toDouble,
      endOriginalPage = nextOption(endPageGen.toDouble)
    )
  }

  def nextMedicalRecordMetaRotation: MedicalRecord.Meta.Rotation = {
    val items =
      Array.tabulate(maxItemsInCollectionNumber)(
        index => nextString() -> index
      ).toMap

    MedicalRecord.Meta.Rotation(
      predicted = nextOption(nextBoolean()),
      items = items
    )
  }

  def nextMedicalRecordMeta: MedicalRecord.Meta = {
    generators.oneOf(medicalRecordMetas)()
  }
}