diff options
author | ktomskikh <ktomskih@datamonsters.co> | 2017-08-03 18:04:00 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-03 18:04:00 +0700 |
commit | 40ee33a7c176895a19ee0f9066849d34c38c75fd (patch) | |
tree | 21b9d9b308f91af1eefaa5f68b4fef0e011c9e98 /src/main/scala/xyz/driver/pdsuidomain/entities | |
parent | a0c4fdf5f4280aa05518b925ed7bdc319758145a (diff) | |
parent | fc7c7063cafd7df8efe2c6c0dbc28e5ff0de06f6 (diff) | |
download | rest-query-40ee33a7c176895a19ee0f9066849d34c38c75fd.tar.gz rest-query-40ee33a7c176895a19ee0f9066849d34c38c75fd.tar.bz2 rest-query-40ee33a7c176895a19ee0f9066849d34c38c75fd.zip |
Merge pull request #15 from drivergroup/PDSUI-2181v0.2.13
PDSUI-2181 Created entities for patient history
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/entities')
-rw-r--r-- | src/main/scala/xyz/driver/pdsuidomain/entities/PatientHistory.scala | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/PatientHistory.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/PatientHistory.scala new file mode 100644 index 0000000..39817c4 --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/PatientHistory.scala @@ -0,0 +1,92 @@ +package xyz.driver.pdsuidomain.entities + +import java.time.{LocalDateTime, ZoneId} + +import xyz.driver.pdsuicommon.domain.{LongId, StringId, User, UuidId} +import xyz.driver.pdsuicommon.logging._ +import xyz.driver.pdsuicommon.utils.Utils +import xyz.driver.pdsuidomain.entities.PatientHistory.{Action, State} + +object PatientHistory { + + implicit def toPhiString(x: PatientHistory): PhiString = { + import x._ + phi"PatientHistory(id=$id, executor=$executor, patientId=$patientId, state=$state, action=$action, created=$created)" + } + + sealed trait State + object State { + case object Verify extends State + case object Curate extends State + case object Review extends State + case object Flag extends State + + val All: Set[State] = Set[State](Verify, Curate, Review, Flag) + + val fromString: PartialFunction[String, State] = { + case "Verify" => State.Verify + case "Curate" => State.Curate + case "Review" => State.Review + case "Flag" => State.Flag + } + + def stateToString(x: State): String = x match { + case State.Verify => "Verify" + case State.Curate => "Curate" + case State.Review => "Review" + case State.Flag => "Flag" + } + + implicit def toPhiString(x: State): PhiString = + Unsafe(Utils.getClassSimpleName(x.getClass)) + } + + sealed trait Action extends Product with Serializable { + + def oneOf(xs: Action*): Boolean = xs.contains(this) + + def oneOf(xs: Set[Action]): Boolean = xs.contains(this) + + } + + object Action { + case object Start extends Action + case object Submit extends Action + case object Unassign extends Action + case object Resolve extends Action + case object Flag extends Action + case object Archive extends Action + + val All: Set[Action] = + Set[Action](Start, Submit, Unassign, Resolve, Flag, Archive) + + val fromString: PartialFunction[String, Action] = { + case "Start" => Action.Start + case "Submit" => Action.Submit + case "Unassign" => Action.Unassign + case "Resolve" => Action.Resolve + case "Flag" => Action.Flag + case "Archive" => Action.Archive + } + + def actionToString(x: Action): String = x match { + case Action.Start => "Start" + case Action.Submit => "Submit" + case Action.Unassign => "Unassign" + case Action.Resolve => "Resolve" + case Action.Flag => "Flag" + case Action.Archive => "Archive" + } + + implicit def toPhiString(x: Action): PhiString = + Unsafe(Utils.getClassSimpleName(x.getClass)) + } + +} + +final case class PatientHistory(id: LongId[PatientHistory], + executor: StringId[User], + patientId: UuidId[Patient], + state: State, + action: Action, + created: LocalDateTime = LocalDateTime.now(ZoneId.of("Z"))) |