{-# 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.RxNormAttribute
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ComprehendMedical.Types.RxNormAttribute where

import Amazonka.ComprehendMedical.Types.RxNormAttributeType
import Amazonka.ComprehendMedical.Types.RxNormTrait
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | The extracted attributes that relate to this entity. The attributes
-- recognized by InferRxNorm are @DOSAGE@, @DURATION@, @FORM@, @FREQUENCY@,
-- @RATE@, @ROUTE_OR_MODE@.
--
-- /See:/ 'newRxNormAttribute' smart constructor.
data RxNormAttribute = RxNormAttribute'
  { -- | The 0-based character offset in the input text that shows where the
    -- attribute begins. The offset returns the UTF-8 code point in the string.
    RxNormAttribute -> Maybe Int
beginOffset :: Prelude.Maybe Prelude.Int,
    -- | The 0-based character offset in the input text that shows where the
    -- attribute ends. The offset returns the UTF-8 code point in the string.
    RxNormAttribute -> Maybe Int
endOffset :: Prelude.Maybe Prelude.Int,
    -- | The numeric identifier for this attribute. This is a monotonically
    -- increasing id unique within this response rather than a global unique
    -- identifier.
    RxNormAttribute -> Maybe Int
id :: Prelude.Maybe Prelude.Int,
    -- | The level of confidence that Amazon Comprehend Medical has that the
    -- attribute is accurately linked to an entity.
    RxNormAttribute -> Maybe Double
relationshipScore :: Prelude.Maybe Prelude.Double,
    -- | The level of confidence that Comprehend Medical has that the segment of
    -- text is correctly recognized as an attribute.
    RxNormAttribute -> Maybe Double
score :: Prelude.Maybe Prelude.Double,
    -- | The segment of input text which corresponds to the detected attribute.
    RxNormAttribute -> Maybe Text
text :: Prelude.Maybe Prelude.Text,
    -- | Contextual information for the attribute. InferRxNorm recognizes the
    -- trait @NEGATION@ for attributes, i.e. that the patient is not taking a
    -- specific dose or form of a medication.
    RxNormAttribute -> Maybe [RxNormTrait]
traits :: Prelude.Maybe [RxNormTrait],
    -- | The type of attribute. The types of attributes recognized by InferRxNorm
    -- are @BRAND_NAME@ and @GENERIC_NAME@.
    RxNormAttribute -> Maybe RxNormAttributeType
type' :: Prelude.Maybe RxNormAttributeType
  }
  deriving (RxNormAttribute -> RxNormAttribute -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RxNormAttribute -> RxNormAttribute -> Bool
$c/= :: RxNormAttribute -> RxNormAttribute -> Bool
== :: RxNormAttribute -> RxNormAttribute -> Bool
$c== :: RxNormAttribute -> RxNormAttribute -> Bool
Prelude.Eq, ReadPrec [RxNormAttribute]
ReadPrec RxNormAttribute
Int -> ReadS RxNormAttribute
ReadS [RxNormAttribute]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RxNormAttribute]
$creadListPrec :: ReadPrec [RxNormAttribute]
readPrec :: ReadPrec RxNormAttribute
$creadPrec :: ReadPrec RxNormAttribute
readList :: ReadS [RxNormAttribute]
$creadList :: ReadS [RxNormAttribute]
readsPrec :: Int -> ReadS RxNormAttribute
$creadsPrec :: Int -> ReadS RxNormAttribute
Prelude.Read, Int -> RxNormAttribute -> ShowS
[RxNormAttribute] -> ShowS
RxNormAttribute -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RxNormAttribute] -> ShowS
$cshowList :: [RxNormAttribute] -> ShowS
show :: RxNormAttribute -> String
$cshow :: RxNormAttribute -> String
showsPrec :: Int -> RxNormAttribute -> ShowS
$cshowsPrec :: Int -> RxNormAttribute -> ShowS
Prelude.Show, forall x. Rep RxNormAttribute x -> RxNormAttribute
forall x. RxNormAttribute -> Rep RxNormAttribute x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RxNormAttribute x -> RxNormAttribute
$cfrom :: forall x. RxNormAttribute -> Rep RxNormAttribute x
Prelude.Generic)

