aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJakob Odersky <jakob@driver.xyz>2017-11-21 22:41:51 -0800
committerJakob Odersky <jakob@driver.xyz>2017-11-29 18:53:10 -0800
commit449d0da264c50a7271dec0a421d7c8f375808aeb (patch)
treec87e7b74e1c54c051bf8cce00cf4a3a4d8007e01 /src
parent357ed83683bf49c952c4de60d8a671089150e23c (diff)
downloadrest-query-449d0da264c50a7271dec0a421d7c8f375808aeb.tar.gz
rest-query-449d0da264c50a7271dec0a421d7c8f375808aeb.tar.bz2
rest-query-449d0da264c50a7271dec0a421d7c8f375808aeb.zip
Add eligibility service endpoint and supporting domain model
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/entities/eligibility.scala5
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/eligibility.scala5
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/services/EligibilitySnapshotService.scala16
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/services/PatientEligibleTrialService.scala10
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/services/rest/RestEligibilitySnapshotService.scala35
5 files changed, 65 insertions, 6 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/eligibility.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/eligibility.scala
index 1a900ac..9362a0c 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/entities/eligibility.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/entities/eligibility.scala
@@ -60,4 +60,9 @@ object eligibility {
orderId: Id[TestOrder],
disease: CancerType,
patientDataStatus: ProcessStepExecutionStatus)
+
+ final case class EligibleTrial(nctId: String, arms: Seq[EligibleArm])
+ final case class EligibleArm(title: String, criteria: Seq[EligibleCriterion])
+ final case class EligibleCriterion(text: String, eligibilityStatus: LabelValue)
+
}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/eligibility.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/eligibility.scala
index 571cbde..925ba65 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/eligibility.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/eligibility.scala
@@ -100,4 +100,9 @@ object eligibility {
implicit def labelRankingsFormat: RootJsonFormat[MismatchRankedLabels] = jsonFormat2(MismatchRankedLabels)
implicit def matchedPatientFormat: RootJsonFormat[MatchedPatient] = jsonFormat6(MatchedPatient)
+
+ implicit lazy val eligibleTrialFormat: RootJsonFormat[EligibleTrial] = jsonFormat2(EligibleTrial.apply)
+ implicit lazy val eligibleArmFormat: RootJsonFormat[EligibleArm] = jsonFormat2(EligibleArm.apply)
+ implicit lazy val eligibleCriterionFormat: RootJsonFormat[EligibleCriterion] = jsonFormat2(EligibleCriterion.apply)
+
}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/EligibilitySnapshotService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/EligibilitySnapshotService.scala
new file mode 100644
index 0000000..b3e6673
--- /dev/null
+++ b/src/main/scala/xyz/driver/pdsuidomain/services/EligibilitySnapshotService.scala
@@ -0,0 +1,16 @@
+package xyz.driver.pdsuidomain.services
+
+import xyz.driver.core.rest.AuthorizedServiceRequestContext
+import xyz.driver.entities.users.AuthUserInfo
+import xyz.driver.pdsuicommon.domain.UuidId
+import xyz.driver.pdsuidomain.entities.{Patient => PdsuiPatient}
+import xyz.driver.pdsuidomain.entities.eligibility.EligibleTrial
+
+import scala.concurrent.Future
+
+trait EligibilitySnapshotService {
+
+ def eligibilitySnapshot(patientId: UuidId[PdsuiPatient])(
+ implicit requestContext: AuthorizedServiceRequestContext[AuthUserInfo]): Future[Seq[EligibleTrial]]
+
+}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/PatientEligibleTrialService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/PatientEligibleTrialService.scala
index f07f6fa..8d1288a 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/services/PatientEligibleTrialService.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/services/PatientEligibleTrialService.scala
@@ -96,11 +96,9 @@ object PatientEligibleTrialService {
case object NotFoundError extends UpdateReply with DefaultNotFoundError with DomainError.NotFoundError
- case object PatientNotFoundError
- extends UpdateReply with DefaultPatientNotFoundError with DomainError.NotFoundError
+ case object PatientNotFoundError extends UpdateReply with DefaultPatientNotFoundError with DomainError.NotFoundError
- case object AuthorizationError
- extends UpdateReply with DomainError.AuthorizationError with DefaultAccessDeniedError
+ case object AuthorizationError extends UpdateReply with DomainError.AuthorizationError with DefaultAccessDeniedError
final case class CommonError(userMessage: String) extends UpdateReply with DomainError
@@ -127,7 +125,7 @@ trait PatientEligibleTrialService {
def getCriterionListByGroupId(patientId: UuidId[Patient], id: LongId[PatientTrialArmGroup])(
implicit requestContext: AuthorizedServiceRequestContext[AuthUserInfo]): Future[GetCriterionListOfGroupReply]
- def update(origEligibleTrialWithTrial: RichPatientEligibleTrial,
- draftPatientTrialArmGroup: PatientTrialArmGroupView)(
+ def update(origEligibleTrialWithTrial: RichPatientEligibleTrial, draftPatientTrialArmGroup: PatientTrialArmGroupView)(
implicit requestContext: AuthorizedServiceRequestContext[AuthUserInfo]): Future[UpdateReply]
+
}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestEligibilitySnapshotService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestEligibilitySnapshotService.scala
new file mode 100644
index 0000000..8754165
--- /dev/null
+++ b/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestEligibilitySnapshotService.scala
@@ -0,0 +1,35 @@
+package xyz.driver.pdsuidomain.services.rest
+
+import akka.http.scaladsl.model.{HttpMethods, HttpRequest, Uri}
+import akka.stream.Materializer
+import xyz.driver.core.rest.{AuthorizedServiceRequestContext, ServiceTransport}
+import xyz.driver.entities.users
+import xyz.driver.entities.users.AuthUserInfo
+import xyz.driver.pdsuicommon.domain.UuidId
+import xyz.driver.pdsuidomain.entities.eligibility.EligibleTrial
+import xyz.driver.pdsuidomain.entities.{Patient, eligibility}
+import xyz.driver.pdsuidomain.services.EligibilitySnapshotService
+
+import scala.concurrent.{ExecutionContext, Future}
+
+class RestEligibilitySnapshotService(transport: ServiceTransport, baseUrl: Uri)(
+ implicit protected val materializer: Materializer,
+ protected val exec: ExecutionContext) extends EligibilitySnapshotService with RestHelper {
+
+ import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
+ import spray.json.DefaultJsonProtocol._
+ import xyz.driver.pdsuidomain.formats.json.eligibility._
+
+ override def eligibilitySnapshot(patientId: UuidId[Patient])
+ (implicit requestContext: AuthorizedServiceRequestContext[AuthUserInfo]):
+ Future[Seq[eligibility.EligibleTrial]] = {
+ val request = HttpRequest(HttpMethods.GET, endpointUri(baseUrl, s"/v1/patient/$patientId/eligibilitySnapshot"))
+ for {
+ response <- transport.sendRequestGetResponse(requestContext)(request)
+ reply <- apiResponse[Seq[EligibleTrial]](response)
+ } yield {
+ reply
+ }
+ }
+
+}