Skip to contents

Writes every column that `add_lmed_v20260924()` writes, and adds `approach5`, `rd_approach5_single` and `rd_approach5_multiple`. It reads `inst/2023-mht/product_table_20261002.xlsx` and `inst/2023-mht/dataDictionary20261002.xlsx`, and no other workbook.

Usage

add_lmed_v20261002(
  skeleton,
  lmed,
  id_name = "lopnr",
  create_rd = TRUE,
  verbose = TRUE
)

Arguments

skeleton

A person-week `data.table` with `id` and `isoyearweek`. Weekly rows only, as for `add_lmed_v20260924()`.

lmed

A `data.table` of dispensed prescriptions.

id_name

The person identifier column of `lmed`.

create_rd

Logical. If `FALSE`, writes no `rd_approach*` column.

verbose

Logical. If `TRUE`, report progress with `message()`.

Value

`invisible(skeleton)`. Mutation is in place.

Details

Every column other than the three approach 5 columns equals the output of `add_lmed_v20260924()`. Approach 5 pools the oestrogen routes of approach 4, and gives the hormonal IUD (E1) its own level. The `post_grouping` sheet gives it the levels below, where oestrogen means A1, A2 or A6:

  • `estrogen_progesterone`: B4 or B11, or oestrogen with C1 or C5.

  • `estrogen_other_progestogen`: B1, B2, B3, B5 to B10, or B12, or oestrogen with C3, C4, D1, D2, D3, I1 or I2.

  • `estrogen_iud`: oestrogen with E1.

  • `estrogen_only`: oestrogen, in a week with no B1 to B12, C1 to C5, D1 to D3, E1, I1 or I2.

  • `tibolone`: F1.

  • `local_or_none_mht`: a week that lights no level above.

A week with oestrogen, E1 and one of C3, C4, D1, D2, D3, I1 or I2 lights both `estrogen_iud` and `estrogen_other_progestogen`.

The resolver is that of `add_lmed_v20260924()`. When two levels are lit, `approach5` reports the level that started most recently. Two levels that start in the same week are `clashingprescriptions` until the treated episode ends.

See also

add_lmed_v20260924, which documents the behaviour the two entry points share. `vignette("lmed-v20261002")` explains approaches 1 to 5.

Examples

library(data.table)

skeleton <- copy(fake_skeleton_mht)
lmed <- copy(fake_lmed_2026)

# Utrogestan takes a codebook rule keyed on strength, so it needs `lnmn`.
lmed[, lnmn := NA_character_]
#>      lopnr     produkt     edatum  fddd   lnmn
#>      <int>      <char>     <Date> <num> <char>
#>   1:     1     Divigel 2015-01-05    90   <NA>
#>   2:     1     Divigel 2015-03-30    90   <NA>
#>   3:     1     Divigel 2015-06-22    90   <NA>
#>   4:     1     Divigel 2015-09-14    90   <NA>
#>   5:     1     Divigel 2015-12-07    90   <NA>
#>  ---                                          
#> 124:    16     Divigel 2016-02-26    90   <NA>
#> 125:    16   Cerazette 2016-03-01    90   <NA>
#> 126:    17     Divigel 2015-01-07   -30   <NA>
#> 127:    17     Divigel 2015-03-31    90   <NA>
#> 128:    18 Paracetamol 2015-01-02    28   <NA>
lmed[produkt == "Utrogestan", lnmn := "Utrogestan, kapsel, mjuk 100 mg"]
#> Index: <produkt>
#>      lopnr     produkt     edatum  fddd   lnmn
#>      <int>      <char>     <Date> <num> <char>
#>   1:     1     Divigel 2015-01-05    90   <NA>
#>   2:     1     Divigel 2015-03-30    90   <NA>
#>   3:     1     Divigel 2015-06-22    90   <NA>
#>   4:     1     Divigel 2015-09-14    90   <NA>
#>   5:     1     Divigel 2015-12-07    90   <NA>
#>  ---                                          
#> 124:    16     Divigel 2016-02-26    90   <NA>
#> 125:    16   Cerazette 2016-03-01    90   <NA>
#> 126:    17     Divigel 2015-01-07   -30   <NA>
#> 127:    17     Divigel 2015-03-31    90   <NA>
#> 128:    18 Paracetamol 2015-01-02    28   <NA>

# The product table holds no row for the fixture-only name `Paracetamol`.
lmed <- lmed[produkt != "Paracetamol"]

# the fixture holds one negative-duration row, which warns
skeleton <- suppressWarnings(
  add_lmed_v20261002(skeleton, lmed, verbose = FALSE)
)
skeleton[, .N, keyby = .(approach5)]
#> Key: <approach5>
#>                     approach5     N
#>                        <char> <int>
#> 1:              estrogen_only   640
#> 2: estrogen_other_progestogen   110
#> 3:      estrogen_progesterone    82
#> 4:          local_or_none_mht  4779
#> 5:                   tibolone     5