Last updated: 2021-09-28

Checks: 6 1

Knit directory: codemapper/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


The R Markdown is untracked by Git. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20210923) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 504e142. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .DS_Store
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    R/.DS_Store
    Ignored:    _targets/
    Ignored:    config.ini
    Ignored:    data/
    Ignored:    output/
    Ignored:    renv/library/
    Ignored:    renv/local/
    Ignored:    renv/staging/
    Ignored:    tests/.DS_Store

Untracked files:
    Untracked:  BNF Snomed Mapping data 20210819.xlsx
    Untracked:  R/lookups_and_mappings.R
    Untracked:  R/utils-pipe.R
    Untracked:  R/utils.R
    Untracked:  analysis/reformat_all_lkps_maps.Rmd
    Untracked:  code/tar_make.R
    Untracked:  man/pipe.Rd

Unstaged changes:
    Modified:   .gitignore
    Modified:   DESCRIPTION
    Modified:   NAMESPACE
    Modified:   _targets.R

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


There are no past versions. Publish this analysis with wflow_publish() to start tracking its development.


Remove irrelevant rows

Last few rows of each sheet

2 columns shown only

bnf_lkp

BNF_Presentation_Code BNF_Presentation
23985859804 Mentor_Carshalton Urinary Diversion Set Triangular 32mm
23985859805 Mentor_Carshalton Urinary Diversion Set Triangular 38mm
23985859806 Mentor_Chiron Ileal Blad Apparatus
23990001111 Unspecified Manufacturer_Stoma/Incont
NA NA
BNF Code Information, NHSBSA Copyright 2019. This information is licenced under the terms of the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA

dmd_lkp

concept_id term
4450411000001101 Zyvox 600mg tablets (Pfizer Ltd) 10 tablet (product)
3862301000001107 Zyvox 600mg/300mL infusion solution
4827211000001109 Zyvox 600mg/300ml solution for injection bags (Pfizer Ltd) (product)
4827411000001108 Zyvox 600mg/300ml solution for injection bags (Pfizer Ltd) 10 bag 10 x 300ml bags (product)
NA NA
This material includes SNOMED Clinical Terms® (SNOMED CT®) which is used by permission of the International Health Terminology Standards Development Organisation (IHTSDO). All rights reserved. SNOMED CT®, was originally created by The College of American Pathologists. “SNOMED” and “SNOMED CT” are registered trademarks of the IHTSDO. NA

icd9_lkp

ICD9 DESCRIPTION_ICD9
V825 CHEMICAL POISONING AND OTHER CONTAMINATION
V826 MULTIPHASIC SCREENING
V828 OTHER
V829 UNSPECIFIED
NA NA
ICD-9 is in the public domain so there are no copyright restrictions over its use. WHO no longer publishes or distributes ICD-9. NA

icd10_lkp

ICD10_CODE ALT_CODE
U84.7 U847
U84.8 U848
U84.9 U849
U85 U85X
NA NA
ICD-10 codes, terms and text used by permission of WHO, from: International Statistical Classification of Diseases and Related Health Problems, Tenth Revision (ICD-10). Vols 1-3. Geneva, World Health Organization, 1992-2016. NA

icd9_icd10

ICD9 DESCRIPTION_ICD9
V468 OTHER ENABLING MACHINES
V468 OTHER ENABLING MACHINES
V469 UNSPECIFIED
NA NA
ICD-10 codes, terms and text used by permission of WHO, from: International Statistical Classification of Diseases and Related Health Problems, Tenth Revision (ICD-10). Vols 1-3. Geneva, World Health Organization, 1992-2016. NA
ICD-9 is in the public domain so there are no copyright restrictions over its use. WHO no longer publishes or distributes ICD-9. NA

read_v2_lkp

read_code term_code
Zw058 00
Zw059 00
Zw05A 00
Zw05B 00
NA NA
Contains information from NHS Digital, licenced under the current version of the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm" NA

read_v2_drugs_lkp

read_code term_description
yz4V. 2016-01-01 GRAMMEZA
yz4W. 2016-02-01 MARMARAS
yz4X. 2016-03-01 MATHRAKI
yz4Y. 2016-04-01 MEGANISI
NA NA
Contains information from NHS Digital, licenced under the current version of the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA

read_v2_drugs_bnf

read_code bnf_code
m22S. 13.02.01.00
m22T. 13.02.01.00
pq3U. 00.00.00.00
NA NA
Contains information from NHS Digital, licenced under the current version of the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA
BNF Code Information, NHSBSA Copyright 2019. This information is licenced under the terms of the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA

read_v2_icd9

