aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuidomain/entities/Intervention.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/entities/Intervention.scala')
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/entities/Intervention.scala24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/Intervention.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/Intervention.scala
index d0eefa9..9ccc267 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/entities/Intervention.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/entities/Intervention.scala
@@ -170,6 +170,18 @@ object InterventionType {
Rectal
)
+ val All: Map[LongId[InterventionType], InterventionType] = Map[LongId[InterventionType], InterventionType](
+ LongId[InterventionType](1) -> RadiationTherapy,
+ LongId[InterventionType](2) -> Chemotherapy,
+ LongId[InterventionType](3) -> TargetedTherapy,
+ LongId[InterventionType](4) -> Immunotherapy,
+ LongId[InterventionType](5) -> Surgery,
+ LongId[InterventionType](6) -> HormoneTherapy,
+ LongId[InterventionType](7) -> Other,
+ LongId[InterventionType](8) -> Radiation,
+ LongId[InterventionType](9) -> SurgeryProcedure
+ )
+
implicit def toPhiString(x: InterventionType): PhiString = {
import x._
phi"InterventionType(id=$id, name=${Unsafe(name)})"
@@ -194,7 +206,17 @@ final case class Intervention(id: LongId[Intervention],
dosage: String,
originalDosage: String,
isActive: Boolean,
- deliveryMethod: Option[String])
+ deliveryMethod: Option[String]) {
+ def deliveryMethodIsCorrect: Boolean = {
+ if (this.typeId.nonEmpty) {
+ this.deliveryMethod.nonEmpty &&
+ InterventionType.All
+ .getOrElse(this.typeId.get, throw new IllegalArgumentException(s"Not found Intervention type ${this.typeId}"))
+ .deliveryMethods
+ .contains(DeliveryMethod.fromString(this.deliveryMethod.get))
+ } else true
+ }
+}
object Intervention {
implicit def toPhiString(x: Intervention): PhiString = {