Package 'BiocFHIR'

Title: Illustration of FHIR ingestion and transformation using R
Description: FHIR R4 bundles in JSON format are derived from https://synthea.mitre.org/downloads. Transformation inspired by a kaggle notebook published by Dr Alexander Scarlat, https://www.kaggle.com/code/drscarlat/fhir-starter-parse-healthcare-bundles-into-tables. This is a very limited illustration of some basic parsing and reorganization processes. Additional tooling will be required to move beyond the Synthea data illustrations.
Authors: Vincent Carey [aut, cre]
Maintainer: Vincent Carey <[email protected]>
License: Artistic-2.0
Version: 1.7.0
Built: 2024-09-20 05:30:37 UTC
Source: https://github.com/bioc/BiocFHIR

Help Index


update a fhir graph on patients and conditions with procedures

Description

update a fhir graph on patients and conditions with procedures

Usage

add_procedures(fhirgraph, listOfProcessedBundles)

Arguments

fhirgraph

instance of BiocFHIR.FHIRgraph

listOfProcessedBundles

list

Value

instance of BiocFHIR.FHIRgraph

Examples

data("allin")
g <- make_condition_graph(allin)
g <- add_procedures(g, allin)
g

collection of synthea FHIR documents ingested

Description

collection of synthea FHIR documents ingested

Usage

data("allin", package = "BiocFHIR")

Format

list

Examples

data("allin", package="BiocFHIR")
allin[[1]]

list available 'retention schemas'

Description

list available 'retention schemas'

Usage

available_retention_schemas()

Value

character vector

Examples

available_retention_schemas()

build graph with patients, conditions and procedures

Description

build graph with patients, conditions and procedures

Usage

build_proccond_igraph(listOfBundles)

Arguments

listOfBundles

list of processed FHIR bundles, processed with 'process_fhir_bundle'

Value

instance of visIgraph from visNetworks

Examples

data("allin")
build_proccond_igraph( allin )

make network visualization

Description

make network visualization

Usage

display_proccond_igraph(igraph)

Arguments

igraph

instance of igraph produced by 'build_procond_igraph'

Value

visIGraph instance

Examples

data("allin")
g <- build_proccond_igraph( allin ) 
if (interactive()) {
 display_proccond_igraph( g )
}

FHIR Resource types recognized in package

Description

FHIR Resource types recognized in package

Usage

FHIR_ResourceTypes()

Value

vector of strings

Examples

FHIR_ResourceTypes() # Oct 2022

collection of FHIR Resource components to be retained

Description

collection of FHIR Resource components to be retained

Usage

FHIR_retention_schemas()

Value

list of vectors of strings

Examples

FHIR_retention_schemas() # Oct 2022

table app

Description

table app

Usage

FHIRtabs()

Value

No value returned.

Examples

if (interactive()) {
 FHIRtabs()
}

produce interactive tables with FHIR resources from a list of ingested bundles

Description

produce interactive tables with FHIR resources from a list of ingested bundles

Usage

freq_app(blist)

Arguments

blist

list of ingested bundles

Value

side-effects of shiny app invocation

Examples

if (interactive()) {
tset = make_test_json_set()
bl = lapply(tset, process_fhir_bundle)
freq_app(bl)
}

get human name from a BiocFHIR.Patient instance

Description

get human name from a BiocFHIR.Patient instance

Usage

getHumanName(Patient)

Arguments

Patient

BiocFHIR.Patient instance

Value

string with name components concatenated

Examples

testf <- system.file("json/Vince741_Rogahn59_6fa3d4ab-c0b6-424a-89d8-7d9105129296.json",
   package="BiocFHIR")
tbun <- process_fhir_bundle(testf)
getHumanName(tbun$Patient)

create graph with links from patients to conditions

Description

create graph with links from patients to conditions

Usage

make_condition_graph(listOfProcessedBundles, keep_with_condition_only = TRUE)

Arguments

listOfProcessedBundles

list with elements generated by 'process_fhir_bundle'

keep_with_condition_only

logical(1) omit bundles that lack a "Condition" element, defaults to TRUE

Value

instance of BiocFHIR.FHIRgraph

Examples

data("allin")
make_condition_graph(allin, TRUE)

produce 50 json FHIR files in a folder

Description

produce 50 json FHIR files in a folder

Usage

