Skip to contents

Intro

This tutorial show how to append additional information to a longitudinal or service-sector table in bigquerry.

Information to add includes, name of the medical codes in English, name for the type of visit, name for the type of provider.

Set up

This tutorial has been developed using dummy data under the Atlas development project. To execute it in Sandbox, be sure to change the following paths.

library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following object is masked from 'package:testthat':
#> 
#>     matches
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(bigrquery)
library(FinnGenUtilsR)


bigrquery::bq_auth(path = Sys.getenv("GCP_SERVICE_KEY"))
project_id <- "atlas-development-270609"

test_longitudinal_data_table <- "atlas-development-270609.sandbox_tools_r10.finngen_r10_service_sector_detailed_longitudinal_v2"
fg_codes_info_table <- "atlas-development-270609.medical_codes.fg_codes_info_v2"
tmp_schema <- "sandbox"

Generate a table in service sector format

For example we create a subset of the main service sector table by querying latest 20 events from subject “FG00000001”:

sql <- paste("SELECT * FROM ", test_longitudinal_data_table, "WHERE FINNGENID='FG00000001' ORDER BY APPROX_EVENT_DAY DESC LIMIT 20")
event_for_subject_1 <- bq_project_query(project_id, sql)

We can see that this table does not currently have information about the medical codes:

bq_table_download(event_for_subject_1)
#> # A tibble: 20 × 16
#>    FINNGENID  SOURCE   EVENT_AGE APPROX_EVENT_DAY CODE1    CODE2 CODE3  CODE4 CODE5 CODE6 CODE7 CODE8 CODE9 ICDVER CATEGORY INDEX
#>    <chr>      <chr>        <dbl> <date>           <chr>    <chr> <chr>  <chr> <chr> <chr> <chr> <chr> <chr> <chr>  <chr>    <chr>
#>  1 FG00000001 PURCH         66.7 2017-11-27       R01AD09  <NA>  474643 1     <NA>  <NA>  <NA>  <NA>  <NA>  <NA>   <NA>     7585 
#>  2 FG00000001 PRIM_OUT      66.7 2017-11-19       A28      <NA>  <NA>   <NA>  R10   T11   32311 <NA>  <NA>  <NA>   ICP1     7    
#>  3 FG00000001 PURCH         66.5 2017-09-23       M01AE01  <NA>  552190 1     <NA>  <NA>  <NA>  <NA>  <NA>  <NA>   <NA>     7583 
#>  4 FG00000001 INPAT         66.5 2017-09-05       I676     <NA>  <NA>   4     1     20G   <NA>  <NA>  <NA>  10     1        5    
#>  5 FG00000001 PRIM_OUT      66.5 2017-09-05       A98      <NA>  <NA>   <NA>  R20   T42   51321 <NA>  <NA>  <NA>   ICP1     3203 
#>  6 FG00000001 INPAT         66.5 2017-09-05       X59      <NA>  <NA>   4     1     20G   <NA>  <NA>  <NA>  10     EX1      5    
#>  7 FG00000001 PURCH         66.4 2017-08-30       <NA>     103   <NA>   1     <NA>  <NA>  <NA>  <NA>  <NA>  <NA>   <NA>     7590 
#>  8 FG00000001 PRIM_OUT      66.4 2017-08-14       SPAT1053 <NA>  <NA>   <NA>  R50   T11   32311 <NA>  <NA>  <NA>   OP1      5256 
#>  9 FG00000001 OPER_OUT      66.4 2017-07-31       TPH00    <NA>  <NA>   <NA>  92    77    <NA>  <NA>  <NA>  <NA>   NOM1     6    
#> 10 FG00000001 PURCH         66.2 2017-06-10       R03BA02  203   482612 1     <NA>  <NA>  <NA>  <NA>  <NA>  <NA>   <NA>     7588 
#> 11 FG00000001 PURCH         66.2 2017-06-07       N06DA02  <NA>  198650 1     <NA>  <NA>  <NA>  <NA>  <NA>  <NA>   <NA>     7591 
#> 12 FG00000001 PURCH         66.2 2017-05-30       R01BA51  <NA>  428284 1     <NA>  <NA>  <NA>  <NA>  <NA>  <NA>   <NA>     7587 
#> 13 FG00000001 PURCH         66.1 2017-05-08       R03BA01  203   593319 2     <NA>  <NA>  <NA>  <NA>  <NA>  <NA>   <NA>     7586 
#> 14 FG00000001 PURCH         66.0 2017-03-18       R03BB04  203   021617 2     <NA>  <NA>  <NA>  <NA>  <NA>  <NA>   <NA>     7593 
#> 15 FG00000001 PURCH         66.0 2017-03-12       H03AA01  <NA>  193102 1     <NA>  <NA>  <NA>  <NA>  <NA>  <NA>   <NA>     7584 
#> 16 FG00000001 PURCH         66.0 2017-03-08       C10AA01  <NA>  003664 1     <NA>  <NA>  <NA>  <NA>  <NA>  <NA>   <NA>     7592 
#> 17 FG00000001 PURCH         66.0 2017-03-06       M01AH05  <NA>  011260 1     <NA>  <NA>  <NA>  <NA>  <NA>  <NA>   <NA>     3201 
#> 18 FG00000001 INPAT         66.0 2017-03-02       W00      <NA>  <NA>   0     1     30    <NA>  <NA>  <NA>  10     EX1      6    
#> 19 FG00000001 INPAT         66.0 2017-03-02       K409     <NA>  <NA>   0     1     30    <NA>  <NA>  <NA>  10     1        6    
#> 20 FG00000001 PURCH         65.9 2017-02-02       C09DA06  205   009688 1     <NA>  <NA>  <NA>  <NA>  <NA>  <NA>   <NA>     7589

