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

import java.time.LocalDate

import xyz.driver.pdsuidomain.services.PatientLabelEvidenceService
import play.api.libs.json._
import xyz.driver.pdsuicommon.domain.FuzzyValue

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: PatientLabelEvidenceService.Aggregated): ApiPatientLabelEvidence = {
    import x._

    ApiPatientLabelEvidence(
      id = evidence.id.id,
      value = FuzzyValue.valueToString(evidence.value),
      evidenceText = evidence.evidenceText,
      documentId = evidence.documentId.map(_.id),
      evidenceId = evidence.evidenceId.map(_.id),
      reportId = evidence.reportId.map(_.toString),
      documentType = documentType,
      date = date,
      providerType = providerType
    )
  }
}