blob: b38c2a0452b0803f03d8174a863f728a5e0cf312 (
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.export
import play.api.libs.functional.syntax._
import play.api.libs.json._
import xyz.driver.pdsuicommon.domain.FuzzyValue
import xyz.driver.pdsuidomain.entities.export.patient.ExportPatientLabelEvidence
final case class ApiExportPatientLabelEvidence(evidenceId: String,
labelValue: String,
evidenceText: String,
document: ApiExportPatientLabelEvidenceDocument)
object ApiExportPatientLabelEvidence {
implicit val format: Format[ApiExportPatientLabelEvidence] = (
(JsPath \ "evidenceId").format[String] and
(JsPath \ "labelValue").format[String](Writes[String](x => JsString(x.toUpperCase))) and
(JsPath \ "evidenceText").format[String] and
(JsPath \ "document").format[ApiExportPatientLabelEvidenceDocument]
) (ApiExportPatientLabelEvidence.apply, unlift(ApiExportPatientLabelEvidence.unapply))
def fromDomain(evidence: ExportPatientLabelEvidence) = ApiExportPatientLabelEvidence(
evidenceId = evidence.id.toString,
labelValue = FuzzyValue.valueToString(evidence.value),
evidenceText = evidence.evidenceText,
document = ApiExportPatientLabelEvidenceDocument.fromDomain(evidence.document)
)
}
|