diff options
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/formats/json/recordissue')
-rw-r--r-- | src/main/scala/xyz/driver/pdsuidomain/formats/json/recordissue/ApiPartialRecordIssue.scala | 42 | ||||
-rw-r--r-- | src/main/scala/xyz/driver/pdsuidomain/formats/json/recordissue/ApiRecordIssue.scala | 40 |
2 files changed, 0 insertions, 82 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 deleted file mode 100644 index 890ad69..0000000 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/recordissue/ApiPartialRecordIssue.scala +++ /dev/null @@ -1,42 +0,0 @@ -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, - archiveRequired: Boolean) { - def applyTo(x: MedicalRecordIssue): MedicalRecordIssue = x.copy( - startPage = startPage, - endPage = endPage, - text = text, - archiveRequired = archiveRequired - ) - - 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, - archiveRequired = false - ) -} - -object ApiPartialRecordIssue { - implicit val format: Format[ApiPartialRecordIssue] = ( - (JsPath \ "startPage").formatNullable[Double] and - (JsPath \ "endPage").formatNullable[Double] and - (JsPath \ "text").format[String] and - (JsPath \ "archiveRequired").format[Boolean] - )(ApiPartialRecordIssue.apply, unlift(ApiPartialRecordIssue.unapply)) -} diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/recordissue/ApiRecordIssue.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/recordissue/ApiRecordIssue.scala deleted file mode 100644 index 45bc469..0000000 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/recordissue/ApiRecordIssue.scala +++ /dev/null @@ -1,40 +0,0 @@ -package xyz.driver.pdsuidomain.formats.json.recordissue - -import java.time.{ZoneId, ZonedDateTime} - -import play.api.libs.functional.syntax._ -import play.api.libs.json._ -import xyz.driver.pdsuidomain.entities.MedicalRecordIssue - -final case class ApiRecordIssue(id: Long, - startPage: Option[Double], - endPage: Option[Double], - text: String, - lastUpdate: ZonedDateTime, - userId: String, - isDraft: Boolean, - archiveRequired: Boolean) - -object ApiRecordIssue { - implicit val format: Format[ApiRecordIssue] = ( - (JsPath \ "id").format[Long] and - (JsPath \ "startPage").formatNullable[Double] and - (JsPath \ "endPage").formatNullable[Double] and - (JsPath \ "text").format[String] and - (JsPath \ "lastUpdate").format[ZonedDateTime] and - (JsPath \ "userId").format[String] and - (JsPath \ "isDraft").format[Boolean] and - (JsPath \ "archiveRequired").format[Boolean] - )(ApiRecordIssue.apply, unlift(ApiRecordIssue.unapply)) - - def fromDomain(x: MedicalRecordIssue) = ApiRecordIssue( - id = x.id.id, - startPage = x.startPage, - endPage = x.endPage, - text = x.text, - lastUpdate = ZonedDateTime.of(x.lastUpdate, ZoneId.of("Z")), - userId = x.userId.id, - isDraft = x.isDraft, - archiveRequired = x.archiveRequired - ) -} |