diff options
author | vlad <vlad@driver.xyz> | 2017-06-30 23:06:43 -0700 |
---|---|---|
committer | vlad <vlad@driver.xyz> | 2017-06-30 23:06:43 -0700 |
commit | 56187bec9276f51886a01a2752c663f2227d9fc3 (patch) | |
tree | 3ddafc15152df5c1b2a6c69f0aa97a03ef7e819d /src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientWithLabels.scala | |
parent | 96d81a36286e41035ff4068859a3b0f9da924fbc (diff) | |
download | rest-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/ApiExportPatientWithLabels.scala')
-rw-r--r-- | src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientWithLabels.scala | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientWithLabels.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientWithLabels.scala new file mode 100644 index 0000000..d5b9eb3 --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientWithLabels.scala @@ -0,0 +1,22 @@ +package xyz.driver.pdsuidomain.formats.json.export + +import play.api.libs.functional.syntax._ +import play.api.libs.json.{Format, JsPath} +import xyz.driver.pdsuidomain.entities.export.patient.ExportPatientWithLabels + +final case class ApiExportPatientWithLabels(patientId: String, labelVersion: Long, labels: List[ApiExportPatientLabel]) + +object ApiExportPatientWithLabels { + + implicit val format: Format[ApiExportPatientWithLabels] = ( + (JsPath \ "patientId").format[String] and + (JsPath \ "labelVersion").format[Long] and + (JsPath \ "labels").format[List[ApiExportPatientLabel]] + ) (ApiExportPatientWithLabels.apply, unlift(ApiExportPatientWithLabels.unapply)) + + def fromDomain(patient: ExportPatientWithLabels) = ApiExportPatientWithLabels( + patientId = patient.patientId.toString, + labelVersion = patient.labelVersion, + labels = patient.labels.map(ApiExportPatientLabel.fromDomain) + ) +} |