From b5e0d5f91b52013bc11ef3ea586a54bb001577bc Mon Sep 17 00:00:00 2001 From: vlad Date: Sun, 1 Oct 2017 12:50:54 -0700 Subject: Fixing IN in filters, Model from EVLS added to common, Reusing domain model labels --- .../pdsuidomain/fakes/entities/rep/Common.scala | 35 ---------------------- .../fakes/entities/rep/DocumentGen.scala | 7 +++-- .../fakes/entities/rep/ExportPatientGen.scala | 11 +++---- .../fakes/entities/rep/ExtractedDataGen.scala | 17 ++++------- .../fakes/entities/rep/MedicalRecordGen.scala | 7 +++-- .../fakes/entities/rep/ProviderTypeGen.scala | 14 --------- 6 files changed, 19 insertions(+), 72 deletions(-) delete mode 100644 src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/Common.scala delete 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/pdsuidomain/fakes/entities/rep/Common.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/Common.scala deleted file mode 100644 index 9618eed..0000000 --- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/Common.scala +++ /dev/null @@ -1,35 +0,0 @@ -package xyz.driver.pdsuidomain.fakes.entities.rep - -import xyz.driver.core.generators -import xyz.driver.core.generators._ -import xyz.driver.pdsuicommon.domain.FuzzyValue - -private[rep] object Common { - def genBoundedRange[T](from: T, to: T)(implicit ord: Ordering[T]): (T, T) = { - if (ord.compare(from, to) > 0) { - to -> from - } else { - from -> to - } - } - - def genBoundedRangeOption[T](from: T, to: T)(implicit ord: Ordering[T]): (Option[T], Option[T]) = { - val ranges = nextOption(from) - .map(left => genBoundedRange(left, to)) - .map { - case (left, right) => - left -> nextOption(right) - } - - ranges.map(_._1) -> ranges.flatMap(_._2) - } - - def nextFuzzyValue(): FuzzyValue = { - generators.oneOf[FuzzyValue](FuzzyValue.All) - } - - def nextStartAndEndPages: (Option[Double], Option[Double]) = { - genBoundedRangeOption[Double](nextDouble(), nextDouble()) - } - -} diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/DocumentGen.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/DocumentGen.scala index 10349bb..6d5330e 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/DocumentGen.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/DocumentGen.scala @@ -4,6 +4,7 @@ import java.time.LocalDate import xyz.driver.core.generators import xyz.driver.core.generators.{nextBoolean, nextDouble, nextOption, nextString} +import xyz.driver.pdsuidomain.fakes.entities.common._ import xyz.driver.pdsuicommon.domain.{LongId, TextJson, User} import xyz.driver.pdsuidomain.entities._ import xyz.driver.pdsuidomain.fakes.entities.common.{nextLocalDate, nextLocalDateTime, nextLongId, nextStringId} @@ -17,13 +18,13 @@ object DocumentGen { } private def nextDates() = - Common.genBoundedRangeOption[LocalDate](nextLocalDate, nextLocalDate) + genBoundedRangeOption[LocalDate](nextLocalDate, nextLocalDate) private def nextStartAndEndPagesOption() = - Common.nextStartAndEndPages + nextStartAndEndPages private def nextStartAndEndPage() = - Common.genBoundedRange(nextDouble(), nextDouble()) + genBoundedRange(nextDouble(), nextDouble()) def nextDocumentStatus(): Document.Status = Document.Status.New diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExportPatientGen.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExportPatientGen.scala index c2909f3..e3ef6bc 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExportPatientGen.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExportPatientGen.scala @@ -1,14 +1,11 @@ package xyz.driver.pdsuidomain.fakes.entities.rep import xyz.driver.core.generators._ +import xyz.driver.entities.labels.Label import xyz.driver.pdsuicommon.domain.{LongId, UuidId} +import xyz.driver.pdsuidomain.fakes.entities.common._ import xyz.driver.pdsuidomain.entities._ -import xyz.driver.pdsuidomain.entities.export.patient.{ - ExportPatientLabel, - ExportPatientLabelEvidence, - ExportPatientLabelEvidenceDocument, - ExportPatientWithLabels -} +import xyz.driver.pdsuidomain.entities.export.patient._ import xyz.driver.pdsuidomain.fakes.entities.common.{nextLocalDate, nextLongId} object ExportPatientGen { @@ -41,7 +38,7 @@ object ExportPatientGen { def nextExportPatientLabelEvidence(documentId: LongId[Document]): ExportPatientLabelEvidence = { ExportPatientLabelEvidence( id = nextLongId[ExtractedData], - value = Common.nextFuzzyValue(), + value = nextFuzzyValue(), evidenceText = nextString(), document = nextExportPatientLabelEvidenceDocument(documentId) ) diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExtractedDataGen.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExtractedDataGen.scala index 8ac07d0..8e77445 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExtractedDataGen.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExtractedDataGen.scala @@ -1,6 +1,7 @@ package xyz.driver.pdsuidomain.fakes.entities.rep import xyz.driver.core.generators._ +import xyz.driver.entities.labels.{Label, LabelCategory} import xyz.driver.pdsuicommon.domain.{LongId, TextJson} import xyz.driver.pdsuidomain.entities._ import xyz.driver.pdsuidomain.entities.ExtractedData.Meta @@ -46,7 +47,7 @@ object ExtractedDataGen { def nextExtractedDataMetaEvidence(): Meta.Evidence = { val layersPosition = - Common.genBoundedRange[ExtractedData.Meta.TextLayerPosition]( + genBoundedRange[ExtractedData.Meta.TextLayerPosition]( nextExtractedDataMetaTextLayerPosition(), nextExtractedDataMetaTextLayerPosition() ) @@ -65,14 +66,8 @@ object ExtractedDataGen { ) } - def nextExtractedDataMetaJson(): TextJson[Meta] = { - TextJson( - ExtractedData.Meta( - nextExtractedDataMetaKeyword(), - nextExtractedDataMetaEvidence() - ) - ) - } + def nextExtractedDataMetaJson(): TextJson[Meta] = + TextJson(ExtractedData.Meta(nextExtractedDataMetaKeyword(), nextExtractedDataMetaEvidence())) def nextExtractedData(documentId: LongId[Document]): ExtractedData = { ExtractedData( @@ -89,8 +84,8 @@ object ExtractedDataGen { id = nextLongId[ExtractedDataLabel], dataId = nextLongId[ExtractedData], labelId = nextOption(nextLongId[Label]), - categoryId = nextOption(nextLongId[Category]), - value = nextOption(Common.nextFuzzyValue()) + categoryId = nextOption(nextLongId[LabelCategory]), + value = nextOption(nextFuzzyValue()) ) } diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/MedicalRecordGen.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/MedicalRecordGen.scala index 7221e66..023dc00 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/MedicalRecordGen.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/MedicalRecordGen.scala @@ -4,7 +4,7 @@ import xyz.driver.pdsuidomain.entities._ import xyz.driver.core.generators import xyz.driver.core.generators._ import xyz.driver.pdsuicommon.domain.{LongId, TextJson, User} -import xyz.driver.pdsuidomain.fakes.entities.common.{nextLocalDateTime, nextLongId, nextStringId, nextUuidId} +import xyz.driver.pdsuidomain.fakes.entities.common._ object MedicalRecordGen { private val maxItemsInCollectionNumber: Int = 50 @@ -126,7 +126,7 @@ object MedicalRecordGen { } def nextMedicalRecordIssue(): MedicalRecordIssue = { - val pages = Common.nextStartAndEndPages + val pages = nextStartAndEndPages MedicalRecordIssue( id = nextLongId[MedicalRecordIssue], @@ -141,4 +141,7 @@ object MedicalRecordGen { ) } + def nextProviderType(): ProviderType = + ProviderType(id = nextLongId[ProviderType], name = nextString()) + } diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ProviderTypeGen.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ProviderTypeGen.scala deleted file mode 100644 index 168f7af..0000000 --- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ProviderTypeGen.scala +++ /dev/null @@ -1,14 +0,0 @@ -package xyz.driver.pdsuidomain.fakes.entities.rep - -import xyz.driver.core.generators.nextString -import xyz.driver.pdsuidomain.entities.ProviderType -import xyz.driver.pdsuidomain.fakes.entities.common.nextLongId - -object ProviderTypeGen { - def nextProviderType(): ProviderType = { - ProviderType( - id = nextLongId[ProviderType], - name = nextString() - ) - } -} -- cgit v1.2.3