diff options
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientLabel.scala')
-rw-r--r-- | src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientLabel.scala | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientLabel.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientLabel.scala new file mode 100644 index 0000000..5474413 --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientLabel.scala @@ -0,0 +1,30 @@ +package xyz.driver.pdsuidomain.entities.export.patient + +import xyz.driver.pdsuicommon.domain.LongId +import xyz.driver.pdsuicommon.logging._ +import xyz.driver.pdsuidomain.entities.{Label, RawPatientLabel} + +final case class ExportPatientLabel(id: LongId[Label], + name: String, + evidences: List[ExportPatientLabelEvidence]) + +object ExportPatientLabel extends PhiLogging { + + implicit def toPhiString(x: ExportPatientLabel): PhiString = { + import x._ + phi"ExportPatientLabel(id=$id, evidences=$evidences)" + } + + def fromRaw(labelId: LongId[Label], rawPatientLabels: List[RawPatientLabel]): ExportPatientLabel = { + val firstLabel = rawPatientLabels.headOption + if (firstLabel.isEmpty) { + logger.warn(phi"rawPatientLabels is empty, labelId: $labelId") + } + + ExportPatientLabel( + id = labelId, + name = firstLabel.map(_.label).getOrElse(""), + evidences = rawPatientLabels.map(ExportPatientLabelEvidence.fromRaw) + ) + } +} |