This function determines whether a given medication, taken by a CHMS respondent, is classified as a beta blocker. The identification is based on Anatomical Therapeutic Chemical (ATC) codes and the timing of the last medication intake.
Arguments
- MEUCATC
A character vector representing the Anatomical Therapeutic Chemical (ATC) code of the medication.
- NPI_25B
An integer representing the CHMS response for the time when the medication was last taken. 1 = Today, 2 = Yesterday, 3 = Within the last week, 4 = Within the last month, 5 = More than a month ago, 6 = Never taken
Details
This function identifies whether a medication is a beta blocker based on their ATC codes, which typically start with "C07". Additionally, specific sub-codes 'C07AA07', 'C07AA12', and 'C07AG02' are excluded from the beta blocker class. A respondent is classified as taking a beta blocker (return = 1) if the ATC code matches the pattern and is not in the exclusion list, and the medication was taken within the last month (NPI_25B <= 4), otherwise the respondent is not taking a beta blocker (return = 0)
Examples
# Example 1: Medication ATC code is "C07AA13", and it was taken within the last week
is_beta_blocker("C07AA13", 3) # Should return 1 (TRUE)
#> [1] 1
# Example 2: Medication ATC code is "C07AA07" (excluded code), and it was taken within last month
is_beta_blocker("C07AA07", 4) # Should return 0 (FALSE)
#> [1] 0