read_code icd9_code
ZVu6Z V444
ZVy.. V01-V82
ZVz.. V01-V82
NA NA
Contains information from NHS Digital, licenced under the current version of the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA
ICD-9 is in the public domain so there are no copyright restrictions over its use. WHO no longer publishes or distributes ICD-9. NA

read_v2_icd10

read_code icd10_code
ZVu6Z Z934
ZVy.. Z769
ZVz.. Z769
NA NA
Contains information from NHS Digital, licenced under the current version of the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA
ICD-10 codes, terms and text used by permission of WHO, from: International Statistical Classification of Diseases and Related Health Problems, Tenth Revision (ICD-10). Vols 1-3. Geneva, World Health Organization, 1992-2016. NA

read_v2_opcs4

read_code opcs_4.2_code
7K1Lf W848+Y713
7K1Lg W848+Y713
7L119 X382+Y532
NA NA
Contains information from NHS Digital, licenced under the current version of the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA
The OPCS Classification of Interventions and Procedures, codes, terms and text is Crown copyright (2016) published by Health and Social Care Information Centre, also known as NHS Digital and licensed under the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA

read_v2_read_ctv3

CHAPTER READV2_CODE
Z Zw058
Z Zw059
Z Zw05A
Z Zw05B
NA NA
Contains information from NHS Digital, licenced under the current version of the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA

read_ctv3_lkp

read_code term_description
x05f4 See u222.
x05f5 See u22y.
yz… See yz0..
yz1.. See yz0..
NA NA
Contains information from NHS Digital, licenced under the current version of the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA

read_ctv3_icd9

read_code icd9_code
ZVu6e V433
ZVu6k V438
ZVu6l V458
NA NA
Contains information from NHS Digital, licenced under the current version of the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA
ICD-9 is in the public domain so there are no copyright restrictions over its use. WHO no longer publishes or distributes ICD-9. NA

read_ctv3_icd10

read_code icd10_code
ZVu6m Z998
ZVy.. Z769
ZVz.. Z769
NA NA
Contains information from NHS Digital, licenced under the current version of the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA
ICD-10 codes, terms and text used by permission of WHO, from: International Statistical Classification of Diseases and Related Health Problems, Tenth Revision (ICD-10). Vols 1-3. Geneva, World Health Organization, 1992-2016. NA

read_ctv3_opcs4

read_code opcs4_code
XaexI X629
Xafdi X612
Xaff0 X629
NA NA
Contains information from NHS Digital, licenced under the current version of the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA
The OPCS Classification of Interventions and Procedures, codes, terms and text is Crown copyright (2016) published by Health and Social Care Information Centre, also known as NHS Digital and licensed under the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA

read_ctv3_read_v2

READV3_CODE TERMV3_CODE
Zw058 YM0dp
Zw059 YM0dq
Zw05A YM0dr
Zw05B YM0ds
NA NA
Contains information from NHS Digital, licenced under the current version of the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA

Cannot just remove NA in column 2

Sheet N rows raw N rows rm NAs in col 2 Difference
bnf_lkp 79829 79827 2
dmd_lkp 434951 434949 2
icd9_lkp 7973 7971 2
icd10_lkp 17936 17934 2
icd9_icd10 16163 9728 6435
read_v2_lkp 101883 101881 2
read_v2_drugs_lkp 67614 67612 2
read_v2_drugs_bnf 67615 58354 9261
read_v2_icd9 35664 35661 3
read_v2_icd10 36667 36664 3
read_v2_opcs4 14927 14924 3
read_v2_read_ctv3 108245 108243 2
read_ctv3_lkp 395654 395652 2
read_ctv3_icd9 67155 67152 3
read_ctv3_icd10 116377 116374 3
read_ctv3_opcs4 54321 54318 3
read_ctv3_read_v2 777522 777520 2

Instead, determine N rows to remove manually

Sheet N rows raw N rows reformatted Difference
bnf_lkp 79829 79827 2
dmd_lkp 434951 434949 2
icd9_lkp 7973 7971 2
icd10_lkp 17936 17934 2
icd9_icd10 16163 16160 3
read_v2_lkp 101883 101881 2
read_v2_drugs_lkp 67614 67612 2
read_v2_drugs_bnf 67615 67612 3
read_v2_icd9 35664 35661 3
read_v2_icd10 36667 36664 3
read_v2_opcs4 14927 14924 3
read_v2_read_ctv3 108245 108243 2
read_ctv3_lkp 395654 395652 2
read_ctv3_icd9 67155 67152 3
read_ctv3_icd10 116377 116374 3
read_ctv3_opcs4 54321 54318 3
read_ctv3_read_v2 777522 777520 2

