aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuidomain/formats/json/patientissue/ApiPatientIssue.scala
diff options
context:
space:
mode:
authorVlad Uspensky <v.uspenskiy@icloud.com>2017-07-28 12:27:48 -0700
committerGitHub <noreply@github.com>2017-07-28 12:27:48 -0700
commita1178df3e08759f85c9c891b17c5185df46f1a93 (patch)
tree06eef00bd8dfa5ecd7a1d207bac7f02a76caba79 /src/main/scala/xyz/driver/pdsuidomain/formats/json/patientissue/ApiPatientIssue.scala
parent838c6a345c749a58472ee4324f60a3759a83aedd (diff)
parent54d0c6f7e7d7040e214cd2595a260bc65f356e33 (diff)
downloadrest-query-a1178df3e08759f85c9c891b17c5185df46f1a93.tar.gz
rest-query-a1178df3e08759f85c9c891b17c5185df46f1a93.tar.bz2
rest-query-a1178df3e08759f85c9c891b17c5185df46f1a93.zip
Merge pull request #14 from drivergroup/PDSUI-2157v0.2.9v0.2.10
PDSUI-2157 Create own messages table for Documents, Medical Records and Patients
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/formats/json/patientissue/ApiPatientIssue.scala')
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/patientissue/ApiPatientIssue.scala42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patientissue/ApiPatientIssue.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patientissue/ApiPatientIssue.scala
new file mode 100644
index 0000000..7e0b174
--- /dev/null
+++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patientissue/ApiPatientIssue.scala
@@ -0,0 +1,42 @@
+package xyz.driver.pdsuidomain.formats.json.patientissue
+
+import java.time.{ZoneId, ZonedDateTime}
+
+import play.api.libs.functional.syntax._
+import play.api.libs.json._
+import xyz.driver.pdsuidomain.entities.PatientIssue
+
+final case class ApiPatientIssue(id: Long,
+ text: String,
+ lastUpdate: ZonedDateTime,
+ userId: String,
+ isDraft: Boolean,
+ evidence: String,
+ archiveRequired: Boolean,
+ meta: String)
+
+object ApiPatientIssue {
+ implicit val format: Format[ApiPatientIssue] = (
+ (JsPath \ "id").format[Long] and
+ (JsPath \ "text").format[String] and
+ (JsPath \ "lastUpdate").format[ZonedDateTime] and
+ (JsPath \ "userId").format[String] and
+ (JsPath \ "isDraft").format[Boolean] and
+ (JsPath \ "evidence").format[String] and
+ (JsPath \ "archiveRequired").format[Boolean] and
+ (JsPath \ "meta").format[String](Format(Reads { x =>
+ JsSuccess(Json.stringify(x))
+ }, Writes[String](Json.parse)))
+ )(ApiPatientIssue.apply, unlift(ApiPatientIssue.unapply))
+
+ def fromDomain(x: PatientIssue) = ApiPatientIssue(
+ id = x.id.id,
+ text = x.text,
+ lastUpdate = ZonedDateTime.of(x.lastUpdate, ZoneId.of("Z")),
+ userId = x.userId.id,
+ isDraft = x.isDraft,
+ evidence = x.evidence,
+ archiveRequired = x.archiveRequired,
+ meta = x.meta
+ )
+}