Skip to content

Commit

Permalink
Merge pull request #175 from saipavan10-git/add_ehr_details
Browse files Browse the repository at this point in the history
Add ehr details
  • Loading branch information
pbchase authored Dec 21, 2024
2 parents e534563 + b55fae3 commit 2fcf36a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
13 changes: 13 additions & 0 deletions R/get_hipaa_disclosure_log_from_ehr_fhir_logs.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,22 @@ get_hipaa_disclosure_log_from_ehr_fhir_logs <- function(
"project_irb_number"
)

redcap_ehr_settings <- dplyr::tbl(conn, "redcap_ehr_settings") |>
dplyr::select(
"ehr_id",
"ehr_name",
"fhir_base_url",
"patient_identifier_string"
)

disclosures <-
dplyr::tbl(conn, "redcap_ehr_fhir_logs") |>
dplyr::filter(.data$resource_type == "Patient" & .data$mrn != "") |>
dplyr::filter(is.na(start_date) | .data$created_at >= start_date) |>
dplyr::filter(ehr_id_is_na | .data$ehr_id %in% ehr_id_local) |>
dplyr::left_join(user_information, by = c("user_id" = "ui_id")) |>
dplyr::left_join(projects, by = c("project_id")) |>
dplyr::left_join(redcap_ehr_settings, by = c("ehr_id")) |>
dplyr::collect() |>
dplyr::mutate(disclosure_date = lubridate::floor_date(.data$created_at, unit = "day")) |>
dplyr::select(-c("id", "created_at")) |>
Expand All @@ -73,6 +82,10 @@ get_hipaa_disclosure_log_from_ehr_fhir_logs <- function(
"disclosure_date",
"fhir_id",
"mrn",
"ehr_id",
"ehr_name",
"fhir_base_url",
"patient_identifier_string",
"project_irb_number",
"project_pi_firstname",
"project_pi_mi",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,25 @@ redcap_projects <- dplyr::tbl(conn, "redcap_projects") |>
) |>
collect()

redcap_ehr_settings <- dplyr::tbl(rc_conn, "redcap_ehr_settings") |>
dplyr::select(
"ehr_id",
"ehr_name",
"fhir_base_url",
"patient_identifier_string"
) |>
collect() |>
dplyr::mutate(
ehr_name = "ehrnameEHRName",
fhir_base_url = "https://fhir.example.com",
patient_identifier_string = "mrnaabbccc"
)

# Save our test tables
test_tables <- c(
"redcap_ehr_fhir_logs",
"redcap_user_information",
"redcap_projects"
"redcap_projects",
"redcap_ehr_settings"
)
purrr::walk(test_tables, write_rds_to_test_dir, "hipaa_disclosure_log")
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ testthat::test_that("get_hipaa_disclosure_log_from_ehr_fhir_logs works", {
test_tables <- c(
"redcap_ehr_fhir_logs",
"redcap_user_information",
"redcap_projects"
"redcap_projects",
"redcap_ehr_settings"
)

conn <- DBI::dbConnect(duckdb::duckdb(), dbdir = ":memory:")
Expand All @@ -34,8 +35,8 @@ testthat::test_that("get_hipaa_disclosure_log_from_ehr_fhir_logs works", {

# Required column names
required_names <- c(
"disclosure_date", "fhir_id", "mrn", "project_irb_number"
)
"disclosure_date", "fhir_id", "mrn", "project_irb_number",
"ehr_id", "ehr_name", "fhir_base_url", "patient_identifier_string")

result <- get_hipaa_disclosure_log_from_ehr_fhir_logs(conn)

Expand Down

0 comments on commit 2fcf36a

Please sign in to comment.