Adding info to medical codes

Function fg_bq_append_code_info_to_longitudinal_data adds new columns with information about the medical code used in each event/row.

event_for_subject_1_with_translations <- fg_bq_append_code_info_to_longitudinal_data(
  project_id, event_for_subject_1, fg_codes_info_table)

For example: code, for the original code; name_en, for the name of the code in English; name_fi for the name of the code in Finnish; and omop_concept_id, to find additional info in Atlas.

bq_table_download(event_for_subject_1_with_translations) |>  
  dplyr::select(FINNGENID, SOURCE, APPROX_EVENT_DAY, CODE1, CODE2, CODE3, code, name_en, name_fi, omop_concept_id) 
#> # A tibble: 20 × 10
#>    FINNGENID  SOURCE   APPROX_EVENT_DAY CODE1    CODE2 CODE3  code     name_en                                                name_fi omop_…¹
#>    <chr>      <chr>    <date>           <chr>    <chr> <chr>  <chr>    <chr>                                                  <chr>   <chr>  
#>  1 FG00000001 PURCH    2017-11-27       R01AD09  <NA>  474643 R01AD09  mometasone; nasal                                      <NA>    216050…
#>  2 FG00000001 PRIM_OUT 2017-11-19       A28      <NA>  <NA>   A28      Limited function/disability NOS                        Toimin… 202900…
#>  3 FG00000001 PURCH    2017-09-23       M01AE01  <NA>  552190 M01AE01  ibuprofen; systemic, rectal                            <NA>    216039…
#>  4 FG00000001 INPAT    2017-09-05       I676     <NA>  <NA>   I67.6    Nonpyogenic thrombosis of intracranial venous system   <NA>    455721…
#>  5 FG00000001 PRIM_OUT 2017-09-05       A98      <NA>  <NA>   A98      Health maint/preventive medicine                       Tervey… 202900…
#>  6 FG00000001 INPAT    2017-09-05       X59      <NA>  <NA>   X59      Exposure to unspecified factor                         <NA>    457564…
#>  7 FG00000001 PURCH    2017-08-30       <NA>     103   <NA>   <NA>     <NA>                                                   <NA>    <NA>   
#>  8 FG00000001 PRIM_OUT 2017-08-14       SPAT1053 <NA>  <NA>   SPAT1053 Memory test                                            Muisti… 200400…
#>  9 FG00000001 OPER_OUT 2017-07-31       TPH00    <NA>  <NA>   TPH00    Phlebotomy                                             Laskim… 201100…
#> 10 FG00000001 PURCH    2017-06-10       R03BA02  203   482612 R03BA02  budesonide; inhalant                                   <NA>    216032…
#> 11 FG00000001 PURCH    2017-06-07       N06DA02  <NA>  198650 N06DA02  donepezil; oral                                        <NA>    216047…
#> 12 FG00000001 PURCH    2017-05-30       R01BA51  <NA>  428284 R01BA51  phenylpropanolamine, combinations; oral                <NA>    216032…
#> 13 FG00000001 PURCH    2017-05-08       R03BA01  203   593319 R03BA01  beclometasone; inhalant                                <NA>    216032…
#> 14 FG00000001 PURCH    2017-03-18       R03BB04  203   021617 R03BB04  tiotropium bromide; inhalant                           <NA>    216032…
#> 15 FG00000001 PURCH    2017-03-12       H03AA01  <NA>  193102 H03AA01  levothyroxine sodium; systemic                         <NA>    216027…
#> 16 FG00000001 PURCH    2017-03-08       C10AA01  <NA>  003664 C10AA01  simvastatin; oral                                      <NA>    216018…
#> 17 FG00000001 PURCH    2017-03-06       M01AH05  <NA>  011260 M01AH05  etoricoxib; oral                                       <NA>    216039…
#> 18 FG00000001 INPAT    2017-03-02       W00      <NA>  <NA>   W00      Fall on same level involving ice and snow              <NA>    457562…
#> 19 FG00000001 INPAT    2017-03-02       K409     <NA>  <NA>   K40.9    Unilateral or unspecified inguinal hernia, without ob… <NA>    455433…
#> 20 FG00000001 PURCH    2017-02-02       C09DA06  205   009688 C09DA06  candesartan and diuretics; oral                        <NA>    216018…
#> # … with abbreviated variable name ¹​omop_concept_id