bnf_lkp

BNF codes in the UK Biobank linked primary care dataset are of variable length (see UKB resource 591).

extend_bnf_lkp() creates all possible versions for BNF codes in bnf_lkp. This facilitates selecting all drugs under a certain chapter/section/etc e.g. to get all BNF codes for all medications in the ‘Treatment Of Glaucoma’ section (i.e. BNF codes starting with 1106). This table shows the results for the first drug in this section:

bnf_dmd

This is downloaded from the NHSBSA website. There are no ‘extra’ rows that need removing at the bottom.

To map BNF codes to DM+D:

Note: There are 354 out of 354 glaucoma medication codes that are not present in bnf_dmd

# A tibble: 6 × 11
  presentation_pack_level vmp_vmpp_amp_ampp bnf_code        bnf_name snomed_code
  <chr>                   <chr>             <chr>           <chr>    <chr>      
1 Presentation            VMP               1106000L0AAAAAA Latanop… 330729005  
2 Pack                    VMPP              1106000L0AAAAAA Latanop… 1075711000…
3 Presentation            AMP               1106000L0BBAAAA Xalatan… 3656110000…
4 Pack                    AMPP              1106000L0BBAAAA Xalatan… 1381911000…
5 Presentation            AMP               1106000L0AAAAAA Latanop… 1984741100…
6 Pack                    AMPP              1106000L0AAAAAA Latanop… 1984751100…
# … with 6 more variables: dm_d_product_description <chr>, strength <dbl>,
#   unit_of_measure <chr>, dm_d_product_and_pack_description <chr>, pack <dbl>,
#   sub_pack <chr>

R version 4.1.0 (2021-05-18)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] codemapper_0.0.0.9000 testthat_3.0.4        ukbwranglr_0.0.0.9000
 [4] targets_0.8.0         crosstalk_1.1.1       readxl_1.3.1         
 [7] reactable_0.2.3       forcats_0.5.1         stringr_1.4.0        
[10] dplyr_1.0.7           purrr_0.3.4           readr_2.0.1          
[13] tidyr_1.1.3           tibble_3.1.4          ggplot2_3.3.5        
[16] tidyverse_1.3.1      

loaded via a namespace (and not attached):
 [1] fs_1.5.0          usethis_2.0.1     lubridate_1.7.10  devtools_2.4.2   
 [5] httr_1.4.2        rprojroot_2.0.2   tools_4.1.0       backports_1.2.1  
 [9] bslib_0.2.5.1     utf8_1.2.2        R6_2.5.0          DBI_1.1.1        
[13] colorspace_2.0-2  withr_2.4.2       tidyselect_1.1.1  prettyunits_1.1.1
[17] processx_3.5.2    compiler_4.1.0    git2r_0.28.0      cli_3.0.1        
[21] rvest_1.0.1       xml2_1.3.2        desc_1.3.0        sass_0.4.0       
[25] scales_1.1.1      callr_3.7.0       digest_0.6.27     rmarkdown_2.9    
[29] ini_0.3.1         pkgconfig_2.0.3   htmltools_0.5.1.1 sessioninfo_1.1.1
[33] highr_0.9         dbplyr_2.1.1      fastmap_1.1.0     htmlwidgets_1.5.4
[37] rlang_0.4.11      rstudioapi_0.13   jquerylib_0.1.4   generics_0.1.0   
[41] configr_0.3.5     jsonlite_1.7.2    magrittr_2.0.1    Rcpp_1.0.7       
[45] munsell_0.5.0     fansi_0.5.0       lifecycle_1.0.0   stringi_1.6.2    
[49] yaml_2.2.1        pkgbuild_1.2.0    grid_4.1.0        promises_1.2.0.1 
[53] RcppTOML_0.1.7    crayon_1.4.1      haven_2.4.3       hms_1.1.0        
[57] knitr_1.34        ps_1.6.0          pillar_1.6.2      igraph_1.2.6     
[61] codetools_0.2-18  pkgload_1.2.2     reprex_2.0.1      glue_1.4.2       
[65] evaluate_0.14     data.table_1.14.0 remotes_2.4.0     modelr_0.1.8     
[69] vctrs_0.3.8       tzdb_0.1.2        httpuv_1.6.1      cellranger_1.1.0 
[73] gtable_0.3.0      reactR_0.4.4      assertthat_0.2.1  cachem_1.0.6     
[77] xfun_0.24         broom_0.7.9       later_1.2.0       memoise_2.0.0    
[81] workflowr_1.6.2   ellipsis_0.3.2