From f10c767bf16f14921a194936188c47dd138ffee7 Mon Sep 17 00:00:00 2001 From: Kseniya Tomskikh Date: Wed, 27 Sep 2017 17:10:59 +0700 Subject: PDSUI-2275 Review fixes --- .../driver/pdsuidomain/entities/Intervention.scala | 48 +++++++++++----------- .../pdsuidomain/fakes/entities/trialcuration.scala | 13 +++++- .../json/intervention/ApiInterventionType.scala | 2 +- .../formats/json/sprayformats/intervention.scala | 2 +- 4 files changed, 38 insertions(+), 27 deletions(-) (limited to 'src/main/scala') diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/Intervention.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/Intervention.scala index f5b486b..d0eefa9 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/Intervention.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/Intervention.scala @@ -8,57 +8,57 @@ import xyz.driver.pdsuidomain.entities.InterventionType.DeliveryMethod._ sealed trait InterventionType { val id: LongId[InterventionType] val name: String - val deliveryMethod: Set[DeliveryMethod] + val deliveryMethods: Set[DeliveryMethod] } object InterventionType { final case object RadiationTherapy extends InterventionType { - val id: LongId[InterventionType] = LongId[InterventionType](1) - val name: String = "Radiation therapy" - val deliveryMethod: Set[DeliveryMethod] = commonMethods + val id: LongId[InterventionType] = LongId[InterventionType](1) + val name: String = "Radiation therapy" + val deliveryMethods: Set[DeliveryMethod] = commonMethods } final case object Chemotherapy extends InterventionType { - val id: LongId[InterventionType] = LongId[InterventionType](2) - val name: String = "Chemotherapy" - val deliveryMethod: Set[DeliveryMethod] = commonMethods + val id: LongId[InterventionType] = LongId[InterventionType](2) + val name: String = "Chemotherapy" + val deliveryMethods: Set[DeliveryMethod] = commonMethods } final case object TargetedTherapy extends InterventionType { - val id: LongId[InterventionType] = LongId[InterventionType](3) - val name: String = "Targeted therapy" - val deliveryMethod: Set[DeliveryMethod] = commonMethods + val id: LongId[InterventionType] = LongId[InterventionType](3) + val name: String = "Targeted therapy" + val deliveryMethods: Set[DeliveryMethod] = commonMethods } final case object Immunotherapy extends InterventionType { - val id: LongId[InterventionType] = LongId[InterventionType](4) - val name: String = "Immunotherapy" - val deliveryMethod: Set[DeliveryMethod] = commonMethods + val id: LongId[InterventionType] = LongId[InterventionType](4) + val name: String = "Immunotherapy" + val deliveryMethods: Set[DeliveryMethod] = commonMethods } final case object Surgery extends InterventionType { - val id: LongId[InterventionType] = LongId[InterventionType](5) - val name: String = "Surgery" - val deliveryMethod: Set[DeliveryMethod] = commonMethods + val id: LongId[InterventionType] = LongId[InterventionType](5) + val name: String = "Surgery" + val deliveryMethods: Set[DeliveryMethod] = commonMethods } final case object HormoneTherapy extends InterventionType { - val id: LongId[InterventionType] = LongId[InterventionType](6) - val name: String = "Hormone therapy" - val deliveryMethod: Set[DeliveryMethod] = commonMethods + val id: LongId[InterventionType] = LongId[InterventionType](6) + val name: String = "Hormone therapy" + val deliveryMethods: Set[DeliveryMethod] = commonMethods } final case object Other extends InterventionType { - val id: LongId[InterventionType] = LongId[InterventionType](7) - val name: String = "Other" - val deliveryMethod: Set[DeliveryMethod] = commonMethods + val id: LongId[InterventionType] = LongId[InterventionType](7) + val name: String = "Other" + val deliveryMethods: Set[DeliveryMethod] = commonMethods } final case object Radiation extends InterventionType { val id: LongId[InterventionType] = LongId[InterventionType](8) val name: String = "Radiation" - val deliveryMethod: Set[DeliveryMethod] = Set( + val deliveryMethods: Set[DeliveryMethod] = Set( ExternalRadiationTherapy, Brachytherapy, SystemicRadiationTherapyIV, @@ -70,7 +70,7 @@ object InterventionType { final case object SurgeryProcedure extends InterventionType { val id: LongId[InterventionType] = LongId[InterventionType](9) val name: String = "Surgery/Procedure" - val deliveryMethod: Set[DeliveryMethod] = Set( + val deliveryMethods: Set[DeliveryMethod] = Set( RadioFrequencyAblationRFA, Cryoablation, TherapeuticConventionalSurgery, diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/trialcuration.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/trialcuration.scala index 19dd95e..fe5bf09 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/trialcuration.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/trialcuration.scala @@ -7,6 +7,7 @@ import xyz.driver.pdsuidomain.services.CriterionService.RichCriterion object trialcuration { import xyz.driver.core.generators import common._ + import xyz.driver.pdsuidomain.entities.InterventionType._ def nextTrial(): Trial = Trial( id = nextStringId[Trial], @@ -130,6 +131,16 @@ object trialcuration { name = generators.nextString() ) - def nextInterventionType(): InterventionType = InterventionType.typeFromString("Other") + def nextInterventionType(): InterventionType = generators.oneOf[InterventionType]( + RadiationTherapy, + Chemotherapy, + TargetedTherapy, + Immunotherapy, + Surgery, + HormoneTherapy, + Other, + Radiation, + SurgeryProcedure + ) } diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/intervention/ApiInterventionType.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/intervention/ApiInterventionType.scala index 3550437..3db8bfa 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/intervention/ApiInterventionType.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/intervention/ApiInterventionType.scala @@ -21,6 +21,6 @@ object ApiInterventionType { def fromDomain(interventionType: InterventionType) = ApiInterventionType( id = interventionType.id.id, name = interventionType.name, - deliveryMethods = interventionType.deliveryMethod.map(DeliveryMethod.methodToString).toList + deliveryMethods = interventionType.deliveryMethods.map(DeliveryMethod.methodToString).toList ) } diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/intervention.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/intervention.scala index 2bf1f2b..62cb9fa 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/intervention.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/intervention.scala @@ -137,7 +137,7 @@ object intervention { JsObject( "id" -> obj.id.toJson, "name" -> obj.name.toJson, - "deliveryMethods" -> obj.deliveryMethod.map(DeliveryMethod.methodToString).toJson + "deliveryMethods" -> obj.deliveryMethods.map(DeliveryMethod.methodToString).toJson ) } -- cgit v1.2.3