If an event/row uses more than one medical code

Some events include more than one medical code, or more than one way to understand a medical code. Parameters in fg_bq_append_code_info_to_longitudinal_data allows to chose how to name the medical code in this situations.

For example:

  • PURCH_map_to = “VNR”, tells to use the VNR code in PURCH register, instead of the default ATC
  • ICD10fi_map_to = “CODE1”, tells to use only the first code in ICD10fi, instead of the default CODE1*CODE2 combination code
event_for_subject_1_with_translations <- fg_bq_append_code_info_to_longitudinal_data(
  project_id, event_for_subject_1, fg_codes_info_table, 
    PURCH_map_to = "VNR", 
    ICD10fi_map_to = "CODE1"
)
one_patient_long_data <- bq_table_download(event_for_subject_1_with_translations)
bq_table_download(event_for_subject_1_with_translations) |>  
  dplyr::select(FINNGENID, SOURCE, APPROX_EVENT_DAY, CODE1, CODE2, CODE3, code, name_en, name_fi, omop_concept_id) 
#> # A tibble: 20 × 10
#>    FINNGENID  SOURCE   APPROX_EVENT_DAY CODE1    CODE2 CODE3  code     name_en                                                name_fi omop_…¹
#>    <chr>      <chr>    <date>           <chr>    <chr> <chr>  <chr>    <chr>                                                  <chr>   <chr>  
#>  1 FG00000001 PURCH    2017-11-27       R01AD09  <NA>  474643 474643   NASONEX nasal spray, suspension 50 mikrog/annos; 3 x … <NA>    203000…
#>  2 FG00000001 PRIM_OUT 2017-11-19       A28      <NA>  <NA>   A28      Limited function/disability NOS                        Toimin… 202900…
#>  3 FG00000001 PURCH    2017-09-23       M01AE01  <NA>  552190 552190   BURANA film-coated tablet 600 mg; 30 FOL               <NA>    203001…
#>  4 FG00000001 INPAT    2017-09-05       I676     <NA>  <NA>   I67.6    Nonpyogenic thrombosis of intracranial venous system   <NA>    455721…
#>  5 FG00000001 PRIM_OUT 2017-09-05       A98      <NA>  <NA>   A98      Health maint/preventive medicine                       Tervey… 202900…
#>  6 FG00000001 INPAT    2017-09-05       X59      <NA>  <NA>   X59      Exposure to unspecified factor                         <NA>    457564…
#>  7 FG00000001 PURCH    2017-08-30       <NA>     103   <NA>   <NA>     <NA>                                                   <NA>    <NA>   
#>  8 FG00000001 PRIM_OUT 2017-08-14       SPAT1053 <NA>  <NA>   SPAT1053 Memory test                                            Muisti… 200400…
#>  9 FG00000001 OPER_OUT 2017-07-31       TPH00    <NA>  <NA>   TPH00    Phlebotomy                                             Laskim… 201100…
#> 10 FG00000001 PURCH    2017-06-10       R03BA02  203   482612 482612   PULMICORT TURBUHALER inhalation powder 200 mikrog/ann… <NA>    203001…
#> 11 FG00000001 PURCH    2017-06-07       N06DA02  <NA>  198650 <NA>     <NA>                                                   <NA>    <NA>   
#> 12 FG00000001 PURCH    2017-05-30       R01BA51  <NA>  428284 428284   LUNERIN oral solution; 100ML                           <NA>    203001…
#> 13 FG00000001 PURCH    2017-05-08       R03BA01  203   593319 593319   BECLOMET EASYHALER inhalation powder 200 mikrog/annos… <NA>    203000…
#> 14 FG00000001 PURCH    2017-03-18       R03BB04  203   021617 021617   SPIRIVA inhalation powder, hard capsule 18 mikrog; 90… <NA>    203000…
#> 15 FG00000001 PURCH    2017-03-12       H03AA01  <NA>  193102 193102   THYROXIN tablet 100 mikrog; 100 kpl                    <NA>    203000…
#> 16 FG00000001 PURCH    2017-03-08       C10AA01  <NA>  003664 003664   LIPCUT film-coated tablet 40 mg; 30                    <NA>    203000…
#> 17 FG00000001 PURCH    2017-03-06       M01AH05  <NA>  011260 011260   ARCOXIA film-coated tablet 90 mg; 7 FOL                <NA>    203000…
#> 18 FG00000001 INPAT    2017-03-02       W00      <NA>  <NA>   W00      Fall on same level involving ice and snow              <NA>    457562…
#> 19 FG00000001 INPAT    2017-03-02       K409     <NA>  <NA>   K40.9    Unilateral or unspecified inguinal hernia, without ob… <NA>    455433…
#> 20 FG00000001 PURCH    2017-02-02       C09DA06  205   009688 009688   ATACAND PLUS tablet 16/12,5 mg; 98 fol                 <NA>    203000…
#> # … with abbreviated variable name ¹​omop_concept_id

