aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuidomain/formats/json/patienthistory/ApiPatientHistory.scala
blob: cdcd510e2df6de769f3ce42f829d7f18a9673ea7 (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
28
package xyz.driver.pdsuidomain.formats.json.patienthistory

import java.time.{ZoneId, ZonedDateTime}
import java.util.UUID

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

final case class ApiPatientHistory(id: Long,
                                   executor: String,
                                   patientId: UUID,
                                   state: String,
                                   action: String,
                                   created: ZonedDateTime)

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

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