LOINC

Only code will be included. Few or no comments.

library(tidyverse);library(magrittr);library(knitr);options(tibble.print_max = 200);library(DT)

fname='n:/loinc/Loinc_2.66/AccessoryFiles/PartFile/LoincPartLink.csv'
d<-read_csv(fname)
## Parsed with column specification:
## cols(
##   LoincNumber = col_character(),
##   LongCommonName = col_character(),
##   PartNumber = col_character(),
##   PartName = col_character(),
##   PartCodeSystem = col_character(),
##   PartTypeName = col_character(),
##   LinkTypeName = col_character(),
##   Property = col_character()
## )
names(d)
## [1] "LoincNumber"    "LongCommonName" "PartNumber"     "PartName"      
## [5] "PartCodeSystem" "PartTypeName"   "LinkTypeName"   "Property"
nrow(d)
## [1] 1481908
#d %>% write_rds('c:/temp/lp.rds')

filtering

d %>% count(LinkTypeName)
## # A tibble: 8 x 2
##   LinkTypeName             n
##   <chr>                <int>
## 1 DetailedModel       457590
## 2 DocumentOntology     10987
## 3 Metadata             91437
## 4 Primary             505507
## 5 Radiology            41659
## 6 Search              254856
## 7 SemanticEnhancement   1518
## 8 SyntaxEnhancement   118354
d %>% count(Property)
## # A tibble: 45 x 2
##    Property                                                               n
##    <chr>                                                              <int>
##  1 http://loinc.org/property/adjustment                                 184
##  2 http://loinc.org/property/analyte                                  82071
##  3 http://loinc.org/property/analyte-core                             91388
##  4 http://loinc.org/property/analyte-divisor                           5432
##  5 http://loinc.org/property/analyte-divisor-suffix                      23
##  6 http://loinc.org/property/analyte-gene                              1518
##  7 http://loinc.org/property/analyte-suffix                           21511
##  8 http://loinc.org/property/category                                    49
##  9 http://loinc.org/property/challenge                                 6211
## 10 http://loinc.org/property/CLASS                                    91388
## 11 http://loinc.org/property/COMPONENT                                91388
## 12 http://loinc.org/property/count                                      148
## 13 http://loinc.org/property/document-kind                             2878
## 14 http://loinc.org/property/document-role                              991
## 15 http://loinc.org/property/document-setting                          2878
## 16 http://loinc.org/property/document-subject-matter-domain            2373
## 17 http://loinc.org/property/document-type-of-service                  1867
## 18 http://loinc.org/property/METHOD_TYP                               87822
## 19 http://loinc.org/property/PROPERTY                                173459
## 20 http://loinc.org/property/rad-anatomic-location-imaging-focus       5436
## 21 http://loinc.org/property/rad-anatomic-location-laterality          3493
## 22 http://loinc.org/property/rad-anatomic-location-laterality-prese~   3475
## 23 http://loinc.org/property/rad-anatomic-location-region-imaged       6335
## 24 http://loinc.org/property/rad-guidance-for-action                   1147
## 25 http://loinc.org/property/rad-guidance-for-approach                  345
## 26 http://loinc.org/property/rad-guidance-for-object                    470
## 27 http://loinc.org/property/rad-guidance-for-presence                 1021
## 28 http://loinc.org/property/rad-maneuver-maneuver-type                 380
## 29 http://loinc.org/property/rad-modality-subtype                      1075
## 30 http://loinc.org/property/rad-modality-type                         6016
## 31 http://loinc.org/property/rad-pharmaceutical-route                  1923
## 32 http://loinc.org/property/rad-pharmaceutical-substance-given        2410
## 33 http://loinc.org/property/rad-reason-for-exam                        446
## 34 http://loinc.org/property/rad-subject                                 33
## 35 http://loinc.org/property/rad-timing                                2684
## 36 http://loinc.org/property/rad-view-aggregation                      3302
## 37 http://loinc.org/property/rad-view-view-type                        1668
## 38 http://loinc.org/property/SCALE_TYP                               173459
## 39 http://loinc.org/property/search                                  254856
## 40 http://loinc.org/property/super-system                             19734
## 41 http://loinc.org/property/SYSTEM                                   91388
## 42 http://loinc.org/property/system-core                              63564
## 43 http://loinc.org/property/time-core                                82071
## 44 http://loinc.org/property/time-modifier                              210
## 45 http://loinc.org/property/TIME_ASPCT                               91388
d2 <-d  %>% filter(LinkTypeName=='Primary')
#d2 %>% write_csv('LoincPartLinkPrimary.csv')

nrow(d2)
## [1] 505507
d2 %>% count(Property)
## # A tibble: 6 x 2
##   Property                                 n
##   <chr>                                <int>
## 1 http://loinc.org/property/COMPONENT  91388
## 2 http://loinc.org/property/METHOD_TYP 48567
## 3 http://loinc.org/property/PROPERTY   91388
## 4 http://loinc.org/property/SCALE_TYP  91388
## 5 http://loinc.org/property/SYSTEM     91388
## 6 http://loinc.org/property/TIME_ASPCT 91388
d2$PartCodeSystem<-NULL
d2$PartCodeSystem<-NULL
d2 %>% count(PartTypeName)
## # A tibble: 6 x 2
##   PartTypeName     n
##   <chr>        <int>
## 1 COMPONENT    91388
## 2 METHOD       48567
## 3 PROPERTY     91388
## 4 SCALE        91388
## 5 SYSTEM       91388
## 6 TIME         91388
d3 <-d2 %>% filter(PartTypeName %in% c('COMPONENT','METHOD','SYSTEM'))


#dt <- datatable(head(d,115000), filter = 'top', options = list(pageLength = 500))
dt <- datatable(d3, filter = 'top', options = list(pageLength = 50))
# %>%
#     formatStyle('V1',  
#                 color = styleInterval(c(0.5, 56), c('black', 'red', 'blue')),
#                 backgroundColor = styleInterval(56.5, c('snow', 'lightyellow')),
#                 fontWeight = styleInterval(58.0, c('italics', 'bold')))

View

dt
## Warning in instance$preRenderHook(instance): It seems your data is too
## big for client-side DataTables. You may consider server-side processing:
## https://rstudio.github.io/DT/server.html