From c24679f1ae7d7ccc4e6693535b0aa3ac0e1ca225 Mon Sep 17 00:00:00 2001 From: Kseniya Tomskikh Date: Wed, 27 Sep 2017 18:28:00 +0700 Subject: PDSUI-2275 Added map with all intervention types --- .../driver/pdsuidomain/entities/Intervention.scala | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/main/scala/xyz/driver/pdsuidomain/entities/Intervention.scala') 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 = { -- cgit v1.2.3