blob: 418f20b92f3780eeb91300c4972f7b0c2ff8ece7 (
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
|
package xyz.driver.pdsuidomain.entities.export.patient
import xyz.driver.pdsuicommon.domain.UuidId
import xyz.driver.pdsuicommon.logging._
import xyz.driver.pdsuidomain.entities.{Patient, RawPatientLabel}
import scala.collection.breakOut
case class ExportPatientWithLabels(patientId: UuidId[Patient], labelVersion: Long, labels: List[ExportPatientLabel])
object ExportPatientWithLabels {
implicit def toPhiString(x: ExportPatientWithLabels): PhiString = {
import x._
phi"ExportPatientWithLabels(patientId=$patientId, version=${Unsafe(labelVersion)}, labels=$labels)"
}
def fromRaw(patientId: UuidId[Patient],
rawPatientRefs: List[RawPatientLabel]) = ExportPatientWithLabels(
patientId = patientId,
labelVersion = 1L, // TODO It is needed to replace this mock label version.
labels = rawPatientRefs
.groupBy(_.labelId)
.map(Function.tupled(ExportPatientLabel.fromRaw))(breakOut)
)
}
|