-- |
-- Create a value of 'RxNormAttribute' 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:
--
-- 'beginOffset', 'rxNormAttribute_beginOffset' - The 0-based character offset in the input text that shows where the
-- attribute begins. The offset returns the UTF-8 code point in the string.
--
-- 'endOffset', 'rxNormAttribute_endOffset' - The 0-based character offset in the input text that shows where the
-- attribute ends. The offset returns the UTF-8 code point in the string.
--
-- 'id', 'rxNormAttribute_id' - The numeric identifier for this attribute. This is a monotonically
-- increasing id unique within this response rather than a global unique
-- identifier.
--
-- 'relationshipScore', 'rxNormAttribute_relationshipScore' - The level of confidence that Amazon Comprehend Medical has that the
-- attribute is accurately linked to an entity.
--
-- 'score', 'rxNormAttribute_score' - The level of confidence that Comprehend Medical has that the segment of
-- text is correctly recognized as an attribute.
--
-- 'text', 'rxNormAttribute_text' - The segment of input text which corresponds to the detected attribute.
--
-- 'traits', 'rxNormAttribute_traits' - Contextual information for the attribute. InferRxNorm recognizes the
-- trait @NEGATION@ for attributes, i.e. that the patient is not taking a
-- specific dose or form of a medication.
--
-- 'type'', 'rxNormAttribute_type' - The type of attribute. The types of attributes recognized by InferRxNorm
-- are @BRAND_NAME@ and @GENERIC_NAME@.
newRxNormAttribute ::
  RxNormAttribute
newRxNormAttribute :: RxNormAttribute
newRxNormAttribute =
  RxNormAttribute'
    { $sel:beginOffset:RxNormAttribute' :: Maybe Int
beginOffset = forall a. Maybe a
Prelude.Nothing,
      $sel:endOffset:RxNormAttribute' :: Maybe Int
endOffset = forall a. Maybe a
Prelude.Nothing,
      $sel:id:RxNormAttribute' :: Maybe Int
id = forall a. Maybe a
Prelude.Nothing,
      $sel:relationshipScore:RxNormAttribute' :: Maybe Double
relationshipScore = forall a. Maybe a
Prelude.Nothing,
      $sel:score:RxNormAttribute' :: Maybe Double
score = forall a. Maybe a
Prelude.Nothing,
      $sel:text:RxNormAttribute' :: Maybe Text
text = forall a. Maybe a
Prelude.Nothing,
      $sel:traits:RxNormAttribute' :: Maybe [RxNormTrait]
traits = forall a. Maybe a
Prelude.Nothing,
      $sel:type':RxNormAttribute' :: Maybe RxNormAttributeType
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | The 0-based character offset in the input text that shows where the
-- attribute begins. The offset returns the UTF-8 code point in the string.
rxNormAttribute_beginOffset :: Lens.Lens' RxNormAttribute (Prelude.Maybe Prelude.Int)
rxNormAttribute_beginOffset :: Lens' RxNormAttribute (Maybe Int)
rxNormAttribute_beginOffset = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RxNormAttribute' {Maybe Int
beginOffset :: Maybe Int
$sel:beginOffset:RxNormAttribute' :: RxNormAttribute -> Maybe Int
beginOffset} -> Maybe Int
beginOffset) (\s :: RxNormAttribute
s@RxNormAttribute' {} Maybe Int
a -> RxNormAttribute
s {$sel:beginOffset:RxNormAttribute' :: Maybe Int
beginOffset = Maybe Int
a} :: RxNormAttribute)

-- | The 0-based character offset in the input text that shows where the
-- attribute ends. The offset returns the UTF-8 code point in the string.
rxNormAttribute_endOffset :: Lens.Lens' RxNormAttribute (Prelude.Maybe Prelude.Int)
rxNormAttribute_endOffset :: Lens' RxNormAttribute (Maybe Int)
rxNormAttribute_endOffset = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RxNormAttribute' {Maybe Int
endOffset :: Maybe Int
$sel:endOffset:RxNormAttribute' :: RxNormAttribute -> Maybe Int
endOffset} -> Maybe Int
endOffset) (\s :: RxNormAttribute
s@RxNormAttribute' {} Maybe Int
a -> RxNormAttribute
s {$sel:endOffset:RxNormAttribute' :: Maybe Int
endOffset = Maybe Int
a} :: RxNormAttribute)