make_test_json_set(target = paste0(tempdir(), "/jsontest"), reuse = TRUE)

Arguments

target

character(1) a path, defaults to 'jsontest' under 'tempdir()'; the contents of synthfhir.zip, in inst/zip of BiocFHIR, will be deposted there.

reuse

logical(1) if TRUE, just use what is there, if folder already exists

Value

a vector of paths to FHIR JSON, invisibly

Examples

z <- make_test_json_set()
z[1:3]

show a combination of graph and patient attributes

Description

show a combination of graph and patient attributes

Usage

## S3 method for class 'BiocFHIR.FHIRgraph'
print(x, ...)

Arguments

x

instance of BiocFHIR.FHIRgraph

...

not used

Value

print method

Examples

data("allin")
make_condition_graph(allin)

print method

Description

print method

Usage

## S3 method for class 'FHIR.bundle'
print(x, ...)

Arguments

x

BiocFHIR FHIR.bundle instance

...

not used

Value

print method


extract information from retained fields in AllergyIntolerance component of FHIR Bundle, produce simple data.frame

Description

extract information from retained fields in AllergyIntolerance component of FHIR Bundle, produce simple data.frame

Usage

process_AllergyIntolerance(AllergyIntolerance)

Arguments

AllergyIntolerance

component of FHIR.bundle instance

Value

data.frame

Examples

testf <- system.file("json/Vince741_Rogahn59_6fa3d4ab-c0b6-424a-89d8-7d9105129296.json",
   package="BiocFHIR")
tbun <- process_fhir_bundle(testf)
process_AllergyIntolerance(tbun$AllergyIntolerance)

extract information from retained fields in CarePlan component of FHIR Bundle, produce simple data.frame

Description

extract information from retained fields in CarePlan component of FHIR Bundle, produce simple data.frame

Usage

process_CarePlan(CarePlan)

Arguments

CarePlan

component of FHIR.bundle instance

Value

data.frame

Note

Nov 13 2022, added code to refine the 'category' data processing.

Examples

testf <- system.file("json/Vince741_Rogahn59_6fa3d4ab-c0b6-424a-89d8-7d9105129296.json",
   package="BiocFHIR")
tbun <- process_fhir_bundle(testf)
process_CarePlan(tbun$CarePlan)

extract information from retained fields in Claim component of FHIR Bundle, produce simple data.frame

Description

extract information from retained fields in Claim component of FHIR Bundle, produce simple data.frame

Usage

process_Claim(Claim)

Arguments

Claim

component of FHIR.bundle instance

Value

data.frame

Examples

testf <- system.file("json/Vince741_Rogahn59_6fa3d4ab-c0b6-424a-89d8-7d9105129296.json",
   package="BiocFHIR")
tbun <- process_fhir_bundle(testf)
process_Claim(tbun$Claim)

extract information from retained fields in Condition component of FHIR Bundle, produce simple data.frame

Description

extract information from retained fields in Condition component of FHIR Bundle, produce simple data.frame

Usage

process_Condition(Condition)

Arguments

Condition

component of FHIR.bundle instance

Value

data.frame

Examples

testf <- system.file("json/Vince741_Rogahn59_6fa3d4ab-c0b6-424a-89d8-7d9105129296.json",
   package="BiocFHIR")
tbun <- process_fhir_bundle(testf)
process_Condition(tbun$Condition)

extract information from retained fields in Encounter component of FHIR Bundle, produce simple data.frame

Description

extract information from retained fields in Encounter component of FHIR Bundle, produce simple data.frame

Usage

process_Encounter(Encounter)

Arguments

Encounter

component of FHIR.bundle instance

Value

data.frame

Examples

testf <- system.file("json/Vince741_Rogahn59_6fa3d4ab-c0b6-424a-89d8-7d9105129296.json",
   package="BiocFHIR")
tbun <- process_fhir_bundle(testf)
process_Encounter(tbun$Encounter)

process a bundle of FHIR R4 JSON

Description

process a bundle of FHIR R4 JSON

Usage

process_fhir_bundle(json_file, schemas = FHIR_retention_schemas())

Arguments

json_file

character(1) path to text in JSON format

schemas

list of character vectors defining expected fields, defaults to FHIR_retention_schemas()

Value

instance of FHIR.bundle, extending list

Note

If one encounters the error "Element ... lacks field", the schemas argument can be modified by removing the noted field from the schema.

