aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksandr <ognelisar@gmail.com>2017-11-14 15:44:43 +0700
committerAleksandr <ognelisar@gmail.com>2017-11-14 15:44:43 +0700
commit2afec69b277c031eb52e1a05e57ff7bb0079f8d1 (patch)
tree285d268bd9a3c536d5b575a4d4689bf984508443
parentf4a3b7aad2075eee91433a000be19cddcb32c7ad (diff)
downloadrest-query-2afec69b277c031eb52e1a05e57ff7bb0079f8d1.tar.gz
rest-query-2afec69b277c031eb52e1a05e57ff7bb0079f8d1.tar.bz2
rest-query-2afec69b277c031eb52e1a05e57ff7bb0079f8d1.zip
Implemented Actions for DocumentHistoryService and MedicalRecordHistoryService
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/entities/DocumentHistory.scala85
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/entities/MedicalRecordHistory.scala114
2 files changed, 102 insertions, 97 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/DocumentHistory.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/DocumentHistory.scala
index 0a8480b..a1404a7 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/entities/DocumentHistory.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/entities/DocumentHistory.scala
@@ -6,7 +6,9 @@ import xyz.driver.core.auth.User
import xyz.driver.pdsuicommon.domain._
import xyz.driver.pdsuicommon.logging._
import xyz.driver.pdsuicommon.utils.Utils
-import xyz.driver.pdsuidomain.entities.DocumentHistory._
+import xyz.driver.pdsuidomain.entities.DocumentHistory.{Action, _}
+
+import scala.collection.immutable
object DocumentHistory {
@@ -21,20 +23,21 @@ object DocumentHistory {
case object Extract extends State
case object Review extends State
case object Flag extends State
+ case object New extends State
+
+ private val stateToName = immutable.Map[State, String](
+ State.Extract -> "Extract",
+ State.Review -> "Review",
+ State.Flag -> "Flag",
+ State.New -> "New"
+ )
- val All: Set[State] = Set[State](Extract, Review, Flag)
+ val All: Set[State] = stateToName.keySet
- val fromString: PartialFunction[String, State] = {
- case "Extract" => State.Extract
- case "Review" => State.Review
- case "Flag" => State.Flag
- }
+ val fromString: PartialFunction[String, State] =
+ for ((k, v) <- stateToName) yield (v, k)
- def stateToString(x: State): String = x match {
- case State.Extract => "Extract"
- case State.Review => "Review"
- case State.Flag => "Flag"
- }
+ def stateToString: State => String = stateToName
implicit def toPhiString(x: State): PhiString =
Unsafe(Utils.getClassSimpleName(x.getClass))
@@ -49,38 +52,40 @@ object DocumentHistory {
}
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"
- }
+ 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
+ case object PostedEvidence extends Action
+ case object CreatedDocument extends Action
+ case object ReadDocument extends Action
+ case object DeletedDocument extends Action
+
+ private val actionToName = immutable.Map[Action, String](
+ Action.Start -> "Start",
+ Action.Submit -> "Submit",
+ Action.Unassign -> "Unassign",
+ Action.Resolve -> "Resolve",
+ Action.Flag -> "Flag",
+ Action.Archive -> "Archive",
+ Action.PostedEvidence -> "PostedEvidence",
+ Action.CreatedDocument -> "CreatedDocument",
+ Action.DeletedDocument -> "DeletedDocument",
+ Action.ReadDocument -> "ReadDocument"
+ )
+
+ val All: Set[Action] = actionToName.keySet
+
+ val fromString: PartialFunction[String, Action] =
+ for ((k, v) <- actionToName) yield (v, k)
+
+ def actionToString: Action => String = actionToName
implicit def toPhiString(x: Action): PhiString =
Unsafe(Utils.getClassSimpleName(x.getClass))
}
-
}
final case class DocumentHistory(id: LongId[DocumentHistory],
diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/MedicalRecordHistory.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/MedicalRecordHistory.scala
index 65c2731..b97120b 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/entities/MedicalRecordHistory.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/entities/MedicalRecordHistory.scala
@@ -8,6 +8,8 @@ import xyz.driver.pdsuicommon.logging._
import xyz.driver.pdsuicommon.utils.Utils
import xyz.driver.pdsuidomain.entities.MedicalRecordHistory._
+import scala.collection.immutable
+
object MedicalRecordHistory {
implicit def toPhiString(x: MedicalRecordHistory): PhiString = {
@@ -17,85 +19,83 @@ object MedicalRecordHistory {
}
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)
+ private val stateToName = immutable.Map[State, String](
+ State.Clean -> "Clean",
+ State.Organize -> "Organize",
+ State.Review -> "Review",
+ State.Flag -> "Flag"
+ )
- val fromString: PartialFunction[String, State] = {
- case "Clean" => State.Clean
- case "Organize" => State.Organize
- case "Review" => State.Review
- case "Flag" => State.Flag
- }
+ val All: Set[State] = stateToName.keySet
- def stateToString(x: State): String = x match {
- case State.Clean => "Clean"
- case State.Organize => "Organize"
- case State.Review => "Review"
- case State.Flag => "Flag"
- }
+ val fromString: PartialFunction[String, State] =
+ for ((k, v) <- stateToName) yield (v, k)
+
+ def stateToString: State => String = stateToName
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: 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
- case object Duplicate extends Action
- case object Reorder extends Action
- case object Rotation extends Action
- case object Clean 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
- case "Duplicate" => Action.Duplicate
- case "Reorder" => Action.Reorder
- case "Rotate" => Action.Rotation
- case "Clean" => Action.Clean
- }
-
- 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"
- case Action.Duplicate => "Duplicate"
- case Action.Reorder => "Reorder"
- case Action.Rotation => "Rotate"
- case Action.Clean => "Clean"
- }
+ 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
+ case object SavedDuplicate extends Action
+ case object SavedReorder extends Action
+ case object SavedRotation extends Action
+ case object DeletedDuplicate extends Action
+ case object DeletedReorder extends Action
+ case object DeletedRotation extends Action
+ case object CreatedDocument extends Action
+ case object DeletedDocument extends Action
+ case object CreatedRecord extends Action
+ case object ReadRecord extends Action
+
+ private val actionToName = immutable.Map[Action, String](
+ Action.Start -> "Start",
+ Action.Submit -> "Submit",
+ Action.Unassign -> "Unassign",
+ Action.Resolve -> "Resolve",
+ Action.Flag -> "Flag",
+ Action.Archive -> "Archive",
+ Action.SavedDuplicate -> "SavedDuplicate",
+ Action.SavedReorder -> "SavedReorder",
+ Action.SavedRotation -> "SavedRotate",
+ Action.DeletedDuplicate -> "DeletedDuplicate",
+ Action.DeletedReorder -> "DeletedReorder",
+ Action.DeletedRotation -> "DeletedRotation",
+ Action.CreatedDocument -> "CreatedDocument",
+ Action.DeletedDocument -> "DeletedDocument",
+ Action.CreatedRecord -> "CreatedRecord",
+ Action.ReadRecord -> "ReadRecord"
+ )
+
+ val fromString: PartialFunction[String, Action] =
+ for ((k, v) <- actionToName) yield (v, k)
+
+ val All: Set[Action] = actionToName.keySet
+
+ def actionToString: Action => String = actionToName
implicit def toPhiString(x: Action): PhiString =
Unsafe(Utils.getClassSimpleName(x.getClass))
}
-
}
final case class MedicalRecordHistory(id: LongId[MedicalRecordHistory],