-- | The numeric identifier for this attribute. This is a monotonically
-- increasing id unique within this response rather than a global unique
-- identifier.
rxNormAttribute_id :: Lens.Lens' RxNormAttribute (Prelude.Maybe Prelude.Int)
rxNormAttribute_id :: Lens' RxNormAttribute (Maybe Int)
rxNormAttribute_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RxNormAttribute' {Maybe Int
id :: Maybe Int
$sel:id:RxNormAttribute' :: RxNormAttribute -> Maybe Int
id} -> Maybe Int
id) (\s :: RxNormAttribute
s@RxNormAttribute' {} Maybe Int
a -> RxNormAttribute
s {$sel:id:RxNormAttribute' :: Maybe Int
id = Maybe Int
a} :: RxNormAttribute)

-- | The level of confidence that Amazon Comprehend Medical has that the
-- attribute is accurately linked to an entity.
rxNormAttribute_relationshipScore :: Lens.Lens' RxNormAttribute (Prelude.Maybe Prelude.Double)
rxNormAttribute_relationshipScore :: Lens' RxNormAttribute (Maybe Double)
rxNormAttribute_relationshipScore = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RxNormAttribute' {Maybe Double
relationshipScore :: Maybe Double
$sel:relationshipScore:RxNormAttribute' :: RxNormAttribute -> Maybe Double
relationshipScore} -> Maybe Double
relationshipScore) (\s :: RxNormAttribute
s@RxNormAttribute' {} Maybe Double
a -> RxNormAttribute
s {$sel:relationshipScore:RxNormAttribute' :: Maybe Double
relationshipScore = Maybe Double
a} :: RxNormAttribute)

-- | The level of confidence that Comprehend Medical has that the segment of
-- text is correctly recognized as an attribute.
rxNormAttribute_score :: Lens.Lens' RxNormAttribute (Prelude.Maybe Prelude.Double)
rxNormAttribute_score :: Lens' RxNormAttribute (Maybe Double)
rxNormAttribute_score = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RxNormAttribute' {Maybe Double
score :: Maybe Double
$sel:score:RxNormAttribute' :: RxNormAttribute -> Maybe Double
score} -> Maybe Double
score) (\s :: RxNormAttribute
s@RxNormAttribute' {} Maybe Double
a -> RxNormAttribute
s {$sel:score:RxNormAttribute' :: Maybe Double
score = Maybe Double
a} :: RxNormAttribute)

-- | The segment of input text which corresponds to the detected attribute.
rxNormAttribute_text :: Lens.Lens' RxNormAttribute (Prelude.Maybe Prelude.Text)
rxNormAttribute_text :: Lens' RxNormAttribute (Maybe Text)
rxNormAttribute_text = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RxNormAttribute' {Maybe Text
text :: Maybe Text
$sel:text:RxNormAttribute' :: RxNormAttribute -> Maybe Text
text} -> Maybe Text
text) (\s :: RxNormAttribute
s@RxNormAttribute' {} Maybe Text
a -> RxNormAttribute
s {$sel:text:RxNormAttribute' :: Maybe Text
text = Maybe Text
a} :: RxNormAttribute)

-- | Contextual information for the attribute. InferRxNorm recognizes the
-- trait @NEGATION@ for attributes, i.e. that the patient is not taking a
-- specific dose or form of a medication.
rxNormAttribute_traits :: Lens.Lens' RxNormAttribute (Prelude.Maybe [RxNormTrait])
rxNormAttribute_traits :: Lens' RxNormAttribute (Maybe [RxNormTrait])
rxNormAttribute_traits = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RxNormAttribute' {Maybe [RxNormTrait]
traits :: Maybe [RxNormTrait]
$sel:traits:RxNormAttribute' :: RxNormAttribute -> Maybe [RxNormTrait]
traits} -> Maybe [RxNormTrait]
traits) (\s :: RxNormAttribute
s@RxNormAttribute' {} Maybe [RxNormTrait]
a -> RxNormAttribute
s {$sel:traits:RxNormAttribute' :: Maybe [RxNormTrait]
traits = Maybe [RxNormTrait]
a} :: RxNormAttribute) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The type of attribute. The types of attributes recognized by InferRxNorm
-- are @BRAND_NAME@ and @GENERIC_NAME@.
rxNormAttribute_type :: Lens.Lens' RxNormAttribute (Prelude.Maybe RxNormAttributeType)
rxNormAttribute_type :: Lens' RxNormAttribute (Maybe RxNormAttributeType)
rxNormAttribute_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RxNormAttribute' {Maybe RxNormAttributeType
type' :: Maybe RxNormAttributeType
$sel:type':RxNormAttribute' :: RxNormAttribute -> Maybe RxNormAttributeType
type'} -> Maybe RxNormAttributeType
type') (\s :: RxNormAttribute
s@RxNormAttribute' {} Maybe RxNormAttributeType
a -> RxNormAttribute
s {$sel:type':RxNormAttribute' :: Maybe RxNormAttributeType
type' = Maybe RxNormAttributeType
a} :: RxNormAttribute)