Examples

testf = system.file("json/Vince741_Rogahn59_6fa3d4ab-c0b6-424a-89d8-7d9105129296.json",
   package="BiocFHIR")
tbun = process_fhir_bundle(testf)
tbun

extract information from retained fields in Immunization component of FHIR Bundle, produce simple data.frame

Description

extract information from retained fields in Immunization component of FHIR Bundle, produce simple data.frame

Usage

process_Immunization(Immunization)

Arguments

Immunization

component of FHIR.bundle instance

Value

data.frame

Examples

testf <- system.file("json/Vince741_Rogahn59_6fa3d4ab-c0b6-424a-89d8-7d9105129296.json",
   package="BiocFHIR")
tbun <- process_fhir_bundle(testf)
process_Immunization(tbun$Immunization)

extract information from retained fields in MedicationRequest component of FHIR Bundle, produce simple data.frame

Description

extract information from retained fields in MedicationRequest component of FHIR Bundle, produce simple data.frame

Usage

process_MedicationRequest(MedicationRequest)

Arguments

MedicationRequest

component of FHIR.bundle instance

Value

data.frame

Examples

testf <- system.file("json/Vince741_Rogahn59_6fa3d4ab-c0b6-424a-89d8-7d9105129296.json",
   package="BiocFHIR")
tbun <- process_fhir_bundle(testf)
process_MedicationRequest(tbun$MedicationRequest)

extract information from retained fields in Observation component of FHIR Bundle, produce simple data.frame

Description

extract information from retained fields in Observation component of FHIR Bundle, produce simple data.frame

Usage

process_Observation(Observation)

Arguments

Observation

component of FHIR.bundle instance

Value

data.frame

Examples

testf <- system.file("json/Vince741_Rogahn59_6fa3d4ab-c0b6-424a-89d8-7d9105129296.json",
   package="BiocFHIR")
tbun <- process_fhir_bundle(testf)
process_Observation(tbun$Observation)

flatten information in Patient component of a bundle to a one-line data.frame

Description

flatten information in Patient component of a bundle to a one-line data.frame

Usage

process_Patient(Patient)

Arguments

Patient

element of FHIR.bundle instance

Value

data.frame

Examples

testf <- system.file("json/Vince741_Rogahn59_6fa3d4ab-c0b6-424a-89d8-7d9105129296.json",
   package="BiocFHIR")
tbun <- process_fhir_bundle(testf)
tpat <- process_Patient(tbun$Patient)
head(names(tpat))
tags <- c("identifier.system3", "identifier.value3")
tpat[tags,,FALSE]
tags2 <- grep("extension.extension", rownames(tpat), value=TRUE)
tpat[tags2,,FALSE]

extract information from retained fields in Procedure component of FHIR Bundle, produce simple data.frame

Description

extract information from retained fields in Procedure component of FHIR Bundle, produce simple data.frame

Usage

process_Procedure(Procedure)

Arguments

Procedure

component of FHIR.bundle instance

Value

data.frame

Examples

testf <- system.file("json/Vince741_Rogahn59_6fa3d4ab-c0b6-424a-89d8-7d9105129296.json",
   package="BiocFHIR")
tbun <- process_fhir_bundle(testf)
process_Procedure(tbun$Procedure)

convert data of a given FHIR type in a list of bundles to a data.frame

Description

convert data of a given FHIR type in a list of bundles to a data.frame

Usage

stack_fhir(blist, type, droperr = TRUE)

Arguments

blist

list of FHIR bundles imported with process_fhir_bundle

type

character(1) type, in names(blist[[1]]), e.g.

droperr

logical(1) exclude records for which process_[type] fails, defaults to TRUE

Value

data.frame

Examples

jj = make_test_json_set()
b2 = lapply(jj[1:2], process_fhir_bundle)
ss = stack_fhir(b2, "Procedure")
head(ss,2)

produce tables summarizing FHIR data

Description

produce tables summarizing FHIR data

Usage

summarise_bundles(
  blist,
  resource = "Condition",
  selection_map = summary_selections()
)

Arguments

blist

list of ingested bundles

resource

character(1) FHIR resource name

selection_map

character() named vector of single strings selected for summarisation

Value

data.frame


vector of fields to be selected for summarization

Description

vector of fields to be selected for summarization

Usage

summary_selections()

Value

named vector of strings