aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuidomain/formats/json/recordhistory/ApiRecordHistory.scala
blob: c55a78fa3aae65cc7322f57e4ad7e9240e79c7c7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package xyz.driver.pdsuidomain.formats.json.recordhistory

import java.time.{ZoneId, ZonedDateTime}

import play.api.libs.json.{Format, Json}
import xyz.driver.pdsuidomain.entities.MedicalRecordHistory

final case class ApiRecordHistory(id: Long,
                                  executor: String,
                                  recordId: Long,
                                  state: String,
                                  action: String,
                                  created: ZonedDateTime)

object ApiRecordHistory {
  implicit val format: Format[ApiRecordHistory] =
    Json.format[ApiRecordHistory]

  def fromDomain(x: MedicalRecordHistory) = ApiRecordHistory(
    id = x.id.id,
    executor = x.executor.id,
    recordId = x.recordId.id,
    state = MedicalRecordHistory.State.stateToString(x.state),
    action = MedicalRecordHistory.Action.actionToString(x.action),
    created = ZonedDateTime.of(x.created, ZoneId.of("Z"))
  )
}