aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuidomain/entities/Message.scala
blob: 68fd5cdc69831d2f93cbb40e12098e5e14943e7a (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
29
30
31
32
33
34
35
package xyz.driver.pdsuidomain.entities

import java.time.LocalDateTime

import xyz.driver.core.auth.User
import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId}
import xyz.driver.pdsuicommon.logging._

final case class Message(id: LongId[Message],
                         text: String,
                         lastUpdate: LocalDateTime,
                         userId: xyz.driver.core.Id[User],
                         isDraft: Boolean,
                         recordId: Option[LongId[MedicalRecord]],
                         documentId: Option[LongId[Document]],
                         patientId: Option[UuidId[Patient]],
                         trialId: Option[StringId[Trial]],
                         startPage: Option[Double],
                         endPage: Option[Double],
                         evidence: Option[String],
                         archiveRequired: Option[Boolean],
                         meta: Option[String])

object Message {
  implicit def toPhiString(x: Message): PhiString = {
    import x._

    val entityId: Option[String] = recordId
      .map(_.toString)
      .orElse(documentId.map(_.toString))
      .orElse(patientId.map(_.toString))

    phi"Message(id=$id, userId=${Unsafe(userId)}, isDraft=$isDraft, entityId=${Unsafe(entityId)}"
  }
}