aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuidomain/formats/json/evidence/ApiPatientLabelEvidence.scala
blob: c7a6de9229216019bfe3d9577d9aeca38e7adf9d (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
package xyz.driver.pdsuidomain.formats.json.evidence

import java.time.LocalDate

import play.api.libs.json._
import xyz.driver.pdsuidomain.entities.PatientLabelEvidenceView

final case class ApiPatientLabelEvidence(id: Long,
                                         value: String,
                                         evidenceText: String,
                                         documentId: Option[Long],
                                         evidenceId: Option[Long],
                                         reportId: Option[String],
                                         documentType: String,
                                         date: LocalDate,
                                         providerType: String)

object ApiPatientLabelEvidence {

  implicit val format: Format[ApiPatientLabelEvidence] = Json.format

  def fromDomain(x: PatientLabelEvidenceView) = ApiPatientLabelEvidence(
    id = x.id.id,
    value = x.value.toString,
    evidenceText = x.evidenceText,
    documentId = x.documentId.map(_.id),
    evidenceId = x.evidenceId.map(_.id),
    reportId = x.reportId.map(_.toString),
    documentType = x.documentType.name,
    date = x.date.get,
    providerType = x.providerType.name
  )
}