aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuidomain/fakes
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/fakes')
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/fakes/entities/common.scala41
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/fakes/entities/eligibility.scala72
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala35
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/Common.scala35
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/DocumentGen.scala7
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExportPatientGen.scala11
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExtractedDataGen.scala17
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/MedicalRecordGen.scala7
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ProviderTypeGen.scala14
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/fakes/entities/trialcuration.scala3
10 files changed, 161 insertions, 81 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/common.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/common.scala
index b259b07..7318ff6 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/common.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/common.scala
@@ -2,26 +2,28 @@ package xyz.driver.pdsuidomain.fakes.entities
import java.time.{LocalDate, LocalDateTime, LocalTime}
-import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId}
+import xyz.driver.core.generators.{nextDouble, nextOption}
+import xyz.driver.pdsuicommon.domain.{FuzzyValue, LongId, StringId, UuidId}
import xyz.driver.pdsuidomain.entities.{Trial, TrialHistory}
+
import scala.util.Random
object common {
import xyz.driver.core.generators
- def nextUuidId[T] = UuidId[T](generators.nextUuid())
+ def nextUuidId[T]: UuidId[T] = UuidId[T](generators.nextUuid())
- def nextLongId[T] = LongId[T](generators.nextInt(Int.MaxValue).toLong)
+ def nextLongId[T]: LongId[T] = LongId[T](generators.nextInt(Int.MaxValue).toLong)
- def nextStringId[T] = StringId[T](generators.nextString(maxLength = 20))
+ def nextStringId[T]: StringId[T] = StringId[T](generators.nextString(maxLength = 20))
- def nextTrialStatus = generators.oneOf[Trial.Status](Trial.Status.All)
+ def nextTrialStatus: Trial.Status = generators.oneOf[Trial.Status](Trial.Status.All)
- def nextPreviousTrialStatus = generators.oneOf[Trial.Status](Trial.Status.AllPrevious)
+ def nextPreviousTrialStatus: Trial.Status = generators.oneOf[Trial.Status](Trial.Status.AllPrevious)
- def nextLocalDateTime = LocalDateTime.of(nextLocalDate, LocalTime.MIDNIGHT)
+ def nextLocalDateTime: LocalDateTime = LocalDateTime.of(nextLocalDate, LocalTime.MIDNIGHT)
- def nextLocalDate = LocalDate.of(
+ def nextLocalDate: LocalDate = LocalDate.of(
1970 + Random.nextInt(68),
1 + Random.nextInt(12),
1 + Random.nextInt(28) // all months have at least 28 days
@@ -33,4 +35,27 @@ object common {
def nextTrialState = generators.oneOf[TrialHistory.State](TrialHistory.State.All)
+ def genBoundedRange[T](from: T, to: T)(implicit ord: Ordering[T]): (T, T) = {
+ if (ord.compare(from, to) > 0) {
+ to -> from
+ } else {
+ from -> to
+ }
+ }
+
+ def genBoundedRangeOption[T](from: T, to: T)(implicit ord: Ordering[T]): (Option[T], Option[T]) = {
+ val ranges = nextOption(from).map { left =>
+ val range = genBoundedRange(left, to)
+ range._1 -> nextOption(range._2)
+ }
+
+ ranges.map(_._1) -> ranges.flatMap(_._2)
+ }
+
+ def nextFuzzyValue(): FuzzyValue =
+ generators.oneOf[FuzzyValue](FuzzyValue.All)
+
+ def nextStartAndEndPages: (Option[Double], Option[Double]) =
+ genBoundedRangeOption[Double](nextDouble(), nextDouble())
+
}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/eligibility.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/eligibility.scala
new file mode 100644
index 0000000..7dc50be
--- /dev/null
+++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/eligibility.scala
@@ -0,0 +1,72 @@
+package xyz.driver.pdsuidomain.fakes.entities
+
+import xyz.driver.core.generators
+import xyz.driver.entities.clinic.{ClinicalRecord, TestOrder}
+import xyz.driver.entities.patient.CancerType
+import xyz.driver.entities.report.Report
+import xyz.driver.fakes
+import xyz.driver.pdsuidomain.entities.eligibility._
+
+object eligibility {
+ import xyz.driver.core.generators._
+
+ def nextMolecularEvidenceDocument(): MolecularEvidenceDocument =
+ MolecularEvidenceDocument(
+ documentType = xyz.driver.pdsuidomain.fakes.entities.rep.DocumentGen.nextDocumentType(),
+ providerType = xyz.driver.pdsuidomain.fakes.entities.rep.MedicalRecordGen.nextProviderType(),
+ providerName = nextOption(nextString(100)),
+ date = nextOption(nextDate()),
+ reportId = nextId[Report](),
+ reportType = fakes.entities.assays.nextAssayType(),
+ isDriverDocument = nextBoolean()
+ )
+
+ def nextClinicalEvidenceDocument(): ClinicalEvidenceDocument =
+ ClinicalEvidenceDocument(
+ documentType = xyz.driver.pdsuidomain.fakes.entities.rep.DocumentGen.nextDocumentType(),
+ providerType = xyz.driver.pdsuidomain.fakes.entities.rep.MedicalRecordGen.nextProviderType(),
+ providerName = nextOption(nextString(100)),
+ date = nextOption(nextDate()),
+ documentId = nextId[ClinicalEvidenceDocument](),
+ requestId = nextId[ClinicalRecord](),
+ isDriverDocument = nextBoolean()
+ )
+
+ def nextEvidenceDocument(): EvidenceDocument =
+ oneOf[EvidenceDocument](nextMolecularEvidenceDocument(),
+ nextClinicalEvidenceDocument(),
+ nextClinicalEvidenceDocument()) // For more clinical documents
+
+ def nextEvidence(): Evidence =
+ Evidence(
+ evidenceId = Option(nextId[Evidence]()),
+ evidenceText = nextString(100),
+ labelValue = xyz.driver.fakes.entities.labels.nextLabelValue(),
+ nextEvidenceDocument(),
+ isPrimaryValue = nextOption(nextBoolean())
+ )
+
+ def nextLabelWithEvidence(): LabelWithEvidence =
+ LabelWithEvidence(label = fakes.entities.labels.nextLabel(), evidence = Seq.empty)
+
+ def nextLabelMismatchRank(): LabelMismatchRank =
+ LabelMismatchRank(
+ label = fakes.entities.labels.nextLabel(),
+ score = nextInt(100),
+ trials = seqOf(xyz.driver.pdsuidomain.fakes.entities.export.nextExportTrialWithLabels()),
+ evidence = seqOf(nextEvidence())
+ )
+
+ def nextMismatchRankedLabels(): MismatchRankedLabels =
+ MismatchRankedLabels(data = seqOf(nextLabelMismatchRank()), labelVersion = nextInt(100))
+
+ def nextMatchedPatient(): MatchedPatient =
+ MatchedPatient(
+ patientId = nextId[MatchedPatient](),
+ name = fakes.entities.common.nextFullName[MatchedPatient](),
+ birthDate = nextDate(),
+ orderId = nextId[TestOrder](),
+ disease = generators.oneOf[CancerType](CancerType.Breast, CancerType.Lung, CancerType.Prostate),
+ patientDataStatus = fakes.entities.process.nextProcessStepExecutionStatus()
+ )
+}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala
new file mode 100644
index 0000000..7f3c410
--- /dev/null
+++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala
@@ -0,0 +1,35 @@
+package xyz.driver.pdsuidomain.fakes.entities
+
+import xyz.driver.entities.labels.Label
+import xyz.driver.pdsuidomain.entities.{Arm, Criterion, Trial}
+import xyz.driver.pdsuidomain.entities.export.trial._
+
+object export {
+ import xyz.driver.core.generators._
+ import common._
+
+ def nextExportTrialArm(): ExportTrialArm =
+ ExportTrialArm(armId = nextLongId[Arm], armName = nextString(100))
+
+ def nextExportTrialLabelCriterion(): ExportTrialLabelCriterion =
+ ExportTrialLabelCriterion(
+ criterionId = nextLongId[Criterion],
+ value = nextOption[Boolean](nextBoolean()),
+ labelId = nextLongId[Label],
+ armIds = setOf(nextLongId[Arm]),
+ criteria = nextString(100),
+ isCompound = nextBoolean(),
+ isDefining = nextBoolean()
+ )
+
+ def nextExportTrialWithLabels(): ExportTrialWithLabels =
+ ExportTrialWithLabels(
+ nctId = nextStringId[Trial],
+ trialId = nextUuidId[Trial],
+ condition = nextString(100),
+ lastReviewed = nextLocalDateTime,
+ labelVersion = nextInt(100).toLong,
+ arms = listOf(nextExportTrialArm()),
+ criteria = listOf(nextExportTrialLabelCriterion())
+ )
+}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/Common.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/Common.scala
deleted file mode 100644
index 9618eed..0000000
--- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/Common.scala
+++ /dev/null
@@ -1,35 +0,0 @@
-package xyz.driver.pdsuidomain.fakes.entities.rep
-
-import xyz.driver.core.generators
-import xyz.driver.core.generators._
-import xyz.driver.pdsuicommon.domain.FuzzyValue
-
-private[rep] object Common {
- def genBoundedRange[T](from: T, to: T)(implicit ord: Ordering[T]): (T, T) = {
- if (ord.compare(from, to) > 0) {
- to -> from
- } else {
- from -> to
- }
- }
-
- def genBoundedRangeOption[T](from: T, to: T)(implicit ord: Ordering[T]): (Option[T], Option[T]) = {
- val ranges = nextOption(from)
- .map(left => genBoundedRange(left, to))
- .map {
- case (left, right) =>
- left -> nextOption(right)
- }
-
- ranges.map(_._1) -> ranges.flatMap(_._2)
- }
-
- def nextFuzzyValue(): FuzzyValue = {
- generators.oneOf[FuzzyValue](FuzzyValue.All)
- }
-
- def nextStartAndEndPages: (Option[Double], Option[Double]) = {
- genBoundedRangeOption[Double](nextDouble(), nextDouble())
- }
-
-}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/DocumentGen.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/DocumentGen.scala
index 10349bb..6d5330e 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/DocumentGen.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/DocumentGen.scala
@@ -4,6 +4,7 @@ import java.time.LocalDate
import xyz.driver.core.generators
import xyz.driver.core.generators.{nextBoolean, nextDouble, nextOption, nextString}
+import xyz.driver.pdsuidomain.fakes.entities.common._
import xyz.driver.pdsuicommon.domain.{LongId, TextJson, User}
import xyz.driver.pdsuidomain.entities._
import xyz.driver.pdsuidomain.fakes.entities.common.{nextLocalDate, nextLocalDateTime, nextLongId, nextStringId}
@@ -17,13 +18,13 @@ object DocumentGen {
}
private def nextDates() =
- Common.genBoundedRangeOption[LocalDate](nextLocalDate, nextLocalDate)
+ genBoundedRangeOption[LocalDate](nextLocalDate, nextLocalDate)
private def nextStartAndEndPagesOption() =
- Common.nextStartAndEndPages
+ nextStartAndEndPages
private def nextStartAndEndPage() =
- Common.genBoundedRange(nextDouble(), nextDouble())
+ genBoundedRange(nextDouble(), nextDouble())
def nextDocumentStatus(): Document.Status =
Document.Status.New
diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExportPatientGen.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExportPatientGen.scala
index c2909f3..e3ef6bc 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExportPatientGen.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExportPatientGen.scala
@@ -1,14 +1,11 @@
package xyz.driver.pdsuidomain.fakes.entities.rep
import xyz.driver.core.generators._
+import xyz.driver.entities.labels.Label
import xyz.driver.pdsuicommon.domain.{LongId, UuidId}
+import xyz.driver.pdsuidomain.fakes.entities.common._
import xyz.driver.pdsuidomain.entities._
-import xyz.driver.pdsuidomain.entities.export.patient.{
- ExportPatientLabel,
- ExportPatientLabelEvidence,
- ExportPatientLabelEvidenceDocument,
- ExportPatientWithLabels
-}
+import xyz.driver.pdsuidomain.entities.export.patient._
import xyz.driver.pdsuidomain.fakes.entities.common.{nextLocalDate, nextLongId}
object ExportPatientGen {
@@ -41,7 +38,7 @@ object ExportPatientGen {
def nextExportPatientLabelEvidence(documentId: LongId[Document]): ExportPatientLabelEvidence = {
ExportPatientLabelEvidence(
id = nextLongId[ExtractedData],
- value = Common.nextFuzzyValue(),
+ value = nextFuzzyValue(),
evidenceText = nextString(),
document = nextExportPatientLabelEvidenceDocument(documentId)
)
diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExtractedDataGen.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExtractedDataGen.scala
index 8ac07d0..8e77445 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExtractedDataGen.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExtractedDataGen.scala
@@ -1,6 +1,7 @@
package xyz.driver.pdsuidomain.fakes.entities.rep
import xyz.driver.core.generators._
+import xyz.driver.entities.labels.{Label, LabelCategory}
import xyz.driver.pdsuicommon.domain.{LongId, TextJson}
import xyz.driver.pdsuidomain.entities._
import xyz.driver.pdsuidomain.entities.ExtractedData.Meta
@@ -46,7 +47,7 @@ object ExtractedDataGen {
def nextExtractedDataMetaEvidence(): Meta.Evidence = {
val layersPosition =
- Common.genBoundedRange[ExtractedData.Meta.TextLayerPosition](
+ genBoundedRange[ExtractedData.Meta.TextLayerPosition](
nextExtractedDataMetaTextLayerPosition(),
nextExtractedDataMetaTextLayerPosition()
)
@@ -65,14 +66,8 @@ object ExtractedDataGen {
)
}
- def nextExtractedDataMetaJson(): TextJson[Meta] = {
- TextJson(
- ExtractedData.Meta(
- nextExtractedDataMetaKeyword(),
- nextExtractedDataMetaEvidence()
- )
- )
- }
+ def nextExtractedDataMetaJson(): TextJson[Meta] =
+ TextJson(ExtractedData.Meta(nextExtractedDataMetaKeyword(), nextExtractedDataMetaEvidence()))
def nextExtractedData(documentId: LongId[Document]): ExtractedData = {
ExtractedData(
@@ -89,8 +84,8 @@ object ExtractedDataGen {
id = nextLongId[ExtractedDataLabel],
dataId = nextLongId[ExtractedData],
labelId = nextOption(nextLongId[Label]),
- categoryId = nextOption(nextLongId[Category]),
- value = nextOption(Common.nextFuzzyValue())
+ categoryId = nextOption(nextLongId[LabelCategory]),
+ value = nextOption(nextFuzzyValue())
)
}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/MedicalRecordGen.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/MedicalRecordGen.scala
index 7221e66..023dc00 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/MedicalRecordGen.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/MedicalRecordGen.scala
@@ -4,7 +4,7 @@ import xyz.driver.pdsuidomain.entities._
import xyz.driver.core.generators
import xyz.driver.core.generators._
import xyz.driver.pdsuicommon.domain.{LongId, TextJson, User}
-import xyz.driver.pdsuidomain.fakes.entities.common.{nextLocalDateTime, nextLongId, nextStringId, nextUuidId}
+import xyz.driver.pdsuidomain.fakes.entities.common._
object MedicalRecordGen {
private val maxItemsInCollectionNumber: Int = 50
@@ -126,7 +126,7 @@ object MedicalRecordGen {
}
def nextMedicalRecordIssue(): MedicalRecordIssue = {
- val pages = Common.nextStartAndEndPages
+ val pages = nextStartAndEndPages
MedicalRecordIssue(
id = nextLongId[MedicalRecordIssue],
@@ -141,4 +141,7 @@ object MedicalRecordGen {
)
}
+ def nextProviderType(): ProviderType =
+ ProviderType(id = nextLongId[ProviderType], name = nextString())
+
}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ProviderTypeGen.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ProviderTypeGen.scala
deleted file mode 100644
index 168f7af..0000000
--- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ProviderTypeGen.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-package xyz.driver.pdsuidomain.fakes.entities.rep
-
-import xyz.driver.core.generators.nextString
-import xyz.driver.pdsuidomain.entities.ProviderType
-import xyz.driver.pdsuidomain.fakes.entities.common.nextLongId
-
-object ProviderTypeGen {
- def nextProviderType(): ProviderType = {
- ProviderType(
- id = nextLongId[ProviderType],
- name = nextString()
- )
- }
-}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/trialcuration.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/trialcuration.scala
index fe5bf09..fcd833a 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/trialcuration.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/trialcuration.scala
@@ -1,5 +1,6 @@
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
@@ -51,7 +52,7 @@ object trialcuration {
id = nextLongId[CriterionLabel],
labelId = Option(nextLongId[Label]),
criterionId = criterionId,
- categoryId = Option(nextLongId[Category]),
+ categoryId = Option(nextLongId[LabelCategory]),
value = Option(generators.nextBoolean()),
isDefining = generators.nextBoolean()
)