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

import java.time.LocalDate

import play.api.libs.json._
import xyz.driver.pdsuicommon.domain.FuzzyValue
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 = FuzzyValue.valueToString(x.value),
    evidenceText = x.evidenceText,
    documentId = x.documentId.map(_.id),
    evidenceId = x.evidenceId.map(_.id),
    reportId = x.reportId.map(_.toString),
    documentType = x.documentType,
    date = x.date.get,
    providerType = x.providerType
  )
}