aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuidomain/formats/json/recordissue/ApiPartialRecordIssue.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/recordissue/ApiPartialRecordIssue.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/recordissue/ApiPartialRecordIssue.scala')
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/recordissue/ApiPartialRecordIssue.scala52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/recordissue/ApiPartialRecordIssue.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/recordissue/ApiPartialRecordIssue.scala
new file mode 100644
index 0000000..07a88aa
--- /dev/null
+++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/recordissue/ApiPartialRecordIssue.scala
@@ -0,0 +1,52 @@
+package xyz.driver.pdsuidomain.formats.json.recordissue
+
+import java.time.LocalDateTime
+
+import play.api.libs.functional.syntax._
+import play.api.libs.json._
+import xyz.driver.pdsuicommon.domain.{LongId, StringId, User}
+import xyz.driver.pdsuidomain.entities.{MedicalRecord, MedicalRecordIssue}
+
+final case class ApiPartialRecordIssue(startPage: Option[Double],
+ endPage: Option[Double],
+ text: String,
+ evidence: String,
+ archiveRequired: Boolean,
+ meta: String) {
+ def applyTo(x: MedicalRecordIssue): MedicalRecordIssue = x.copy(
+ startPage = startPage,
+ endPage = endPage,
+ text = text,
+ evidence = evidence,
+ archiveRequired = archiveRequired,
+ meta = meta
+ )
+
+ def toDomain(userId: StringId[User], recordId: LongId[MedicalRecord]) =
+ MedicalRecordIssue(
+ id = LongId(0),
+ userId = userId,
+ recordId = recordId,
+ startPage = startPage,
+ endPage = endPage,
+ lastUpdate = LocalDateTime.MIN,
+ isDraft = true,
+ text = text,
+ evidence = evidence,
+ archiveRequired = false,
+ meta = meta
+ )
+}
+
+object ApiPartialRecordIssue {
+ implicit val format: Format[ApiPartialRecordIssue] = (
+ (JsPath \ "startPage").formatNullable[Double] and
+ (JsPath \ "endPage").formatNullable[Double] and
+ (JsPath \ "text").format[String] 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)))
+ )(ApiPartialRecordIssue.apply, unlift(ApiPartialRecordIssue.unapply))
+}