Skip to content

Commit 2fcf36a

Browse files
authored
Merge pull request #175 from saipavan10-git/add_ehr_details
Add ehr details
2 parents e534563 + b55fae3 commit 2fcf36a

4 files changed

+33
-4
lines changed

R/get_hipaa_disclosure_log_from_ehr_fhir_logs.R

+13
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,22 @@ get_hipaa_disclosure_log_from_ehr_fhir_logs <- function(
5656
"project_irb_number"
5757
)
5858

59+
redcap_ehr_settings <- dplyr::tbl(conn, "redcap_ehr_settings") |>
60+
dplyr::select(
61+
"ehr_id",
62+
"ehr_name",
63+
"fhir_base_url",
64+
"patient_identifier_string"
65+
)
66+
5967
disclosures <-
6068
dplyr::tbl(conn, "redcap_ehr_fhir_logs") |>
6169
dplyr::filter(.data$resource_type == "Patient" & .data$mrn != "") |>
6270
dplyr::filter(is.na(start_date) | .data$created_at >= start_date) |>
6371
dplyr::filter(ehr_id_is_na | .data$ehr_id %in% ehr_id_local) |>
6472
dplyr::left_join(user_information, by = c("user_id" = "ui_id")) |>
6573
dplyr::left_join(projects, by = c("project_id")) |>
74+
dplyr::left_join(redcap_ehr_settings, by = c("ehr_id")) |>
6675
dplyr::collect() |>
6776
dplyr::mutate(disclosure_date = lubridate::floor_date(.data$created_at, unit = "day")) |>
6877
dplyr::select(-c("id", "created_at")) |>
@@ -73,6 +82,10 @@ get_hipaa_disclosure_log_from_ehr_fhir_logs <- function(
7382
"disclosure_date",
7483
"fhir_id",
7584
"mrn",
85+
"ehr_id",
86+
"ehr_name",
87+
"fhir_base_url",
88+
"patient_identifier_string",
7689
"project_irb_number",
7790
"project_pi_firstname",
7891
"project_pi_mi",

tests/testthat/hipaa_disclosure_log/make_hipaa_disclosure_log_test_data.R

+16-1
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,25 @@ redcap_projects <- dplyr::tbl(conn, "redcap_projects") |>
4949
) |>
5050
collect()
5151

52+
redcap_ehr_settings <- dplyr::tbl(rc_conn, "redcap_ehr_settings") |>
53+
dplyr::select(
54+
"ehr_id",
55+
"ehr_name",
56+
"fhir_base_url",
57+
"patient_identifier_string"
58+
) |>
59+
collect() |>
60+
dplyr::mutate(
61+
ehr_name = "ehrnameEHRName",
62+
fhir_base_url = "https://fhir.example.com",
63+
patient_identifier_string = "mrnaabbccc"
64+
)
65+
5266
# Save our test tables
5367
test_tables <- c(
5468
"redcap_ehr_fhir_logs",
5569
"redcap_user_information",
56-
"redcap_projects"
70+
"redcap_projects",
71+
"redcap_ehr_settings"
5772
)
5873
purrr::walk(test_tables, write_rds_to_test_dir, "hipaa_disclosure_log")
Binary file not shown.

tests/testthat/test-get_hipaa_disclosure_log_from_ehr_fhir_logs.R

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ testthat::test_that("get_hipaa_disclosure_log_from_ehr_fhir_logs works", {
1212
test_tables <- c(
1313
"redcap_ehr_fhir_logs",
1414
"redcap_user_information",
15-
"redcap_projects"
15+
"redcap_projects",
16+
"redcap_ehr_settings"
1617
)
1718

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

3536
# Required column names
3637
required_names <- c(
37-
"disclosure_date", "fhir_id", "mrn", "project_irb_number"
38-
)
38+
"disclosure_date", "fhir_id", "mrn", "project_irb_number",
39+
"ehr_id", "ehr_name", "fhir_base_url", "patient_identifier_string")
3940

4041
result <- get_hipaa_disclosure_log_from_ehr_fhir_logs(conn)
4142

0 commit comments

Comments
 (0)