utlede_segmentStent_variabler: New variables from NORIC's SementStent-table

utlede_segmentStent_variablerR Documentation

New variables from NORIC's SementStent-table

Description

Functions for creating variables based on NORIC's SegmentStent-table and for merging these variables into NORIC's AngioPCIVar-table by key variables ForlopsID and AvdRESH.

Usage

legg_til_antall_stent(df_ap, df_ss)

legg_til_antall_stent_opphold(df_ap)

satt_inn_stent_i_lms(df_ap, df_ss)

utlede_kar_segment_stent(df_ss)

utlede_kar_graft_segment_stent(df_ss)

legg_til_pci_per_kar(df_ap, df_ss)

legg_til_wireforsok_per_kar(df_ap, df_ss)

Arguments

df_ap

NORICS's AngioPCIVar-table. Must contain the variables AvdRESH and ForlopsID.

df_ss

NORICS's SegmentStent-table. Must contain the variables AvdRESH and ForlopsID. Additionally, the variable StentType is mandatory in the function legg_til_antall_stent() and the variables Segment, Graft and ProsedyreType are mandatory in the functions utlede_kar_segment_stent(), utlede_kar_graft_segment_stent(), legg_til_pci_per_kar() and legg_til_wireforsok_per_kar().

Details

The function legg_til_antall_stent() counts the number of non-missing stent-types for each procedure in df_ss. The variable antall_stent is then added in df_ap before df_ap is returned. For procedures with no entries in df_ss, antall_stent has the value <NA>.

The function legg_til_antall_stent_opphold() groups the procedures (primErforløp - koblet primaerforløp) by main procedure and counts the total number of stents. If no registration in SegmentStent-table for any procedure associated with a main procedure, NA is returned. If at least one registration is available in SegmentStent, the sum om stents is returned (the sum might be 0, if only other types of interventions were registered).

The function utlede_kar_segment_stent() groups the Segments in df_ss into coronary arteries in the new variable kar, then df_ss is returned from the function.

The function utlede_kar_graft_segment_stent() groups the Segments and Grafts in df_ss into coronary arteries and/or grafts in the new variable kar_graft, then df_ss is returned from the function.

The function satt_inn_stent_i_lms() adds the variable satt_inn_stent_i_LMS in table df_ap. The variable is binary and has value ja if at least one stent is registered in LMS for the procedure, value nei if 0 stents are registered in LMS and finally value NA if no rows are available in df_ss for the procedure.

The function legg_til_pci_per_kar() uses the data in df_ss to calculate 10 new variables. Variable names are prefixed by PCI_ and suffixed by level of kar_graft (p.ex.: PCI_LAD, PCI_CX, PCI_CX_veneGraft, PCI_CX_arterieGraft). The variables indicates whether or not a PCI is performed in each kar_graft. If at least one PCI is done in a kar_graft the value of the corresponding variable is ja, otherwise the value is nei. These 10 variables are then merged into df_ap, before df_ap is returned from the function. For procedures where no PCI's are done on segment-level (e.g. no entries available in df_ss), the values for the 10 new variables are <NA>. Procedures of type wireforsoek are not counted.

The function legg_til_wireforsok_per_kar() uses the data in df_ss to calculate 10 new variables. Variable names are prefixed by wireforsok_ and suffixed by level of kar_graft (p.ex.: wireforsok_LAD, wireforsok_CX, wireforsok_CX_veneGraft, wireforsok_CX_arterieGraft). The variables indicates whether or not a wireforsøk is performed in each kar_graft. If at least one wireforsøk is done in a kar_graft the value of the corresponding variable is ja, otherwise the value is nei. These 10 variables are then merged into df_ap, before df_ap is returned from the function. For procedures where no wireforsok's are done on segment-level (e.g. no entries available in df_ss), the values for the 10 new variables are <NA>. Only procedures of type wireforsoek are counted.

Examples

df_ap <- data.frame(ForlopsID = 1:5,
                    AvdRESH = rep(1,5))

# Legg til antall stent i df_ap
df_ss <- data.frame(
  ForlopsID = c(1, 3, 3, 3, 5, 5),
  AvdRESH = rep(1,6),
  Segment = 1:6,
  StentType = c("DES",
                "BMS", "DES", "Annet",
                NA, NA))
legg_til_antall_stent(df_ap = df_ap, df_ss = df_ss)


x <- data.frame(AvdRESH = rep(1, 13),
                OppholdsID = c(101:106, 101, 102, 102, 103, 104, 106, 50),
                antall_stent = c(0, 5, NA, 1, NA, NA,
                                 3, 1, 2, 3, NA, NA, 10))
noric::legg_til_antall_stent_opphold(x)



# Legg til kar ellerkar_graft i df_ss
df_ss <- data.frame(ForlopsID = 1:23,
                    AvdRESH = rep(1,23),
                    Segment = c(1:20, 1:3),
                    Graft=c(rep("Nei", 20), "Arteriell", "Vene", NA))
utlede_kar_segment_stent(df_ss)
utlede_kar_graft_segment_stent(df_ss)


# Legg til PCI-variabler og wireforsok-variabler per kar_graft i df_ap
df_ss <- data.frame(ForlopsID = c(1,2,3,3,3),
                    AvdRESH = rep(1,5),
                    Segment = c(1,5,10,12,13),
                    Graft = c(rep("Nei", 3),
                              rep("Arteriell", 1),
                              rep("Vene", 1)),
                    ProsedyreType = c("Ballong + Stent",
                                      "Wireforsøk",
                                      "Rotablator",
                                      "Wireforsøk",
                                      "Direktestent"))
legg_til_pci_per_kar(df_ap = df_ap, df_ss = df_ss)
legg_til_wireforsok_per_kar(df_ap = df_ap, df_ss = df_ss)

Rapporteket/NORIC documentation built on Feb. 15, 2024, 5:25 p.m.