diff options
author | Jakob Odersky <jakob@driver.xyz> | 2017-11-29 19:25:10 -0800 |
---|---|---|
committer | Jakob Odersky <jakob@driver.xyz> | 2017-11-29 19:25:10 -0800 |
commit | d10fbf057accdf87bc8a160a2b0a08a22fef9087 (patch) | |
tree | 5f20bad9ebf5d18065c3c3cd413640ae70ced852 /src/main/scala/xyz/driver/pdsuidomain/services | |
parent | 16b8fa21f38ee98864e1476d78ca78aa949f2ad3 (diff) | |
parent | 449d0da264c50a7271dec0a421d7c8f375808aeb (diff) | |
download | rest-query-d10fbf057accdf87bc8a160a2b0a08a22fef9087.tar.gz rest-query-d10fbf057accdf87bc8a160a2b0a08a22fef9087.tar.bz2 rest-query-d10fbf057accdf87bc8a160a2b0a08a22fef9087.zip |
Merge branch 'eligibility-snapshot'v0.14.23
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/services')
3 files changed, 55 insertions, 6 deletions
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 + } + } + +} |