aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialWithLabels.scala
diff options
context:
space:
mode:
authorvlad <vlad@driver.xyz>2017-06-30 23:06:43 -0700
committervlad <vlad@driver.xyz>2017-06-30 23:06:43 -0700
commit56187bec9276f51886a01a2752c663f2227d9fc3 (patch)
tree3ddafc15152df5c1b2a6c69f0aa97a03ef7e819d /src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialWithLabels.scala
parent96d81a36286e41035ff4068859a3b0f9da924fbc (diff)
downloadrest-query-56187bec9276f51886a01a2752c663f2227d9fc3.tar.gz
rest-query-56187bec9276f51886a01a2752c663f2227d9fc3.tar.bz2
rest-query-56187bec9276f51886a01a2752c663f2227d9fc3.zip
Export entities JSON formatsv0.1.13
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialWithLabels.scala')
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialWithLabels.scala38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialWithLabels.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialWithLabels.scala
new file mode 100644
index 0000000..dd855f7
--- /dev/null
+++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialWithLabels.scala
@@ -0,0 +1,38 @@
+package xyz.driver.pdsuidomain.formats.json.export
+
+import java.time.ZoneId
+
+import play.api.libs.functional.syntax._
+import play.api.libs.json.{Format, JsPath}
+import xyz.driver.pdsuidomain.entities.export.trial.ExportTrialWithLabels
+
+final case class ApiExportTrialWithLabels(nctId: String,
+ trialId: String,
+ condition: String,
+ lastReviewed: Long,
+ labelVersion: Long,
+ arms: List[ApiExportTrialArm],
+ criteria: List[ApiExportTrialLabelCriterion])
+
+object ApiExportTrialWithLabels {
+
+ implicit val format: Format[ApiExportTrialWithLabels] = (
+ (JsPath \ "nctId").format[String] and
+ (JsPath \ "trialId").format[String] and
+ (JsPath \ "disease").format[String] and
+ (JsPath \ "lastReviewed").format[Long] and
+ (JsPath \ "labelVersion").format[Long] and
+ (JsPath \ "arms").format[List[ApiExportTrialArm]] and
+ (JsPath \ "criteria").format[List[ApiExportTrialLabelCriterion]]
+ ) (ApiExportTrialWithLabels.apply, unlift(ApiExportTrialWithLabels.unapply))
+
+ def fromDomain(x: ExportTrialWithLabels) = ApiExportTrialWithLabels(
+ nctId = x.nctId.id,
+ trialId = x.trialId.toString,
+ condition = x.condition,
+ lastReviewed = x.lastReviewed.atZone(ZoneId.of("Z")).toEpochSecond,
+ labelVersion = x.labelVersion,
+ arms = x.arms.map(ApiExportTrialArm.fromDomain),
+ criteria = x.criteria.map(ApiExportTrialLabelCriterion.fromDomain)
+ )
+}