aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarvin Bertin <marvin.bertin@gmail.com>2017-10-10 13:27:40 -0700
committerMarvin Bertin <marvin.bertin@gmail.com>2017-10-10 13:27:40 -0700
commit6a692412fd7e2ab07a10065d5d2a07d86edd03cc (patch)
tree10dc442bf45608a11fcf61132c7166fd8e712bea
parent00eb4db341afee67b726c2779da4388a64bac9e6 (diff)
downloadrest-query-6a692412fd7e2ab07a10065d5d2a07d86edd03cc.tar.gz
rest-query-6a692412fd7e2ab07a10065d5d2a07d86edd03cc.tar.bz2
rest-query-6a692412fd7e2ab07a10065d5d2a07d86edd03cc.zip
add disease list to ExportTrialArm
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialArm.scala2
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialWithLabels.scala3
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala7
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala17
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala4
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala11
6 files changed, 17 insertions, 27 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialArm.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialArm.scala
index 5a9a406..b2ed7fb 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialArm.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialArm.scala
@@ -4,7 +4,7 @@ import xyz.driver.pdsuicommon.domain._
import xyz.driver.pdsuicommon.logging._
import xyz.driver.pdsuidomain.entities.Arm
-final case class ExportTrialArm(armId: LongId[Arm], armName: String)
+final case class ExportTrialArm(armId: LongId[Arm], armName: String, diseaseList: Seq[String])
object ExportTrialArm {
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 3a9434b..3681945 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
@@ -8,7 +8,6 @@ import xyz.driver.pdsuidomain.entities.Trial
final case class ExportTrialWithLabels(nctId: StringId[Trial],
trialId: UuidId[Trial],
- disease: String,
lastReviewed: LocalDateTime,
labelVersion: Long,
arms: List[ExportTrialArm],
@@ -18,7 +17,7 @@ object ExportTrialWithLabels {
implicit def toPhiString(x: ExportTrialWithLabels): PhiString = {
import x._
- phi"TrialWithLabels(nctId=$nctId, trialId=$trialId, disease=${Unsafe(disease)}, " +
+ phi"TrialWithLabels(nctId=$nctId, trialId=$trialId}, " +
phi"lastReviewed=$lastReviewed, labelVersion=${Unsafe(labelVersion)}, arms=$arms, criteria=$criteria)"
}
}
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 a3ba562..b769893 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala
@@ -1,15 +1,15 @@
package xyz.driver.pdsuidomain.fakes.entities
import xyz.driver.entities.labels.Label
-import xyz.driver.pdsuidomain.entities.{Arm, Criterion, Trial}
import xyz.driver.pdsuidomain.entities.export.trial._
+import xyz.driver.pdsuidomain.entities.{Arm, Criterion, Trial}
object export {
- import xyz.driver.core.generators._
import common._
+ import xyz.driver.core.generators._
def nextExportTrialArm(): ExportTrialArm =
- ExportTrialArm(armId = nextLongId[Arm], armName = nextString(100))
+ ExportTrialArm(armId = nextLongId[Arm], armName = nextString(100), diseaseList = listOf(nextString(100)))
def nextExportTrialLabelCriterion(): ExportTrialLabelCriterion =
ExportTrialLabelCriterion(
@@ -26,7 +26,6 @@ object export {
ExportTrialWithLabels(
nctId = nextStringId[Trial],
trialId = nextUuidId[Trial],
- disease = nextString(100),
lastReviewed = nextLocalDateTime,
labelVersion = nextInt(100).toLong,
arms = listOf(nextExportTrialArm()),
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala
index 85d614d..0fe85ea 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala
@@ -2,16 +2,16 @@ package xyz.driver.pdsuidomain.formats.json.sprayformats
import spray.json._
import xyz.driver.entities.labels.Label
-import xyz.driver.pdsuidomain.entities.{Arm, Criterion}
+import xyz.driver.formats.json.labels._
import xyz.driver.pdsuidomain.entities.export.patient._
import xyz.driver.pdsuidomain.entities.export.trial.{ExportTrialArm, ExportTrialLabelCriterion, ExportTrialWithLabels}
-import xyz.driver.formats.json.labels._
+import xyz.driver.pdsuidomain.entities.{Arm, Criterion}
object export {
import DefaultJsonProtocol._
import common._
- import record._
import document._
+ import record._
implicit val patientLabelEvidenceDocumentFormat: RootJsonFormat[ExportPatientLabelEvidenceDocument] =
jsonFormat5(ExportPatientLabelEvidenceDocument.apply)
@@ -25,7 +25,7 @@ object export {
implicit val patientWithLabelsFormat: RootJsonFormat[ExportPatientWithLabels] =
jsonFormat(ExportPatientWithLabels.apply, "patientId", "labelVersion", "labels")
- implicit val trialArmFormat: RootJsonFormat[ExportTrialArm] = jsonFormat2(ExportTrialArm.apply)
+ implicit val trialArmFormat: RootJsonFormat[ExportTrialArm] = jsonFormat3(ExportTrialArm.apply)
implicit val trialLabelCriterionFormat: RootJsonFormat[ExportTrialLabelCriterion] =
new RootJsonFormat[ExportTrialLabelCriterion] {
@@ -82,12 +82,5 @@ object export {
}
implicit val trialWithLabelsFormat: RootJsonFormat[ExportTrialWithLabels] =
- jsonFormat(ExportTrialWithLabels.apply,
- "nctId",
- "trialId",
- "disease",
- "lastReviewed",
- "labelVersion",
- "arms",
- "criteria")
+ jsonFormat(ExportTrialWithLabels.apply, "nctId", "trialId", "lastReviewed", "labelVersion", "arms", "criteria")
}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala
index cb7f8bc..37c3de5 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala
@@ -69,13 +69,13 @@ class FakeTrialService extends TrialService {
ExportTrialWithLabels(
StringId[Trial]("NCT" + generators.nextInt(999999).toString),
UuidId[Trial](generators.nextUuid()),
- generators.oneOf("adenocarcinoma", "breast", "prostate"),
LocalDateTime.now(),
labelVersion = 1L,
generators.listOf(
new ExportTrialArm(
LongId[Arm](generators.nextInt(999999).toLong),
- generators.nextName().value
+ generators.nextName().value,
+ generators.listOf(generators.oneOf("adenocarcinoma", "breast", "prostate"))
)),
generators.listOf(
new ExportTrialLabelCriterion(
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala
index 402e893..41d7825 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala
@@ -3,8 +3,8 @@ package xyz.driver.pdsuidomain.formats.json.sprayformats
import java.time.{LocalDate, LocalDateTime}
import java.util.UUID
-import spray.json._
import org.scalatest.{FlatSpec, Matchers}
+import spray.json._
import xyz.driver.entities.labels.LabelValue
import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId}
import xyz.driver.pdsuidomain.entities.{DocumentType, ProviderType, RecordRequestId}
@@ -81,8 +81,8 @@ class ExportFormatSuite extends FlatSpec with Matchers {
"Json format for ApiExportTrialWithLabels" should "read and write correct JSON" in {
import xyz.driver.pdsuidomain.entities.export.trial._
val arms = List(
- ExportTrialArm(armId = LongId(1), armName = "arm 1"),
- ExportTrialArm(armId = LongId(2), armName = "arm 2")
+ ExportTrialArm(armId = LongId(1), armName = "arm 1", diseaseList = Seq("Breast")),
+ ExportTrialArm(armId = LongId(2), armName = "arm 2", diseaseList = Seq("Breast"))
)
val criteriaList = List(
ExportTrialLabelCriterion(
@@ -107,7 +107,6 @@ class ExportFormatSuite extends FlatSpec with Matchers {
val trialWithLabels = ExportTrialWithLabels(
nctId = StringId("NCT000001"),
trialId = UuidId("40892a07-c638-49d2-9795-1edfefbbcc7c"),
- disease = "Breast",
lastReviewed = LocalDateTime.parse("2017-08-10T18:00:00"),
labelVersion = 1L,
arms = arms,
@@ -116,8 +115,8 @@ class ExportFormatSuite extends FlatSpec with Matchers {
val writtenJson = trialWithLabelsFormat.write(trialWithLabels)
writtenJson should be(
- """{"nctId":"NCT000001","trialId":"40892a07-c638-49d2-9795-1edfefbbcc7c","disease":"Breast","lastReviewed":"2017-08-10T18:00Z",
- "labelVersion":1,"arms":[{"armId":1,"armName":"arm 1"},{"armId":2,"armName":"arm 2"}],"criteria":[
+ """{"nctId":"NCT000001","trialId":"40892a07-c638-49d2-9795-1edfefbbcc7c","lastReviewed":"2017-08-10T18:00Z",
+ "labelVersion":1,"arms":[{"armId":1,"armName":"arm 1", "diseaseList":["Breast"]},{"armId":2,"armName":"arm 2", "diseaseList":["Breast"]}],"criteria":[
{"value":"Yes","labelId":21,"criterionId":10,"criterionText":"criteria 10 text","armIds":[1,2],"isCompound":false,"isDefining":false},
{"value":"Unknown","labelId":21,"criterionId":11,"criterionText":"criteria 11 text","armIds":[2],"isCompound":true,"isDefining":false}]}""".parseJson)
}