instance Data.FromJSON RxNormAttribute where
  parseJSON :: Value -> Parser RxNormAttribute
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RxNormAttribute"
      ( \Object
x ->
          Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Double
-> Maybe Double
-> Maybe Text
-> Maybe [RxNormTrait]
-> Maybe RxNormAttributeType
-> RxNormAttribute
RxNormAttribute'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"BeginOffset")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"EndOffset")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Id")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"RelationshipScore")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Score")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Text")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Traits" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Type")
      )

instance Prelude.Hashable RxNormAttribute where
  hashWithSalt :: Int -> RxNormAttribute -> Int
hashWithSalt Int
_salt RxNormAttribute' {Maybe Double
Maybe Int
Maybe [RxNormTrait]
Maybe Text
Maybe RxNormAttributeType
type' :: Maybe RxNormAttributeType
traits :: Maybe [RxNormTrait]
text :: Maybe Text
score :: Maybe Double
relationshipScore :: Maybe Double
id :: Maybe Int
endOffset :: Maybe Int
beginOffset :: Maybe Int
$sel:type':RxNormAttribute' :: RxNormAttribute -> Maybe RxNormAttributeType
$sel:traits:RxNormAttribute' :: RxNormAttribute -> Maybe [RxNormTrait]
$sel:text:RxNormAttribute' :: RxNormAttribute -> Maybe Text
$sel:score:RxNormAttribute' :: RxNormAttribute -> Maybe Double
$sel:relationshipScore:RxNormAttribute' :: RxNormAttribute -> Maybe Double
$sel:id:RxNormAttribute' :: RxNormAttribute -> Maybe Int
$sel:endOffset:RxNormAttribute' :: RxNormAttribute -> Maybe Int
$sel:beginOffset:RxNormAttribute' :: RxNormAttribute -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
beginOffset
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
endOffset
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
relationshipScore
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
score
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
text
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [RxNormTrait]
traits
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RxNormAttributeType
type'

instance Prelude.NFData RxNormAttribute where
  rnf :: RxNormAttribute -> ()
rnf RxNormAttribute' {Maybe Double
Maybe Int
Maybe [RxNormTrait]
Maybe Text
Maybe RxNormAttributeType
type' :: Maybe RxNormAttributeType
traits :: Maybe [RxNormTrait]
text :: Maybe Text
score :: Maybe Double
relationshipScore :: Maybe Double
id :: Maybe Int
endOffset :: Maybe Int
beginOffset :: Maybe Int
$sel:type':RxNormAttribute' :: RxNormAttribute -> Maybe RxNormAttributeType
$sel:traits:RxNormAttribute' :: RxNormAttribute -> Maybe [RxNormTrait]
$sel:text:RxNormAttribute' :: RxNormAttribute -> Maybe Text
$sel:score:RxNormAttribute' :: RxNormAttribute -> Maybe Double
$sel:relationshipScore:RxNormAttribute' :: RxNormAttribute -> Maybe Double
$sel:id:RxNormAttribute' :: RxNormAttribute -> Maybe Int
$sel:endOffset:RxNormAttribute' :: RxNormAttribute -> Maybe Int
$sel:beginOffset:RxNormAttribute' :: RxNormAttribute -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
beginOffset
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
endOffset
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
relationshipScore
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
score
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
text
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [RxNormTrait]
traits
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RxNormAttributeType
type'