diff options
author | Vlad Uspensky <v.uspenskiy@icloud.com> | 2017-07-27 09:22:50 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-27 09:22:50 -0700 |
commit | e120d1b2ffbf42b5b809b69a2201b3b8dd1a1ef9 (patch) | |
tree | 8d782fdb79c56615dcaf052e7a4bd0cfd7f4d5ef /src/main/scala/xyz/driver/pdsuidomain/entities | |
parent | 56209581161e4cc2f83f85b52bd573dd25bb7201 (diff) | |
parent | 4c7b4102dede53b9707fe3758a4a9ff9ccf87bf8 (diff) | |
download | rest-query-0.2.7.tar.gz rest-query-0.2.7.tar.bz2 rest-query-0.2.7.zip |
Merge pull request #10 from drivergroup/PDSUI-2145v0.2.7
PDSUI-2145 Create own user history for Documents and Medical Records
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/entities')
-rw-r--r-- | src/main/scala/xyz/driver/pdsuidomain/entities/DocumentHistory.scala | 90 | ||||
-rw-r--r-- | src/main/scala/xyz/driver/pdsuidomain/entities/MedicalRecordHistory.scala | 93 |
2 files changed, 183 insertions, 0 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/DocumentHistory.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/DocumentHistory.scala new file mode 100644 index 0000000..a82da12 --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/DocumentHistory.scala @@ -0,0 +1,90 @@ +package xyz.driver.pdsuidomain.entities + +import java.time.{LocalDateTime, ZoneId} + +import xyz.driver.pdsuicommon.domain._ +import xyz.driver.pdsuicommon.logging._ +import xyz.driver.pdsuicommon.utils.Utils +import xyz.driver.pdsuidomain.entities.DocumentHistory._ + +object DocumentHistory { + + implicit def toPhiString(x: DocumentHistory): PhiString = { + import x._ + phi"DocumentHistory(id=$id, executor=$executor, documentId=$documentId, state=$state, action=$action, " + + phi"created=$created)" + } + + sealed trait State + object State { + case object Extract extends State + case object Review extends State + case object Flag extends State + + val All: Set[State] = Set[State](Extract, Review, Flag) + + val fromString: PartialFunction[String, State] = { + case "Extract" => State.Extract + case "Review" => State.Review + case "Flag" => State.Flag + } + + def stateToString(x: State): String = x match { + case State.Extract => "Extract" + 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 DocumentHistory(id: LongId[DocumentHistory], + executor: StringId[User], + documentId: LongId[Document], + state: State, + action: Action, + created: LocalDateTime = LocalDateTime.now(ZoneId.of("Z"))) diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/MedicalRecordHistory.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/MedicalRecordHistory.scala new file mode 100644 index 0000000..d01433c --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/MedicalRecordHistory.scala @@ -0,0 +1,93 @@ +package xyz.driver.pdsuidomain.entities + +import java.time.{LocalDateTime, ZoneId} + +import xyz.driver.pdsuicommon.domain._ +import xyz.driver.pdsuicommon.logging._ +import xyz.driver.pdsuicommon.utils.Utils +import xyz.driver.pdsuidomain.entities.MedicalRecordHistory._ + +object MedicalRecordHistory { + + implicit def toPhiString(x: MedicalRecordHistory): PhiString = { + import x._ + phi"MedicalRecordHistory(id=$id, executor=$executor, recordId=$recordId, state=$state, action=$action, " + + phi"created=$created)" + } + + sealed trait State + object State { + case object Clean extends State + case object Organize extends State + case object Review extends State + case object Flag extends State + + val All: Set[State] = Set[State](Clean, Organize, Review, Flag) + + val fromString: PartialFunction[String, State] = { + case "Clean" => State.Clean + case "Organize" => State.Organize + case "Review" => State.Review + case "Flag" => State.Flag + } + + def stateToString(x: State): String = x match { + case State.Clean => "Clean" + case State.Organize => "Organize" + 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 MedicalRecordHistory(id: LongId[MedicalRecordHistory], + executor: StringId[User], + recordId: LongId[MedicalRecord], + state: State, + action: Action, + created: LocalDateTime = LocalDateTime.now(ZoneId.of("Z"))) |