From f4bd1f867020c9a6b5f3ec3fca11fbaa69e58f22 Mon Sep 17 00:00:00 2001 From: timgushue Date: Mon, 25 Sep 2017 13:32:15 -0700 Subject: Added slot and eligibility arms to entities, json and services --- .../services/EligibilityArmService.scala | 124 +++++++++++++++++++++ .../pdsuidomain/services/SlotArmService.scala | 124 +++++++++++++++++++++ 2 files changed, 248 insertions(+) create mode 100644 src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala create mode 100644 src/main/scala/xyz/driver/pdsuidomain/services/SlotArmService.scala (limited to 'src/main/scala/xyz/driver/pdsuidomain/services') diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala new file mode 100644 index 0000000..fc28e5f --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala @@ -0,0 +1,124 @@ +package xyz.driver.pdsuidomain.services + +import xyz.driver.pdsuicommon.auth.AuthenticatedRequestContext +import xyz.driver.pdsuicommon.db._ +import xyz.driver.pdsuicommon.domain.LongId +import xyz.driver.pdsuicommon.error.DomainError +import xyz.driver.pdsuicommon.logging._ +import xyz.driver.pdsuidomain.entities.EligibilityArm + +import scala.concurrent.Future + +object EligibilityArmService { + + trait DefaultAccessDeniedError { + def userMessage: String = "Access denied" + } + + trait DefaultNotFoundError { + def userMessage: String = "EligibilityArm not found" + } + + sealed trait GetByIdReply + object GetByIdReply { + + final case class Entity(x: EligibilityArm) extends GetByIdReply + + type Error = GetByIdReply with DomainError + + case object NotFoundError extends GetByIdReply with DefaultNotFoundError with DomainError.NotFoundError + + case object AuthorizationError + extends GetByIdReply with DomainError.AuthorizationError with DefaultAccessDeniedError + + final case class CommonError(userMessage: String)(implicit requestContext: AuthenticatedRequestContext) + extends GetByIdReply with DomainError + } + + sealed trait GetListReply + object GetListReply { + type Error = GetListReply with DomainError + + final case class EntityList(xs: Seq[EligibilityArm], totalFound: Int) extends GetListReply + + case object AuthorizationError + extends GetListReply with DomainError.AuthorizationError with DefaultAccessDeniedError + } + + sealed trait UpdateReply + object UpdateReply { + + final case class Updated(updated: EligibilityArm) extends UpdateReply + + type Error = UpdateReply with DomainError + + case object NotFoundError extends UpdateReply with DefaultNotFoundError with DomainError.NotFoundError + + case object AuthorizationError + extends UpdateReply with DefaultAccessDeniedError with DomainError.AuthorizationError + + final case class CommonError(userMessage: String) extends UpdateReply with DomainError + + final case class AlreadyExistsError(x: EligibilityArm) extends UpdateReply with DomainError { + val userMessage = s"The arm with such name of trial already exists." + } + + implicit def toPhiString(reply: UpdateReply): PhiString = reply match { + case Updated(x) => phi"Updated($x)" + case x: Error => DomainError.toPhiString(x) + } + } + + sealed trait CreateReply + object CreateReply { + final case class Created(x: EligibilityArm) extends CreateReply + + type Error = CreateReply with DomainError + + case object AuthorizationError + extends CreateReply with DefaultAccessDeniedError with DomainError.AuthorizationError + + final case class CommonError(userMessage: String) extends CreateReply with DomainError + + final case class AlreadyExistsError(x: EligibilityArm) extends CreateReply with DomainError { + val userMessage = s"The arm with this name of trial already exists." + } + + implicit def toPhiString(reply: CreateReply): PhiString = reply match { + case Created(x) => phi"Created($x)" + case x: Error => DomainError.toPhiString(x) + } + } + + sealed trait DeleteReply + object DeleteReply { + case object Deleted extends DeleteReply + + type Error = DeleteReply with DomainError + + case object NotFoundError extends DeleteReply with DefaultNotFoundError with DomainError.NotFoundError + + case object AuthorizationError + extends DeleteReply with DefaultAccessDeniedError with DomainError.AuthorizationError + + final case class CommonError(userMessage: String) extends DeleteReply with DomainError + } +} + +trait EligibilityArmService { + + import EligibilityArmService._ + + def getAll(filter: SearchFilterExpr = SearchFilterExpr.Empty, + sorting: Option[Sorting] = None, + pagination: Option[Pagination] = None)( + implicit requestContext: AuthenticatedRequestContext): Future[GetListReply] + + def getById(armId: LongId[EligibilityArm])(implicit requestContext: AuthenticatedRequestContext): Future[GetByIdReply] + + def create(draftEligibilityArm: EligibilityArm)(implicit requestContext: AuthenticatedRequestContext): Future[CreateReply] + + def update(origEligibilityArm: EligibilityArm, draftEligibilityArm: EligibilityArm)(implicit requestContext: AuthenticatedRequestContext): Future[UpdateReply] + + def delete(id: LongId[EligibilityArm])(implicit requestContext: AuthenticatedRequestContext): Future[DeleteReply] +} diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/SlotArmService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/SlotArmService.scala new file mode 100644 index 0000000..3c55909 --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/services/SlotArmService.scala @@ -0,0 +1,124 @@ +package xyz.driver.pdsuidomain.services + +import xyz.driver.pdsuicommon.auth.AuthenticatedRequestContext +import xyz.driver.pdsuicommon.db._ +import xyz.driver.pdsuicommon.domain.LongId +import xyz.driver.pdsuicommon.error.DomainError +import xyz.driver.pdsuicommon.logging._ +import xyz.driver.pdsuidomain.entities.SlotArm + +import scala.concurrent.Future + +object SlotArmService { + + trait DefaultAccessDeniedError { + def userMessage: String = "Access denied" + } + + trait DefaultNotFoundError { + def userMessage: String = "SlotArm not found" + } + + sealed trait GetByIdReply + object GetByIdReply { + + final case class Entity(x: SlotArm) extends GetByIdReply + + type Error = GetByIdReply with DomainError + + case object NotFoundError extends GetByIdReply with DefaultNotFoundError with DomainError.NotFoundError + + case object AuthorizationError + extends GetByIdReply with DomainError.AuthorizationError with DefaultAccessDeniedError + + final case class CommonError(userMessage: String)(implicit requestContext: AuthenticatedRequestContext) + extends GetByIdReply with DomainError + } + + sealed trait GetListReply + object GetListReply { + type Error = GetListReply with DomainError + + final case class EntityList(xs: Seq[SlotArm], totalFound: Int) extends GetListReply + + case object AuthorizationError + extends GetListReply with DomainError.AuthorizationError with DefaultAccessDeniedError + } + + sealed trait UpdateReply + object UpdateReply { + + final case class Updated(updated: SlotArm) extends UpdateReply + + type Error = UpdateReply with DomainError + + case object NotFoundError extends UpdateReply with DefaultNotFoundError with DomainError.NotFoundError + + case object AuthorizationError + extends UpdateReply with DefaultAccessDeniedError with DomainError.AuthorizationError + + final case class CommonError(userMessage: String) extends UpdateReply with DomainError + + final case class AlreadyExistsError(x: SlotArm) extends UpdateReply with DomainError { + val userMessage = s"The arm with such name of trial already exists." + } + + implicit def toPhiString(reply: UpdateReply): PhiString = reply match { + case Updated(x) => phi"Updated($x)" + case x: Error => DomainError.toPhiString(x) + } + } + + sealed trait CreateReply + object CreateReply { + final case class Created(x: SlotArm) extends CreateReply + + type Error = CreateReply with DomainError + + case object AuthorizationError + extends CreateReply with DefaultAccessDeniedError with DomainError.AuthorizationError + + final case class CommonError(userMessage: String) extends CreateReply with DomainError + + final case class AlreadyExistsError(x: SlotArm) extends CreateReply with DomainError { + val userMessage = s"The arm with this name of trial already exists." + } + + implicit def toPhiString(reply: CreateReply): PhiString = reply match { + case Created(x) => phi"Created($x)" + case x: Error => DomainError.toPhiString(x) + } + } + + sealed trait DeleteReply + object DeleteReply { + case object Deleted extends DeleteReply + + type Error = DeleteReply with DomainError + + case object NotFoundError extends DeleteReply with DefaultNotFoundError with DomainError.NotFoundError + + case object AuthorizationError + extends DeleteReply with DefaultAccessDeniedError with DomainError.AuthorizationError + + final case class CommonError(userMessage: String) extends DeleteReply with DomainError + } +} + +trait SlotArmService { + + import SlotArmService._ + + def getAll(filter: SearchFilterExpr = SearchFilterExpr.Empty, + sorting: Option[Sorting] = None, + pagination: Option[Pagination] = None)( + implicit requestContext: AuthenticatedRequestContext): Future[GetListReply] + + def getById(armId: LongId[SlotArm])(implicit requestContext: AuthenticatedRequestContext): Future[GetByIdReply] + + def create(draftSlotArm: SlotArm)(implicit requestContext: AuthenticatedRequestContext): Future[CreateReply] + + def update(origSlotArm: SlotArm, draftSlotArm: SlotArm)(implicit requestContext: AuthenticatedRequestContext): Future[UpdateReply] + + def delete(id: LongId[SlotArm])(implicit requestContext: AuthenticatedRequestContext): Future[DeleteReply] +} -- cgit v1.2.3 From 6f25de20ee67ec4a4d262bcc0ce962a1d7f6fe35 Mon Sep 17 00:00:00 2001 From: timgushue Date: Tue, 26 Sep 2017 11:19:08 -0700 Subject: Fixed richcriterion to use eligibility arms --- .../scala/xyz/driver/pdsuidomain/fakes/entities/trialcuration.scala | 2 +- .../driver/pdsuidomain/formats/json/criterion/ApiCriterion.scala | 4 ++-- .../driver/pdsuidomain/formats/json/criterion/ApiNewCriterion.scala | 2 +- .../pdsuidomain/formats/json/criterion/ApiUpdateCriterion.scala | 4 ++-- .../driver/pdsuidomain/formats/json/sprayformats/criterion.scala | 6 +++--- .../scala/xyz/driver/pdsuidomain/services/CriterionService.scala | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/main/scala/xyz/driver/pdsuidomain/services') 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 574d008..ac7412c 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/trialcuration.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/trialcuration.scala @@ -59,7 +59,7 @@ object trialcuration { val criterion = nextCriterion() RichCriterion( criterion = criterion, - armIds = Seq(nextLongId[Arm], nextLongId[Arm]), + armIds = Seq(nextLongId[EligibilityArm], nextLongId[EligibilityArm]), labels = Seq( nextCriterionLabel(criterion.id), nextCriterionLabel(criterion.id) diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion/ApiCriterion.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion/ApiCriterion.scala index 4986b17..b34f339 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion/ApiCriterion.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion/ApiCriterion.scala @@ -4,7 +4,7 @@ import xyz.driver.pdsuicommon.json.Serialization.seqJsonFormat import play.api.libs.functional.syntax._ import play.api.libs.json._ import xyz.driver.pdsuicommon.domain.{LongId, StringId} -import xyz.driver.pdsuidomain.entities.{Arm, Criterion, Trial} +import xyz.driver.pdsuidomain.entities.{EligibilityArm, Criterion, Trial} import xyz.driver.pdsuidomain.formats.json.label.ApiCriterionLabel import xyz.driver.pdsuidomain.services.CriterionService.RichCriterion @@ -24,7 +24,7 @@ final case class ApiCriterion(id: Long, isCompound, meta.getOrElse("") ), - armIds = arms.map(LongId[Arm]), + armIds = arms.map(LongId[EligibilityArm]), labels = labels.map(_.toDomain(LongId[Criterion](id))) ) } diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion/ApiNewCriterion.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion/ApiNewCriterion.scala index ab7641f..21be524 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion/ApiNewCriterion.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion/ApiNewCriterion.scala @@ -23,7 +23,7 @@ final case class ApiNewCriterion(meta: Option[String], isCompound = isCompound.getOrElse(false), text = text ), - armIds = arms.getOrElse(Seq.empty).map(LongId[Arm]), + armIds = arms.getOrElse(Seq.empty).map(LongId[EligibilityArm]), labels = labels.map(_.toDomain(LongId(Long.MaxValue))) // A developer should specify right criterionId himself ) } diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion/ApiUpdateCriterion.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion/ApiUpdateCriterion.scala index 2bcda56..2113d8e 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion/ApiUpdateCriterion.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/criterion/ApiUpdateCriterion.scala @@ -2,7 +2,7 @@ package xyz.driver.pdsuidomain.formats.json.criterion import xyz.driver.pdsuicommon.domain.LongId import xyz.driver.pdsuicommon.json.Serialization.seqJsonFormat -import xyz.driver.pdsuidomain.entities.{Arm, Criterion} +import xyz.driver.pdsuidomain.entities.{EligibilityArm, Criterion} import org.davidbild.tristate._ import org.davidbild.tristate.contrib.play.ToJsPathOpsFromJsPath import play.api.libs.functional.syntax._ @@ -18,7 +18,7 @@ final case class ApiUpdateCriterion(meta: Tristate[String], def applyTo(orig: RichCriterion): RichCriterion = RichCriterion( criterion = applyTo(orig.criterion), - armIds = arms.cata(_.map(LongId[Arm]), Seq.empty, orig.armIds), + armIds = arms.cata(_.map(LongId[EligibilityArm]), Seq.empty, orig.armIds), labels = labels.cata(_.map(_.toDomain(orig.criterion.id)), Seq.empty, orig.labels) ) diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/criterion.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/criterion.scala index 732bcad..c406cc1 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/criterion.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/criterion.scala @@ -74,7 +74,7 @@ object criterion { val arms = fields .get("arms") - .map(_.convertTo[Option[List[LongId[Arm]]]].getOrElse(List.empty[LongId[Arm]])) + .map(_.convertTo[Option[List[LongId[EligibilityArm]]]].getOrElse(List.empty[LongId[EligibilityArm]])) .getOrElse(orig.armIds) val labels = fields @@ -130,8 +130,8 @@ object criterion { val arms = fields .get("arms") - .map(_.convertTo[List[LongId[Arm]]]) - .getOrElse(List.empty[LongId[Arm]]) + .map(_.convertTo[List[LongId[EligibilityArm]]]) + .getOrElse(List.empty[LongId[EligibilityArm]]) val labels = fields .get("labels") diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/CriterionService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/CriterionService.scala index fd9268b..fdefa65 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/CriterionService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/CriterionService.scala @@ -21,7 +21,7 @@ object CriterionService { def userMessage: String = "Access denied" } - final case class RichCriterion(criterion: Criterion, armIds: Seq[LongId[Arm]], labels: Seq[CriterionLabel]) + final case class RichCriterion(criterion: Criterion, armIds: Seq[LongId[EligibilityArm]], labels: Seq[CriterionLabel]) object RichCriterion { implicit def toPhiString(x: RichCriterion): PhiString = { import x._ -- cgit v1.2.3 From 0ef0059e9b47430e52d6bad4ced5b1be7f3b1a0d Mon Sep 17 00:00:00 2001 From: timgushue Date: Tue, 26 Sep 2017 14:11:40 -0700 Subject: fixing test in CriterionFormatSuite --- src/main/scala/xyz/driver/pdsuidomain/entities/SlotArms.scala | 1 - .../formats/json/eligibilityarm/ApiEligibilityArm.scala | 4 ++-- .../formats/json/eligibilityarm/ApiEligibilityCreateArm.scala | 1 - .../pdsuidomain/formats/json/slotarm/ApiPartialSlotArm.scala | 1 - .../xyz/driver/pdsuidomain/formats/json/slotarm/ApiSlotArm.scala | 4 ++-- .../scala/xyz/driver/pdsuidomain/services/CriterionService.scala | 4 +++- .../xyz/driver/pdsuidomain/services/EligibilityArmService.scala | 9 ++++++--- .../scala/xyz/driver/pdsuidomain/services/SlotArmService.scala | 3 ++- .../formats/json/sprayformats/CriterionFormatSuite.scala | 4 ++-- 9 files changed, 17 insertions(+), 14 deletions(-) (limited to 'src/main/scala/xyz/driver/pdsuidomain/services') diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/SlotArms.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/SlotArms.scala index 8363c7e..932de38 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/SlotArms.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/SlotArms.scala @@ -18,4 +18,3 @@ object SlotArm { phi"Arm(id=$id, name=${Unsafe(x.name)}, trialId=${Unsafe(x.trialId)})" } } - diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/eligibilityarm/ApiEligibilityArm.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/eligibilityarm/ApiEligibilityArm.scala index 51821d8..e7eb022 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/eligibilityarm/ApiEligibilityArm.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/eligibilityarm/ApiEligibilityArm.scala @@ -24,7 +24,7 @@ object ApiEligibilityArm { (JsPath \ "name").format[String] and (JsPath \ "originalName").format[String] and (JsPath \ "trialId").format[String] - )(ApiEligibilityArm.apply, unlift(ApiEligibilityArm.unapply)) + )(ApiEligibilityArm.apply, unlift(ApiEligibilityArm.unapply)) def fromDomain(arm: EligibilityArm): ApiEligibilityArm = ApiEligibilityArm( id = arm.id.id, @@ -32,4 +32,4 @@ object ApiEligibilityArm { originalName = arm.originalName, trialId = arm.trialId.id ) -} \ No newline at end of file +} diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/eligibilityarm/ApiEligibilityCreateArm.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/eligibilityarm/ApiEligibilityCreateArm.scala index a31182f..6f55c10 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/eligibilityarm/ApiEligibilityCreateArm.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/eligibilityarm/ApiEligibilityCreateArm.scala @@ -4,7 +4,6 @@ import xyz.driver.pdsuicommon.domain.{LongId, StringId} import xyz.driver.pdsuidomain.entities.EligibilityArm import play.api.libs.json.{Format, Json} - final case class ApiCreateEligibilityArm(name: String, trialId: String) { def toDomain = EligibilityArm( diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/slotarm/ApiPartialSlotArm.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/slotarm/ApiPartialSlotArm.scala index 06696fd..2f8e93f 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/slotarm/ApiPartialSlotArm.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/slotarm/ApiPartialSlotArm.scala @@ -1,6 +1,5 @@ package xyz.driver.pdsuidomain.formats.json.slotarm - import xyz.driver.pdsuidomain.entities.SlotArm import play.api.libs.json.{Format, Json} diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/slotarm/ApiSlotArm.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/slotarm/ApiSlotArm.scala index 2e26a01..375c1a2 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/slotarm/ApiSlotArm.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/slotarm/ApiSlotArm.scala @@ -24,7 +24,7 @@ object ApiSlotArm { (JsPath \ "name").format[String] and (JsPath \ "originalName").format[String] and (JsPath \ "trialId").format[String] - )(ApiSlotArm.apply, unlift(ApiSlotArm.unapply)) + )(ApiSlotArm.apply, unlift(ApiSlotArm.unapply)) def fromDomain(arm: SlotArm): ApiSlotArm = ApiSlotArm( id = arm.id.id, @@ -32,4 +32,4 @@ object ApiSlotArm { originalName = arm.originalName, trialId = arm.trialId.id ) -} \ No newline at end of file +} diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/CriterionService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/CriterionService.scala index fdefa65..7dbf0d9 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/CriterionService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/CriterionService.scala @@ -21,7 +21,9 @@ object CriterionService { def userMessage: String = "Access denied" } - final case class RichCriterion(criterion: Criterion, armIds: Seq[LongId[EligibilityArm]], labels: Seq[CriterionLabel]) + final case class RichCriterion(criterion: Criterion, + armIds: Seq[LongId[EligibilityArm]], + labels: Seq[CriterionLabel]) object RichCriterion { implicit def toPhiString(x: RichCriterion): PhiString = { import x._ diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala index fc28e5f..b34b34e 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala @@ -114,11 +114,14 @@ trait EligibilityArmService { pagination: Option[Pagination] = None)( implicit requestContext: AuthenticatedRequestContext): Future[GetListReply] - def getById(armId: LongId[EligibilityArm])(implicit requestContext: AuthenticatedRequestContext): Future[GetByIdReply] + def getById(armId: LongId[EligibilityArm])( + implicit requestContext: AuthenticatedRequestContext): Future[GetByIdReply] - def create(draftEligibilityArm: EligibilityArm)(implicit requestContext: AuthenticatedRequestContext): Future[CreateReply] + def create(draftEligibilityArm: EligibilityArm)( + implicit requestContext: AuthenticatedRequestContext): Future[CreateReply] - def update(origEligibilityArm: EligibilityArm, draftEligibilityArm: EligibilityArm)(implicit requestContext: AuthenticatedRequestContext): Future[UpdateReply] + def update(origEligibilityArm: EligibilityArm, draftEligibilityArm: EligibilityArm)( + implicit requestContext: AuthenticatedRequestContext): Future[UpdateReply] def delete(id: LongId[EligibilityArm])(implicit requestContext: AuthenticatedRequestContext): Future[DeleteReply] } diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/SlotArmService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/SlotArmService.scala index 3c55909..af7084b 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/SlotArmService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/SlotArmService.scala @@ -118,7 +118,8 @@ trait SlotArmService { def create(draftSlotArm: SlotArm)(implicit requestContext: AuthenticatedRequestContext): Future[CreateReply] - def update(origSlotArm: SlotArm, draftSlotArm: SlotArm)(implicit requestContext: AuthenticatedRequestContext): Future[UpdateReply] + def update(origSlotArm: SlotArm, draftSlotArm: SlotArm)( + implicit requestContext: AuthenticatedRequestContext): Future[UpdateReply] def delete(id: LongId[SlotArm])(implicit requestContext: AuthenticatedRequestContext): Future[DeleteReply] } diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/CriterionFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/CriterionFormatSuite.scala index d24c4c1..9601834 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/CriterionFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/CriterionFormatSuite.scala @@ -3,7 +3,7 @@ package xyz.driver.pdsuidomain.formats.json.sprayformats import spray.json._ import org.scalatest.{FlatSpec, Matchers} import xyz.driver.pdsuicommon.domain.{LongId, StringId} -import xyz.driver.pdsuidomain.entities.{Arm, Criterion, CriterionLabel} +import xyz.driver.pdsuidomain.entities.{EligibilityArm, Criterion, CriterionLabel} import xyz.driver.pdsuidomain.services.CriterionService.RichCriterion class CriterionFormatSuite extends FlatSpec with Matchers { @@ -35,7 +35,7 @@ class CriterionFormatSuite extends FlatSpec with Matchers { isDefining = true ) ) - val arms = List(LongId[Arm](20), LongId[Arm](21), LongId[Arm](21)) + val arms = List(LongId[EligibilityArm](20), LongId[EligibilityArm](21), LongId[EligibilityArm](21)) val richCriterion = RichCriterion( criterion = criterion, armIds = arms, -- cgit v1.2.3 From 979f4112d8aed85a445db7d8c6a19036a4137146 Mon Sep 17 00:00:00 2001 From: timgushue Date: Wed, 27 Sep 2017 11:15:59 -0700 Subject: Removed condition from trial --- src/main/scala/xyz/driver/pdsuidomain/entities/Trial.scala | 3 +-- .../xyz/driver/pdsuidomain/fakes/entities/trialcuration.scala | 1 - .../xyz/driver/pdsuidomain/formats/json/sprayformats/trial.scala | 1 - .../xyz/driver/pdsuidomain/formats/json/trial/ApiTrial.scala | 8 -------- .../xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala | 1 - .../json/sprayformats/PatientEligibleTrialFormatSuite.scala | 1 - .../pdsuidomain/formats/json/sprayformats/TrialFormatSuite.scala | 3 +-- 7 files changed, 2 insertions(+), 16 deletions(-) (limited to 'src/main/scala/xyz/driver/pdsuidomain/services') diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/Trial.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/Trial.scala index db4def2..bd86057 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/Trial.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/Trial.scala @@ -5,7 +5,7 @@ import java.time.LocalDateTime import xyz.driver.pdsuicommon.domain.{LongId, StringId, User, UuidId} import xyz.driver.pdsuicommon.logging._ import xyz.driver.pdsuicommon.utils.Utils -import xyz.driver.pdsuidomain.entities.Trial.{Condition, Status} +import xyz.driver.pdsuidomain.entities.Trial.Status final case class StudyDesign(id: LongId[StudyDesign], name: String) @@ -86,7 +86,6 @@ final case class Trial(id: StringId[Trial], previousAssignee: Option[StringId[User]], lastActiveUserId: Option[StringId[User]], lastUpdate: LocalDateTime, - condition: Condition, phase: String, hypothesisId: Option[UuidId[Hypothesis]], studyDesignId: Option[LongId[StudyDesign]], 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 f9a267f..3a2f6bc 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/trialcuration.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/trialcuration.scala @@ -18,7 +18,6 @@ object trialcuration { previousAssignee = Option(nextStringId[User]), lastActiveUserId = Option(nextStringId[User]), lastUpdate = nextLocalDateTime, - condition = nextCondition, phase = generators.nextString(), hypothesisId = Option(nextUuidId[Hypothesis]), studyDesignId = Option(nextLongId[StudyDesign]), diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/trial.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/trial.scala index c1751bf..a778000 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/trial.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/trial.scala @@ -41,7 +41,6 @@ object trial { "previousStatus" -> obj.previousStatus.toJson, "previousAssignee" -> obj.previousAssignee.toJson, "lastActiveUser" -> obj.lastActiveUserId.toJson, - "condition" -> obj.condition.toJson, "phase" -> obj.phase.toJson, "hypothesisId" -> obj.hypothesisId.toJson, "studyDesignId" -> obj.studyDesignId.toJson, diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/trial/ApiTrial.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/trial/ApiTrial.scala index 1b4ac64..fbf506b 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/trial/ApiTrial.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/trial/ApiTrial.scala @@ -16,7 +16,6 @@ final case class ApiTrial(id: String, previousStatus: Option[String], previousAssignee: Option[String], lastActiveUser: Option[String], - condition: String, phase: String, hypothesisId: Option[UUID], studyDesignId: Option[Long], @@ -37,11 +36,6 @@ final case class ApiTrial(id: String, previousAssignee = this.previousAssignee.map(id => StringId(id)), lastActiveUserId = this.lastActiveUser.map(id => StringId(id)), lastUpdate = this.lastUpdate.toLocalDateTime, - condition = Trial.Condition - .fromString(this.condition) - .getOrElse( - throw new NoSuchElementException(s"unknown condition ${this.condition}") - ), phase = this.phase, hypothesisId = this.hypothesisId.map(id => UuidId(id)), studyDesignId = this.studyDesignId.map(id => LongId(id)), @@ -67,7 +61,6 @@ object ApiTrial { (JsPath \ "previousStatus").formatNullable[String] and (JsPath \ "previousAssignee").formatNullable[String] and (JsPath \ "lastActiveUser").formatNullable[String] and - (JsPath \ "condition").format[String] and (JsPath \ "phase").format[String] and (JsPath \ "hypothesisId").formatNullable[UUID] and (JsPath \ "studyDesignId").formatNullable[Long] and @@ -89,7 +82,6 @@ object ApiTrial { previousAssignee = trial.previousAssignee.map(_.id), lastActiveUser = trial.lastActiveUserId.map(_.id), lastUpdate = ZonedDateTime.of(trial.lastUpdate, ZoneId.of("Z")), - condition = trial.condition.toString, phase = trial.phase, hypothesisId = trial.hypothesisId.map(_.id), studyDesignId = trial.studyDesignId.map(_.id), diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala index 3793c1f..e10165c 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala @@ -28,7 +28,6 @@ class FakeTrialService extends TrialService { previousAssignee = None, lastActiveUserId = None, lastUpdate = LocalDateTime.now(), - condition = Trial.Condition.Breast, phase = "", hypothesisId = None, studyDesignId = None, diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientEligibleTrialFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientEligibleTrialFormatSuite.scala index ad54946..8b00883 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientEligibleTrialFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientEligibleTrialFormatSuite.scala @@ -21,7 +21,6 @@ class PatientEligibleTrialFormatSuite extends FlatSpec with Matchers { previousAssignee = None, lastActiveUserId = None, lastUpdate = LocalDateTime.parse("2017-08-10T18:16:19"), - condition = Trial.Condition.Breast, phase = "", hypothesisId = Some(UuidId("e76e2fc4-a29c-44fb-a81b-8856d06bb1d4")), studyDesignId = Some(LongId(321)), diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialFormatSuite.scala index 59cf779..3533c07 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialFormatSuite.scala @@ -20,7 +20,6 @@ class TrialFormatSuite extends FlatSpec with Matchers { previousAssignee = None, lastActiveUserId = None, lastUpdate = LocalDateTime.parse("2017-08-10T18:16:19"), - condition = Trial.Condition.Breast, phase = "", hypothesisId = Some(UuidId("3b80b2e2-5372-4cf5-a342-6e4ebe10fafd")), studyDesignId = Some(LongId(321)), @@ -39,7 +38,7 @@ class TrialFormatSuite extends FlatSpec with Matchers { "isUpdated":false,"overviewTemplate":"","phase":"","originalStudyDesignId":null, "hypothesisId":"3b80b2e2-5372-4cf5-a342-6e4ebe10fafd","originalTitle":"orig trial title", "studyDesignId":321,"lastActiveUser":null,"externalid":"40892a07-c638-49d2-9795-1edfefbbcc7c", - "id":"NCT000001","condition":"Breast","status":"New","overview":null,"previousAssignee":null,"title":"trial title"}""".parseJson) + "id":"NCT000001","status":"New","overview":null,"previousAssignee":null,"title":"trial title"}""".parseJson) val updateTrialJson = """{"hypothesisId":null,"overview":"new overview"}""".parseJson val expectedUpdatedTrial = orig.copy(hypothesisId = None, overview = Some("new overview")) -- cgit v1.2.3 From a38cb5bf77f1119533cb98565ea222a5bf877238 Mon Sep 17 00:00:00 2001 From: Marvin Bertin Date: Mon, 2 Oct 2017 13:33:21 -0700 Subject: add with disease for EligibilityArmService --- .../pdsuidomain/services/EligibilityArmService.scala | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/main/scala/xyz/driver/pdsuidomain/services') diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala index b34b34e..af7cecb 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala @@ -5,7 +5,7 @@ import xyz.driver.pdsuicommon.db._ import xyz.driver.pdsuicommon.domain.LongId import xyz.driver.pdsuicommon.error.DomainError import xyz.driver.pdsuicommon.logging._ -import xyz.driver.pdsuidomain.entities.EligibilityArm +import xyz.driver.pdsuidomain.entities.{EligibilityArm, EligibilityArmWithDiseases} import scala.concurrent.Future @@ -22,7 +22,7 @@ object EligibilityArmService { sealed trait GetByIdReply object GetByIdReply { - final case class Entity(x: EligibilityArm) extends GetByIdReply + final case class Entity(x: EligibilityArmWithDiseases) extends GetByIdReply type Error = GetByIdReply with DomainError @@ -39,7 +39,7 @@ object EligibilityArmService { object GetListReply { type Error = GetListReply with DomainError - final case class EntityList(xs: Seq[EligibilityArm], totalFound: Int) extends GetListReply + final case class EntityList(xs: Seq[EligibilityArmWithDiseases], totalFound: Int) extends GetListReply case object AuthorizationError extends GetListReply with DomainError.AuthorizationError with DefaultAccessDeniedError @@ -48,7 +48,7 @@ object EligibilityArmService { sealed trait UpdateReply object UpdateReply { - final case class Updated(updated: EligibilityArm) extends UpdateReply + final case class Updated(updated: EligibilityArmWithDiseases) extends UpdateReply type Error = UpdateReply with DomainError @@ -59,7 +59,7 @@ object EligibilityArmService { final case class CommonError(userMessage: String) extends UpdateReply with DomainError - final case class AlreadyExistsError(x: EligibilityArm) extends UpdateReply with DomainError { + final case class AlreadyExistsError(x: EligibilityArmWithDiseases) extends UpdateReply with DomainError { val userMessage = s"The arm with such name of trial already exists." } @@ -71,7 +71,7 @@ object EligibilityArmService { sealed trait CreateReply object CreateReply { - final case class Created(x: EligibilityArm) extends CreateReply + final case class Created(x: EligibilityArmWithDiseases) extends CreateReply type Error = CreateReply with DomainError @@ -80,7 +80,7 @@ object EligibilityArmService { final case class CommonError(userMessage: String) extends CreateReply with DomainError - final case class AlreadyExistsError(x: EligibilityArm) extends CreateReply with DomainError { + final case class AlreadyExistsError(x: EligibilityArmWithDiseases) extends CreateReply with DomainError { val userMessage = s"The arm with this name of trial already exists." } @@ -117,10 +117,10 @@ trait EligibilityArmService { def getById(armId: LongId[EligibilityArm])( implicit requestContext: AuthenticatedRequestContext): Future[GetByIdReply] - def create(draftEligibilityArm: EligibilityArm)( + def create(draftEligibilityArm: EligibilityArmWithDiseases)( implicit requestContext: AuthenticatedRequestContext): Future[CreateReply] - def update(origEligibilityArm: EligibilityArm, draftEligibilityArm: EligibilityArm)( + def update(origEligibilityArm: EligibilityArmWithDiseases, draftEligibilityArm: EligibilityArmWithDiseases)( implicit requestContext: AuthenticatedRequestContext): Future[UpdateReply] def delete(id: LongId[EligibilityArm])(implicit requestContext: AuthenticatedRequestContext): Future[DeleteReply] -- cgit v1.2.3 From 9347b0d5f8d21c6e6f42405965979c1633400501 Mon Sep 17 00:00:00 2001 From: Marvin Bertin Date: Wed, 4 Oct 2017 11:51:47 -0700 Subject: update EligibilityArmService with slot arm id parameter --- .../xyz/driver/pdsuidomain/services/EligibilityArmService.scala | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/main/scala/xyz/driver/pdsuidomain/services') diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala index af7cecb..928b657 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala @@ -5,7 +5,7 @@ import xyz.driver.pdsuicommon.db._ import xyz.driver.pdsuicommon.domain.LongId import xyz.driver.pdsuicommon.error.DomainError import xyz.driver.pdsuicommon.logging._ -import xyz.driver.pdsuidomain.entities.{EligibilityArm, EligibilityArmWithDiseases} +import xyz.driver.pdsuidomain.entities.{EligibilityArm, EligibilityArmWithDiseases, SlotArm} import scala.concurrent.Future @@ -114,10 +114,13 @@ trait EligibilityArmService { pagination: Option[Pagination] = None)( implicit requestContext: AuthenticatedRequestContext): Future[GetListReply] - def getById(armId: LongId[EligibilityArm])( + def getByEligibilityId(armId: LongId[EligibilityArm])( implicit requestContext: AuthenticatedRequestContext): Future[GetByIdReply] - def create(draftEligibilityArm: EligibilityArmWithDiseases)( + def getBysSlotId(armId: LongId[EligibilityArm])( + implicit requestContext: AuthenticatedRequestContext): Future[GetByIdReply] + + def create(slotArmId: LongId[SlotArm], draftEligibilityArm: EligibilityArmWithDiseases)( implicit requestContext: AuthenticatedRequestContext): Future[CreateReply] def update(origEligibilityArm: EligibilityArmWithDiseases, draftEligibilityArm: EligibilityArmWithDiseases)( -- cgit v1.2.3 From b95572cfffa621a129488a9655c060dc418af6f4 Mon Sep 17 00:00:00 2001 From: Marvin Bertin Date: Wed, 4 Oct 2017 12:10:39 -0700 Subject: fix spelling for getBySlotId merthod --- .../scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/scala/xyz/driver/pdsuidomain/services') diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala index 928b657..55f3a57 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala @@ -117,7 +117,7 @@ trait EligibilityArmService { def getByEligibilityId(armId: LongId[EligibilityArm])( implicit requestContext: AuthenticatedRequestContext): Future[GetByIdReply] - def getBysSlotId(armId: LongId[EligibilityArm])( + def getBySlotId(armId: LongId[EligibilityArm])( implicit requestContext: AuthenticatedRequestContext): Future[GetByIdReply] def create(slotArmId: LongId[SlotArm], draftEligibilityArm: EligibilityArmWithDiseases)( -- cgit v1.2.3 From 33948327a7c7b29a409165c493762853f3bf5a75 Mon Sep 17 00:00:00 2001 From: Marvin Bertin Date: Wed, 4 Oct 2017 16:03:05 -0700 Subject: fix getBySlotId return type --- .../scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/scala/xyz/driver/pdsuidomain/services') diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala index 55f3a57..cf4fb37 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala @@ -118,7 +118,7 @@ trait EligibilityArmService { implicit requestContext: AuthenticatedRequestContext): Future[GetByIdReply] def getBySlotId(armId: LongId[EligibilityArm])( - implicit requestContext: AuthenticatedRequestContext): Future[GetByIdReply] + implicit requestContext: AuthenticatedRequestContext): Future[GetListReply] def create(slotArmId: LongId[SlotArm], draftEligibilityArm: EligibilityArmWithDiseases)( implicit requestContext: AuthenticatedRequestContext): Future[CreateReply] -- cgit v1.2.3 From 8c8eb25f90c9d169f256a5b51b5568faa2d93b53 Mon Sep 17 00:00:00 2001 From: Marvin Bertin Date: Wed, 4 Oct 2017 16:12:35 -0700 Subject: fix getBySlotId return type --- .../scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/scala/xyz/driver/pdsuidomain/services') diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala index cf4fb37..8efb98b 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala @@ -117,7 +117,7 @@ trait EligibilityArmService { def getByEligibilityId(armId: LongId[EligibilityArm])( implicit requestContext: AuthenticatedRequestContext): Future[GetByIdReply] - def getBySlotId(armId: LongId[EligibilityArm])( + def getBySlotId(armId: LongId[SlotArm])( implicit requestContext: AuthenticatedRequestContext): Future[GetListReply] def create(slotArmId: LongId[SlotArm], draftEligibilityArm: EligibilityArmWithDiseases)( -- cgit v1.2.3 From 54e1014da82dd35656f7d09599601337fa722971 Mon Sep 17 00:00:00 2001 From: Marvin Bertin Date: Thu, 5 Oct 2017 11:13:34 -0700 Subject: add sql parameters to getBySlotId --- .../xyz/driver/pdsuidomain/services/EligibilityArmService.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/main/scala/xyz/driver/pdsuidomain/services') diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala index 8efb98b..a56e30a 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala @@ -117,7 +117,10 @@ trait EligibilityArmService { def getByEligibilityId(armId: LongId[EligibilityArm])( implicit requestContext: AuthenticatedRequestContext): Future[GetByIdReply] - def getBySlotId(armId: LongId[SlotArm])( + def getBySlotId(armId: LongId[SlotArm], + filter: SearchFilterExpr = SearchFilterExpr.Empty, + sorting: Option[Sorting] = None, + pagination: Option[Pagination] = None)( implicit requestContext: AuthenticatedRequestContext): Future[GetListReply] def create(slotArmId: LongId[SlotArm], draftEligibilityArm: EligibilityArmWithDiseases)( -- cgit v1.2.3 From 0be360064e7b46eb0ebeac3bfde09d5e80c21d81 Mon Sep 17 00:00:00 2001 From: Marvin Bertin Date: Thu, 5 Oct 2017 14:11:19 -0700 Subject: add NoFoundError to CreateReply --- .../xyz/driver/pdsuidomain/services/EligibilityArmService.scala | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/main/scala/xyz/driver/pdsuidomain/services') diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala index a56e30a..e250e8f 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/EligibilityArmService.scala @@ -19,6 +19,10 @@ object EligibilityArmService { def userMessage: String = "EligibilityArm not found" } + trait SlotArmNotFoundError { + def userMessage: String = "SlotArm not found" + } + sealed trait GetByIdReply object GetByIdReply { @@ -78,6 +82,8 @@ object EligibilityArmService { case object AuthorizationError extends CreateReply with DefaultAccessDeniedError with DomainError.AuthorizationError + case object NotFoundError extends CreateReply with SlotArmNotFoundError with DomainError.NotFoundError + final case class CommonError(userMessage: String) extends CreateReply with DomainError final case class AlreadyExistsError(x: EligibilityArmWithDiseases) extends CreateReply with DomainError { -- cgit v1.2.3 From 6a692412fd7e2ab07a10065d5d2a07d86edd03cc Mon Sep 17 00:00:00 2001 From: Marvin Bertin Date: Tue, 10 Oct 2017 13:27:40 -0700 Subject: add disease list to ExportTrialArm --- .../entities/export/trial/ExportTrialArm.scala | 2 +- .../entities/export/trial/ExportTrialWithLabels.scala | 3 +-- .../xyz/driver/pdsuidomain/fakes/entities/export.scala | 7 +++---- .../pdsuidomain/formats/json/sprayformats/export.scala | 17 +++++------------ .../pdsuidomain/services/fake/FakeTrialService.scala | 4 ++-- .../formats/json/sprayformats/ExportFormatSuite.scala | 11 +++++------ 6 files changed, 17 insertions(+), 27 deletions(-) (limited to 'src/main/scala/xyz/driver/pdsuidomain/services') diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialArm.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialArm.scala index 5a9a406..b2ed7fb 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialArm.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialArm.scala @@ -4,7 +4,7 @@ import xyz.driver.pdsuicommon.domain._ import xyz.driver.pdsuicommon.logging._ import xyz.driver.pdsuidomain.entities.Arm -final case class ExportTrialArm(armId: LongId[Arm], armName: String) +final case class ExportTrialArm(armId: LongId[Arm], armName: String, diseaseList: Seq[String]) object ExportTrialArm { diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialWithLabels.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialWithLabels.scala index 3a9434b..3681945 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialWithLabels.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialWithLabels.scala @@ -8,7 +8,6 @@ import xyz.driver.pdsuidomain.entities.Trial final case class ExportTrialWithLabels(nctId: StringId[Trial], trialId: UuidId[Trial], - disease: String, lastReviewed: LocalDateTime, labelVersion: Long, arms: List[ExportTrialArm], @@ -18,7 +17,7 @@ object ExportTrialWithLabels { implicit def toPhiString(x: ExportTrialWithLabels): PhiString = { import x._ - phi"TrialWithLabels(nctId=$nctId, trialId=$trialId, disease=${Unsafe(disease)}, " + + phi"TrialWithLabels(nctId=$nctId, trialId=$trialId}, " + phi"lastReviewed=$lastReviewed, labelVersion=${Unsafe(labelVersion)}, arms=$arms, criteria=$criteria)" } } diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala index a3ba562..b769893 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala @@ -1,15 +1,15 @@ package xyz.driver.pdsuidomain.fakes.entities import xyz.driver.entities.labels.Label -import xyz.driver.pdsuidomain.entities.{Arm, Criterion, Trial} import xyz.driver.pdsuidomain.entities.export.trial._ +import xyz.driver.pdsuidomain.entities.{Arm, Criterion, Trial} object export { - import xyz.driver.core.generators._ import common._ + import xyz.driver.core.generators._ def nextExportTrialArm(): ExportTrialArm = - ExportTrialArm(armId = nextLongId[Arm], armName = nextString(100)) + ExportTrialArm(armId = nextLongId[Arm], armName = nextString(100), diseaseList = listOf(nextString(100))) def nextExportTrialLabelCriterion(): ExportTrialLabelCriterion = ExportTrialLabelCriterion( @@ -26,7 +26,6 @@ object export { ExportTrialWithLabels( nctId = nextStringId[Trial], trialId = nextUuidId[Trial], - disease = nextString(100), lastReviewed = nextLocalDateTime, labelVersion = nextInt(100).toLong, arms = listOf(nextExportTrialArm()), diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala index 85d614d..0fe85ea 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala @@ -2,16 +2,16 @@ package xyz.driver.pdsuidomain.formats.json.sprayformats import spray.json._ import xyz.driver.entities.labels.Label -import xyz.driver.pdsuidomain.entities.{Arm, Criterion} +import xyz.driver.formats.json.labels._ import xyz.driver.pdsuidomain.entities.export.patient._ import xyz.driver.pdsuidomain.entities.export.trial.{ExportTrialArm, ExportTrialLabelCriterion, ExportTrialWithLabels} -import xyz.driver.formats.json.labels._ +import xyz.driver.pdsuidomain.entities.{Arm, Criterion} object export { import DefaultJsonProtocol._ import common._ - import record._ import document._ + import record._ implicit val patientLabelEvidenceDocumentFormat: RootJsonFormat[ExportPatientLabelEvidenceDocument] = jsonFormat5(ExportPatientLabelEvidenceDocument.apply) @@ -25,7 +25,7 @@ object export { implicit val patientWithLabelsFormat: RootJsonFormat[ExportPatientWithLabels] = jsonFormat(ExportPatientWithLabels.apply, "patientId", "labelVersion", "labels") - implicit val trialArmFormat: RootJsonFormat[ExportTrialArm] = jsonFormat2(ExportTrialArm.apply) + implicit val trialArmFormat: RootJsonFormat[ExportTrialArm] = jsonFormat3(ExportTrialArm.apply) implicit val trialLabelCriterionFormat: RootJsonFormat[ExportTrialLabelCriterion] = new RootJsonFormat[ExportTrialLabelCriterion] { @@ -82,12 +82,5 @@ object export { } implicit val trialWithLabelsFormat: RootJsonFormat[ExportTrialWithLabels] = - jsonFormat(ExportTrialWithLabels.apply, - "nctId", - "trialId", - "disease", - "lastReviewed", - "labelVersion", - "arms", - "criteria") + jsonFormat(ExportTrialWithLabels.apply, "nctId", "trialId", "lastReviewed", "labelVersion", "arms", "criteria") } diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala index cb7f8bc..37c3de5 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala @@ -69,13 +69,13 @@ class FakeTrialService extends TrialService { ExportTrialWithLabels( StringId[Trial]("NCT" + generators.nextInt(999999).toString), UuidId[Trial](generators.nextUuid()), - generators.oneOf("adenocarcinoma", "breast", "prostate"), LocalDateTime.now(), labelVersion = 1L, generators.listOf( new ExportTrialArm( LongId[Arm](generators.nextInt(999999).toLong), - generators.nextName().value + generators.nextName().value, + generators.listOf(generators.oneOf("adenocarcinoma", "breast", "prostate")) )), generators.listOf( new ExportTrialLabelCriterion( diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala index 402e893..41d7825 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala @@ -3,8 +3,8 @@ package xyz.driver.pdsuidomain.formats.json.sprayformats import java.time.{LocalDate, LocalDateTime} import java.util.UUID -import spray.json._ import org.scalatest.{FlatSpec, Matchers} +import spray.json._ import xyz.driver.entities.labels.LabelValue import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId} import xyz.driver.pdsuidomain.entities.{DocumentType, ProviderType, RecordRequestId} @@ -81,8 +81,8 @@ class ExportFormatSuite extends FlatSpec with Matchers { "Json format for ApiExportTrialWithLabels" should "read and write correct JSON" in { import xyz.driver.pdsuidomain.entities.export.trial._ val arms = List( - ExportTrialArm(armId = LongId(1), armName = "arm 1"), - ExportTrialArm(armId = LongId(2), armName = "arm 2") + ExportTrialArm(armId = LongId(1), armName = "arm 1", diseaseList = Seq("Breast")), + ExportTrialArm(armId = LongId(2), armName = "arm 2", diseaseList = Seq("Breast")) ) val criteriaList = List( ExportTrialLabelCriterion( @@ -107,7 +107,6 @@ class ExportFormatSuite extends FlatSpec with Matchers { val trialWithLabels = ExportTrialWithLabels( nctId = StringId("NCT000001"), trialId = UuidId("40892a07-c638-49d2-9795-1edfefbbcc7c"), - disease = "Breast", lastReviewed = LocalDateTime.parse("2017-08-10T18:00:00"), labelVersion = 1L, arms = arms, @@ -116,8 +115,8 @@ class ExportFormatSuite extends FlatSpec with Matchers { val writtenJson = trialWithLabelsFormat.write(trialWithLabels) writtenJson should be( - """{"nctId":"NCT000001","trialId":"40892a07-c638-49d2-9795-1edfefbbcc7c","disease":"Breast","lastReviewed":"2017-08-10T18:00Z", - "labelVersion":1,"arms":[{"armId":1,"armName":"arm 1"},{"armId":2,"armName":"arm 2"}],"criteria":[ + """{"nctId":"NCT000001","trialId":"40892a07-c638-49d2-9795-1edfefbbcc7c","lastReviewed":"2017-08-10T18:00Z", + "labelVersion":1,"arms":[{"armId":1,"armName":"arm 1", "diseaseList":["Breast"]},{"armId":2,"armName":"arm 2", "diseaseList":["Breast"]}],"criteria":[ {"value":"Yes","labelId":21,"criterionId":10,"criterionText":"criteria 10 text","armIds":[1,2],"isCompound":false,"isDefining":false}, {"value":"Unknown","labelId":21,"criterionId":11,"criterionText":"criteria 11 text","armIds":[2],"isCompound":true,"isDefining":false}]}""".parseJson) } -- cgit v1.2.3 From 17edd2f48d93a2a96bafd5f10820b41b7416d177 Mon Sep 17 00:00:00 2001 From: Marvin Bertin Date: Tue, 10 Oct 2017 13:47:26 -0700 Subject: update to eligibility arm id --- .../driver/pdsuidomain/entities/export/trial/ExportTrialArm.scala | 4 ++-- src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala | 4 ++-- .../xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala | 2 +- .../xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala | 7 +++---- 4 files changed, 8 insertions(+), 9 deletions(-) (limited to 'src/main/scala/xyz/driver/pdsuidomain/services') diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialArm.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialArm.scala index b2ed7fb..24fe641 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialArm.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialArm.scala @@ -2,9 +2,9 @@ package xyz.driver.pdsuidomain.entities.export.trial import xyz.driver.pdsuicommon.domain._ import xyz.driver.pdsuicommon.logging._ -import xyz.driver.pdsuidomain.entities.Arm +import xyz.driver.pdsuidomain.entities.EligibilityArm -final case class ExportTrialArm(armId: LongId[Arm], armName: String, diseaseList: Seq[String]) +final case class ExportTrialArm(armId: LongId[EligibilityArm], armName: String) object ExportTrialArm { diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala index b769893..7221d28 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala @@ -2,14 +2,14 @@ package xyz.driver.pdsuidomain.fakes.entities import xyz.driver.entities.labels.Label import xyz.driver.pdsuidomain.entities.export.trial._ -import xyz.driver.pdsuidomain.entities.{Arm, Criterion, Trial} +import xyz.driver.pdsuidomain.entities.{Arm, Criterion, EligibilityArm, Trial} object export { import common._ import xyz.driver.core.generators._ def nextExportTrialArm(): ExportTrialArm = - ExportTrialArm(armId = nextLongId[Arm], armName = nextString(100), diseaseList = listOf(nextString(100))) + ExportTrialArm(armId = nextLongId[EligibilityArm], armName = nextString(100)) def nextExportTrialLabelCriterion(): ExportTrialLabelCriterion = ExportTrialLabelCriterion( diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala index 0fe85ea..8a67469 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala @@ -25,7 +25,7 @@ object export { implicit val patientWithLabelsFormat: RootJsonFormat[ExportPatientWithLabels] = jsonFormat(ExportPatientWithLabels.apply, "patientId", "labelVersion", "labels") - implicit val trialArmFormat: RootJsonFormat[ExportTrialArm] = jsonFormat3(ExportTrialArm.apply) + implicit val trialArmFormat: RootJsonFormat[ExportTrialArm] = jsonFormat2(ExportTrialArm.apply) implicit val trialLabelCriterionFormat: RootJsonFormat[ExportTrialLabelCriterion] = new RootJsonFormat[ExportTrialLabelCriterion] { diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala index 37c3de5..517b563 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala @@ -12,7 +12,7 @@ import xyz.driver.pdsuicommon.auth.AuthenticatedRequestContext import xyz.driver.pdsuicommon.db._ import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId} import xyz.driver.pdsuidomain.entities.export.trial.{ExportTrialArm, ExportTrialLabelCriterion, ExportTrialWithLabels} -import xyz.driver.pdsuidomain.entities.{Arm, Criterion, Trial} +import xyz.driver.pdsuidomain.entities.{Arm, Criterion, EligibilityArm, Trial} import xyz.driver.pdsuidomain.services.TrialService import scala.concurrent.Future @@ -73,9 +73,8 @@ class FakeTrialService extends TrialService { labelVersion = 1L, generators.listOf( new ExportTrialArm( - LongId[Arm](generators.nextInt(999999).toLong), - generators.nextName().value, - generators.listOf(generators.oneOf("adenocarcinoma", "breast", "prostate")) + LongId[EligibilityArm](generators.nextInt(999999).toLong), + generators.nextName().value )), generators.listOf( new ExportTrialLabelCriterion( -- cgit v1.2.3 From 9c95eb7247cb0818af9a9e4afe884698360f994c Mon Sep 17 00:00:00 2001 From: Marvin Bertin Date: Tue, 10 Oct 2017 15:20:08 -0700 Subject: fix exports with EligibilityArms --- .../entities/export/trial/ExportTrialLabelCriterion.scala | 4 ++-- src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala | 4 ++-- .../xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala | 4 ++-- .../xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala | 4 ++-- .../pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/main/scala/xyz/driver/pdsuidomain/services') diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialLabelCriterion.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialLabelCriterion.scala index 385bbbe..8376e34 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialLabelCriterion.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialLabelCriterion.scala @@ -3,12 +3,12 @@ package xyz.driver.pdsuidomain.entities.export.trial import xyz.driver.entities.labels.Label import xyz.driver.pdsuicommon.domain._ import xyz.driver.pdsuicommon.logging._ -import xyz.driver.pdsuidomain.entities.{Arm, Criterion} +import xyz.driver.pdsuidomain.entities.{Criterion, EligibilityArm} final case class ExportTrialLabelCriterion(criterionId: LongId[Criterion], value: Option[Boolean], labelId: LongId[Label], - armIds: Set[LongId[Arm]], + armIds: Set[LongId[EligibilityArm]], criteria: String, isCompound: Boolean, isDefining: Boolean) diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala index 7221d28..5febd8f 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala @@ -2,7 +2,7 @@ package xyz.driver.pdsuidomain.fakes.entities import xyz.driver.entities.labels.Label import xyz.driver.pdsuidomain.entities.export.trial._ -import xyz.driver.pdsuidomain.entities.{Arm, Criterion, EligibilityArm, Trial} +import xyz.driver.pdsuidomain.entities.{Criterion, EligibilityArm, Trial} object export { import common._ @@ -16,7 +16,7 @@ object export { criterionId = nextLongId[Criterion], value = nextOption[Boolean](nextBoolean()), labelId = nextLongId[Label], - armIds = setOf(nextLongId[Arm]), + armIds = setOf(nextLongId[EligibilityArm]), criteria = nextString(100), isCompound = nextBoolean(), isDefining = nextBoolean() diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala index 8a67469..1c4b6b4 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala @@ -5,7 +5,7 @@ import xyz.driver.entities.labels.Label import xyz.driver.formats.json.labels._ import xyz.driver.pdsuidomain.entities.export.patient._ import xyz.driver.pdsuidomain.entities.export.trial.{ExportTrialArm, ExportTrialLabelCriterion, ExportTrialWithLabels} -import xyz.driver.pdsuidomain.entities.{Arm, Criterion} +import xyz.driver.pdsuidomain.entities.{Criterion, EligibilityArm} object export { import DefaultJsonProtocol._ @@ -68,7 +68,7 @@ object export { longIdFormat[Criterion].read(criterionId), value, longIdFormat[Label].read(labelId), - armIdsVector.map(longIdFormat[Arm].read).toSet, + armIdsVector.map(longIdFormat[EligibilityArm].read).toSet, criterionText, isCompound, isDefining diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala index 517b563..0431d95 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala @@ -12,7 +12,7 @@ import xyz.driver.pdsuicommon.auth.AuthenticatedRequestContext import xyz.driver.pdsuicommon.db._ import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId} import xyz.driver.pdsuidomain.entities.export.trial.{ExportTrialArm, ExportTrialLabelCriterion, ExportTrialWithLabels} -import xyz.driver.pdsuidomain.entities.{Arm, Criterion, EligibilityArm, Trial} +import xyz.driver.pdsuidomain.entities.{Criterion, EligibilityArm, Trial} import xyz.driver.pdsuidomain.services.TrialService import scala.concurrent.Future @@ -81,7 +81,7 @@ class FakeTrialService extends TrialService { LongId[Criterion](generators.nextInt(999999).toLong), generators.nextOption(generators.nextBoolean()), LongId[Label](generators.nextInt(999999).toLong), - generators.setOf(LongId[Arm](generators.nextInt(999999).toLong)), + generators.setOf(LongId[EligibilityArm](generators.nextInt(999999).toLong)), generators.nextName().value, generators.nextBoolean(), generators.nextBoolean() diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala index 41d7825..3eaf93f 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala @@ -81,8 +81,8 @@ class ExportFormatSuite extends FlatSpec with Matchers { "Json format for ApiExportTrialWithLabels" should "read and write correct JSON" in { import xyz.driver.pdsuidomain.entities.export.trial._ val arms = List( - ExportTrialArm(armId = LongId(1), armName = "arm 1", diseaseList = Seq("Breast")), - ExportTrialArm(armId = LongId(2), armName = "arm 2", diseaseList = Seq("Breast")) + ExportTrialArm(armId = LongId(1), armName = "arm 1"), + ExportTrialArm(armId = LongId(2), armName = "arm 2") ) val criteriaList = List( ExportTrialLabelCriterion( @@ -116,7 +116,7 @@ class ExportFormatSuite extends FlatSpec with Matchers { val writtenJson = trialWithLabelsFormat.write(trialWithLabels) writtenJson should be( """{"nctId":"NCT000001","trialId":"40892a07-c638-49d2-9795-1edfefbbcc7c","lastReviewed":"2017-08-10T18:00Z", - "labelVersion":1,"arms":[{"armId":1,"armName":"arm 1", "diseaseList":["Breast"]},{"armId":2,"armName":"arm 2", "diseaseList":["Breast"]}],"criteria":[ + "labelVersion":1,"arms":[{"armId":1,"armName":"arm 1"},{"armId":2,"armName":"arm 2"}],"criteria":[ {"value":"Yes","labelId":21,"criterionId":10,"criterionText":"criteria 10 text","armIds":[1,2],"isCompound":false,"isDefining":false}, {"value":"Unknown","labelId":21,"criterionId":11,"criterionText":"criteria 11 text","armIds":[2],"isCompound":true,"isDefining":false}]}""".parseJson) } -- cgit v1.2.3 From 85c78f58f0428d13795aa0419ff42471513a34d6 Mon Sep 17 00:00:00 2001 From: Marvin Bertin Date: Tue, 10 Oct 2017 18:09:49 -0700 Subject: add diseaseList to ExportTrialArm --- .../driver/pdsuidomain/entities/export/trial/ExportTrialArm.scala | 4 ++-- src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala | 4 +++- .../xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala | 2 +- .../xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala | 3 ++- .../pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala | 6 +++--- 5 files changed, 11 insertions(+), 8 deletions(-) (limited to 'src/main/scala/xyz/driver/pdsuidomain/services') diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialArm.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialArm.scala index 24fe641..fbac0df 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialArm.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialArm.scala @@ -4,12 +4,12 @@ import xyz.driver.pdsuicommon.domain._ import xyz.driver.pdsuicommon.logging._ import xyz.driver.pdsuidomain.entities.EligibilityArm -final case class ExportTrialArm(armId: LongId[EligibilityArm], armName: String) +final case class ExportTrialArm(armId: LongId[EligibilityArm], armName: String, diseaseList: Seq[String]) object ExportTrialArm { implicit def toPhiString(x: ExportTrialArm): PhiString = { import x._ - phi"ExportTrialArm(armId=$armId, armName=${Unsafe(armName)})" + phi"ExportTrialArm(armId=$armId, armName=${Unsafe(armName)}, diseaseList=${Unsafe(diseaseList)})" } } diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala index 5febd8f..1fe7533 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/export.scala @@ -9,7 +9,9 @@ object export { import xyz.driver.core.generators._ def nextExportTrialArm(): ExportTrialArm = - ExportTrialArm(armId = nextLongId[EligibilityArm], armName = nextString(100)) + ExportTrialArm(armId = nextLongId[EligibilityArm], + armName = nextString(100), + diseaseList = listOf(nextString(100))) def nextExportTrialLabelCriterion(): ExportTrialLabelCriterion = ExportTrialLabelCriterion( diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala index 1c4b6b4..4391453 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala @@ -25,7 +25,7 @@ object export { implicit val patientWithLabelsFormat: RootJsonFormat[ExportPatientWithLabels] = jsonFormat(ExportPatientWithLabels.apply, "patientId", "labelVersion", "labels") - implicit val trialArmFormat: RootJsonFormat[ExportTrialArm] = jsonFormat2(ExportTrialArm.apply) + implicit val trialArmFormat: RootJsonFormat[ExportTrialArm] = jsonFormat3(ExportTrialArm.apply) implicit val trialLabelCriterionFormat: RootJsonFormat[ExportTrialLabelCriterion] = new RootJsonFormat[ExportTrialLabelCriterion] { diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala index 0431d95..e0efcd1 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/fake/FakeTrialService.scala @@ -74,7 +74,8 @@ class FakeTrialService extends TrialService { generators.listOf( new ExportTrialArm( LongId[EligibilityArm](generators.nextInt(999999).toLong), - generators.nextName().value + generators.nextName().value, + generators.listOf(generators.oneOf("adenocarcinoma", "breast", "prostate")) )), generators.listOf( new ExportTrialLabelCriterion( diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala index 3eaf93f..d78e754 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala @@ -81,8 +81,8 @@ class ExportFormatSuite extends FlatSpec with Matchers { "Json format for ApiExportTrialWithLabels" should "read and write correct JSON" in { import xyz.driver.pdsuidomain.entities.export.trial._ val arms = List( - ExportTrialArm(armId = LongId(1), armName = "arm 1"), - ExportTrialArm(armId = LongId(2), armName = "arm 2") + ExportTrialArm(armId = LongId(1), armName = "arm 1", diseaseList = Seq("Breast")), + ExportTrialArm(armId = LongId(2), armName = "arm 2", diseaseList = Seq("Breast")) ) val criteriaList = List( ExportTrialLabelCriterion( @@ -116,7 +116,7 @@ class ExportFormatSuite extends FlatSpec with Matchers { val writtenJson = trialWithLabelsFormat.write(trialWithLabels) writtenJson should be( """{"nctId":"NCT000001","trialId":"40892a07-c638-49d2-9795-1edfefbbcc7c","lastReviewed":"2017-08-10T18:00Z", - "labelVersion":1,"arms":[{"armId":1,"armName":"arm 1"},{"armId":2,"armName":"arm 2"}],"criteria":[ + "labelVersion":1,"arms":[{"armId":1,"armName":"arm 1","diseaseList":["Breast"]},{"armId":2,"armName":"arm 2","diseaseList":["Breast"]}],"criteria":[ {"value":"Yes","labelId":21,"criterionId":10,"criterionText":"criteria 10 text","armIds":[1,2],"isCompound":false,"isDefining":false}, {"value":"Unknown","labelId":21,"criterionId":11,"criterionText":"criteria 11 text","armIds":[2],"isCompound":true,"isDefining":false}]}""".parseJson) } -- cgit v1.2.3