aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKseniya Tomskikh <ktomskih@datamonsters.co>2017-10-17 11:15:54 +0700
committerGitHub <noreply@github.com>2017-10-17 11:15:54 +0700
commitc5d36593cc14bfdfb7b8f06d680ad6fc2eb6dde0 (patch)
tree485fc8a1c7ac8e7a9dd8fc8ed5308dba185fb6ca
parentf3b809659969ee29ab7f0a62ec1cff25a3e263dc (diff)
parenta0599ae4d12acafb934b40f52d4a771709b3e583 (diff)
downloadrest-query-c5d36593cc14bfdfb7b8f06d680ad6fc2eb6dde0.tar.gz
rest-query-c5d36593cc14bfdfb7b8f06d680ad6fc2eb6dde0.tar.bz2
rest-query-c5d36593cc14bfdfb7b8f06d680ad6fc2eb6dde0.zip
Merge pull request #47 from drivergroup/PDSUI-2318v0.8.8
PDSUI-2318 Created custom swagger format for TM
-rw-r--r--src/main/scala/xyz/driver/pdsuicommon/utils/CustomSwaggerJsonFormats.scala132
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/fakes/entities/common.scala46
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/fakes/entities/eligibility.scala8
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala44
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/fakes/entities/recordprocessing.scala284
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/BridgeUploadQueueGen.scala22
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/DocumentGen.scala103
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExportPatientGen.scala54
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExtractedDataGen.scala101
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/MedicalRecordGen.scala131
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/fakes/entities/treatmentmatching.scala167
11 files changed, 620 insertions, 472 deletions
diff --git a/src/main/scala/xyz/driver/pdsuicommon/utils/CustomSwaggerJsonFormats.scala b/src/main/scala/xyz/driver/pdsuicommon/utils/CustomSwaggerJsonFormats.scala
index 6d2a068..b122fab 100644
--- a/src/main/scala/xyz/driver/pdsuicommon/utils/CustomSwaggerJsonFormats.scala
+++ b/src/main/scala/xyz/driver/pdsuicommon/utils/CustomSwaggerJsonFormats.scala
@@ -17,8 +17,16 @@ import xyz.driver.pdsuidomain.formats.json.sprayformats.trialissue._
import xyz.driver.core.swagger.CustomSwaggerJsonConverter._
import xyz.driver.entities.patient.CancerType
import xyz.driver.pdsuicommon.concurrent.BridgeUploadQueue
+import xyz.driver.pdsuidomain.fakes.entities.common
+import xyz.driver.pdsuidomain.formats.json.sprayformats.bridgeuploadqueue._
+import xyz.driver.pdsuidomain.formats.json.sprayformats.record._
+import xyz.driver.pdsuidomain.formats.json.sprayformats.document._
import xyz.driver.pdsuidomain.services.CriterionService.RichCriterion
import xyz.driver.pdsuidomain.services.ExtractedDataService.RichExtractedData
+import xyz.driver.pdsuidomain.services.PatientCriterionService.{DraftPatientCriterion, RichPatientCriterion}
+import xyz.driver.pdsuidomain.services.PatientEligibleTrialService.RichPatientEligibleTrial
+import xyz.driver.pdsuidomain.services.PatientHypothesisService.RichPatientHypothesis
+import xyz.driver.pdsuidomain.services.PatientLabelService.RichPatientLabel
import scala.collection.immutable
@@ -29,11 +37,18 @@ object CustomSwaggerJsonFormats {
classOf[LocalDate] -> stringProperty(example = Some("2010-12-31")),
classOf[UuidId[_]] -> stringProperty(example = Some("370b0450-35cb-4aab-ba74-0145be75add5")),
classOf[StringId[_]] -> stringProperty(),
- classOf[LongId[_]] -> stringProperty()
+ classOf[LongId[_]] -> stringProperty(),
+ classOf[CancerType] -> stringProperty()
)
+
+ val customCommonObjectsExamples = immutable.Map[Class[_], JsValue](
+ classOf[BridgeUploadQueue.Item] -> queueUploadItemFormat.write(common.nextBridgeUploadQueueItem()),
+ classOf[ProviderType] -> providerTypeFormat.write(common.nextProviderType()),
+ classOf[DocumentType] -> documentTypeFormat.write(common.nextDocumentType())
+ )
+
val customTrialCurationProperties = immutable.Map[Class[_], Property](
classOf[Trial.Status] -> stringProperty(),
- classOf[CancerType] -> stringProperty(),
classOf[TrialHistory.Action] -> stringProperty(),
classOf[TrialHistory.State] -> stringProperty()
) ++ customCommonProperties
@@ -59,70 +74,83 @@ object CustomSwaggerJsonFormats {
// 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.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
+ import xyz.driver.pdsuidomain.fakes.entities.recordprocessing._
+ import xyz.driver.pdsuidomain.formats.json.sprayformats._
+
+ val customRecordProcessingProperties = immutable.Map[Class[_], Property](
+ classOf[MedicalRecord.Status] -> stringProperty(),
+ classOf[MedicalRecordHistory.Action] -> stringProperty(),
+ classOf[MedicalRecordHistory.State] -> stringProperty(),
+ classOf[Document.Status] -> stringProperty(),
+ classOf[Document.RequiredType] -> stringProperty(),
+ classOf[DocumentHistory.Action] -> stringProperty(),
+ classOf[DocumentHistory.State] -> stringProperty()
+ ) ++ customCommonProperties
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()),
+ document.documentFormat.write(nextDocument()),
classOf[DocumentIssue] ->
- documentissue.documentIssueFormat.write(rep.DocumentGen.nextDocumentIssue()),
+ documentissue.documentIssueFormat.write(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] ->
- record.providerTypeFormat.write(rep.MedicalRecordGen.nextProviderType()),
+ documenthistory.documentHistoryFormat.write(nextDocumentHistory()),
classOf[TextJson[List[MedicalRecord.Meta]]] ->
- record.recordMetaFormat.write(rep.MedicalRecordGen.nextMedicalRecordMetasJson()),
+ record.recordMetaFormat.write(nextMedicalRecordMetaJson()),
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()),
+ record.recordFormat.write(nextMedicalRecord()),
classOf[MedicalRecordIssue] ->
- recordissue.recordIssueFormat.write(rep.MedicalRecordGen.nextMedicalRecordIssue()),
+ recordissue.recordIssueFormat.write(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()),
+ recordhistory.recordHistoryFormat.write(nextMedicalRecordHistory()),
+ classOf[RichExtractedData] ->
+ extracteddata.extractedDataFormat.write(nextRichExtractedData()),
+ classOf[MedicalRecord.Meta] ->
+ record.recordMetaTypeFormat.write(nextMedicalRecordMeta()),
+ classOf[TextJson[Document.Meta]] ->
+ document.fullDocumentMetaFormat.write(nextDocumentMetaJson()),
classOf[ExtractedData.Meta] ->
- extracteddata.extractedDataMetaFormat.write(rep.ExtractedDataGen.nextExtractedDataMeta()),
+ extracteddata.extractedDataMetaFormat.write(nextExtractedDataMeta()),
classOf[ExtractedData.Meta.Evidence] ->
- extracteddata.metaEvidenceFormat.write(rep.ExtractedDataGen.nextExtractedDataMetaEvidence()),
+ extracteddata.metaEvidenceFormat.write(nextExtractedDataMetaEvidence()),
classOf[ExtractedData.Meta.Keyword] ->
- extracteddata.metaKeywordFormat.write(rep.ExtractedDataGen.nextExtractedDataMetaKeyword()),
+ extracteddata.metaKeywordFormat.write(nextExtractedDataMetaKeyword()),
classOf[ExtractedData.Meta.TextLayerPosition] ->
- extracteddata.metaTextLayerPositionFormat.write(rep.ExtractedDataGen.nextExtractedDataMetaTextLayerPosition()),
+ extracteddata.metaTextLayerPositionFormat.write(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())
- )
+ extracteddata.fullExtractedDataMetaFormat.write(nextExtractedDataMetaJson())
+ ) ++ customCommonObjectsExamples
+ }
+
+ object treatmentmatching {
+ import xyz.driver.pdsuidomain.fakes.entities.treatmentmatching._
+ import xyz.driver.pdsuidomain.formats.json.sprayformats.patient._
+ import xyz.driver.pdsuidomain.formats.json.sprayformats.patientcriterion._
+ import xyz.driver.pdsuidomain.formats.json.sprayformats.patientdefiningcriteria._
+ import xyz.driver.pdsuidomain.formats.json.sprayformats.patienteligibletrial._
+ import xyz.driver.pdsuidomain.formats.json.sprayformats.patientlabel._
+ import xyz.driver.pdsuidomain.formats.json.sprayformats.patienthypothesis._
+ import xyz.driver.pdsuidomain.formats.json.sprayformats.patienthistory._
+ import xyz.driver.pdsuidomain.formats.json.sprayformats.patientissue._
+
+ val customTreatmentMatchingProperties = immutable.Map[Class[_], Property](
+ classOf[Patient.Status] -> stringProperty(),
+ classOf[PatientHistory.Action] -> stringProperty(),
+ classOf[PatientHistory.State] -> stringProperty()
+ ) ++ customCommonProperties
+
+ val customTreatmentMatchingObjectsExamples = immutable.Map[Class[_], JsValue](
+ classOf[Patient] -> patientWriter.write(nextPatient()),
+ classOf[RichPatientLabel] -> richPatientLabelWriter.write(nextRichPatientLabel()),
+ classOf[PatientLabel] -> patientLabelDefiningCriteriaWriter.write(nextPatientLabel()),
+ classOf[RichPatientCriterion] -> patientCriterionWriter.write(nextRichPatientCriterion()),
+ classOf[DraftPatientCriterion] -> draftPatientCriterionFormat.write(nextDraftPatientCriterion()),
+ classOf[PatientLabelEvidenceView] -> patientLabelEvidenceWriter.write(nextPatientLabelEvidenceView()),
+ classOf[RichPatientEligibleTrial] -> patientEligibleTrialWriter.write(nextRichPatientEligibleTrial()),
+ classOf[PatientHypothesis] -> patientHypothesisWriter.write(nextPatientHypothesis()),
+ classOf[RichPatientHypothesis] -> richPatientHypothesisWriter.write(nextRichPatientHypothesis()),
+ classOf[PatientHistory] -> patientHistoryFormat.write(nextPatientHistory()),
+ classOf[PatientIssue] -> patientIssueWriter.write(nextPatientIssue())
+ ) ++ customCommonObjectsExamples
}
}
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 f77c2e0..0ac2be5 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/common.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/common.scala
@@ -2,9 +2,12 @@ package xyz.driver.pdsuidomain.fakes.entities
import java.time.{LocalDate, LocalDateTime, LocalTime}
-import xyz.driver.core.generators.{nextDouble, nextOption}
-import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId}
-import xyz.driver.pdsuidomain.entities.{Trial, TrialHistory}
+import xyz.driver.core.generators._
+import xyz.driver.entities.common.FullName
+import xyz.driver.entities.patient.CancerType
+import xyz.driver.pdsuicommon.concurrent.BridgeUploadQueue
+import xyz.driver.pdsuicommon.domain.{LongId, StringId, TextJson, UuidId}
+import xyz.driver.pdsuidomain.entities._
import scala.util.Random
@@ -50,7 +53,42 @@ object common {
ranges.map(_._1) -> ranges.flatMap(_._2)
}
- def nextStartAndEndPages: (Option[Double], Option[Double]) =
+ def nextStartAndEndPagesOption: (Option[Double], Option[Double]) =
genBoundedRangeOption[Double](nextDouble(), nextDouble())
+ def nextStartAndEndPages: (Double, Double) =
+ genBoundedRange(nextDouble(), nextDouble())
+
+ def nextPatientStatus: Patient.Status = generators.oneOf[Patient.Status](Patient.Status.All)
+
+ def nextFullName[T]: FullName[T] = FullName(
+ firstName = generators.nextName[T](10),
+ middleName = generators.nextName[T](10),
+ lastName = generators.nextName[T](10)
+ )
+
+ def nextCancerType: CancerType =
+ generators.oneOf[CancerType](CancerType.Breast, CancerType.Lung, CancerType.Prostate)
+
+ 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())
+ )
+ }
+
+ def nextDocumentType(): DocumentType = generators.oneOf[DocumentType](DocumentType.All: _*)
+
+ def nextProviderType(): ProviderType = generators.oneOf[ProviderType](ProviderType.All: _*)
+
+ def nextTextJson[T](obj: T): TextJson[T] = TextJson(obj)
+
}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/eligibility.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/eligibility.scala
index 5f3321c..1796fe6 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/eligibility.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/eligibility.scala
@@ -12,8 +12,8 @@ object eligibility {
def nextMolecularEvidenceDocument(): MolecularEvidenceDocument =
MolecularEvidenceDocument(
- documentType = xyz.driver.pdsuidomain.fakes.entities.rep.DocumentGen.nextDocumentType(),
- providerType = xyz.driver.pdsuidomain.fakes.entities.rep.MedicalRecordGen.nextProviderType(),
+ documentType = xyz.driver.pdsuidomain.fakes.entities.common.nextDocumentType(),
+ providerType = xyz.driver.pdsuidomain.fakes.entities.common.nextProviderType(),
providerName = nextOption(nextString(100)),
date = nextOption(nextDate()),
reportId = nextId[Report](),
@@ -23,8 +23,8 @@ object eligibility {
def nextClinicalEvidenceDocument(): ClinicalEvidenceDocument =
ClinicalEvidenceDocument(
- documentType = xyz.driver.pdsuidomain.fakes.entities.rep.DocumentGen.nextDocumentType(),
- providerType = xyz.driver.pdsuidomain.fakes.entities.rep.MedicalRecordGen.nextProviderType(),
+ documentType = xyz.driver.pdsuidomain.fakes.entities.common.nextDocumentType(),
+ providerType = xyz.driver.pdsuidomain.fakes.entities.common.nextProviderType(),
providerName = nextOption(nextString(100)),
date = nextOption(nextDate()),
documentId = nextId[ClinicalEvidenceDocument](),
diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala
index 1fe7533..2c7d0e0 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala
@@ -1,8 +1,15 @@
package xyz.driver.pdsuidomain.fakes.entities
import xyz.driver.entities.labels.Label
+import xyz.driver.fakes
+import xyz.driver.pdsuidomain.entities.export.patient.{
+ ExportPatientLabel,
+ ExportPatientLabelEvidence,
+ ExportPatientLabelEvidenceDocument,
+ ExportPatientWithLabels
+}
import xyz.driver.pdsuidomain.entities.export.trial._
-import xyz.driver.pdsuidomain.entities.{Criterion, EligibilityArm, Trial}
+import xyz.driver.pdsuidomain.entities._
object export {
import common._
@@ -33,4 +40,39 @@ object export {
arms = listOf(nextExportTrialArm()),
criteria = listOf(nextExportTrialLabelCriterion())
)
+
+ def nextExportPatientLabelEvidenceDocument(): ExportPatientLabelEvidenceDocument = {
+ ExportPatientLabelEvidenceDocument(
+ documentId = nextLongId[Document],
+ requestId = recordprocessing.nextRecordRequestId(),
+ documentType = nextDocumentType(),
+ providerType = nextProviderType(),
+ date = nextLocalDate
+ )
+ }
+
+ def nextExportPatientLabelEvidence(): ExportPatientLabelEvidence = {
+ ExportPatientLabelEvidence(
+ id = nextLongId[ExtractedData],
+ value = fakes.entities.labels.nextLabelValue(),
+ evidenceText = nextString(),
+ document = nextExportPatientLabelEvidenceDocument()
+ )
+ }
+
+ def nextExportPatientLabel(): ExportPatientLabel = {
+ ExportPatientLabel(
+ id = nextLongId[Label],
+ evidences = List.fill(nextInt(10))(nextExportPatientLabelEvidence())
+ )
+ }
+
+ def nextExportPatientWithLabels(): ExportPatientWithLabels = {
+ ExportPatientWithLabels(
+ patientId = nextUuidId[Patient],
+ labelVersion = nextInt(Int.MaxValue).toLong,
+ labels = List.fill(nextInt(10))(nextExportPatientLabel())
+ )
+ }
+
}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/recordprocessing.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/recordprocessing.scala
new file mode 100644
index 0000000..279ea38
--- /dev/null
+++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/recordprocessing.scala
@@ -0,0 +1,284 @@
+package xyz.driver.pdsuidomain.fakes.entities
+
+import java.time.LocalDate
+
+import xyz.driver.core.generators
+import xyz.driver.core.generators._
+import xyz.driver.entities.labels.{Label, LabelCategory, LabelValue}
+import xyz.driver.pdsuicommon.domain.{LongId, TextJson, User}
+import xyz.driver.pdsuidomain.entities.ExtractedData.Meta
+import xyz.driver.pdsuidomain.entities._
+import xyz.driver.pdsuidomain.fakes.entities.common._
+import xyz.driver.pdsuidomain.services.ExtractedDataService.RichExtractedData
+
+object recordprocessing {
+
+ private val maxItemsInCollectionNumber: Int = 50
+ private val maxPageNumber = 100
+ private val maxIndexNumber = 100
+ private val maxOffsetNumber = 10
+
+ implicit private class LocalDateOrdering(localData: LocalDate) extends Ordered[LocalDate] {
+ override def compare(that: LocalDate): Int = {
+ this.localData.compareTo(that)
+ }
+ }
+
+ 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
+ }
+ }
+
+ private def nextDates(): (Option[LocalDate], Option[LocalDate]) =
+ genBoundedRangeOption[LocalDate](nextLocalDate, nextLocalDate)
+
+ private val medicalRecordMeta: Set[() => MedicalRecord.Meta] = {
+ Set(
+ () => nextMedicalRecordMetaReorder(),
+ () => nextMedicalRecordMetaDuplicate(),
+ () => nextMedicalRecordMetaRotation()
+ )
+ }
+
+ def nextMedicalRecordMeta(count: Int): List[MedicalRecord.Meta] =
+ List.fill(count)(nextMedicalRecordMeta())
+
+ def nextMedicalRecordMetaJson(): TextJson[List[MedicalRecord.Meta]] =
+ TextJson(nextMedicalRecordMeta(nextInt(maxItemsInCollectionNumber)))
+
+ private def nextDocumentList(count: Int): List[Document] =
+ List.fill(count)(nextDocument())
+
+ def nextDocumentList(recordId: LongId[MedicalRecord]): TextJson[List[Document]] = {
+ val documents = nextDocumentList(
+ nextInt(maxItemsInCollectionNumber)
+ )
+ 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(items)
+ }
+
+ def nextMedicalRecordMetaDuplicate(): MedicalRecord.Meta.Duplicate = {
+ val startPageGen = nextInt(maxPageNumber)
+ val endPageGen = nextInt(maxPageNumber, startPageGen)
+
+ MedicalRecord.Meta.Duplicate(
+ 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(items = items)
+ }
+
+ def nextMedicalRecordMeta(): MedicalRecord.Meta = generators.oneOf(medicalRecordMeta)()
+
+ def nextRecordRequestId(): RecordRequestId = RecordRequestId(generators.nextUuid())
+
+ def nextMedicalRecord(): MedicalRecord = MedicalRecord(
+ id = nextLongId[MedicalRecord],
+ status = nextMedicalRecordStatus(),
+ previousStatus = None,
+ assignee = nextOption(nextStringId),
+ previousAssignee = nextOption(nextStringId),
+ lastActiveUserId = nextOption(nextStringId),
+ patientId = nextUuidId,
+ requestId = nextRecordRequestId(),
+ disease = generators.nextString(),
+ caseId = nextOption(CaseId(generators.nextString())),
+ physician = nextOption(generators.nextString()),
+ meta = nextOption(nextMedicalRecordMetaJson()),
+ lastUpdate = nextLocalDateTime,
+ totalPages = nextInt(10)
+ )
+
+ def nextMedicalRecordHistory(): MedicalRecordHistory = MedicalRecordHistory(
+ id = nextLongId[MedicalRecordHistory],
+ executor = nextStringId[User],
+ recordId = nextLongId[MedicalRecord],
+ state = nextMedicalRecordHistoryState(),
+ action = nextMedicalRecordHistoryAction(),
+ created = nextLocalDateTime
+ )
+
+ def nextMedicalRecordIssue(): MedicalRecordIssue = {
+ val (startPage, endPage) = nextStartAndEndPagesOption
+
+ MedicalRecordIssue(
+ id = nextLongId[MedicalRecordIssue],
+ userId = nextStringId[User],
+ recordId = nextLongId[MedicalRecord],
+ startPage = startPage,
+ endPage = endPage,
+ lastUpdate = nextLocalDateTime,
+ isDraft = nextBoolean(),
+ text = nextString(),
+ archiveRequired = nextBoolean()
+ )
+ }
+
+ 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) = nextStartAndEndPages
+ Document.Meta(startPage, endPage)
+ }
+
+ def nextDocumentMetaJson(): TextJson[Document.Meta] = nextTextJson(nextDocumentMeta())
+
+ def nextDocument(): Document = {
+ val (startDate, endDate) = 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()),
+ institutionName = nextOption(nextString()),
+ meta = nextOption(nextDocumentMetaJson()),
+ startDate = startDate,
+ endDate = endDate,
+ lastUpdate = nextLocalDateTime
+ )
+ }
+
+ def nextDocumentIssue(documentId: LongId[Document] = nextLongId): DocumentIssue = {
+ val (startPage, endPage) = nextStartAndEndPagesOption
+ DocumentIssue(
+ id = nextLongId[DocumentIssue],
+ userId = nextStringId[User],
+ documentId = documentId,
+ startPage = startPage,
+ endPage = endPage,
+ lastUpdate = nextLocalDateTime,
+ isDraft = nextBoolean(),
+ text = nextString(),
+ archiveRequired = nextBoolean()
+ )
+ }
+
+ def nextDocumentHistory(): DocumentHistory = DocumentHistory(
+ id = nextLongId[DocumentHistory],
+ executor = nextStringId[User],
+ documentId = nextLongId[Document],
+ state = nextDocumentHistoryState(),
+ action = nextDocumentHistoryAction(),
+ created = nextLocalDateTime
+ )
+
+ def nextExtractedDataMetaKeyword(): Meta.Keyword = {
+ ExtractedData.Meta.Keyword(
+ page = nextInt(maxPageNumber),
+ pageRatio = nextOption(nextDouble()),
+ index = nextInt(maxIndexNumber),
+ sortIndex = nextString()
+ )
+ }
+
+ def nextExtractedDataMetaTextLayerPosition(): Meta.TextLayerPosition = {
+ ExtractedData.Meta.TextLayerPosition(
+ page = nextInt(maxPageNumber),
+ index = nextInt(maxIndexNumber),
+ offset = nextInt(maxOffsetNumber)
+ )
+ }
+
+ def nextExtractedDataMetaEvidence(): Meta.Evidence = {
+ val (start, end) =
+ genBoundedRange[ExtractedData.Meta.TextLayerPosition](
+ nextExtractedDataMetaTextLayerPosition(),
+ nextExtractedDataMetaTextLayerPosition()
+ )
+
+ ExtractedData.Meta.Evidence(
+ pageRatio = nextDouble(),
+ start = start,
+ end = end
+ )
+ }
+
+ def nextExtractedDataMeta(): Meta = {
+ ExtractedData.Meta(
+ nextExtractedDataMetaKeyword(),
+ nextExtractedDataMetaEvidence()
+ )
+ }
+
+ def nextExtractedDataMetaJson(): TextJson[Meta] =
+ nextTextJson(ExtractedData.Meta(nextExtractedDataMetaKeyword(), nextExtractedDataMetaEvidence()))
+
+ def nextExtractedData(): ExtractedData = {
+ ExtractedData(
+ id = nextLongId[ExtractedData],
+ documentId = nextLongId[Document],
+ keywordId = nextOption(nextLongId[Keyword]),
+ evidenceText = nextOption(nextString()),
+ meta = nextOption(nextExtractedDataMetaJson())
+ )
+ }
+
+ def nextExtractedDataLabel(dataId: LongId[ExtractedData]): ExtractedDataLabel = {
+ ExtractedDataLabel(
+ id = nextLongId[ExtractedDataLabel],
+ dataId = nextLongId[ExtractedData],
+ labelId = nextOption(nextLongId[Label]),
+ categoryId = nextOption(nextLongId[LabelCategory]),
+ value = nextOption(generators.oneOf[LabelValue](LabelValue.Yes, LabelValue.No, LabelValue.Maybe))
+ )
+ }
+
+ def nextRichExtractedData(): RichExtractedData = {
+ val extractedData = nextExtractedData()
+ RichExtractedData(
+ extractedData = extractedData,
+ labels = List.fill(
+ nextInt(maxItemsInCollectionNumber)
+ )(nextExtractedDataLabel(extractedData.id))
+ )
+ }
+
+}
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
deleted file mode 100644
index e7cbd19..0000000
--- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/BridgeUploadQueueGen.scala
+++ /dev/null
@@ -1,22 +0,0 @@
-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
deleted file mode 100644
index 0dadc41..0000000
--- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/DocumentGen.scala
+++ /dev/null
@@ -1,103 +0,0 @@
-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(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()),
- institutionName = nextOption(nextString()),
- 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
deleted file mode 100644
index 85bab8c..0000000
--- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExportPatientGen.scala
+++ /dev/null
@@ -1,54 +0,0 @@
-package xyz.driver.pdsuidomain.fakes.entities.rep
-
-import xyz.driver.core.generators
-import xyz.driver.core.generators._
-import xyz.driver.entities.labels.{Label, LabelValue}
-import xyz.driver.pdsuicommon.domain.{LongId, UuidId}
-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 = generators.oneOf[LabelValue](LabelValue.Yes, LabelValue.No, LabelValue.Maybe),
- 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
deleted file mode 100644
index 70ddd10..0000000
--- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExtractedDataGen.scala
+++ /dev/null
@@ -1,101 +0,0 @@
-package xyz.driver.pdsuidomain.fakes.entities.rep
-
-import xyz.driver.core.generators
-import xyz.driver.core.generators._
-import xyz.driver.entities.labels.{Label, LabelCategory, LabelValue}
-import xyz.driver.pdsuicommon.domain.{LongId, TextJson}
-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(generators.oneOf[LabelValue](LabelValue.Yes, LabelValue.No, LabelValue.Maybe))
- )
- }
-
- 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
deleted file mode 100644
index 0ff0c3b..0000000
--- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/MedicalRecordGen.scala
+++ /dev/null
@@ -1,131 +0,0 @@
-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(items)
- }
-
- def nextMedicalRecordMetaDuplicate(): MedicalRecord.Meta.Duplicate = {
- val startPageGen =
- nextInt(pageMaxNumber, minValue = 0)
- val endPageGen =
- nextInt(pageMaxNumber, startPageGen)
-
- MedicalRecord.Meta.Duplicate(
- 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(items = items)
- }
-
- def nextMedicalRecordMeta(): MedicalRecord.Meta = {
- generators.oneOf(medicalRecordMetas)()
- }
-
- def nextMedicalRecord(): 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()),
- lastUpdate = nextLocalDateTime,
- totalPages = nextInt(10)
- )
- }
-
- 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/treatmentmatching.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/treatmentmatching.scala
new file mode 100644
index 0000000..35aa5ef
--- /dev/null
+++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/treatmentmatching.scala
@@ -0,0 +1,167 @@
+package xyz.driver.pdsuidomain.fakes.entities
+
+import xyz.driver.entities.labels.Label
+import xyz.driver.fakes
+import xyz.driver.pdsuicommon.domain.{LongId, StringId, User}
+import xyz.driver.pdsuidomain.entities._
+import xyz.driver.pdsuidomain.services.PatientCriterionService.{DraftPatientCriterion, RichPatientCriterion}
+import xyz.driver.pdsuidomain.services.PatientEligibleTrialService.RichPatientEligibleTrial
+import xyz.driver.pdsuidomain.services.PatientHypothesisService.RichPatientHypothesis
+import xyz.driver.pdsuidomain.services.PatientLabelService.RichPatientLabel
+
+object treatmentmatching {
+ import common._
+ import xyz.driver.core.generators
+
+ def nextPatientOrderId: PatientOrderId = PatientOrderId(generators.nextUuid())
+
+ def nextPatientAction: PatientHistory.Action =
+ generators.oneOf[PatientHistory.Action](PatientHistory.Action.All)
+
+ def nextPatientState: PatientHistory.State =
+ generators.oneOf[PatientHistory.State](PatientHistory.State.All)
+
+ def nextPatient(): Patient = Patient(
+ id = nextUuidId[Patient],
+ status = nextPatientStatus,
+ name = nextFullName[Patient],
+ dob = nextLocalDate,
+ assignee = generators.nextOption(nextStringId[User]),
+ previousStatus = generators.nextOption(nextPatientStatus),
+ previousAssignee = generators.nextOption(nextStringId[User]),
+ lastActiveUserId = generators.nextOption(nextStringId[User]),
+ isUpdateRequired = generators.nextBoolean(),
+ disease = nextCancerType,
+ orderId = nextPatientOrderId,
+ lastUpdate = nextLocalDateTime
+ )
+
+ def nextPatientLabel(): PatientLabel = PatientLabel(
+ id = nextLongId[PatientLabel],
+ patientId = nextUuidId[Patient],
+ labelId = nextLongId[Label],
+ score = generators.nextInt(100),
+ primaryValue = generators.nextOption(fakes.entities.labels.nextLabelValue()),
+ verifiedPrimaryValue = generators.nextOption(fakes.entities.labels.nextLabelValue()),
+ isImplicitMatch = generators.nextBoolean(),
+ isVisible = generators.nextBoolean()
+ )
+
+ def nextRichPatientLabel(): RichPatientLabel = RichPatientLabel(
+ patientLabel = nextPatientLabel(),
+ isVerified = generators.nextBoolean()
+ )
+
+ def nextPatientCriterion(): PatientCriterion = PatientCriterion(
+ id = nextLongId[PatientCriterion],
+ patientLabelId = nextLongId[PatientLabel],
+ trialId = generators.nextInt(Int.MaxValue).toLong,
+ nctId = nextStringId[Trial],
+ criterionId = nextLongId[Criterion],
+ criterionText = generators.nextString(),
+ criterionValue = generators.nextOption(generators.nextBoolean()),
+ criterionIsDefining = generators.nextBoolean(),
+ eligibilityStatus = generators.nextOption(fakes.entities.labels.nextLabelValue()),
+ verifiedEligibilityStatus = generators.nextOption(fakes.entities.labels.nextLabelValue()),
+ isVerified = generators.nextBoolean(),
+ isVisible = generators.nextBoolean(),
+ lastUpdate = nextLocalDateTime
+ )
+
+ def nextDraftPatientCriterion(): DraftPatientCriterion = DraftPatientCriterion(
+ id = nextLongId[PatientCriterion],
+ eligibilityStatus = generators.nextOption(fakes.entities.labels.nextLabelValue()),
+ isVerified = generators.nextOption(generators.nextBoolean())
+ )
+
+ def nextPatientCriterionArm(criterionId: LongId[PatientCriterion]): PatientCriterionArm = PatientCriterionArm(
+ patientCriterionId = criterionId,
+ armId = nextLongId[Arm],
+ armName = generators.nextString()
+ )
+
+ def nextRichPatientCriterion(): RichPatientCriterion = {
+ val patientCriterion = nextPatientCriterion()
+ RichPatientCriterion(
+ patientCriterion = patientCriterion,
+ labelId = nextLongId[Label],
+ armList = List(
+ nextPatientCriterionArm(patientCriterion.id),
+ nextPatientCriterionArm(patientCriterion.id),
+ nextPatientCriterionArm(patientCriterion.id)
+ )
+ )
+ }
+
+ def nextPatientLabelEvidenceView(): PatientLabelEvidenceView = PatientLabelEvidenceView(
+ id = nextLongId[PatientLabelEvidence],
+ value = fakes.entities.labels.nextLabelValue(),
+ evidenceText = generators.nextString(),
+ documentId = generators.nextOption(nextLongId[Document]),
+ evidenceId = generators.nextOption(nextLongId[ExtractedData]),
+ reportId = generators.nextOption(nextUuidId[DirectReport]),
+ documentType = nextDocumentType(),
+ date = generators.nextOption(nextLocalDate),
+ providerType = nextProviderType(),
+ patientId = nextUuidId[Patient],
+ labelId = nextLongId[Label],
+ isImplicitMatch = generators.nextBoolean()
+ )
+
+ def nextPatientTrialArmGroupView(trialId: StringId[Trial]): PatientTrialArmGroupView = PatientTrialArmGroupView(
+ id = nextLongId[PatientTrialArmGroup],
+ patientId = nextUuidId[Patient],
+ trialId = trialId,
+ hypothesisId = nextUuidId[Hypothesis],
+ eligibilityStatus = generators.nextOption(fakes.entities.labels.nextLabelValue()),
+ verifiedEligibilityStatus = generators.nextOption(fakes.entities.labels.nextLabelValue()),
+ isVerified = generators.nextBoolean()
+ )
+
+ def nextRichPatientEligibleTrial(): RichPatientEligibleTrial = {
+ val patientCriterionId = nextLongId[PatientCriterion]
+ val trial = trialcuration.nextTrial()
+ RichPatientEligibleTrial(
+ trial = trial,
+ group = nextPatientTrialArmGroupView(trial.id),
+ arms = List(
+ nextPatientCriterionArm(patientCriterionId),
+ nextPatientCriterionArm(patientCriterionId),
+ nextPatientCriterionArm(patientCriterionId)
+ )
+ )
+ }
+
+ def nextPatientHypothesis(): PatientHypothesis = PatientHypothesis(
+ id = nextUuidId[PatientHypothesis],
+ patientId = nextUuidId[Patient],
+ hypothesisId = nextUuidId[Hypothesis],
+ rationale = Option(generators.nextString()),
+ matchedTrials = generators.nextInt(Int.MaxValue).toLong
+ )
+
+ def nextRichPatientHypothesis(): RichPatientHypothesis = RichPatientHypothesis(
+ patientHypothesis = nextPatientHypothesis(),
+ isRequired = generators.nextBoolean()
+ )
+
+ def nextPatientIssue(): PatientIssue = PatientIssue(
+ id = nextLongId[PatientIssue],
+ userId = nextStringId[User],
+ patientId = nextUuidId[Patient],
+ lastUpdate = nextLocalDateTime,
+ isDraft = generators.nextBoolean(),
+ text = generators.nextString(),
+ archiveRequired = generators.nextBoolean()
+ )
+
+ def nextPatientHistory(): PatientHistory = PatientHistory(
+ id = nextLongId[PatientHistory],
+ executor = nextStringId[User],
+ patientId = nextUuidId[Patient],
+ state = nextPatientState,
+ action = nextPatientAction,
+ created = nextLocalDateTime
+ )
+
+}