From eeeb6d90f1c6882f0b3d765022b114d97e4dba40 Mon Sep 17 00:00:00 2001 From: vlad Date: Mon, 9 Oct 2017 12:49:02 -0700 Subject: Getting rid of the FuzzyValues, Name as a string, and condition --- .../export/trial/ExportTrialLabelCriterion.scala | 12 +------- .../export/trial/ExportTrialWithLabels.scala | 36 ++-------------------- 2 files changed, 4 insertions(+), 44 deletions(-) (limited to 'src/main/scala/xyz/driver/pdsuidomain/entities/export/trial') diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialLabelCriterion.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialLabelCriterion.scala index 1f06e0d..385bbbe 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialLabelCriterion.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialLabelCriterion.scala @@ -3,7 +3,7 @@ package xyz.driver.pdsuidomain.entities.export.trial import xyz.driver.entities.labels.Label import xyz.driver.pdsuicommon.domain._ import xyz.driver.pdsuicommon.logging._ -import xyz.driver.pdsuidomain.entities.{Arm, Criterion, RawTrialLabel} +import xyz.driver.pdsuidomain.entities.{Arm, Criterion} final case class ExportTrialLabelCriterion(criterionId: LongId[Criterion], value: Option[Boolean], @@ -20,14 +20,4 @@ object ExportTrialLabelCriterion { phi"TrialLabelCriterion(criterionId=$criterionId, value=$value, labelId=$labelId, " + phi"criteria=${Unsafe(criteria)}, isCompound=$isCompound, isDefining=$isDefining)" } - - def fromRaw(x: RawTrialLabel, armIds: Set[LongId[Arm]]) = ExportTrialLabelCriterion( - criterionId = x.criterionId, - value = x.value, - labelId = x.labelId, - armIds = armIds, - criteria = x.criteria, - isCompound = x.isCompound, - isDefining = x.isDefining - ) } diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialWithLabels.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialWithLabels.scala index cf55694..3a9434b 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialWithLabels.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialWithLabels.scala @@ -4,13 +4,11 @@ import java.time.LocalDateTime import xyz.driver.pdsuicommon.domain._ import xyz.driver.pdsuicommon.logging._ -import xyz.driver.pdsuidomain.entities.{RawTrialLabel, Trial} - -import scala.collection.breakOut +import xyz.driver.pdsuidomain.entities.Trial final case class ExportTrialWithLabels(nctId: StringId[Trial], trialId: UuidId[Trial], - condition: String, + disease: String, lastReviewed: LocalDateTime, labelVersion: Long, arms: List[ExportTrialArm], @@ -20,35 +18,7 @@ object ExportTrialWithLabels { implicit def toPhiString(x: ExportTrialWithLabels): PhiString = { import x._ - phi"TrialWithLabels(nctId=$nctId, trialId=$trialId, condition=${Unsafe(condition)}, " + + phi"TrialWithLabels(nctId=$nctId, trialId=$trialId, disease=${Unsafe(disease)}, " + phi"lastReviewed=$lastReviewed, labelVersion=${Unsafe(labelVersion)}, arms=$arms, criteria=$criteria)" } - - def fromRaw(rawData: List[RawTrialLabel]): ExportTrialWithLabels = { - val trials: Set[StringId[Trial]] = rawData.map(_.nctId)(breakOut) - - assert(trials.size == 1, "There are more than one trial in the rawData") - val trial = rawData.head - - ExportTrialWithLabels( - nctId = trial.nctId, - trialId = trial.trialId, - condition = trial.condition, - lastReviewed = trial.lastReviewed, - labelVersion = 1, // TODO It is needed to replace this mock label version. - arms = rawData - .groupBy(_.armId) - .map { - case (armId, rawTrials) => - ExportTrialArm(armId, rawTrials.head.armName) - }(breakOut), - criteria = rawData - .groupBy(x => (x.criterionId, x.labelId)) - .map { - case (_, rawTrialLabels) => - val armIds = rawTrialLabels.map(_.criterionArmId).toSet - ExportTrialLabelCriterion.fromRaw(rawTrialLabels.head, armIds) - }(breakOut) - ) - } } -- cgit v1.2.3