aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion
diff options
context:
space:
mode:
authorMarvin Bertin <marvin.bertin@gmail.com>2017-10-03 13:08:00 -0700
committerMarvin Bertin <marvin.bertin@gmail.com>2017-10-03 13:08:00 -0700
commit0653b90dddc294fddb0e81059aef00b202113d78 (patch)
tree3d8abb424b0f0495f1cbb18849184dd20d6897fc /src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion
parent5750f2f3633e75f2f96d6a36264ab4b8f3fec7d2 (diff)
parenta321a978353439fc516b0f2016c28fb32ba1b7ae (diff)
downloadrest-query-0653b90dddc294fddb0e81059aef00b202113d78.tar.gz
rest-query-0653b90dddc294fddb0e81059aef00b202113d78.tar.bz2
rest-query-0653b90dddc294fddb0e81059aef00b202113d78.zip
Merge branch 'master' into add-slot-eligibility-arms
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion')
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion/ApiCriterion.scala12
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion/ApiNewCriterion.scala9
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion/ApiUpdateCriterion.scala6
3 files changed, 19 insertions, 8 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion/ApiCriterion.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion/ApiCriterion.scala
index b34f339..239adb1 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion/ApiCriterion.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion/ApiCriterion.scala
@@ -14,7 +14,8 @@ final case class ApiCriterion(id: Long,
text: Option[String],
isCompound: Boolean,
labels: Seq[ApiCriterionLabel],
- trialId: String) {
+ trialId: String,
+ inclusion: Option[Boolean]) {
def toDomain = RichCriterion(
criterion = Criterion(
@@ -22,7 +23,8 @@ final case class ApiCriterion(id: Long,
trialId = StringId[Trial](trialId),
text,
isCompound,
- meta.getOrElse("")
+ meta.getOrElse(""),
+ inclusion
),
armIds = arms.map(LongId[EligibilityArm]),
labels = labels.map(_.toDomain(LongId[Criterion](id)))
@@ -40,7 +42,8 @@ object ApiCriterion {
(JsPath \ "text").formatNullable[String] and
(JsPath \ "isCompound").format[Boolean] and
(JsPath \ "labels").format(seqJsonFormat[ApiCriterionLabel]) and
- (JsPath \ "trialId").format[String]
+ (JsPath \ "trialId").format[String] and
+ (JsPath \ "inclusion").formatNullable[Boolean]
)(ApiCriterion.apply, unlift(ApiCriterion.unapply))
def fromDomain(richCriterion: RichCriterion) = ApiCriterion(
@@ -50,6 +53,7 @@ object ApiCriterion {
text = richCriterion.criterion.text,
isCompound = richCriterion.criterion.isCompound,
labels = richCriterion.labels.map(ApiCriterionLabel.fromDomain),
- trialId = richCriterion.criterion.trialId.id
+ trialId = richCriterion.criterion.trialId.id,
+ inclusion = richCriterion.criterion.inclusion
)
}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion/ApiNewCriterion.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion/ApiNewCriterion.scala
index 21be524..4b85f83 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion/ApiNewCriterion.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion/ApiNewCriterion.scala
@@ -13,7 +13,8 @@ final case class ApiNewCriterion(meta: Option[String],
text: Option[String],
isCompound: Option[Boolean],
labels: Seq[ApiCriterionLabel],
- trialId: String) {
+ trialId: String,
+ inclusion: Option[Boolean]) {
def toDomain = RichCriterion(
criterion = Criterion(
@@ -21,7 +22,8 @@ final case class ApiNewCriterion(meta: Option[String],
meta = meta.getOrElse(""),
trialId = StringId(trialId),
isCompound = isCompound.getOrElse(false),
- text = text
+ text = text,
+ inclusion = inclusion
),
armIds = arms.getOrElse(Seq.empty).map(LongId[EligibilityArm]),
labels = labels.map(_.toDomain(LongId(Long.MaxValue))) // A developer should specify right criterionId himself
@@ -38,6 +40,7 @@ object ApiNewCriterion {
(JsPath \ "text").formatNullable[String] and
(JsPath \ "isCompound").formatNullable[Boolean] and
(JsPath \ "labels").format(seqJsonFormat[ApiCriterionLabel]) and
- (JsPath \ "trialId").format[String]
+ (JsPath \ "trialId").format[String] and
+ (JsPath \ "inclusion").formatNullable[Boolean]
)(ApiNewCriterion.apply, unlift(ApiNewCriterion.unapply))
}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion/ApiUpdateCriterion.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion/ApiUpdateCriterion.scala
index 2113d8e..a700309 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion/ApiUpdateCriterion.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion/ApiUpdateCriterion.scala
@@ -14,6 +14,7 @@ final case class ApiUpdateCriterion(meta: Tristate[String],
arms: Tristate[Seq[Long]],
text: Option[String],
isCompound: Option[Boolean],
+ inclusion: Tristate[Boolean],
labels: Tristate[Seq[ApiCriterionLabel]]) {
def applyTo(orig: RichCriterion): RichCriterion = RichCriterion(
@@ -27,7 +28,8 @@ final case class ApiUpdateCriterion(meta: Tristate[String],
meta = meta.cata(identity, "{}", orig.meta),
text = text.orElse(orig.text),
isCompound = isCompound.getOrElse(orig.isCompound),
- trialId = orig.trialId
+ trialId = orig.trialId,
+ inclusion = inclusion.cata(x => Some(x), None, orig.inclusion)
)
}
@@ -45,6 +47,7 @@ object ApiUpdateCriterion {
(JsPath \ "arms").readTristate(seqJsonFormat[Long]) and
(JsPath \ "text").readNullable[String] and
(JsPath \ "isCompound").readNullable[Boolean] and
+ (JsPath \ "inclusion").readTristate[Boolean] and
(JsPath \ "labels").readTristate(seqJsonFormat[ApiCriterionLabel])
)(ApiUpdateCriterion.apply _)
@@ -53,6 +56,7 @@ object ApiUpdateCriterion {
(JsPath \ "arms").writeTristate(seqJsonFormat[Long]) and
(JsPath \ "text").writeNullable[String] and
(JsPath \ "isCompound").writeNullable[Boolean] and
+ (JsPath \ "inclusion").writeTristate[Boolean] and
(JsPath \ "labels").writeTristate(seqJsonFormat[ApiCriterionLabel])
)(unlift(ApiUpdateCriterion.unapply))