diff options
author | Vyatcheslav Suharnikov <arz.freezy@gmail.com> | 2017-07-28 13:40:28 +0300 |
---|---|---|
committer | Vyatcheslav Suharnikov <arz.freezy@gmail.com> | 2017-07-28 15:41:57 +0300 |
commit | 54d0c6f7e7d7040e214cd2595a260bc65f356e33 (patch) | |
tree | 06eef00bd8dfa5ecd7a1d207bac7f02a76caba79 /src/main/scala/xyz/driver/pdsuidomain/formats/json/patientissue/ApiPatientIssue.scala | |
parent | 838c6a345c749a58472ee4324f60a3759a83aedd (diff) | |
download | rest-query-54d0c6f7e7d7040e214cd2595a260bc65f356e33.tar.gz rest-query-54d0c6f7e7d7040e214cd2595a260bc65f356e33.tar.bz2 rest-query-54d0c6f7e7d7040e214cd2595a260bc65f356e33.zip |
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.scala | 42 |
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 + ) +} |