Se the help, for more options

?fg_append_code_info_to_longitudinal_data_sql

Reduce code precision

ICD10fi, ICD9fi, ICD8fi, ATC, and NCSPfi, code systems reflect the hierarchy of the code by the first letters on them.

It is possible to truncate these medical codes before the information is added. This in practice adds the code and names of the parent codes.

event_for_subject_1_with_translations <- fg_bq_append_code_info_to_longitudinal_data(
  project_id, event_for_subject_1, fg_codes_info_table, 
  ICD10fi_precision = 3,
  ICD9fi_precision = 3,
  ICD8fi_precision = 3,
  ATC_precision = 3,
  NCSPfi_precision = 2
)

We can see in column code the trucated code and in name_en the name of the trucated code.

bq_table_download(event_for_subject_1_with_translations) |>  
  dplyr::select(FINNGENID, SOURCE, APPROX_EVENT_DAY, CODE1, CODE2, CODE3, code, name_en, name_fi, omop_concept_id) 
#> # A tibble: 20 × 10
#>    FINNGENID  SOURCE   APPROX_EVENT_DAY CODE1    CODE2 CODE3  code     name_en                                       name_fi          omop_…¹
#>    <chr>      <chr>    <date>           <chr>    <chr> <chr>  <chr>    <chr>                                         <chr>            <chr>  
#>  1 FG00000001 PURCH    2017-11-27       R01AD09  <NA>  474643 R01      NASAL PREPARATIONS                            <NA>             216050…
#>  2 FG00000001 PRIM_OUT 2017-11-19       A28      <NA>  <NA>   A28      Limited function/disability NOS               Toiminnanvajaus… 202900…
#>  3 FG00000001 PURCH    2017-09-23       M01AE01  <NA>  552190 M01      ANTIINFLAMMATORY AND ANTIRHEUMATIC PRODUCTS   <NA>             216039…
#>  4 FG00000001 INPAT    2017-09-05       I676     <NA>  <NA>   I67      Other cerebrovascular diseases                <NA>             455817…
#>  5 FG00000001 PRIM_OUT 2017-09-05       A98      <NA>  <NA>   A98      Health maint/preventive medicine              Terveyden ylläp… 202900…
#>  6 FG00000001 INPAT    2017-09-05       X59      <NA>  <NA>   X59      Exposure to unspecified factor                <NA>             457564…
#>  7 FG00000001 PURCH    2017-08-30       <NA>     103   <NA>   <NA>     <NA>                                          <NA>             <NA>   
#>  8 FG00000001 PRIM_OUT 2017-08-14       SPAT1053 <NA>  <NA>   SPAT1053 Memory test                                   Muistitutkimus   200400…
#>  9 FG00000001 OPER_OUT 2017-07-31       TPH00    <NA>  <NA>   <NA>     <NA>                                          <NA>             <NA>   
#> 10 FG00000001 PURCH    2017-06-10       R03BA02  203   482612 R03      DRUGS FOR OBSTRUCTIVE AIRWAY DISEASES         <NA>             216032…
#> 11 FG00000001 PURCH    2017-06-07       N06DA02  <NA>  198650 N06      PSYCHOANALEPTICS                              <NA>             216046…
#> 12 FG00000001 PURCH    2017-05-30       R01BA51  <NA>  428284 R01      NASAL PREPARATIONS                            <NA>             216050…
#> 13 FG00000001 PURCH    2017-05-08       R03BA01  203   593319 R03      DRUGS FOR OBSTRUCTIVE AIRWAY DISEASES         <NA>             216032…
#> 14 FG00000001 PURCH    2017-03-18       R03BB04  203   021617 R03      DRUGS FOR OBSTRUCTIVE AIRWAY DISEASES         <NA>             216032…
#> 15 FG00000001 PURCH    2017-03-12       H03AA01  <NA>  193102 H03      THYROID THERAPY                               <NA>             216027…
#> 16 FG00000001 PURCH    2017-03-08       C10AA01  <NA>  003664 C10      LIPID MODIFYING AGENTS                        <NA>             216018…
#> 17 FG00000001 PURCH    2017-03-06       M01AH05  <NA>  011260 M01      ANTIINFLAMMATORY AND ANTIRHEUMATIC PRODUCTS   <NA>             216039…
#> 18 FG00000001 INPAT    2017-03-02       W00      <NA>  <NA>   W00      Fall on same level involving ice and snow     <NA>             457562…
#> 19 FG00000001 INPAT    2017-03-02       K409     <NA>  <NA>   K40      Inguinal hernia                               <NA>             455433…
#> 20 FG00000001 PURCH    2017-02-02       C09DA06  205   009688 C09      AGENTS ACTING ON THE RENIN-ANGIOTENSIN SYSTEM <NA>             216017…
#> # … with abbreviated variable name ¹​omop_concept_id

