module Claims.Parser.AST
  ( ParsedRule(..)
  , Condition(..)
  , Action(..)
  , CompOp(..)
  ) where

-- | A parsed rule from the external DSL
data ParsedRule = ParsedRule
  { ParsedRule -> String
ruleName :: String
  , ParsedRule -> String
ruleDescription :: String
  , ParsedRule -> Condition
conditions :: Condition
  , ParsedRule -> Action
action :: Action
  , ParsedRule -> Maybe (Condition, Action)
elseAction :: Maybe (Condition, Action)
  } deriving (Int -> ParsedRule -> ShowS
[ParsedRule] -> ShowS
ParsedRule -> String
(Int -> ParsedRule -> ShowS)
-> (ParsedRule -> String)
-> ([ParsedRule] -> ShowS)
-> Show ParsedRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ParsedRule -> ShowS
showsPrec :: Int -> ParsedRule -> ShowS
$cshow :: ParsedRule -> String
show :: ParsedRule -> String
$cshowList :: [ParsedRule] -> ShowS
showList :: [ParsedRule] -> ShowS
Show, ParsedRule -> ParsedRule -> Bool
(ParsedRule -> ParsedRule -> Bool)
-> (ParsedRule -> ParsedRule -> Bool) -> Eq ParsedRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ParsedRule -> ParsedRule -> Bool
== :: ParsedRule -> ParsedRule -> Bool
$c/= :: ParsedRule -> ParsedRule -> Bool
/= :: ParsedRule -> ParsedRule -> Bool
Eq)

-- | Condition expressions in the external DSL
data Condition
  = CompareAmount CompOp Double
  | AmountBetween Double Double
  | CheckDiagnosis String
  | CheckProcedure String
  | CheckPlaceOfService String
  | CheckClaimType String
  | AndCond Condition Condition
  | OrCond Condition Condition
  | NotCond Condition
  deriving (Int -> Condition -> ShowS
[Condition] -> ShowS
Condition -> String
(Int -> Condition -> ShowS)
-> (Condition -> String)
-> ([Condition] -> ShowS)
-> Show Condition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Condition -> ShowS
showsPrec :: Int -> Condition -> ShowS
$cshow :: Condition -> String
show :: Condition -> String
$cshowList :: [Condition] -> ShowS
showList :: [Condition] -> ShowS
Show, Condition -> Condition -> Bool
(Condition -> Condition -> Bool)
-> (Condition -> Condition -> Bool) -> Eq Condition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Condition -> Condition -> Bool
== :: Condition -> Condition -> Bool
$c/= :: Condition -> Condition -> Bool
/= :: Condition -> Condition -> Bool
Eq)

-- | Comparison operators
data CompOp = Gt | Lt | Eq | Gte | Lte
  deriving (Int -> CompOp -> ShowS
[CompOp] -> ShowS
CompOp -> String
(Int -> CompOp -> ShowS)
-> (CompOp -> String) -> ([CompOp] -> ShowS) -> Show CompOp
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CompOp -> ShowS
showsPrec :: Int -> CompOp -> ShowS
$cshow :: CompOp -> String
show :: CompOp -> String
$cshowList :: [CompOp] -> ShowS
showList :: [CompOp] -> ShowS
Show, CompOp -> CompOp -> Bool
(CompOp -> CompOp -> Bool)
-> (CompOp -> CompOp -> Bool) -> Eq CompOp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CompOp -> CompOp -> Bool
== :: CompOp -> CompOp -> Bool
$c/= :: CompOp -> CompOp -> Bool
/= :: CompOp -> CompOp -> Bool
Eq)

-- | Actions that can be taken on a claim
data Action
  = RejectClaim String
  | ApproveClaim
  | RequireReview String
  deriving (Int -> Action -> ShowS
[Action] -> ShowS
Action -> String
(Int -> Action -> ShowS)
-> (Action -> String) -> ([Action] -> ShowS) -> Show Action
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Action -> ShowS
showsPrec :: Int -> Action -> ShowS
$cshow :: Action -> String
show :: Action -> String
$cshowList :: [Action] -> ShowS
showList :: [Action] -> ShowS
Show, Action -> Action -> Bool
(Action -> Action -> Bool)
-> (Action -> Action -> Bool) -> Eq Action
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Action -> Action -> Bool
== :: Action -> Action -> Bool
$c/= :: Action -> Action -> Bool
/= :: Action -> Action -> Bool
Eq)