{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.ComprehendMedical.Types.RxNormTrait
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ComprehendMedical.Types.RxNormTrait where

import Amazonka.ComprehendMedical.Types.RxNormTraitName
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The contextual information for the entity. InferRxNorm recognizes the
-- trait @NEGATION@, which is any indication that the patient is not taking
-- a medication.
--
-- /See:/ 'newRxNormTrait' smart constructor.
data RxNormTrait = RxNormTrait'
  { -- | The level of confidence that Amazon Comprehend Medical has in the
    -- accuracy of the detected trait.
    RxNormTrait -> Maybe Double
score :: Prelude.Maybe Prelude.Double,
    -- | Provides a name or contextual description about the trait.
    RxNormTrait -> Maybe RxNormTraitName
name :: Prelude.Maybe RxNormTraitName
  }
  deriving (RxNormTrait -> RxNormTrait -> Bool
(RxNormTrait -> RxNormTrait -> Bool)
-> (RxNormTrait -> RxNormTrait -> Bool) -> Eq RxNormTrait
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RxNormTrait -> RxNormTrait -> Bool
$c/= :: RxNormTrait -> RxNormTrait -> Bool
== :: RxNormTrait -> RxNormTrait -> Bool
$c== :: RxNormTrait -> RxNormTrait -> Bool
Prelude.Eq, ReadPrec [RxNormTrait]
ReadPrec RxNormTrait
Int -> ReadS RxNormTrait
ReadS [RxNormTrait]
(Int -> ReadS RxNormTrait)
-> ReadS [RxNormTrait]
-> ReadPrec RxNormTrait
-> ReadPrec [RxNormTrait]
-> Read RxNormTrait
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RxNormTrait]
$creadListPrec :: ReadPrec [RxNormTrait]
readPrec :: ReadPrec RxNormTrait
$creadPrec :: ReadPrec RxNormTrait
readList :: ReadS [RxNormTrait]
$creadList :: ReadS [RxNormTrait]
readsPrec :: Int -> ReadS RxNormTrait
$creadsPrec :: Int -> ReadS RxNormTrait
Prelude.Read, Int -> RxNormTrait -> ShowS
[RxNormTrait] -> ShowS
RxNormTrait -> String
(Int -> RxNormTrait -> ShowS)
-> (RxNormTrait -> String)
-> ([RxNormTrait] -> ShowS)
-> Show RxNormTrait
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RxNormTrait] -> ShowS
$cshowList :: [RxNormTrait] -> ShowS
show :: RxNormTrait -> String
$cshow :: RxNormTrait -> String
showsPrec :: Int -> RxNormTrait -> ShowS
$cshowsPrec :: Int -> RxNormTrait -> ShowS
Prelude.Show, (forall x. RxNormTrait -> Rep RxNormTrait x)
-> (forall x. Rep RxNormTrait x -> RxNormTrait)
-> Generic RxNormTrait
forall x. Rep RxNormTrait x -> RxNormTrait
forall x. RxNormTrait -> Rep RxNormTrait x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RxNormTrait x -> RxNormTrait
$cfrom :: forall x. RxNormTrait -> Rep RxNormTrait x
Prelude.Generic)

-- |
-- Create a value of 'RxNormTrait' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'score', 'rxNormTrait_score' - The level of confidence that Amazon Comprehend Medical has in the
-- accuracy of the detected trait.
--
-- 'name', 'rxNormTrait_name' - Provides a name or contextual description about the trait.
newRxNormTrait ::
  RxNormTrait
newRxNormTrait :: RxNormTrait
newRxNormTrait =
  RxNormTrait' :: Maybe Double -> Maybe RxNormTraitName -> RxNormTrait
RxNormTrait'
    { $sel:score:RxNormTrait' :: Maybe Double
score = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:name:RxNormTrait' :: Maybe RxNormTraitName
name = Maybe RxNormTraitName
forall a. Maybe a
Prelude.Nothing
    }

-- | The level of confidence that Amazon Comprehend Medical has in the
-- accuracy of the detected trait.
rxNormTrait_score :: Lens.Lens' RxNormTrait (Prelude.Maybe Prelude.Double)
rxNormTrait_score :: (Maybe Double -> f (Maybe Double)) -> RxNormTrait -> f RxNormTrait
rxNormTrait_score = (RxNormTrait -> Maybe Double)
-> (RxNormTrait -> Maybe Double -> RxNormTrait)
-> Lens RxNormTrait RxNormTrait (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RxNormTrait' {Maybe Double
score :: Maybe Double
$sel:score:RxNormTrait' :: RxNormTrait -> Maybe Double
score} -> Maybe Double
score) (\s :: RxNormTrait
s@RxNormTrait' {} Maybe Double
a -> RxNormTrait
s {$sel:score:RxNormTrait' :: Maybe Double
score = Maybe Double
a} :: RxNormTrait)

-- | Provides a name or contextual description about the trait.
rxNormTrait_name :: Lens.Lens' RxNormTrait (Prelude.Maybe RxNormTraitName)
rxNormTrait_name :: (Maybe RxNormTraitName -> f (Maybe RxNormTraitName))
-> RxNormTrait -> f RxNormTrait
rxNormTrait_name = (RxNormTrait -> Maybe RxNormTraitName)
-> (RxNormTrait -> Maybe RxNormTraitName -> RxNormTrait)
-> Lens
     RxNormTrait
     RxNormTrait
     (Maybe RxNormTraitName)
     (Maybe RxNormTraitName)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RxNormTrait' {Maybe RxNormTraitName
name :: Maybe RxNormTraitName
$sel:name:RxNormTrait' :: RxNormTrait -> Maybe RxNormTraitName
name} -> Maybe RxNormTraitName
name) (\s :: RxNormTrait
s@RxNormTrait' {} Maybe RxNormTraitName
a -> RxNormTrait
s {$sel:name:RxNormTrait' :: Maybe RxNormTraitName
name = Maybe RxNormTraitName
a} :: RxNormTrait)

instance Core.FromJSON RxNormTrait where
  parseJSON :: Value -> Parser RxNormTrait
parseJSON =
    String
-> (Object -> Parser RxNormTrait) -> Value -> Parser RxNormTrait
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RxNormTrait"
      ( \Object
x ->
          Maybe Double -> Maybe RxNormTraitName -> RxNormTrait
RxNormTrait'
            (Maybe Double -> Maybe RxNormTraitName -> RxNormTrait)
-> Parser (Maybe Double)
-> Parser (Maybe RxNormTraitName -> RxNormTrait)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Score") Parser (Maybe RxNormTraitName -> RxNormTrait)
-> Parser (Maybe RxNormTraitName) -> Parser RxNormTrait
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe RxNormTraitName)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Name")
      )

instance Prelude.Hashable RxNormTrait

instance Prelude.NFData RxNormTrait