Adding info to visit type

Function fg_bq_append_visit_type_info_to_service_sector_data adds new columns with information about the visit type.

In the service-sector data, information about the visit type is defined in CODE5 to CODE9 depending on the SOURCE and time period. fg_bq_append_visit_type_info_to_service_sector_data abstracts this nuances, and assign one visit type code per row. Notice that a visit may contain more than one event/row. Events/rows belonging to the same visit share the same combination of SOURCE+INDEX.

event_for_subject_1_with_visit_type <- fg_bq_append_visit_type_info_to_service_sector_data(
  project_id, event_for_subject_1, fg_codes_info_table
  )
bigrquery::bq_table_download(event_for_subject_1_with_visit_type) |> 
  dplyr::select(FINNGENID, SOURCE, INDEX, APPROX_EVENT_DAY, CODE5, CODE6, CODE8, CODE9, visit_type_code, visit_type_name_en)
#> # A tibble: 20 × 10
#>    FINNGENID  SOURCE   INDEX APPROX_EVENT_DAY CODE5 CODE6 CODE8 CODE9 visit_type_code  visit_type_name_en                                    
#>    <chr>      <chr>    <chr> <date>           <chr> <chr> <chr> <chr> <chr>            <chr>                                                 
#>  1 FG00000001 PRIM_OUT 7     2017-11-19       R10   T11   <NA>  <NA>  PRIM_OUT|R10|T11 PRIM_OUT | Contact Type: The customer's visit to the …
#>  2 FG00000001 OPER_OUT 6     2017-07-31       92    77    <NA>  <NA>  OPER_OUT|92      OPER_OUT | Service Sector: Appointment visit, first v…
#>  3 FG00000001 PRIM_OUT 5256  2017-08-14       R50   T11   <NA>  <NA>  PRIM_OUT|R50|T11 PRIM_OUT | Contact Type: Phone connection | Service T…
#>  4 FG00000001 INPAT    5     2017-09-05       1     20G   <NA>  <NA>  INPAT|1          INPAT | Service Sector: Hospital / health center ward 
#>  5 FG00000001 INPAT    6     2017-03-02       1     30    <NA>  <NA>  INPAT|1          INPAT | Service Sector: Hospital / health center ward 
#>  6 FG00000001 INPAT    5     2017-09-05       1     20G   <NA>  <NA>  INPAT|1          INPAT | Service Sector: Hospital / health center ward 
#>  7 FG00000001 INPAT    6     2017-03-02       1     30    <NA>  <NA>  INPAT|1          INPAT | Service Sector: Hospital / health center ward 
#>  8 FG00000001 PURCH    7585  2017-11-27       <NA>  <NA>  <NA>  <NA>  PURCH            Entry in kela drug purchases registry                 
#>  9 FG00000001 PURCH    7591  2017-06-07       <NA>  <NA>  <NA>  <NA>  PURCH            Entry in kela drug purchases registry                 
#> 10 FG00000001 PURCH    7593  2017-03-18       <NA>  <NA>  <NA>  <NA>  PURCH            Entry in kela drug purchases registry                 
#> 11 FG00000001 PURCH    7592  2017-03-08       <NA>  <NA>  <NA>  <NA>  PURCH            Entry in kela drug purchases registry                 
#> 12 FG00000001 PURCH    7584  2017-03-12       <NA>  <NA>  <NA>  <NA>  PURCH            Entry in kela drug purchases registry                 
#> 13 FG00000001 PURCH    7586  2017-05-08       <NA>  <NA>  <NA>  <NA>  PURCH            Entry in kela drug purchases registry                 
#> 14 FG00000001 PURCH    7583  2017-09-23       <NA>  <NA>  <NA>  <NA>  PURCH            Entry in kela drug purchases registry                 
#> 15 FG00000001 PURCH    7587  2017-05-30       <NA>  <NA>  <NA>  <NA>  PURCH            Entry in kela drug purchases registry                 
#> 16 FG00000001 PURCH    7589  2017-02-02       <NA>  <NA>  <NA>  <NA>  PURCH            Entry in kela drug purchases registry                 
#> 17 FG00000001 PURCH    7588  2017-06-10       <NA>  <NA>  <NA>  <NA>  PURCH            Entry in kela drug purchases registry                 
#> 18 FG00000001 PURCH    7590  2017-08-30       <NA>  <NA>  <NA>  <NA>  PURCH            Entry in kela drug purchases registry                 
#> 19 FG00000001 PURCH    3201  2017-03-06       <NA>  <NA>  <NA>  <NA>  PURCH            Entry in kela drug purchases registry                 
#> 20 FG00000001 PRIM_OUT 3203  2017-09-05       R20   T42   <NA>  <NA>  PRIM_OUT|R20|T42 PRIM_OUT | Contact Type: Professional's visit to cust…

