diff options
author | Kseniya Tomskikh <ktomskih@datamonsters.co> | 2017-10-02 18:37:52 +0700 |
---|---|---|
committer | Kseniya Tomskikh <ktomskih@datamonsters.co> | 2017-10-02 18:37:52 +0700 |
commit | d0e3c6f37347142a3ef5eab871dde47ea70af304 (patch) | |
tree | a87d24b1b5d6489576f00fe446f05b5110d62cc0 /src/main/scala/xyz/driver/pdsuidomain/fakes | |
parent | 283ca02360949143ffe7ee8ad87d51902426b450 (diff) | |
parent | 1913870abec9e31d080f6858d0fc296445852cc6 (diff) | |
download | rest-query-d0e3c6f37347142a3ef5eab871dde47ea70af304.tar.gz rest-query-d0e3c6f37347142a3ef5eab871dde47ea70af304.tar.bz2 rest-query-d0e3c6f37347142a3ef5eab871dde47ea70af304.zip |
Merge branch 'master' into synch-refactor
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/fakes')
9 files changed, 574 insertions, 10 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..5f3321c --- /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, Patient} +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 nextLabelEvidence(): LabelEvidence = + LabelEvidence(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[Patient](), + name = fakes.entities.common.nextFullName[Patient](), + 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/BridgeUploadQueueGen.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/BridgeUploadQueueGen.scala new file mode 100644 index 0000000..e7cbd19 --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/BridgeUploadQueueGen.scala @@ -0,0 +1,22 @@ +package xyz.driver.pdsuidomain.fakes.entities.rep + +import xyz.driver.core.generators.{nextBoolean, nextInt, nextOption, nextString} +import xyz.driver.pdsuicommon.concurrent.BridgeUploadQueue +import xyz.driver.pdsuidomain.fakes.entities.common.nextLocalDateTime + +object BridgeUploadQueueGen { + private val maxAttemptsNumber = 100 + + def nextBridgeUploadQueueItem(): BridgeUploadQueue.Item = { + BridgeUploadQueue.Item( + kind = nextString(), + tag = nextString(), + created = nextLocalDateTime, + attempts = nextInt(maxAttemptsNumber, minValue = 0), + nextAttempt = nextLocalDateTime, + completed = nextBoolean(), + dependencyKind = nextOption(nextString()), + dependencyTag = nextOption(nextString()) + ) + } +} 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 new file mode 100644 index 0000000..1ac75ab --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/DocumentGen.scala @@ -0,0 +1,107 @@ +package xyz.driver.pdsuidomain.fakes.entities.rep + +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} + +object DocumentGen { + implicit private class LocalDateOrdering(localData: LocalDate) extends Ordered[LocalDate] { + + override def compare(that: LocalDate): Int = { + this.localData.compareTo(that) + } + } + + private def nextDates() = + genBoundedRangeOption[LocalDate](nextLocalDate, nextLocalDate) + + private def nextStartAndEndPagesOption() = + nextStartAndEndPages + + private def nextStartAndEndPage() = + genBoundedRange(nextDouble(), nextDouble()) + + def nextDocumentStatus(): Document.Status = + Document.Status.New + + def nextDocumentRequiredType(): Document.RequiredType = + generators.oneOf[Document.RequiredType](Document.RequiredType.All) + + def nextDocumentHistoryState(): DocumentHistory.State = + generators.oneOf[DocumentHistory.State](DocumentHistory.State.All) + + def nextDocumentHistoryAction(): DocumentHistory.Action = + generators.oneOf[DocumentHistory.Action](DocumentHistory.Action.All) + + def nextDocumentMeta(): Document.Meta = { + val (startPage, endPage) = nextStartAndEndPage() + + Document.Meta( + nextOption(nextBoolean()), + startPage, + endPage + ) + } + + def nextDocumentMetaJson(): TextJson[Document.Meta] = { + TextJson(nextDocumentMeta()) + } + + def nextDocument(): Document = { + val dates = nextDates() + + Document( + id = nextLongId[Document], + status = nextDocumentStatus(), + previousStatus = None, + assignee = nextOption(nextStringId[User]), + previousAssignee = nextOption(nextStringId[User]), + lastActiveUserId = nextOption(nextStringId[User]), + recordId = nextLongId[MedicalRecord], + physician = nextOption(nextString()), + typeId = nextOption(nextLongId[DocumentType]), + providerName = nextOption(nextString()), + providerTypeId = nextOption(nextLongId[ProviderType]), + requiredType = nextOption(nextDocumentRequiredType()), + meta = nextOption(nextDocumentMetaJson()), + startDate = dates._1, + endDate = dates._2, + lastUpdate = nextLocalDateTime + ) + } + + def nextDocumentType(): DocumentType = + generators.oneOf(DocumentType.All: _*) + + def nextDocumentIssue(documentId: LongId[Document] = nextLongId): DocumentIssue = { + val pages = nextStartAndEndPagesOption() + + DocumentIssue( + id = nextLongId[DocumentIssue], + userId = nextStringId[User], + documentId = documentId, + startPage = pages._1, + endPage = pages._2, + lastUpdate = nextLocalDateTime, + isDraft = nextBoolean(), + text = nextString(), + archiveRequired = nextBoolean() + ) + } + + def nextDocumentHistory(documentId: LongId[Document] = nextLongId): DocumentHistory = { + DocumentHistory( + id = nextLongId[DocumentHistory], + executor = nextStringId[User], + documentId = documentId, + state = nextDocumentHistoryState(), + action = nextDocumentHistoryAction(), + created = nextLocalDateTime + ) + } +} 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 new file mode 100644 index 0000000..3fcc4cb --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExportPatientGen.scala @@ -0,0 +1,54 @@ +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._ +import xyz.driver.pdsuidomain.fakes.entities.common.{nextLocalDate, nextLongId} +import xyz.driver.pdsuidomain.fakes.entities.rep.DocumentGen._ +import xyz.driver.pdsuidomain.fakes.entities.rep.MedicalRecordGen._ + +object ExportPatientGen { + private val maxItemsInCollectionNumber = 3 + + def nextExportPatientLabelEvidenceDocument(documentId: LongId[Document]): ExportPatientLabelEvidenceDocument = { + ExportPatientLabelEvidenceDocument( + documentId = documentId, + requestId = RecordRequestId(nextUuid()), + documentType = nextDocumentType(), + providerType = nextProviderType(), + date = nextLocalDate + ) + } + + def nextExportPatientLabelEvidence(documentId: LongId[Document]): ExportPatientLabelEvidence = { + ExportPatientLabelEvidence( + id = nextLongId[ExtractedData], + value = nextFuzzyValue(), + evidenceText = nextString(), + document = nextExportPatientLabelEvidenceDocument(documentId) + ) + } + + def nextExportPatientLabel(documentId: LongId[Document]): ExportPatientLabel = { + ExportPatientLabel( + id = nextLongId[Label], + evidences = List.fill( + nextInt(maxItemsInCollectionNumber, minValue = 0) + )(nextExportPatientLabelEvidence(documentId)) + ) + } + + def nextExportPatientWithLabels(documentId: LongId[Document]): ExportPatientWithLabels = { + ExportPatientWithLabels( + patientId = UuidId[xyz.driver.pdsuidomain.entities.Patient](nextUuid()), + labelVersion = scala.util.Random.nextLong(), + labels = List.fill( + nextInt(maxItemsInCollectionNumber, minValue = 0) + )(nextExportPatientLabel(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 new file mode 100644 index 0000000..8e77445 --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExtractedDataGen.scala @@ -0,0 +1,100 @@ +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 +import xyz.driver.pdsuidomain.fakes.entities.common._ +import xyz.driver.pdsuidomain.services.ExtractedDataService.RichExtractedData + +object ExtractedDataGen { + private val maxItemsInCollectionNumber = 50 + + private val maxPageNumber = 100 + private val maxIndexNumber = 100 + private val maxOffsetNumber = 10 + + implicit private class TextLayerPositionOrdering(textLayerPosition: ExtractedData.Meta.TextLayerPosition) + extends Ordered[ExtractedData.Meta.TextLayerPosition] { + override def compare(that: Meta.TextLayerPosition): Int = { + if (this.textLayerPosition.page < that.page) -1 + else if (this.textLayerPosition.page > that.page) 1 + else if (this.textLayerPosition.index < that.index) -1 + else if (this.textLayerPosition.index > that.index) 1 + else if (this.textLayerPosition.offset < that.offset) -1 + else if (this.textLayerPosition.offset > that.offset) 1 + else 0 + } + } + + def nextExtractedDataMetaKeyword(): Meta.Keyword = { + ExtractedData.Meta.Keyword( + page = nextInt(maxPageNumber, minValue = 0), + pageRatio = nextOption(nextDouble()), + index = nextInt(maxIndexNumber, minValue = 0), + sortIndex = nextString() + ) + } + + def nextExtractedDataMetaTextLayerPosition(): Meta.TextLayerPosition = { + ExtractedData.Meta.TextLayerPosition( + page = nextInt(maxPageNumber, minValue = 0), + index = nextInt(maxIndexNumber, minValue = 0), + offset = nextInt(maxOffsetNumber, minValue = 0) + ) + } + + def nextExtractedDataMetaEvidence(): Meta.Evidence = { + val layersPosition = + genBoundedRange[ExtractedData.Meta.TextLayerPosition]( + nextExtractedDataMetaTextLayerPosition(), + nextExtractedDataMetaTextLayerPosition() + ) + + ExtractedData.Meta.Evidence( + pageRatio = nextDouble(), + start = layersPosition._1, + end = layersPosition._2 + ) + } + + def nextExtractedDataMeta(): Meta = { + ExtractedData.Meta( + nextExtractedDataMetaKeyword(), + nextExtractedDataMetaEvidence() + ) + } + + def nextExtractedDataMetaJson(): TextJson[Meta] = + TextJson(ExtractedData.Meta(nextExtractedDataMetaKeyword(), nextExtractedDataMetaEvidence())) + + def nextExtractedData(documentId: LongId[Document]): ExtractedData = { + ExtractedData( + id = nextLongId[ExtractedData], + documentId = documentId, + keywordId = nextOption(nextLongId[xyz.driver.pdsuidomain.entities.Keyword]), + evidenceText = nextOption(nextString()), + meta = nextOption(nextExtractedDataMetaJson()) + ) + } + + def nextExtractedDataLabel(): ExtractedDataLabel = { + ExtractedDataLabel( + id = nextLongId[ExtractedDataLabel], + dataId = nextLongId[ExtractedData], + labelId = nextOption(nextLongId[Label]), + categoryId = nextOption(nextLongId[LabelCategory]), + value = nextOption(nextFuzzyValue()) + ) + } + + def nextRichExtractedData(documentId: LongId[Document] = nextLongId): RichExtractedData = { + RichExtractedData( + extractedData = nextExtractedData(documentId), + labels = List.fill( + nextInt(maxItemsInCollectionNumber, minValue = 0) + )(nextExtractedDataLabel()) + ) + } +} 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 new file mode 100644 index 0000000..2777116 --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/MedicalRecordGen.scala @@ -0,0 +1,147 @@ +package xyz.driver.pdsuidomain.fakes.entities.rep + +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._ + +object MedicalRecordGen { + private val maxItemsInCollectionNumber: Int = 50 + + private val pageMaxNumber: Int = 1000 + + private val medicalRecordMetas: Set[() => MedicalRecord.Meta] = { + Set( + () => nextMedicalRecordMetaReorder(), + () => nextMedicalRecordMetaDuplicate(), + () => nextMedicalRecordMetaRotation() + ) + } + + def nextMedicalRecordMetas(count: Int): List[MedicalRecord.Meta] = + List.fill(count)(nextMedicalRecordMeta()) + + def nextMedicalRecordMetasJson(): TextJson[List[MedicalRecord.Meta]] = + TextJson(nextMedicalRecordMetas(nextInt(maxItemsInCollectionNumber, minValue = 0))) + + private def nextDocument(): Document = + DocumentGen.nextDocument() + + private def nextDocuments(count: Int): List[Document] = + List.fill(count)(nextDocument()) + + def nextDocuments(recordId: LongId[MedicalRecord]): TextJson[List[Document]] = { + val documents = nextDocuments( + nextInt(maxItemsInCollectionNumber, minValue = 0) + ) + + TextJson(documents.map(_.copy(recordId = recordId))) + } + + def nextMedicalRecordStatus(): MedicalRecord.Status = + MedicalRecord.Status.New + + def nextMedicalRecordHistoryState(): MedicalRecordHistory.State = + generators.oneOf[MedicalRecordHistory.State](MedicalRecordHistory.State.All) + + def nextMedicalRecordHistoryAction(): MedicalRecordHistory.Action = + generators.oneOf[MedicalRecordHistory.Action](MedicalRecordHistory.Action.All) + + 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)() + } + + def nextMedicalRecord(): MedicalRecord = { + val id = nextLongId[MedicalRecord] + MedicalRecord( + id = nextLongId[MedicalRecord], + status = nextMedicalRecordStatus(), + previousStatus = None, + assignee = nextOption(nextStringId), + previousAssignee = nextOption(nextStringId), + lastActiveUserId = nextOption(nextStringId), + patientId = nextUuidId, + requestId = RecordRequestId(generators.nextUuid()), + disease = generators.nextString(), + caseId = nextOption(CaseId(generators.nextString())), + physician = nextOption(generators.nextString()), + meta = nextOption(nextMedicalRecordMetasJson()), + predictedMeta = nextOption(nextMedicalRecordMetasJson()), + predictedDocuments = nextOption(nextDocuments(id)), + lastUpdate = nextLocalDateTime + ) + } + + def nextMedicalRecordHistory(): MedicalRecordHistory = { + MedicalRecordHistory( + id = nextLongId[MedicalRecordHistory], + executor = nextStringId[User], + recordId = nextLongId[MedicalRecord], + state = nextMedicalRecordHistoryState(), + action = nextMedicalRecordHistoryAction(), + created = nextLocalDateTime + ) + } + + def nextMedicalRecordIssue(): MedicalRecordIssue = { + val pages = nextStartAndEndPages + + MedicalRecordIssue( + id = nextLongId[MedicalRecordIssue], + userId = nextStringId[User], + recordId = nextLongId[MedicalRecord], + startPage = pages._1, + endPage = pages._2, + lastUpdate = nextLocalDateTime, + isDraft = nextBoolean(), + text = nextString(), + archiveRequired = nextBoolean() + ) + } + + def nextProviderType(): ProviderType = + generators.oneOf(ProviderType.All: _*) + +} 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..9a5022c 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 @@ -44,14 +45,15 @@ object trialcuration { trialId = nextStringId[Trial], text = Option(generators.nextString()), isCompound = generators.nextBoolean(), - meta = generators.nextString() + meta = generators.nextString(), + inclusion = Option(generators.nextBoolean()) ) def nextCriterionLabel(criterionId: LongId[Criterion]): CriterionLabel = CriterionLabel( id = nextLongId[CriterionLabel], labelId = Option(nextLongId[Label]), criterionId = criterionId, - categoryId = Option(nextLongId[Category]), + categoryId = Option(nextLongId[LabelCategory]), value = Option(generators.nextBoolean()), isDefining = generators.nextBoolean() ) |