Skip to contents

This function checks if a given medication is a calcium channel blocker. This function processes multiple inputs efficiently.

Usage

is_calcium_channel_blocker(MEUCATC, NPI_25B)

Arguments

MEUCATC

character ATC code of the medication.

NPI_25B

integer Time when the medication was last taken.

Value

numeric 1 if medication is a calcium channel blocker, 0 otherwise. If inputs are invalid or out of bounds, the function returns a tagged NA.

Details

Identifies calcium channel blockers based on ATC codes starting with "C08".

     **Missing Data Codes:**
     - `MEUCATC`: `9999996` (Not applicable), `9999997-9999999` (Missing)
     - `NPI_25B`: `6` (Not applicable), `7-9` (Missing)

Examples

# Scalar usage: Single respondent
is_calcium_channel_blocker("C08CA05", 1)
#> [1] 1
# Returns: 1

# Example: Respondent has non-response values for all inputs.
result <- is_calcium_channel_blocker("9999998", 8)
result # Shows: NA
#> [1] NA
haven::is_tagged_na(result, "b") # Shows: TRUE (confirms it's tagged NA(b))
#> [1] TRUE
format(result, tag = TRUE) # Shows: "NA(b)" (displays the tag)
#> [1] "NA"

# Multiple respondents
is_calcium_channel_blocker(c("C08CA05", "C01AA05"), c(1, 2))
#> [1] 1 0
# Returns: c(1, 0)