Skip to contents

Writes the product category columns, `approach1` to `approach3`, the `rd_approach*` columns, and the two person-level exclusion columns. It reads `inst/2023-mht/product_table_20260922.xlsx` and `inst/2023-mht/dataDictionary20260922.xlsx`, and no other workbook.

Usage

add_lmed_v20260922(
  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_v20260902()`.

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

The output equals that of `add_lmed_v20260902()`, except for the effects of two workbook changes:

  • `Estradiol Valerate` is category `A7`. A woman with any dispensing of it gets `ri_mht_excluded_product = TRUE` and the reason `possible gender-affirming therapy`.

  • No rule of the `post_grouping` sheet reads `A7`. The `A7` column still shows each week an `A7` product covers, and the approach columns ignore it.

See also

add_lmed_v20260902, which documents the behaviour the two entry points share.

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_v20260922(skeleton, lmed, verbose = FALSE)
)
skeleton[, .N, keyby = .(ri_mht_excluded_product, ri_mht_excluded_reason)]
#> Key: <ri_mht_excluded_product, ri_mht_excluded_reason>
#>    ri_mht_excluded_product            ri_mht_excluded_reason     N
#>                     <lgcl>                            <char> <int>
#> 1:                   FALSE                              <NA>  5304
#> 2:                    TRUE possible gender-affirming therapy   312