diff options
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain')
4 files changed, 42 insertions, 110 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/TrialHistory.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/TrialHistory.scala index cc96cbd..9210742 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/TrialHistory.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/TrialHistory.scala @@ -17,25 +17,31 @@ object TrialHistory { sealed trait State object State { - case object Summarize extends State - case object Criteriarize extends State - case object Review extends State - case object Flag extends State + case object Summarize extends State + case object Criteriarize extends State + case object Review extends State + case object ReviewSummary extends State + case object ReviewCriteria extends State + case object Flag extends State - val All: Set[State] = Set[State](Summarize, Criteriarize, Review, Flag) + val All: Set[State] = Set[State](Summarize, Criteriarize, Review, ReviewSummary, ReviewCriteria, Flag) val fromString: PartialFunction[String, State] = { - case "Summarize" => State.Summarize - case "Criteriarize" => State.Criteriarize - case "Review" => State.Review - case "Flag" => State.Flag + case "Summarize" => State.Summarize + case "Criteriarize" => State.Criteriarize + case "Review" => State.Review + case "ReviewSummary" => State.ReviewSummary + case "ReviewCriteria" => State.ReviewCriteria + case "Flag" => State.Flag } def stateToString(x: State): String = x match { - case State.Summarize => "Summarize" - case State.Criteriarize => "Criteriarize" - case State.Review => "Review" - case State.Flag => "Flag" + case State.Summarize => "Summarize" + case State.Criteriarize => "Criteriarize" + case State.Review => "Review" + case State.ReviewSummary => "ReviewSummary" + case State.ReviewCriteria => "ReviewCriteria" + case State.Flag => "Flag" } implicit def toPhiString(x: State): PhiString = diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patienteligibletrial.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patienteligibletrial.scala index f21b0cb..4c006f9 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patienteligibletrial.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patienteligibletrial.scala @@ -8,14 +8,13 @@ import xyz.driver.pdsuidomain.services.PatientEligibleTrialService.RichPatientEl object patienteligibletrial { import DefaultJsonProtocol._ import common._ - import xyz.driver.pdsuidomain.formats.json.trial._ - import xyz.driver.pdsuidomain.formats.json.patientcriterion._ def applyUpdateToTrialArmGroup(json: JsValue, orig: PatientTrialArmGroupView): PatientTrialArmGroupView = json match { case JsObject(fields) => - val isVerified = fields.get("group").map(_.asJsObject) - .flatMap(_.fields.get("isVerified")).map(_.convertTo[Boolean]) + val isVerified = fields + .get("isVerified") + .map(_.convertTo[Boolean]) .getOrElse(orig.isVerified) orig.copy(isVerified = isVerified) @@ -23,10 +22,19 @@ object patienteligibletrial { case _ => deserializationError(s"Expected Json Object as partial PatientTrialArmGroupView, but got $json") } - implicit val patientEligibleArmGroupView: RootJsonFormat[PatientTrialArmGroupView] = - jsonFormat7(PatientTrialArmGroupView.apply) - - implicit val patientEligibleTrialFormat: RootJsonFormat[RichPatientEligibleTrial] = - jsonFormat3(RichPatientEligibleTrial.apply) + implicit val patientEligibleTrialWriter: RootJsonWriter[RichPatientEligibleTrial] = + new RootJsonWriter[RichPatientEligibleTrial] { + override def write(obj: RichPatientEligibleTrial) = + JsObject( + "id" -> obj.group.id.toJson, + "patientId" -> obj.group.patientId.toJson, + "trialId" -> obj.group.trialId.toJson, + "trialTitle" -> obj.trial.title.toJson, + "arms" -> obj.arms.map(_.armName).toJson, + "hypothesisId" -> obj.trial.hypothesisId.toJson, + "verifiedEligibilityStatus" -> obj.group.verifiedEligibilityStatus.toJson, + "isVerified" -> obj.group.isVerified.toJson + ) + } } diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/trialhistory.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/trialhistory.scala index c8df1d8..f71ec12 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/trialhistory.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/trialhistory.scala @@ -10,10 +10,12 @@ object trialhistory { import common._ implicit val trialStateFormat = new EnumJsonFormat[State]( - "Summarize" -> State.Summarize, - "Criteriarize" -> State.Criteriarize, - "Review" -> State.Review, - "Flag" -> State.Flag + "Summarize" -> State.Summarize, + "Criteriarize" -> State.Criteriarize, + "Review" -> State.Review, + "ReviewSummary" -> State.ReviewSummary, + "ReviewCriteria" -> State.ReviewCriteria, + "Flag" -> State.Flag ) implicit val trialActionFormat = new EnumJsonFormat[Action]( diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestPatientEligibleTrialService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestPatientEligibleTrialService.scala deleted file mode 100644 index 06aa6d0..0000000 --- a/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestPatientEligibleTrialService.scala +++ /dev/null @@ -1,84 +0,0 @@ -package xyz.driver.pdsuidomain.services.rest - -import akka.http.scaladsl.marshalling.Marshal -import akka.http.scaladsl.model._ -import akka.stream.Materializer -import xyz.driver.core.rest.{Pagination => _, _} -import xyz.driver.entities.users.AuthUserInfo -import xyz.driver.pdsuicommon.db._ -import xyz.driver.pdsuicommon.domain._ -import xyz.driver.pdsuidomain.ListResponse -import xyz.driver.pdsuidomain.entities._ -import xyz.driver.pdsuidomain.services.PatientCriterionService.RichPatientCriterion -import xyz.driver.pdsuidomain.services.PatientEligibleTrialService - -import scala.concurrent.{ExecutionContext, Future} - -class RestPatientEligibleTrialService(transport: ServiceTransport, baseUri: Uri)( - implicit protected val materializer: Materializer, - protected val exec: ExecutionContext) - extends PatientEligibleTrialService with RestHelper { - - import PatientEligibleTrialService._ - import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._ - import xyz.driver.pdsuidomain.formats.json.listresponse._ - import xyz.driver.pdsuidomain.formats.json.patientcriterion._ - import xyz.driver.pdsuidomain.formats.json.patienteligibletrial._ - - def getAll(patientId: UuidId[Patient], - filter: SearchFilterExpr = SearchFilterExpr.Empty, - sorting: Option[Sorting] = None, - pagination: Option[Pagination] = None)( - implicit requestContext: AuthorizedServiceRequestContext[AuthUserInfo]): Future[GetListReply] = { - val request = HttpRequest(HttpMethods.GET, - endpointUri(baseUri, - s"/v1/patient/$patientId/trial", - filterQuery(filter) ++ sortingQuery(sorting) ++ paginationQuery(pagination))) - for { - response <- transport.sendRequestGetResponse(requestContext)(request) - reply <- apiResponse[ListResponse[RichPatientEligibleTrial]](response) - } yield { - GetListReply.EntityList(reply.items, reply.meta.itemsCount) - } - } - - - def getById(patientId: UuidId[Patient], id: LongId[PatientTrialArmGroup])( - implicit requestContext: AuthorizedServiceRequestContext[AuthUserInfo]): Future[GetByIdReply] = { - val request = HttpRequest(HttpMethods.GET, endpointUri(baseUri, s"/v1/patient/$patientId/trial/$id")) - for { - response <- transport.sendRequestGetResponse(requestContext)(request) - reply <- apiResponse[RichPatientEligibleTrial](response) - } yield { - GetByIdReply.Entity(reply) - } - } - - def getCriterionListByGroupId(patientId: UuidId[Patient], id: LongId[PatientTrialArmGroup])( - implicit requestContext: AuthorizedServiceRequestContext[AuthUserInfo]): Future[GetCriterionListOfGroupReply] = { - val request = HttpRequest(HttpMethods.GET, endpointUri(baseUri, s"/v1/patient/$patientId/trial/$id/criterion")) - for { - response <- transport.sendRequestGetResponse(requestContext)(request) - reply <- apiResponse[ListResponse[RichPatientCriterion]](response) - } yield { - GetCriterionListOfGroupReply.EntityList(reply.items, reply.meta.itemsCount) - } - } - - def update(origEligibleTrialWithTrial: RichPatientEligibleTrial, - draftPatientTrialArmGroup: PatientTrialArmGroupView)( - implicit requestContext: AuthorizedServiceRequestContext[AuthUserInfo]): Future[UpdateReply] = { - for { - entity <- Marshal(draftPatientTrialArmGroup).to[RequestEntity] - request = HttpRequest( - HttpMethods.PATCH, - endpointUri(baseUri, s"/v1/patient/${origEligibleTrialWithTrial.group.patientId}/trial/${origEligibleTrialWithTrial.group.id}")) - .withEntity(entity) - response <- transport.sendRequestGetResponse(requestContext)(request) - reply <- apiResponse[RichPatientEligibleTrial](response) - } yield { - UpdateReply.Updated(reply) - } - } - -} |