Adding info to provider type

Function fg_bq_append_provider_info_to_service_sector_data adds new columns with information about the personal or unit that provided the diagnose during the visit.

In the service-sector data, information about the provider is defined in CODE6 to CODE7 depending on the SOURCE. fg_bq_append_visit_type_info_to_service_sector_data abstracts this nuances, and assign one provider type code per row.

event_for_subject_1_with_provider <- fg_bq_append_provider_info_to_service_sector_data(
  project_id, event_for_subject_1, fg_codes_info_table
  )
bigrquery::bq_table_download(event_for_subject_1_with_provider) |> 
  dplyr::select(FINNGENID, SOURCE, INDEX, APPROX_EVENT_DAY, CODE5, CODE6, CODE8, CODE9, provider_code, provider_name_en, provider_concept_class_id)
#> # A tibble: 20 × 11
#>    FINNGENID  SOURCE   INDEX APPROX_EVENT_DAY CODE5 CODE6 CODE8 CODE9 provider_code provider_name_en            provider_concept_class_id
#>    <chr>      <chr>    <chr> <date>           <chr> <chr> <chr> <chr> <chr>         <chr>                       <chr>                    
#>  1 FG00000001 PURCH    7589  2017-02-02       <NA>  <NA>  <NA>  <NA>  <NA>          <NA>                        <NA>                     
#>  2 FG00000001 PURCH    7588  2017-06-10       <NA>  <NA>  <NA>  <NA>  <NA>          <NA>                        <NA>                     
#>  3 FG00000001 PURCH    7585  2017-11-27       <NA>  <NA>  <NA>  <NA>  <NA>          <NA>                        <NA>                     
#>  4 FG00000001 PURCH    7591  2017-06-07       <NA>  <NA>  <NA>  <NA>  <NA>          <NA>                        <NA>                     
#>  5 FG00000001 PURCH    7590  2017-08-30       <NA>  <NA>  <NA>  <NA>  <NA>          <NA>                        <NA>                     
#>  6 FG00000001 PURCH    7592  2017-03-08       <NA>  <NA>  <NA>  <NA>  <NA>          <NA>                        <NA>                     
#>  7 FG00000001 PURCH    7587  2017-05-30       <NA>  <NA>  <NA>  <NA>  <NA>          <NA>                        <NA>                     
#>  8 FG00000001 PURCH    7593  2017-03-18       <NA>  <NA>  <NA>  <NA>  <NA>          <NA>                        <NA>                     
#>  9 FG00000001 PURCH    7584  2017-03-12       <NA>  <NA>  <NA>  <NA>  <NA>          <NA>                        <NA>                     
#> 10 FG00000001 PURCH    7586  2017-05-08       <NA>  <NA>  <NA>  <NA>  <NA>          <NA>                        <NA>                     
#> 11 FG00000001 PURCH    3201  2017-03-06       <NA>  <NA>  <NA>  <NA>  <NA>          <NA>                        <NA>                     
#> 12 FG00000001 PURCH    7583  2017-09-23       <NA>  <NA>  <NA>  <NA>  <NA>          <NA>                        <NA>                     
#> 13 FG00000001 INPAT    5     2017-09-05       1     20G   <NA>  <NA>  20G           Gastroenterological Surgery MEDSPECfi Level 1        
#> 14 FG00000001 INPAT    5     2017-09-05       1     20G   <NA>  <NA>  20G           Gastroenterological Surgery MEDSPECfi Level 1        
#> 15 FG00000001 INPAT    6     2017-03-02       1     30    <NA>  <NA>  30            Gynecology and childbirth   MEDSPECfi Level 0        
#> 16 FG00000001 INPAT    6     2017-03-02       1     30    <NA>  <NA>  30            Gynecology and childbirth   MEDSPECfi Level 0        
#> 17 FG00000001 PRIM_OUT 5256  2017-08-14       R50   T11   <NA>  <NA>  32311         Nurses                      ProfessionalCode         
#> 18 FG00000001 PRIM_OUT 7     2017-11-19       R10   T11   <NA>  <NA>  32311         Nurses                      ProfessionalCode         
#> 19 FG00000001 OPER_OUT 6     2017-07-31       92    77    <NA>  <NA>  77            Neurology                   MEDSPECfi Level 0        
#> 20 FG00000001 PRIM_OUT 3203  2017-09-05       R20   T42   <NA>  <NA>  51321         Practical nurses            ProfessionalCode