From 96d81a36286e41035ff4068859a3b0f9da924fbc Mon Sep 17 00:00:00 2001 From: vlad Date: Fri, 30 Jun 2017 19:38:37 -0700 Subject: Latest PDS UI utils including all the domain stuff --- .../export/patient/ExportPatientWithLabels.scala | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientWithLabels.scala (limited to 'src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientWithLabels.scala') diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientWithLabels.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientWithLabels.scala new file mode 100644 index 0000000..e6262ed --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientWithLabels.scala @@ -0,0 +1,26 @@ +package xyz.driver.pdsuidomain.entities.export.patient + +import xyz.driver.pdsuicommon.domain._ +import xyz.driver.pdsuicommon.logging._ +import xyz.driver.pdsuidomain.entities.{Patient, RawPatientLabel} + +import scala.collection.breakOut + +final 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) + ) +} -- cgit v1.2.3