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.scala29
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/fakes/entities/recordprocessing.scala40
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/fakes/entities/treatmentmatching.scala123
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/fakes/entities/trialcuration.scala57
4 files changed, 157 insertions, 92 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 0ac2be5..2aaa251 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/common.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/common.scala
@@ -7,6 +7,7 @@ import xyz.driver.entities.common.FullName
import xyz.driver.entities.patient.CancerType
import xyz.driver.pdsuicommon.concurrent.BridgeUploadQueue
import xyz.driver.pdsuicommon.domain.{LongId, StringId, TextJson, UuidId}
+import xyz.driver.pdsuidomain.ListResponse
import xyz.driver.pdsuidomain.entities._
import scala.util.Random
@@ -85,10 +86,38 @@ object common {
)
}
+ def nextBridgeUploadQueueItemListResponse(): ListResponse[BridgeUploadQueue.Item] = {
+ val xs: Seq[BridgeUploadQueue.Item] = Seq.fill(3)(nextBridgeUploadQueueItem())
+ nextListResponse(xs)
+ }
+
def nextDocumentType(): DocumentType = generators.oneOf[DocumentType](DocumentType.All: _*)
def nextProviderType(): ProviderType = generators.oneOf[ProviderType](ProviderType.All: _*)
+ def nextDocumentTypeListResponse(): ListResponse[DocumentType] = {
+ val xs: Seq[DocumentType] = Seq.fill(3)(nextDocumentType())
+ nextListResponse(xs)
+ }
+
+ def nextProviderTypeListResponse(): ListResponse[ProviderType] = {
+ val xs: Seq[ProviderType] = Seq.fill(3)(nextProviderType())
+ nextListResponse(xs)
+ }
+
def nextTextJson[T](obj: T): TextJson[T] = TextJson(obj)
+ def nextListResponse[T](xs: Seq[T]): ListResponse[T] = {
+ val pageSize = generators.nextInt(xs.size, 1)
+ ListResponse(
+ items = xs,
+ meta = ListResponse.Meta(
+ itemsCount = xs.size,
+ pageNumber = generators.nextInt(xs.size / pageSize),
+ pageSize = pageSize,
+ lastUpdate = generators.nextOption(nextLocalDateTime)
+ )
+ )
+ }
+
}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/recordprocessing.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/recordprocessing.scala
index d2a648c..c0c3391 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/recordprocessing.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/recordprocessing.scala
@@ -6,6 +6,7 @@ import xyz.driver.core.generators
import xyz.driver.core.generators._
import xyz.driver.entities.labels.{Label, LabelCategory, LabelValue}
import xyz.driver.pdsuicommon.domain.{LongId, TextJson, User}
+import xyz.driver.pdsuidomain.ListResponse
import xyz.driver.pdsuidomain.entities.ExtractedData.Meta
import xyz.driver.pdsuidomain.entities._
import xyz.driver.pdsuidomain.fakes.entities.common._
@@ -186,12 +187,12 @@ object recordprocessing {
)
}
- def nextDocumentIssue(documentId: LongId[Document] = nextLongId): DocumentIssue = {
+ def nextDocumentIssue(): DocumentIssue = {
val (startPage, endPage) = nextStartAndEndPagesOption
DocumentIssue(
id = nextLongId[DocumentIssue],
userId = nextStringId[User],
- documentId = documentId,
+ documentId = nextLongId[Document],
startPage = startPage,
endPage = endPage,
lastUpdate = nextLocalDateTime,
@@ -281,4 +282,39 @@ object recordprocessing {
)
}
+ def nextMedicalRecordListResponse(): ListResponse[MedicalRecord] = {
+ val xs: Seq[MedicalRecord] = Seq.fill(3)(nextMedicalRecord())
+ nextListResponse(xs)
+ }
+
+ def nextMedicalRecordIssueListResponse(): ListResponse[MedicalRecordIssue] = {
+ val xs: Seq[MedicalRecordIssue] = Seq.fill(3)(nextMedicalRecordIssue())
+ nextListResponse(xs)
+ }
+
+ def nextMedicalRecordHistoryListResponse(): ListResponse[MedicalRecordHistory] = {
+ val xs: Seq[MedicalRecordHistory] = Seq.fill(3)(nextMedicalRecordHistory())
+ nextListResponse(xs)
+ }
+
+ def nextDocumentListResponse(): ListResponse[Document] = {
+ val xs: Seq[Document] = Seq.fill(3)(nextDocument())
+ nextListResponse(xs)
+ }
+
+ def nextDocumentIssueListResponse(): ListResponse[DocumentIssue] = {
+ val xs: Seq[DocumentIssue] = Seq.fill(3)(nextDocumentIssue())
+ nextListResponse(xs)
+ }
+
+ def nextDocumentHistoryListResponse(): ListResponse[DocumentHistory] = {
+ val xs: Seq[DocumentHistory] = Seq.fill(3)(nextDocumentHistory())
+ nextListResponse(xs)
+ }
+
+ def nextRichExtractedDataListResponse(): ListResponse[RichExtractedData] = {
+ val xs: Seq[RichExtractedData] = Seq.fill(3)(nextRichExtractedData())
+ nextListResponse(xs)
+ }
+
}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/treatmentmatching.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/treatmentmatching.scala
index f8244f8..d5adc32 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/treatmentmatching.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/treatmentmatching.scala
@@ -14,6 +14,26 @@ object treatmentmatching {
import common._
import xyz.driver.core.generators
+ final case class DraftPatientCriterionList(list: List[DraftPatientCriterion])
+ object DraftPatientCriterionList {
+ import spray.json._
+ import xyz.driver.pdsuidomain.formats.json.sprayformats.patientcriterion._
+
+ implicit val draftPatientCriterionListFormat: RootJsonFormat[DraftPatientCriterionList] =
+ new RootJsonFormat[DraftPatientCriterionList] {
+ override def write(obj: DraftPatientCriterionList): JsValue = {
+ JsArray(obj.list.map(_.toJson).toVector)
+ }
+
+ override def read(json: JsValue): DraftPatientCriterionList = json match {
+ case j: JsObject =>
+ DraftPatientCriterionList(draftPatientCriterionListReader.read(j))
+
+ case _ => deserializationError(s"Expected List of DraftPatientCriterion json object, but got $json")
+ }
+ }
+ }
+
def nextPatientOrderId: PatientOrderId = PatientOrderId(generators.nextUuid())
def nextPatientAction: PatientHistory.Action =
@@ -75,6 +95,10 @@ object treatmentmatching {
isVerified = generators.nextOption(generators.nextBoolean())
)
+ def nextDraftPatientCriterionList(): DraftPatientCriterionList = {
+ DraftPatientCriterionList(List.fill(3)(nextDraftPatientCriterion()))
+ }
+
def nextPatientCriterionArm(criterionId: LongId[PatientCriterion]): PatientCriterionArm = PatientCriterionArm(
patientCriterionId = criterionId,
armId = nextLongId[Arm],
@@ -167,128 +191,47 @@ object treatmentmatching {
def nextPatientListResponse(): ListResponse[Patient] = {
val xs: Seq[Patient] = Seq.fill(3)(nextPatient())
- val pageSize = generators.nextInt(xs.size, 1)
- new ListResponse[Patient](
- items = xs,
- meta = ListResponse.Meta(
- itemsCount = xs.size,
- pageNumber = generators.nextInt(xs.size / pageSize),
- pageSize = pageSize,
- lastUpdate = generators.nextOption(nextLocalDateTime)
- )
- )
+ nextListResponse(xs)
}
def nextRichPatientLabelListResponse(): ListResponse[RichPatientLabel] = {
val xs: Seq[RichPatientLabel] = Seq.fill(3)(nextRichPatientLabel())
- val pageSize = generators.nextInt(xs.size, 1)
- new ListResponse[RichPatientLabel](
- items = xs,
- meta = ListResponse.Meta(
- itemsCount = xs.size,
- pageNumber = generators.nextInt(xs.size / pageSize),
- pageSize = pageSize,
- lastUpdate = generators.nextOption(nextLocalDateTime)
- )
- )
+ nextListResponse(xs)
}
def nextPatientLabelListResponse(): ListResponse[PatientLabel] = {
val xs: Seq[PatientLabel] = Seq.fill(3)(nextPatientLabel())
- val pageSize = generators.nextInt(xs.size, 1)
- new ListResponse[PatientLabel](
- items = xs,
- meta = ListResponse.Meta(
- itemsCount = xs.size,
- pageNumber = generators.nextInt(xs.size / pageSize),
- pageSize = pageSize,
- lastUpdate = generators.nextOption(nextLocalDateTime)
- )
- )
+ nextListResponse(xs)
}
def nextRichPatientCriterionListResponse(): ListResponse[RichPatientCriterion] = {
val xs: Seq[RichPatientCriterion] = Seq.fill(3)(nextRichPatientCriterion())
- val pageSize = generators.nextInt(xs.size, 1)
- new ListResponse[RichPatientCriterion](
- items = xs,
- meta = ListResponse.Meta(
- itemsCount = xs.size,
- pageNumber = generators.nextInt(xs.size / pageSize),
- pageSize = pageSize,
- lastUpdate = generators.nextOption(nextLocalDateTime)
- )
- )
+ nextListResponse(xs)
}
def nextRichPatientEligibleTrialListResponse(): ListResponse[RichPatientEligibleTrial] = {
val xs: Seq[RichPatientEligibleTrial] = Seq.fill(3)(nextRichPatientEligibleTrial())
- val pageSize = generators.nextInt(xs.size, 1)
- new ListResponse[RichPatientEligibleTrial](
- items = xs,
- meta = ListResponse.Meta(
- itemsCount = xs.size,
- pageNumber = generators.nextInt(xs.size / pageSize),
- pageSize = pageSize,
- lastUpdate = generators.nextOption(nextLocalDateTime)
- )
- )
+ nextListResponse(xs)
}
def nextRichPatientHypothesisListResponse(): ListResponse[RichPatientHypothesis] = {
val xs: Seq[RichPatientHypothesis] = Seq.fill(3)(nextRichPatientHypothesis())
- val pageSize = generators.nextInt(xs.size, 1)
- new ListResponse[RichPatientHypothesis](
- items = xs,
- meta = ListResponse.Meta(
- itemsCount = xs.size,
- pageNumber = generators.nextInt(xs.size / pageSize),
- pageSize = pageSize,
- lastUpdate = generators.nextOption(nextLocalDateTime)
- )
- )
+ nextListResponse(xs)
}
def nextPatientLabelEvidenceViewListResponse(): ListResponse[PatientLabelEvidenceView] = {
val xs: Seq[PatientLabelEvidenceView] = Seq.fill(3)(nextPatientLabelEvidenceView())
- val pageSize = generators.nextInt(xs.size, 1)
- new ListResponse[PatientLabelEvidenceView](
- items = xs,
- meta = ListResponse.Meta(
- itemsCount = xs.size,
- pageNumber = generators.nextInt(xs.size / pageSize),
- pageSize = pageSize,
- lastUpdate = generators.nextOption(nextLocalDateTime)
- )
- )
+ nextListResponse(xs)
}
def nextPatientIssuesListResponse(): ListResponse[PatientIssue] = {
val xs: Seq[PatientIssue] = Seq.fill(3)(nextPatientIssue())
- val pageSize = generators.nextInt(xs.size, 1)
- new ListResponse[PatientIssue](
- items = xs,
- meta = ListResponse.Meta(
- itemsCount = xs.size,
- pageNumber = generators.nextInt(xs.size / pageSize),
- pageSize = pageSize,
- lastUpdate = generators.nextOption(nextLocalDateTime)
- )
- )
+ nextListResponse(xs)
}
def nextPatientHistoryListResponse(): ListResponse[PatientHistory] = {
val xs: Seq[PatientHistory] = Seq.fill(3)(nextPatientHistory())
- val pageSize = generators.nextInt(xs.size, 1)
- new ListResponse[PatientHistory](
- items = xs,
- meta = ListResponse.Meta(
- itemsCount = xs.size,
- pageNumber = generators.nextInt(xs.size / pageSize),
- pageSize = pageSize,
- lastUpdate = generators.nextOption(nextLocalDateTime)
- )
- )
+ nextListResponse(xs)
}
}
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 84dcb88..3ab50e1 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/trialcuration.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/trialcuration.scala
@@ -3,6 +3,7 @@ package xyz.driver.pdsuidomain.fakes.entities
import xyz.driver.core.generators._
import xyz.driver.entities.labels.{Label, LabelCategory}
import xyz.driver.pdsuicommon.domain.{LongId, User}
+import xyz.driver.pdsuidomain.ListResponse
import xyz.driver.pdsuidomain.entities._
import xyz.driver.pdsuidomain.services.CriterionService.RichCriterion
@@ -182,4 +183,60 @@ object trialcuration {
originalName = nextString(),
trialId = nextStringId
)
+
+ def nextTrialListResponse(): ListResponse[Trial] = {
+ val xs: Seq[Trial] = Seq.fill(3)(nextTrial())
+ nextListResponse(xs)
+ }
+
+ def nextTrialIssueListResponse(): ListResponse[TrialIssue] = {
+ val xs: Seq[TrialIssue] = Seq.fill(3)(nextTrialIssue())
+ nextListResponse(xs)
+ }
+
+ def nextTrialHistoryListResponse(): ListResponse[TrialHistory] = {
+ val xs: Seq[TrialHistory] = Seq.fill(3)(nextTrialHistory())
+ nextListResponse(xs)
+ }
+
+ def nextArmListResponse(): ListResponse[Arm] = {
+ val xs: Seq[Arm] = Seq.fill(3)(nextArm())
+ nextListResponse(xs)
+ }
+
+ def nextInterventionWithArmsListResponse(): ListResponse[InterventionWithArms] = {
+ val xs: Seq[InterventionWithArms] = Seq.fill(3)(nextInterventionWithArms())
+ nextListResponse(xs)
+ }
+
+ def nextEligibilityArmWithDiseasesListResponse(): ListResponse[EligibilityArmWithDiseases] = {
+ val xs: Seq[EligibilityArmWithDiseases] = Seq.fill(3)(nextEligibilityArmWithDiseases())
+ nextListResponse(xs)
+ }
+
+ def nextSlotArmListResponse(): ListResponse[SlotArm] = {
+ val xs: Seq[SlotArm] = Seq.fill(3)(nextSlotArm())
+ nextListResponse(xs)
+ }
+
+ def nextRichCriterionListResponse(): ListResponse[RichCriterion] = {
+ val xs: Seq[RichCriterion] = Seq.fill(3)(nextRichCriterion())
+ nextListResponse(xs)
+ }
+
+ def nextInterventionTypeListResponse(): ListResponse[InterventionType] = {
+ val xs: Seq[InterventionType] = Seq.fill(3)(nextInterventionType())
+ nextListResponse(xs)
+ }
+
+ def nextStudyDesignListResponse(): ListResponse[StudyDesign] = {
+ val xs: Seq[StudyDesign] = Seq.fill(3)(nextStudyDesign())
+ nextListResponse(xs)
+ }
+
+ def nextHypothesesListResponse(): ListResponse[Hypothesis] = {
+ val xs: Seq[Hypothesis] = Seq.fill(3)(nextHypothesis())
+ nextListResponse(xs)
+ }
+
}