From d8e71e0a9ee7db58032384d059403bc227a35138 Mon Sep 17 00:00:00 2001 From: Aleksandr Date: Thu, 28 Sep 2017 13:31:21 +0700 Subject: Implemented some REP entities objects generators --- .../pdsuidomain/fakes/entities/rep/Common.scala | 35 ++++++++++ .../fakes/entities/rep/DocumentGen.scala | 68 ++++++++++++++++++++ .../fakes/entities/rep/ExtractedDataGen.scala | 74 ++++++++++++++++++++++ .../fakes/entities/rep/MedicalRecordMetaGen.scala | 63 ++++++++++++++++++ 4 files changed, 240 insertions(+) create mode 100644 src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/Common.scala create mode 100644 src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/DocumentGen.scala create mode 100644 src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExtractedDataGen.scala create mode 100644 src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/MedicalRecordMetaGen.scala (limited to 'src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep') 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 new file mode 100644 index 0000000..d09e09b --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/Common.scala @@ -0,0 +1,35 @@ +package xyz.driver.pdsuidomain.fakes.entities.rep + +import xyz.driver.core.generators._ + +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 genStartAndEndPages: (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 new file mode 100644 index 0000000..1c77a78 --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/DocumentGen.scala @@ -0,0 +1,68 @@ +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.pdsuicommon.domain.{TextJson, User} +import xyz.driver.pdsuidomain.entities.{Document, DocumentType, MedicalRecord, ProviderType} +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) + } + } + + def nextDocumentStatus: Document.Status = + generators.oneOf[Document.Status](Document.Status.All) + + def nextDocumentRequiredType: Document.RequiredType = + generators.oneOf[Document.RequiredType](Document.RequiredType.All) + + def nextDocumentMeta: Document.Meta = { + val (startPage, endPage) = { + val startPage = nextDouble() + val endPage = nextDouble() + if (startPage > endPage) { + endPage -> startPage + } + else { + startPage -> endPage + } + } + + Document.Meta( + nextOption(nextBoolean()), startPage, endPage + ) + } + + def nextDocument: Document = { + val dates = Common + .genBoundedRangeOption[LocalDate](nextLocalDate, nextLocalDate) + + Document( + id = nextLongId[Document], + status = nextDocumentStatus, + previousStatus = nextOption(nextDocumentStatus), + 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(TextJson(nextDocumentMeta)), + startDate = dates._1, + endDate = dates._2, + lastUpdate = nextLocalDateTime + ) + } + +} 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..48eaf79 --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExtractedDataGen.scala @@ -0,0 +1,74 @@ +package xyz.driver.pdsuidomain.fakes.entities.rep + +import xyz.driver.core.generators._ +import xyz.driver.pdsuidomain.entities.{Document, ExtractedData} +import xyz.driver.pdsuidomain.entities.ExtractedData.Meta +import xyz.driver.pdsuidomain.fakes.entities.common._ + + +object ExtractedDataGen { + 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 = + Common.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 nextExtractedData() = { + ExtractedData.apply( + id = nextLongId[ExtractedData], + documentId = nextLongId[Document], + keywordId = nextOption(nextLongId[xyz.driver.pdsuidomain.entities.Keyword]), + evidenceText = nextOption(nextString()), + ??? + ) + } +} diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/MedicalRecordMetaGen.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/MedicalRecordMetaGen.scala new file mode 100644 index 0000000..1536c65 --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/MedicalRecordMetaGen.scala @@ -0,0 +1,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)() + } +} -- cgit v1.2.3 From 1f569ac1a31f88334c25976d94e7c495a7bbde80 Mon Sep 17 00:00:00 2001 From: Aleksandr Date: Thu, 28 Sep 2017 14:32:21 +0700 Subject: Implemented all generator for REP's entities --- .../fakes/entities/RecordsProcessingApi.scala | 112 ---------------- .../fakes/entities/rep/BridgeUploadQueueGen.scala | 31 +++++ .../pdsuidomain/fakes/entities/rep/Common.scala | 10 +- .../fakes/entities/rep/DocumentGen.scala | 68 ++++++++-- .../fakes/entities/rep/ExportPatientGen.scala | 55 ++++++++ .../fakes/entities/rep/ExtractedDataGen.scala | 35 ++++- .../fakes/entities/rep/MedicalRecordGen.scala | 146 +++++++++++++++++++++ .../fakes/entities/rep/MedicalRecordMetaGen.scala | 63 --------- 8 files changed, 324 insertions(+), 196 deletions(-) delete mode 100644 src/main/scala/xyz/driver/pdsuidomain/fakes/entities/RecordsProcessingApi.scala create mode 100644 src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/BridgeUploadQueueGen.scala create mode 100644 src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExportPatientGen.scala create mode 100644 src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/MedicalRecordGen.scala delete mode 100644 src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/MedicalRecordMetaGen.scala (limited to 'src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep') diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/RecordsProcessingApi.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/RecordsProcessingApi.scala deleted file mode 100644 index 93bfce6..0000000 --- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/RecordsProcessingApi.scala +++ /dev/null @@ -1,112 +0,0 @@ -package xyz.driver.pdsuidomain.fakes.entities - - -import xyz.driver.pdsuidomain.entities._ -import xyz.driver.core.generators -import xyz.driver.core.generators._ -import common._ -import xyz.driver.pdsuicommon.concurrent.BridgeUploadQueue -import xyz.driver.pdsuicommon.domain.{TextJson, User} -import xyz.driver.pdsuidomain.fakes.entities.rep.{DocumentGen, MedicalRecordMetaGen, Common} - - -object RecordsProcessingApi { - private val maxCollectionNumber = 5 - - private val maxAttemtsNumber = 100 - - private def nextMedicalRecordMetasJson: TextJson[List[MedicalRecord.Meta]] = - TextJson(nextMedicalRecordMetas(nextInt(maxCollectionNumber, minValue = 0))) - - private def nextDocuments: TextJson[List[Document]] = - TextJson(nextDocuments(nextInt(maxCollectionNumber, minValue = 0))) - - def nextMedicalRecordStatus: MedicalRecord.Status = - generators.oneOf[MedicalRecord.Status](MedicalRecord.Status.All) - - def nextMedicalRecordMeta: MedicalRecord.Meta = - MedicalRecordMetaGen.nextMedicalRecordMeta - - def nextMedicalRecordMetas(count: Int): List[MedicalRecord.Meta] = - List.fill(count)(nextMedicalRecordMeta) - - def nextMedicalRecordHistoryState: MedicalRecordHistory.State = - generators.oneOf[MedicalRecordHistory.State](MedicalRecordHistory.State.All) - - def nextMedicalRecordHistoryAction: MedicalRecordHistory.Action = - generators.oneOf[MedicalRecordHistory.Action](MedicalRecordHistory.Action.All) - - def nextDocument: Document = - DocumentGen.nextDocument - - def nextDocuments(count: Int): List[Document] = - List.fill(count)(nextDocument) - - def nextMedicalRecord() = { - MedicalRecord( - id = nextLongId[MedicalRecord], - status = nextMedicalRecordStatus, - previousStatus = nextOption(nextMedicalRecordStatus), - 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), - lastUpdate = nextLocalDateTime - ) - } - - def nextMedicalRecordHistory() = { - MedicalRecordHistory( - id = nextLongId[MedicalRecordHistory], - executor = nextStringId[User], - recordId = nextLongId[MedicalRecord], - state = nextMedicalRecordHistoryState, - action = nextMedicalRecordHistoryAction, - created = nextLocalDateTime - ) - } - - def nextMedicalRecordIssue(): MedicalRecordIssue = { - val pages = Common.genStartAndEndPages - - 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 nextBridgeUploadQueueItem(): BridgeUploadQueue.Item = { - BridgeUploadQueue.Item( - kind = nextString(), - tag = nextString(), - created = nextLocalDateTime, - attempts = nextInt(maxAttemtsNumber, minValue = 0), - nextAttempt = nextLocalDateTime, - completed = nextBoolean(), - dependencyKind = nextOption(nextString()), - dependencyTag = nextOption(nextString()) - ) - } - - def nextProviderType(): ProviderType = { - ProviderType( - id = nextLongId[ProviderType], - name = nextString() - ) - } - -} 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..fb1d3e3 --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/BridgeUploadQueueGen.scala @@ -0,0 +1,31 @@ +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.entities.ProviderType +import xyz.driver.pdsuidomain.fakes.entities.common.{nextLocalDateTime, nextLongId} + +object BridgeUploadQueueGen { + private val maxAttemtsNumber = 100 + + def nextBridgeUploadQueueItem(): BridgeUploadQueue.Item = { + BridgeUploadQueue.Item( + kind = nextString(), + tag = nextString(), + created = nextLocalDateTime, + attempts = nextInt(maxAttemtsNumber, minValue = 0), + nextAttempt = nextLocalDateTime, + completed = nextBoolean(), + dependencyKind = nextOption(nextString()), + dependencyTag = nextOption(nextString()) + ) + } + + def nextProviderType(): ProviderType = { + ProviderType( + id = nextLongId[ProviderType], + name = nextString() + ) + } + +} 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 index d09e09b..337dc2b 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/Common.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/Common.scala @@ -1,8 +1,10 @@ package xyz.driver.pdsuidomain.fakes.entities.rep +import xyz.driver.core.generators import xyz.driver.core.generators._ +import xyz.driver.pdsuicommon.domain.FuzzyValue -object Common { +private[rep] object Common { def genBoundedRange[T](from: T, to: T) (implicit ord: Ordering[T]): (T, T) = { @@ -28,7 +30,11 @@ object Common { ranges.map(_._1) -> ranges.flatMap(_._2) } - def genStartAndEndPages: (Option[Double], Option[Double]) = { + 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 1c77a78..2f07f1d 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 @@ -5,8 +5,8 @@ import java.time.LocalDate import xyz.driver.core.generators import xyz.driver.core.generators.{nextBoolean, nextDouble, nextOption, nextString} -import xyz.driver.pdsuicommon.domain.{TextJson, User} -import xyz.driver.pdsuidomain.entities.{Document, DocumentType, MedicalRecord, ProviderType} +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 { @@ -18,23 +18,30 @@ object DocumentGen { } } + private def nextDates = + Common.genBoundedRangeOption[LocalDate](nextLocalDate, nextLocalDate) + + private def nextStartAndEndPagesOption = + Common.nextStartAndEndPages + + private def nextStartAndEndPage = + Common.genBoundedRange(nextDouble(),nextDouble()) + + def nextDocumentStatus: Document.Status = generators.oneOf[Document.Status](Document.Status.All) 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) = { - val startPage = nextDouble() - val endPage = nextDouble() - if (startPage > endPage) { - endPage -> startPage - } - else { - startPage -> endPage - } - } + val (startPage, endPage) = nextStartAndEndPage Document.Meta( nextOption(nextBoolean()), startPage, endPage @@ -42,8 +49,7 @@ object DocumentGen { } def nextDocument: Document = { - val dates = Common - .genBoundedRangeOption[LocalDate](nextLocalDate, nextLocalDate) + val dates = nextDates Document( id = nextLongId[Document], @@ -65,4 +71,38 @@ object DocumentGen { ) } + def nextDocumentType: DocumentType = { + DocumentType( + id = nextLongId[DocumentType], + name = nextString() + ) + } + + def nextDocumentIssue(documentId: LongId[Document]): 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]): 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..4a4164a --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExportPatientGen.scala @@ -0,0 +1,55 @@ +package xyz.driver.pdsuidomain.fakes.entities.rep + +import xyz.driver.core.generators._ +import xyz.driver.pdsuicommon.domain.{LongId, UuidId} +import xyz.driver.pdsuidomain.entities.{Document, ExtractedData, Label, RecordRequestId} +import xyz.driver.pdsuidomain.entities.export.patient.{ +ExportPatientLabel, +ExportPatientLabelEvidence, +ExportPatientLabelEvidenceDocument, +ExportPatientWithLabels +} +import xyz.driver.pdsuidomain.fakes.entities.common.{nextLocalDate, nextLongId} + +object ExportPatientGen { + private val maxItemsInCollectionNumber = 3 + + def nextExportPatientLabelEvidenceDocument(documentId: LongId[Document]): ExportPatientLabelEvidenceDocument = { + ExportPatientLabelEvidenceDocument( + documentId = documentId, + requestId = RecordRequestId(nextUuid()), + documentType = nextString(), + providerType = nextString(), + date = nextLocalDate + ) + } + + def nextExportPatientLabelEvidence(documentId: LongId[Document]): ExportPatientLabelEvidence = { + ExportPatientLabelEvidence( + id = nextLongId[ExtractedData], + value = Common.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 index 48eaf79..512e324 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,12 +1,17 @@ package xyz.driver.pdsuidomain.fakes.entities.rep + import xyz.driver.core.generators._ -import xyz.driver.pdsuidomain.entities.{Document, ExtractedData} +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 @@ -62,13 +67,33 @@ object ExtractedDataGen { ) } - def nextExtractedData() = { - ExtractedData.apply( + def nextExtractedData(documentId: LongId[Document]): ExtractedData = { + ExtractedData( id = nextLongId[ExtractedData], - documentId = nextLongId[Document], + documentId = documentId, keywordId = nextOption(nextLongId[xyz.driver.pdsuidomain.entities.Keyword]), evidenceText = nextOption(nextString()), - ??? + meta = nextOption(TextJson(nextExtractedDataMeta())) + ) + } + + + def nextExtractedDataLabel(): ExtractedDataLabel = { + ExtractedDataLabel( + id = nextLongId[ExtractedDataLabel], + dataId = nextLongId[ExtractedData], + labelId = nextOption(nextLongId[Label]), + categoryId = nextOption(nextLongId[Category]), + value = nextOption(Common.nextFuzzyValue()) + ) + } + + def nextRichExtractedData(documentId: LongId[Document]): 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..0ea3cdd --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/MedicalRecordGen.scala @@ -0,0 +1,146 @@ +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.{nextLocalDateTime, nextLongId, nextStringId, nextUuidId} + +object MedicalRecordGen { + private val maxItemsInCollectionNumber = 50 + + private val pageMaxNumber = 1000 + + private val medicalRecordMetas = { + Set( + () => nextMedicalRecordMetaReorder, + () => nextMedicalRecordMetaDuplicate, + () => nextMedicalRecordMetaRotation + ) + } + + def nextMedicalRecordMetas(count: Int): List[MedicalRecord.Meta] = + List.fill(count)(nextMedicalRecordMeta) + + private 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) + + private 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 = + generators.oneOf[MedicalRecord.Status](MedicalRecord.Status.All) + + 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 = nextOption(nextMedicalRecordStatus), + 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 = Common.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() + ) + } + +} diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/MedicalRecordMetaGen.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/MedicalRecordMetaGen.scala deleted file mode 100644 index 1536c65..0000000 --- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/MedicalRecordMetaGen.scala +++ /dev/null @@ -1,63 +0,0 @@ -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)() - } -} -- cgit v1.2.3 From f8902d43cb189b408210ae7c80e2112346bdc037 Mon Sep 17 00:00:00 2001 From: Aleksandr Date: Thu, 28 Sep 2017 18:26:36 +0700 Subject: Fixed generators of entities for ReP; Implemented json examples for swagger for ReP --- .../utils/CustomSwaggerJsonFormats.scala | 94 +++++++++++++++++++++- .../fakes/entities/rep/BridgeUploadQueueGen.scala | 15 +--- .../fakes/entities/rep/DocumentGen.scala | 48 ++++++----- .../fakes/entities/rep/ExtractedDataGen.scala | 14 +++- .../fakes/entities/rep/MedicalRecordGen.scala | 52 ++++++------ .../fakes/entities/rep/ProviderTypeGen.scala | 14 ++++ 6 files changed, 171 insertions(+), 66 deletions(-) create mode 100644 src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ProviderTypeGen.scala (limited to 'src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep') diff --git a/src/main/scala/xyz/driver/pdsuicommon/utils/CustomSwaggerJsonFormats.scala b/src/main/scala/xyz/driver/pdsuicommon/utils/CustomSwaggerJsonFormats.scala index 6c87858..f2c6d94 100644 --- a/src/main/scala/xyz/driver/pdsuicommon/utils/CustomSwaggerJsonFormats.scala +++ b/src/main/scala/xyz/driver/pdsuicommon/utils/CustomSwaggerJsonFormats.scala @@ -4,7 +4,7 @@ import java.time.{LocalDate, LocalDateTime} import io.swagger.models.properties.Property import spray.json.JsValue -import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId} +import xyz.driver.pdsuicommon.domain.{LongId, StringId, TextJson, UuidId} import xyz.driver.pdsuidomain.entities._ import xyz.driver.pdsuidomain.formats.json.sprayformats.arm._ import xyz.driver.pdsuidomain.formats.json.sprayformats.criterion._ @@ -15,25 +15,29 @@ import xyz.driver.pdsuidomain.formats.json.sprayformats.trial._ import xyz.driver.pdsuidomain.formats.json.sprayformats.trialhistory._ import xyz.driver.pdsuidomain.formats.json.sprayformats.trialissue._ import xyz.driver.core.swagger.CustomSwaggerJsonConverter._ +import xyz.driver.pdsuicommon.concurrent.BridgeUploadQueue import xyz.driver.pdsuidomain.services.CriterionService.RichCriterion +import xyz.driver.pdsuidomain.services.ExtractedDataService.RichExtractedData + +import scala.collection.immutable object CustomSwaggerJsonFormats { - val customCommonProperties = Map[Class[_], Property]( + val customCommonProperties = immutable.Map[Class[_], Property]( classOf[LocalDateTime] -> stringProperty(example = Some("2010-12-31'T'18:59:59Z")), classOf[LocalDate] -> stringProperty(example = Some("2010-12-31")), classOf[UuidId[_]] -> stringProperty(example = Some("370b0450-35cb-4aab-ba74-0145be75add5")), classOf[StringId[_]] -> stringProperty(), classOf[LongId[_]] -> stringProperty() ) - val customTrialCurationProperties = Map[Class[_], Property]( + val customTrialCurationProperties = immutable.Map[Class[_], Property]( classOf[Trial.Status] -> stringProperty(), classOf[Trial.Condition] -> stringProperty(), classOf[TrialHistory.Action] -> stringProperty(), classOf[TrialHistory.State] -> stringProperty() ) ++ customCommonProperties - val customTrialCurationObjectsExamples = Map[Class[_], JsValue]( + val customTrialCurationObjectsExamples = immutable.Map[Class[_], JsValue]( classOf[Trial] -> trialWriter.write(xyz.driver.pdsuidomain.fakes.entities.trialcuration.nextTrial()), classOf[Arm] -> armFormat.write(xyz.driver.pdsuidomain.fakes.entities.trialcuration.nextArm()), classOf[TrialHistory] -> trialHistoryFormat.write( @@ -52,4 +56,86 @@ object CustomSwaggerJsonFormats { xyz.driver.pdsuidomain.fakes.entities.trialcuration.nextStudyDesign()) ) + //records-processing-service + object Rep { + import xyz.driver.pdsuidomain.fakes.entities.rep + import xyz.driver.pdsuidomain.formats.json.sprayformats.document + import xyz.driver.pdsuidomain.formats.json.sprayformats.documentissue + import xyz.driver.pdsuidomain.formats.json.sprayformats.documenthistory + import xyz.driver.pdsuidomain.formats.json.sprayformats.providertype + import xyz.driver.pdsuidomain.formats.json.sprayformats.record + import xyz.driver.pdsuidomain.formats.json.sprayformats.recordissue + import xyz.driver.pdsuidomain.formats.json.sprayformats.recordhistory + import xyz.driver.pdsuidomain.formats.json.sprayformats.bridgeuploadqueue + import xyz.driver.pdsuidomain.formats.json.sprayformats.extracteddata + + + val customRepObjectsExamples = immutable.Map[Class[_], JsValue]( + classOf[Document] -> + document.documentFormat.write(rep.DocumentGen.nextDocument()), + classOf[Document.Meta] -> + document.documentMetaFormat.write(rep.DocumentGen.nextDocumentMeta()), + classOf[TextJson[Document.Meta]] -> + document.fullDocumentMetaFormat.write(rep.DocumentGen.nextDocumentMetaJson()), + classOf[Document.RequiredType] -> + document.requiredTypeFormat.write(rep.DocumentGen.nextDocumentRequiredType()), + classOf[Document.Status] -> + document.documentStatusFormat.write(rep.DocumentGen.nextDocumentStatus()), + + classOf[DocumentIssue] -> + documentissue.documentIssueFormat.write(rep.DocumentGen.nextDocumentIssue()), + + classOf[DocumentHistory] -> + documenthistory.documentHistoryFormat.write(rep.DocumentGen.nextDocumentHistory()), + classOf[DocumentHistory.Action] -> + documenthistory.documentActionFormat.write(rep.DocumentGen.nextDocumentHistoryAction()), + classOf[DocumentHistory.State] -> + documenthistory.documentStateFormat.write(rep.DocumentGen.nextDocumentHistoryState()), + + classOf[ProviderType] -> + providertype.providerTypeFormat.write(rep.ProviderTypeGen.nextProviderType()), + + classOf[TextJson[List[MedicalRecord.Meta]]] -> + record.recordMetaFormat.write(rep.MedicalRecordGen.nextMedicalRecordMetasJson()), + classOf[MedicalRecord] -> + record.recordFormat.write(rep.MedicalRecordGen.nextMedicalRecord()), + classOf[MedicalRecord.Meta] -> + record.recordMetaTypeFormat.write(rep.MedicalRecordGen.nextMedicalRecordMeta()), + classOf[MedicalRecord.Status] -> + record.recordStatusFormat.write(rep.MedicalRecordGen.nextMedicalRecordStatus()), + + classOf[MedicalRecordIssue] -> + recordissue.recordIssueFormat.write(rep.MedicalRecordGen.nextMedicalRecordIssue()), + + classOf[MedicalRecordHistory] -> + recordhistory.recordHistoryFormat.write(rep.MedicalRecordGen.nextMedicalRecordHistory()), + classOf[MedicalRecordHistory.Action] -> + recordhistory.recordActionFormat.write(rep.MedicalRecordGen.nextMedicalRecordHistoryAction()), + classOf[MedicalRecordHistory.State] -> + recordhistory.recordStateFormat.write(rep.MedicalRecordGen.nextMedicalRecordHistoryState()), + + classOf[BridgeUploadQueue.Item] -> + bridgeuploadqueue.queueUploadItemFormat.write(rep.BridgeUploadQueueGen.nextBridgeUploadQueueItem()), + + classOf[ExtractedData.Meta] -> + extracteddata.extractedDataMetaFormat.write(rep.ExtractedDataGen.nextExtractedDataMeta()), + classOf[ExtractedData.Meta.Evidence] -> + extracteddata.metaEvidenceFormat.write(rep.ExtractedDataGen.nextExtractedDataMetaEvidence()), + classOf[ExtractedData.Meta.Keyword] -> + extracteddata.metaKeywordFormat.write(rep.ExtractedDataGen.nextExtractedDataMetaKeyword()), + classOf[ExtractedData.Meta.TextLayerPosition] -> + extracteddata.metaTextLayerPositionFormat.write(rep.ExtractedDataGen.nextExtractedDataMetaTextLayerPosition()), + + classOf[TextJson[ExtractedData.Meta]] -> + extracteddata.fullExtractedDataMetaFormat.write(rep.ExtractedDataGen.nextExtractedDataMetaJson()), + + classOf[RichExtractedData] -> + extracteddata.extractedDataFormat.write(rep.ExtractedDataGen.nextRichExtractedData()), + + classOf[ExtractedDataLabel] -> + extracteddata.extractedDataLabelWriter.write(rep.ExtractedDataGen.nextExtractedDataLabel()) + ) + } + + } 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 index fb1d3e3..e7cbd19 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/BridgeUploadQueueGen.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/BridgeUploadQueueGen.scala @@ -2,30 +2,21 @@ 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.entities.ProviderType -import xyz.driver.pdsuidomain.fakes.entities.common.{nextLocalDateTime, nextLongId} +import xyz.driver.pdsuidomain.fakes.entities.common.nextLocalDateTime object BridgeUploadQueueGen { - private val maxAttemtsNumber = 100 + private val maxAttemptsNumber = 100 def nextBridgeUploadQueueItem(): BridgeUploadQueue.Item = { BridgeUploadQueue.Item( kind = nextString(), tag = nextString(), created = nextLocalDateTime, - attempts = nextInt(maxAttemtsNumber, minValue = 0), + attempts = nextInt(maxAttemptsNumber, minValue = 0), nextAttempt = nextLocalDateTime, completed = nextBoolean(), dependencyKind = nextOption(nextString()), dependencyTag = nextOption(nextString()) ) } - - def nextProviderType(): ProviderType = { - ProviderType( - id = nextLongId[ProviderType], - name = 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 index 2f07f1d..0d32495 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 @@ -18,43 +18,47 @@ object DocumentGen { } } - private def nextDates = + private def nextDates() = Common.genBoundedRangeOption[LocalDate](nextLocalDate, nextLocalDate) - private def nextStartAndEndPagesOption = + private def nextStartAndEndPagesOption() = Common.nextStartAndEndPages - private def nextStartAndEndPage = + private def nextStartAndEndPage() = Common.genBoundedRange(nextDouble(),nextDouble()) - def nextDocumentStatus: Document.Status = - generators.oneOf[Document.Status](Document.Status.All) + def nextDocumentStatus(): Document.Status = + Document.Status.New - def nextDocumentRequiredType: Document.RequiredType = + def nextDocumentRequiredType(): Document.RequiredType = generators.oneOf[Document.RequiredType](Document.RequiredType.All) - def nextDocumentHistoryState: DocumentHistory.State = + def nextDocumentHistoryState(): DocumentHistory.State = generators.oneOf[DocumentHistory.State](DocumentHistory.State.All) - def nextDocumentHistoryAction: DocumentHistory.Action = + def nextDocumentHistoryAction(): DocumentHistory.Action = generators.oneOf[DocumentHistory.Action](DocumentHistory.Action.All) - def nextDocumentMeta: Document.Meta = { - val (startPage, endPage) = nextStartAndEndPage + def nextDocumentMeta(): Document.Meta = { + val (startPage, endPage) = nextStartAndEndPage() Document.Meta( nextOption(nextBoolean()), startPage, endPage ) } - def nextDocument: Document = { - val dates = nextDates + def nextDocumentMetaJson(): TextJson[Document.Meta] = { + TextJson(nextDocumentMeta()) + } + + def nextDocument(): Document = { + val dates = nextDates() Document( id = nextLongId[Document], - status = nextDocumentStatus, - previousStatus = nextOption(nextDocumentStatus), + status = nextDocumentStatus(), + previousStatus = None, assignee = nextOption(nextStringId[User]), previousAssignee = nextOption(nextStringId[User]), lastActiveUserId = nextOption(nextStringId[User]), @@ -63,23 +67,23 @@ object DocumentGen { typeId = nextOption(nextLongId[DocumentType]), providerName = nextOption(nextString()), providerTypeId = nextOption(nextLongId[ProviderType]), - requiredType = nextOption(nextDocumentRequiredType), - meta = nextOption(TextJson(nextDocumentMeta)), + requiredType = nextOption(nextDocumentRequiredType()), + meta = nextOption(nextDocumentMetaJson()), startDate = dates._1, endDate = dates._2, lastUpdate = nextLocalDateTime ) } - def nextDocumentType: DocumentType = { + def nextDocumentType(): DocumentType = { DocumentType( id = nextLongId[DocumentType], name = nextString() ) } - def nextDocumentIssue(documentId: LongId[Document]): DocumentIssue = { - val pages = nextStartAndEndPagesOption + def nextDocumentIssue(documentId: LongId[Document] = nextLongId): DocumentIssue = { + val pages = nextStartAndEndPagesOption() DocumentIssue( id = nextLongId[DocumentIssue], @@ -95,13 +99,13 @@ object DocumentGen { } - def nextDocumentHistory(documentId: LongId[Document]): DocumentHistory = { + def nextDocumentHistory(documentId: LongId[Document] = nextLongId): DocumentHistory = { DocumentHistory( id = nextLongId[DocumentHistory], executor = nextStringId[User], documentId = documentId, - state = nextDocumentHistoryState, - action = nextDocumentHistoryAction, + state = nextDocumentHistoryState(), + action = nextDocumentHistoryAction(), created = nextLocalDateTime ) } 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 512e324..0d99d19 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 @@ -67,13 +67,23 @@ object ExtractedDataGen { ) } + 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(TextJson(nextExtractedDataMeta())) + meta = nextOption(nextExtractedDataMetaJson()) ) } @@ -88,7 +98,7 @@ object ExtractedDataGen { ) } - def nextRichExtractedData(documentId: LongId[Document]): RichExtractedData = { + def nextRichExtractedData(documentId: LongId[Document] = nextLongId): RichExtractedData = { RichExtractedData( extractedData = nextExtractedData(documentId), labels = List.fill( 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 0ea3cdd..90c98c3 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 @@ -7,31 +7,31 @@ import xyz.driver.pdsuicommon.domain.{LongId, TextJson, User} import xyz.driver.pdsuidomain.fakes.entities.common.{nextLocalDateTime, nextLongId, nextStringId, nextUuidId} object MedicalRecordGen { - private val maxItemsInCollectionNumber = 50 + private val maxItemsInCollectionNumber: Int = 50 - private val pageMaxNumber = 1000 + private val pageMaxNumber: Int = 1000 - private val medicalRecordMetas = { + private val medicalRecordMetas: Set[() => MedicalRecord.Meta] = { Set( - () => nextMedicalRecordMetaReorder, - () => nextMedicalRecordMetaDuplicate, - () => nextMedicalRecordMetaRotation + () => nextMedicalRecordMetaReorder(), + () => nextMedicalRecordMetaDuplicate(), + () => nextMedicalRecordMetaRotation() ) } def nextMedicalRecordMetas(count: Int): List[MedicalRecord.Meta] = - List.fill(count)(nextMedicalRecordMeta) + List.fill(count)(nextMedicalRecordMeta()) - private def nextMedicalRecordMetasJson: TextJson[List[MedicalRecord.Meta]] = + def nextMedicalRecordMetasJson(): TextJson[List[MedicalRecord.Meta]] = TextJson(nextMedicalRecordMetas(nextInt(maxItemsInCollectionNumber, minValue = 0))) - private def nextDocument: Document = - DocumentGen.nextDocument + private def nextDocument(): Document = + DocumentGen.nextDocument() private def nextDocuments(count: Int): List[Document] = - List.fill(count)(nextDocument) + List.fill(count)(nextDocument()) - private def nextDocuments(recordId: LongId[MedicalRecord]): TextJson[List[Document]] = { + def nextDocuments(recordId: LongId[MedicalRecord]): TextJson[List[Document]] = { val documents = nextDocuments( nextInt(maxItemsInCollectionNumber, minValue = 0) ) @@ -40,17 +40,17 @@ object MedicalRecordGen { } - def nextMedicalRecordStatus: MedicalRecord.Status = - generators.oneOf[MedicalRecord.Status](MedicalRecord.Status.All) + def nextMedicalRecordStatus(): MedicalRecord.Status = + MedicalRecord.Status.New - def nextMedicalRecordHistoryState: MedicalRecordHistory.State = + def nextMedicalRecordHistoryState(): MedicalRecordHistory.State = generators.oneOf[MedicalRecordHistory.State](MedicalRecordHistory.State.All) - def nextMedicalRecordHistoryAction: MedicalRecordHistory.Action = + def nextMedicalRecordHistoryAction(): MedicalRecordHistory.Action = generators.oneOf[MedicalRecordHistory.Action](MedicalRecordHistory.Action.All) - def nextMedicalRecordMetaReorder: MedicalRecord.Meta.Reorder = { + def nextMedicalRecordMetaReorder(): MedicalRecord.Meta.Reorder = { val itemsNumber = maxItemsInCollectionNumber val items = scala.util.Random @@ -63,7 +63,7 @@ object MedicalRecordGen { } - def nextMedicalRecordMetaDuplicate: MedicalRecord.Meta.Duplicate = { + def nextMedicalRecordMetaDuplicate(): MedicalRecord.Meta.Duplicate = { val startPageGen = nextInt(pageMaxNumber, minValue = 0) val endPageGen = @@ -78,7 +78,7 @@ object MedicalRecordGen { ) } - def nextMedicalRecordMetaRotation: MedicalRecord.Meta.Rotation = { + def nextMedicalRecordMetaRotation(): MedicalRecord.Meta.Rotation = { val items = Array.tabulate(maxItemsInCollectionNumber)( index => nextString() -> index @@ -90,7 +90,7 @@ object MedicalRecordGen { ) } - def nextMedicalRecordMeta: MedicalRecord.Meta = { + def nextMedicalRecordMeta(): MedicalRecord.Meta = { generators.oneOf(medicalRecordMetas)() } @@ -99,8 +99,8 @@ object MedicalRecordGen { val id = nextLongId[MedicalRecord] MedicalRecord( id = nextLongId[MedicalRecord], - status = nextMedicalRecordStatus, - previousStatus = nextOption(nextMedicalRecordStatus), + status = nextMedicalRecordStatus(), + previousStatus = None, assignee = nextOption(nextStringId), previousAssignee = nextOption(nextStringId), lastActiveUserId = nextOption(nextStringId), @@ -109,8 +109,8 @@ object MedicalRecordGen { disease = generators.nextString(), caseId = nextOption(CaseId(generators.nextString())), physician = nextOption(generators.nextString()), - meta = nextOption(nextMedicalRecordMetasJson), - predictedMeta = nextOption(nextMedicalRecordMetasJson), + meta = nextOption(nextMedicalRecordMetasJson()), + predictedMeta = nextOption(nextMedicalRecordMetasJson()), predictedDocuments = nextOption(nextDocuments(id)), lastUpdate = nextLocalDateTime ) @@ -121,8 +121,8 @@ object MedicalRecordGen { id = nextLongId[MedicalRecordHistory], executor = nextStringId[User], recordId = nextLongId[MedicalRecord], - state = nextMedicalRecordHistoryState, - action = nextMedicalRecordHistoryAction, + state = nextMedicalRecordHistoryState(), + action = nextMedicalRecordHistoryAction(), created = nextLocalDateTime ) } 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 new file mode 100644 index 0000000..168f7af --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ProviderTypeGen.scala @@ -0,0 +1,14 @@ +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() + ) + } +} -- cgit v1.2.3 From fa841b8902ff29dc3d3e8c7dccd93d7b5b2b827f Mon Sep 17 00:00:00 2001 From: Aleksandr Date: Thu, 28 Sep 2017 18:27:34 +0700 Subject: Formatted code by scalafmt --- .../pdsuicommon/utils/CustomSwaggerJsonFormats.scala | 13 ------------- .../pdsuidomain/fakes/entities/rep/Common.scala | 20 +++++++------------- .../pdsuidomain/fakes/entities/rep/DocumentGen.scala | 12 +++++------- .../fakes/entities/rep/ExportPatientGen.scala | 8 ++++---- .../fakes/entities/rep/ExtractedDataGen.scala | 12 ++++-------- .../fakes/entities/rep/MedicalRecordGen.scala | 12 +++++------- 6 files changed, 25 insertions(+), 52 deletions(-) (limited to 'src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep') diff --git a/src/main/scala/xyz/driver/pdsuicommon/utils/CustomSwaggerJsonFormats.scala b/src/main/scala/xyz/driver/pdsuicommon/utils/CustomSwaggerJsonFormats.scala index f2c6d94..538618b 100644 --- a/src/main/scala/xyz/driver/pdsuicommon/utils/CustomSwaggerJsonFormats.scala +++ b/src/main/scala/xyz/driver/pdsuicommon/utils/CustomSwaggerJsonFormats.scala @@ -69,7 +69,6 @@ object CustomSwaggerJsonFormats { import xyz.driver.pdsuidomain.formats.json.sprayformats.bridgeuploadqueue import xyz.driver.pdsuidomain.formats.json.sprayformats.extracteddata - val customRepObjectsExamples = immutable.Map[Class[_], JsValue]( classOf[Document] -> document.documentFormat.write(rep.DocumentGen.nextDocument()), @@ -81,20 +80,16 @@ object CustomSwaggerJsonFormats { document.requiredTypeFormat.write(rep.DocumentGen.nextDocumentRequiredType()), classOf[Document.Status] -> document.documentStatusFormat.write(rep.DocumentGen.nextDocumentStatus()), - classOf[DocumentIssue] -> documentissue.documentIssueFormat.write(rep.DocumentGen.nextDocumentIssue()), - classOf[DocumentHistory] -> documenthistory.documentHistoryFormat.write(rep.DocumentGen.nextDocumentHistory()), classOf[DocumentHistory.Action] -> documenthistory.documentActionFormat.write(rep.DocumentGen.nextDocumentHistoryAction()), classOf[DocumentHistory.State] -> documenthistory.documentStateFormat.write(rep.DocumentGen.nextDocumentHistoryState()), - classOf[ProviderType] -> providertype.providerTypeFormat.write(rep.ProviderTypeGen.nextProviderType()), - classOf[TextJson[List[MedicalRecord.Meta]]] -> record.recordMetaFormat.write(rep.MedicalRecordGen.nextMedicalRecordMetasJson()), classOf[MedicalRecord] -> @@ -103,20 +98,16 @@ object CustomSwaggerJsonFormats { record.recordMetaTypeFormat.write(rep.MedicalRecordGen.nextMedicalRecordMeta()), classOf[MedicalRecord.Status] -> record.recordStatusFormat.write(rep.MedicalRecordGen.nextMedicalRecordStatus()), - classOf[MedicalRecordIssue] -> recordissue.recordIssueFormat.write(rep.MedicalRecordGen.nextMedicalRecordIssue()), - classOf[MedicalRecordHistory] -> recordhistory.recordHistoryFormat.write(rep.MedicalRecordGen.nextMedicalRecordHistory()), classOf[MedicalRecordHistory.Action] -> recordhistory.recordActionFormat.write(rep.MedicalRecordGen.nextMedicalRecordHistoryAction()), classOf[MedicalRecordHistory.State] -> recordhistory.recordStateFormat.write(rep.MedicalRecordGen.nextMedicalRecordHistoryState()), - classOf[BridgeUploadQueue.Item] -> bridgeuploadqueue.queueUploadItemFormat.write(rep.BridgeUploadQueueGen.nextBridgeUploadQueueItem()), - classOf[ExtractedData.Meta] -> extracteddata.extractedDataMetaFormat.write(rep.ExtractedDataGen.nextExtractedDataMeta()), classOf[ExtractedData.Meta.Evidence] -> @@ -125,17 +116,13 @@ object CustomSwaggerJsonFormats { extracteddata.metaKeywordFormat.write(rep.ExtractedDataGen.nextExtractedDataMetaKeyword()), classOf[ExtractedData.Meta.TextLayerPosition] -> extracteddata.metaTextLayerPositionFormat.write(rep.ExtractedDataGen.nextExtractedDataMetaTextLayerPosition()), - classOf[TextJson[ExtractedData.Meta]] -> extracteddata.fullExtractedDataMetaFormat.write(rep.ExtractedDataGen.nextExtractedDataMetaJson()), - classOf[RichExtractedData] -> extracteddata.extractedDataFormat.write(rep.ExtractedDataGen.nextRichExtractedData()), - classOf[ExtractedDataLabel] -> extracteddata.extractedDataLabelWriter.write(rep.ExtractedDataGen.nextExtractedDataLabel()) ) } - } 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 index 337dc2b..9618eed 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/Common.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/Common.scala @@ -5,26 +5,20 @@ 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) = { + def genBoundedRange[T](from: T, to: T)(implicit ord: Ordering[T]): (T, T) = { if (ord.compare(from, to) > 0) { to -> from - } - else { + } else { from -> to } } - def genBoundedRangeOption[T](from: T, - to: T) - (implicit ord: Ordering[T]): (Option[T], Option[T]) = { + 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) + .map(left => genBoundedRange(left, to)) + .map { + case (left, right) => + left -> nextOption(right) } ranges.map(_._1) -> ranges.flatMap(_._2) 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 0d32495..10349bb 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 @@ -1,6 +1,5 @@ package xyz.driver.pdsuidomain.fakes.entities.rep - import java.time.LocalDate import xyz.driver.core.generators @@ -10,8 +9,7 @@ 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] { + implicit private class LocalDateOrdering(localData: LocalDate) extends Ordered[LocalDate] { override def compare(that: LocalDate): Int = { this.localData.compareTo(that) @@ -25,8 +23,7 @@ object DocumentGen { Common.nextStartAndEndPages private def nextStartAndEndPage() = - Common.genBoundedRange(nextDouble(),nextDouble()) - + Common.genBoundedRange(nextDouble(), nextDouble()) def nextDocumentStatus(): Document.Status = Document.Status.New @@ -44,7 +41,9 @@ object DocumentGen { val (startPage, endPage) = nextStartAndEndPage() Document.Meta( - nextOption(nextBoolean()), startPage, endPage + nextOption(nextBoolean()), + startPage, + endPage ) } @@ -98,7 +97,6 @@ object DocumentGen { ) } - def nextDocumentHistory(documentId: LongId[Document] = nextLongId): DocumentHistory = { DocumentHistory( id = nextLongId[DocumentHistory], 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 4a4164a..7259d0c 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 @@ -4,10 +4,10 @@ import xyz.driver.core.generators._ import xyz.driver.pdsuicommon.domain.{LongId, UuidId} import xyz.driver.pdsuidomain.entities.{Document, ExtractedData, Label, RecordRequestId} import xyz.driver.pdsuidomain.entities.export.patient.{ -ExportPatientLabel, -ExportPatientLabelEvidence, -ExportPatientLabelEvidenceDocument, -ExportPatientWithLabels + ExportPatientLabel, + ExportPatientLabelEvidence, + ExportPatientLabelEvidenceDocument, + ExportPatientWithLabels } import xyz.driver.pdsuidomain.fakes.entities.common.{nextLocalDate, nextLongId} 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 0d99d19..8ac07d0 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,5 @@ package xyz.driver.pdsuidomain.fakes.entities.rep - import xyz.driver.core.generators._ import xyz.driver.pdsuicommon.domain.{LongId, TextJson} import xyz.driver.pdsuidomain.entities._ @@ -8,16 +7,15 @@ 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 maxPageNumber = 100 + private val maxIndexNumber = 100 private val maxOffsetNumber = 10 implicit private class TextLayerPositionOrdering(textLayerPosition: ExtractedData.Meta.TextLayerPosition) - extends Ordered[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 @@ -56,7 +54,7 @@ object ExtractedDataGen { ExtractedData.Meta.Evidence( pageRatio = nextDouble(), start = layersPosition._1, - end = layersPosition._2 + end = layersPosition._2 ) } @@ -76,7 +74,6 @@ object ExtractedDataGen { ) } - def nextExtractedData(documentId: LongId[Document]): ExtractedData = { ExtractedData( id = nextLongId[ExtractedData], @@ -87,7 +84,6 @@ object ExtractedDataGen { ) } - def nextExtractedDataLabel(): ExtractedDataLabel = { ExtractedDataLabel( id = nextLongId[ExtractedDataLabel], 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 90c98c3..7221e66 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 @@ -39,7 +39,6 @@ object MedicalRecordGen { TextJson(documents.map(_.copy(recordId = recordId))) } - def nextMedicalRecordStatus(): MedicalRecord.Status = MedicalRecord.Status.New @@ -49,7 +48,6 @@ object MedicalRecordGen { def nextMedicalRecordHistoryAction(): MedicalRecordHistory.Action = generators.oneOf[MedicalRecordHistory.Action](MedicalRecordHistory.Action.All) - def nextMedicalRecordMetaReorder(): MedicalRecord.Meta.Reorder = { val itemsNumber = maxItemsInCollectionNumber @@ -62,7 +60,6 @@ object MedicalRecordGen { ) } - def nextMedicalRecordMetaDuplicate(): MedicalRecord.Meta.Duplicate = { val startPageGen = nextInt(pageMaxNumber, minValue = 0) @@ -80,9 +77,11 @@ object MedicalRecordGen { def nextMedicalRecordMetaRotation(): MedicalRecord.Meta.Rotation = { val items = - Array.tabulate(maxItemsInCollectionNumber)( - index => nextString() -> index - ).toMap + Array + .tabulate(maxItemsInCollectionNumber)( + index => nextString() -> index + ) + .toMap MedicalRecord.Meta.Rotation( predicted = nextOption(nextBoolean()), @@ -94,7 +93,6 @@ object MedicalRecordGen { generators.oneOf(medicalRecordMetas)() } - def nextMedicalRecord(): MedicalRecord = { val id = nextLongId[MedicalRecord] MedicalRecord( -- cgit v1.2.3 From 642f98c2ddd8af6c83d3de5a51c643ba93b23f96 Mon Sep 17 00:00:00 2001 From: Aleksandr Date: Fri, 29 Sep 2017 13:48:22 +0700 Subject: Fixed ExportPatientGen class --- .../fakes/entities/rep/ExportPatientGen.scala | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep') 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 7259d0c..c2909f3 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 @@ -2,7 +2,7 @@ package xyz.driver.pdsuidomain.fakes.entities.rep import xyz.driver.core.generators._ import xyz.driver.pdsuicommon.domain.{LongId, UuidId} -import xyz.driver.pdsuidomain.entities.{Document, ExtractedData, Label, RecordRequestId} +import xyz.driver.pdsuidomain.entities._ import xyz.driver.pdsuidomain.entities.export.patient.{ ExportPatientLabel, ExportPatientLabelEvidence, @@ -14,12 +14,26 @@ import xyz.driver.pdsuidomain.fakes.entities.common.{nextLocalDate, nextLongId} object ExportPatientGen { private val maxItemsInCollectionNumber = 3 + def nextDocumentType(documentTypeId: LongId[DocumentType] = nextLongId): DocumentType = { + DocumentType( + documentTypeId, + nextString() + ) + } + + def nextProviderType(providerTypeId: LongId[ProviderType] = nextLongId): ProviderType = { + ProviderType( + providerTypeId, + nextString() + ) + } + def nextExportPatientLabelEvidenceDocument(documentId: LongId[Document]): ExportPatientLabelEvidenceDocument = { ExportPatientLabelEvidenceDocument( documentId = documentId, requestId = RecordRequestId(nextUuid()), - documentType = nextString(), - providerType = nextString(), + documentType = nextDocumentType(), + providerType = nextProviderType(), date = nextLocalDate ) } -- cgit v1.2.3