diff options
author | Kseniya Tomskikh <ktomskih@datamonsters.co> | 2018-01-18 22:14:22 +0200 |
---|---|---|
committer | Kseniya Tomskikh <ktomskih@datamonsters.co> | 2018-01-18 22:14:22 +0200 |
commit | e6efab471cb30df21d07883b56af6e94e0507849 (patch) | |
tree | f4e5a107db79fec4a3dca724aa01b2f500f8f320 /src/main/scala/xyz/driver/pdsuidomain/services/rest/RestPatientLabelService.scala | |
parent | af10bb0a3131ebad9050f1766dadfa3954268f2c (diff) | |
parent | 57b1a08669ddb3fb54cf79a2f42cb473e0ced3f5 (diff) | |
download | rest-query-e6efab471cb30df21d07883b56af6e94e0507849.tar.gz rest-query-e6efab471cb30df21d07883b56af6e94e0507849.tar.bz2 rest-query-e6efab471cb30df21d07883b56af6e94e0507849.zip |
Merge branch 'master' into TRIAL-193v0.15.1.1
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/services/rest/RestPatientLabelService.scala')
-rw-r--r-- | src/main/scala/xyz/driver/pdsuidomain/services/rest/RestPatientLabelService.scala | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestPatientLabelService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestPatientLabelService.scala index a6ef5b4..932e123 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestPatientLabelService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestPatientLabelService.scala @@ -6,7 +6,7 @@ import akka.stream.Materializer import xyz.driver.core.rest.{Pagination => _, _} import xyz.driver.entities.labels.Label import xyz.driver.entities.users.AuthUserInfo -import xyz.driver.pdsuicommon.db._ +import xyz.driver.pdsuicommon.db.{Pagination, _} import xyz.driver.pdsuicommon.domain._ import xyz.driver.pdsuidomain.ListResponse import xyz.driver.pdsuidomain.entities._ @@ -22,53 +22,52 @@ class RestPatientLabelService(transport: ServiceTransport, baseUri: Uri)( import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._ import xyz.driver.pdsuidomain.formats.json.listresponse._ import xyz.driver.pdsuidomain.formats.json.patientlabel._ - import xyz.driver.pdsuidomain.services.PatientLabelService._ def getAll(patientId: UuidId[Patient], filter: SearchFilterExpr = SearchFilterExpr.Empty, sorting: Option[Sorting] = None, - pagination: Option[Pagination] = None)( - implicit requestContext: AuthorizedServiceRequestContext[AuthUserInfo]): Future[GetListReply] = { + pagination: Pagination = Pagination.Default)( + implicit requestContext: AuthorizedServiceRequestContext[AuthUserInfo]): Future[ListResponse[RichPatientLabel]] = { val request = HttpRequest(HttpMethods.GET, endpointUri(baseUri, s"/v1/patient/$patientId/label", - filterQuery(filter) ++ sortingQuery(sorting) ++ paginationQuery(pagination))) + filterQuery(filter) ++ sortingQuery(sorting) ++ paginationQuery(Some(pagination)))) for { response <- transport.sendRequestGetResponse(requestContext)(request) reply <- apiResponse[ListResponse[RichPatientLabel]](response) } yield { - GetListReply.EntityList(reply.items, reply.meta.itemsCount) + reply } } def getDefiningCriteriaList(patientId: UuidId[Patient], hypothesisId: UuidId[Hypothesis], - pagination: Option[Pagination] = None)( + pagination: Pagination = Pagination.Default)( implicit requestContext: AuthorizedServiceRequestContext[AuthUserInfo] - ): Future[GetDefiningCriteriaListReply] = { + ): Future[ListResponse[PatientLabel]] = { val request = HttpRequest(HttpMethods.GET, - endpointUri(baseUri, s"/patient/$patientId/hypothesis", paginationQuery(pagination))) + endpointUri(baseUri, s"/patient/$patientId/hypothesis", paginationQuery(Some(pagination)))) for { response <- transport.sendRequestGetResponse(requestContext)(request) reply <- apiResponse[ListResponse[PatientLabel]](response) } yield { - GetDefiningCriteriaListReply.EntityList(reply.items, reply.meta.itemsCount) + reply } } def getByLabelIdOfPatient(patientId: UuidId[Patient], labelId: LongId[Label])( - implicit requestContext: AuthorizedServiceRequestContext[AuthUserInfo]): Future[GetByLabelIdReply] = { + implicit requestContext: AuthorizedServiceRequestContext[AuthUserInfo]): Future[Option[RichPatientLabel]] = { val request = HttpRequest(HttpMethods.GET, endpointUri(baseUri, s"/v1/patient/$patientId/label/$labelId")) for { response <- transport.sendRequestGetResponse(requestContext)(request) - reply <- apiResponse[RichPatientLabel](response) + entity <- apiResponse[RichPatientLabel](response) } yield { - GetByLabelIdReply.Entity(reply) + Option(entity) } } def update(origPatientLabel: PatientLabel, draftPatientLabel: PatientLabel)( - implicit requestContext: AuthorizedServiceRequestContext[AuthUserInfo]): Future[UpdateReply] = { + implicit requestContext: AuthorizedServiceRequestContext[AuthUserInfo]): Future[RichPatientLabel] = { for { entity <- Marshal(draftPatientLabel).to[RequestEntity] request = HttpRequest( @@ -76,9 +75,9 @@ class RestPatientLabelService(transport: ServiceTransport, baseUri: Uri)( endpointUri(baseUri, s"/v1/patient/${origPatientLabel.patientId}/label/${origPatientLabel.labelId}")) .withEntity(entity) response <- transport.sendRequestGetResponse(requestContext)(request) - reply <- apiResponse[RichPatientLabel](response) + entity <- apiResponse[RichPatientLabel](response) } yield { - UpdateReply.Updated(reply) + entity } } |