aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuidomain/services/ExportService.scala
blob: 5be037cc038eec00ff3aff5b3ec6e87aea421c5b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package xyz.driver.pdsuidomain.services

import java.time.LocalDateTime

import xyz.driver.pdsuicommon.auth.AnonymousRequestContext
import xyz.driver.pdsuicommon.db.SearchFilterExpr
import xyz.driver.pdsuicommon.domain.{StringId, UuidId}
import xyz.driver.pdsuicommon.error.DomainError
import xyz.driver.pdsuicommon.logging._
import xyz.driver.pdsuidomain.entities.{Patient, Trial}
import xyz.driver.pdsuidomain.entities.export.patient.ExportPatientWithLabels
import xyz.driver.pdsuidomain.entities.export.trial.{ExportTrial, ExportTrialWithLabels}

import scala.concurrent.Future

object ExportService {

  sealed trait GetPatientReply
  object GetPatientReply {
    type Error = GetPatientReply with DomainError

    case class Entity(x: ExportPatientWithLabels) extends GetPatientReply

    case object NotFoundError extends GetPatientReply with DomainError.NotFoundError {
      def userMessage: String = "Patient not found"
    }
  }

  sealed trait GetTrialListReply
  object GetTrialListReply {
    case class EntityList(xs: Seq[ExportTrial], totalFound: Int, lastUpdate: Option[LocalDateTime])
        extends GetTrialListReply
  }

  sealed trait GetTrialReply
  object GetTrialReply {
    type Error = GetTrialReply with DomainError

    case class Entity(x: ExportTrialWithLabels) extends GetTrialReply

    case object NotFoundError extends GetTrialReply with DomainError.NotFoundError {
      def userMessage: String = "Trial not found"
    }
  }
}

trait ExportService extends PhiLogging {

  import ExportService._

  def getPatient(id: UuidId[Patient])(implicit requestContext: AnonymousRequestContext): Future[GetPatientReply]

  def getTrialList(filter: SearchFilterExpr = SearchFilterExpr.Empty)(
          implicit requestContext: AnonymousRequestContext): Future[GetTrialListReply]

  def getTrial(trialId: StringId[Trial], condition: String)(
          implicit requestContext: AnonymousRequestContext): Future[GetTrialReply]

}