diff --git a/NEWS.md b/NEWS.md
index 09a0e92..1774f87 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,3 +1,7 @@
+# EHDEN HMB v0.1.7
+
+* Correct event in time to procedure intervention
+
# EHDEN HMB v0.1.6
* Minor bug fix to treatment patterns analysis
diff --git a/analysis/private/_procedureAnalysis.R b/analysis/private/_procedureAnalysis.R
index a7b2647..74133ef 100644
--- a/analysis/private/_procedureAnalysis.R
+++ b/analysis/private/_procedureAnalysis.R
@@ -94,6 +94,52 @@ getWindowPrevalence <- function(tb, timeA, timeB) {
}
+getTteRes <- function(tb, outcomeCohortId) {
+
+ ##CORRECTION needs to be time to event happening
+ tab2 <- tb %>%
+ dplyr::filter(cohortDefinitionId == outcomeCohortId) %>%
+ dplyr::mutate(
+ event = ifelse(is.na(cohortDefinitionId), 0, 1),
+ duration = dplyr::case_when(
+ event == 0 ~ as.integer(cohortEndDate - cohortStartDate) / 365.25,
+ event == 1 ~ as.integer(eventDate - cohortStartDate) / 365.25
+ )
+ ) %>%
+ dplyr::select(duration, event)
+
+
+ if (nrow(tab2) > 0) {
+ # get surv fit object
+ survFit <- ggsurvfit::survfit2(
+ survival::Surv(duration, event) ~ 1, data = tab2
+ )
+ # retrieve tidy survfit
+ survDat <- ggsurvfit::tidy_survfit(survFit) %>%
+ dplyr::select(time, `n.risk`, `n.event`, estimate, std.error) %>%
+ dplyr::filter(
+ time <= 3 # only take first 3 years of data
+ ) %>%
+ dplyr::mutate(
+ outcomeCohortId = !!outcomeCohortId
+ )
+ } else {
+ # if no data return an all zero row
+ survDat <- tibble::tibble(
+ time = 0,
+ n.risk = 0,
+ n.event = 0,
+ estimate = 0,
+ std.error = 0,
+ outcomeCohortId = outcomeCohortId
+ )
+ }
+
+ return(survDat)
+
+}
+
+
executeProcedureAnalysis <- function(con,
executionSettings,
analysisSettings) {
@@ -191,21 +237,10 @@ executeProcedureAnalysis <- function(con,
bullet = "checkbox_on", bullet_col = "green")
# subset table for survival analysis
- tab2 <- tb %>%
- dplyr::filter(!is.na(cohortDefinitionId)) %>%
- dplyr::mutate(
- event = 1,
- duration = as.integer(eventDate - cohortStartDate) / 365.25
- ) %>%
- dplyr::select(cohortDefinitionId, duration, event)
-
- # get surv fit object
- survFit <- ggsurvfit::survfit2(
- survival::Surv(duration, event) ~ cohortDefinitionId, data = tab2
+ survDat <- purrr::map_dfr(
+ procedureCohortIds,
+ ~getTteRes(tb, outcomeCohortId = .x)
)
- # retrieve tidy survfit
- survDat <- ggsurvfit::tidy_survfit(survFit) %>%
- dplyr::select(time, `n.risk`, `n.event`, estimate:strata)
fileNm2 <- glue::glue("procedure_survival_{idx}")
diff --git a/docs/news.html b/docs/news.html
index 1c7265b..43891b5 100644
--- a/docs/news.html
+++ b/docs/news.html
@@ -156,7 +156,8 @@
On this page
- - EHDEN HMB v0.1.6
+ - EHDEN HMB v0.1.7
+ - EHDEN HMB v0.1.6
- EHDEN HMB v0.1.5
- EHDEN HMB v0.1.4
- EHDEN HMB v0.1.3
@@ -192,6 +193,12 @@ News
+
+EHDEN HMB v0.1.7
+
+- Correct event in time to procedure intervention
+
+
EHDEN HMB v0.1.6
diff --git a/docs/search.json b/docs/search.json
index 2bc5b61..0ab28ba 100644
--- a/docs/search.json
+++ b/docs/search.json
@@ -46,7 +46,7 @@
"href": "news.html",
"title": "News",
"section": "",
- "text": "EHDEN HMB v0.1.6\n\nMinor bug fix to treatment patterns analysis\nCorrect typo in functions\n\n\n\nEHDEN HMB v0.1.5\n\nCorrect bug in analysis settings (Issue #12)\nUpdate package website\nAdd yearly incidence to Incidence Analysis (Issue #13)\nAdd R scripts for data exchange and CD preview (Issue #14)\nupdate cohort definitions from Siir\n\ncopperIUDproc\ncopperIUDdrug\ndisorderOfOvary\n\n\n\n\nEHDEN HMB v0.1.4\n\nFix bug in baseline characteristics; typo in analysis settings (Issue #10)\nCorrections to the study website\n\n\n\nEHDEN HMB v0.1.3\n\nUpdate cohort definitions\n\nadd baseline procedures\nadd baseline drugs\n\nInclude procedure prevalence at baseline [-365,0]\n\n\n\nEHDEN HMB v0.1.2\n\nUpdate cohort definitions\n\nrerun drug exposure with Capr\nrerun procedures with Capr\nadd time restraints to nsaids\nadd hmb cohort without hysterectomy censor\n\nAdd secondary treatment sequence including procedures\n\n\n\nEHDEN HMB v0.1.1\n\nAdd study website\nUpdate cohort definitions for denominator\nAddition of executeStudy.R file to automate execution\nadd age strata [under 30, 30-45, 45-55]\n\n\n\nEHDEN HMB v0.1.0\n\nFirst release of study code for EHDEN HMB\n\nAdd Incidence Analysis\nAdd Baseline Characteristics\nAdd Treatment Patterns\nAdd Procedure Analysis\n\n\n\n\nEHDEN HMB v0.0.6\n\nAdd file StoreResults to upload cohort diagnostics zip to aws s3 bucket\nUpdate KeyringSetup to match Ulysses\nUpdate renv.lock to add aws.s3 and Ulysses v0.0.2\nminor correction to study task files\n\n\n\nEHDEN HMB v0.0.5\n\nAdd in renv\nminor correction to HMB cohort for cohort diagnostics\n\n\n\nEHDEN HMB v0.0.4\n\nFix errors in KeyringSetup.R file\nFix cohort diagnostics to use integer64 with id in cohortDefinitionSet\n\n\n\nEHDEN HMB v0.0.3\n\nUpdate How to run file with installation instructions for usethis and Ulysses\nFix extras/KeyringSetup.R file to correctly set up credentials and check them\nEdit startSnowflakeSession function to handle string split of workDatabaseSchema\nEdit study tasks to order snowflake start correctly and close connection at end of file\n\n\n\nEHDEN HMB v0.0.2\n\nUpdate cohort definition for HMB to fix error\nAdd cohort diagnostics script\nAdd How to Run file and key ring file\n\n\n\nEHDEN HMB v0.0.1\n\nAdd HMB cohort definition to repo\nStart preparing documentation about study\nInitialize OHDSI study\nAdd NEWS.md to"
+ "text": "EHDEN HMB v0.1.7\n\nCorrect event in time to procedure intervention\n\n\n\nEHDEN HMB v0.1.6\n\nMinor bug fix to treatment patterns analysis\nCorrect typo in functions\n\n\n\nEHDEN HMB v0.1.5\n\nCorrect bug in analysis settings (Issue #12)\nUpdate package website\nAdd yearly incidence to Incidence Analysis (Issue #13)\nAdd R scripts for data exchange and CD preview (Issue #14)\nupdate cohort definitions from Siir\n\ncopperIUDproc\ncopperIUDdrug\ndisorderOfOvary\n\n\n\n\nEHDEN HMB v0.1.4\n\nFix bug in baseline characteristics; typo in analysis settings (Issue #10)\nCorrections to the study website\n\n\n\nEHDEN HMB v0.1.3\n\nUpdate cohort definitions\n\nadd baseline procedures\nadd baseline drugs\n\nInclude procedure prevalence at baseline [-365,0]\n\n\n\nEHDEN HMB v0.1.2\n\nUpdate cohort definitions\n\nrerun drug exposure with Capr\nrerun procedures with Capr\nadd time restraints to nsaids\nadd hmb cohort without hysterectomy censor\n\nAdd secondary treatment sequence including procedures\n\n\n\nEHDEN HMB v0.1.1\n\nAdd study website\nUpdate cohort definitions for denominator\nAddition of executeStudy.R file to automate execution\nadd age strata [under 30, 30-45, 45-55]\n\n\n\nEHDEN HMB v0.1.0\n\nFirst release of study code for EHDEN HMB\n\nAdd Incidence Analysis\nAdd Baseline Characteristics\nAdd Treatment Patterns\nAdd Procedure Analysis\n\n\n\n\nEHDEN HMB v0.0.6\n\nAdd file StoreResults to upload cohort diagnostics zip to aws s3 bucket\nUpdate KeyringSetup to match Ulysses\nUpdate renv.lock to add aws.s3 and Ulysses v0.0.2\nminor correction to study task files\n\n\n\nEHDEN HMB v0.0.5\n\nAdd in renv\nminor correction to HMB cohort for cohort diagnostics\n\n\n\nEHDEN HMB v0.0.4\n\nFix errors in KeyringSetup.R file\nFix cohort diagnostics to use integer64 with id in cohortDefinitionSet\n\n\n\nEHDEN HMB v0.0.3\n\nUpdate How to run file with installation instructions for usethis and Ulysses\nFix extras/KeyringSetup.R file to correctly set up credentials and check them\nEdit startSnowflakeSession function to handle string split of workDatabaseSchema\nEdit study tasks to order snowflake start correctly and close connection at end of file\n\n\n\nEHDEN HMB v0.0.2\n\nUpdate cohort definition for HMB to fix error\nAdd cohort diagnostics script\nAdd How to Run file and key ring file\n\n\n\nEHDEN HMB v0.0.1\n\nAdd HMB cohort definition to repo\nStart preparing documentation about study\nInitialize OHDSI study\nAdd NEWS.md to"
},
{
"objectID": "contribution.html",
diff --git a/documentation/news.qmd b/documentation/news.qmd
index 7c1b041..7699cf8 100644
--- a/documentation/news.qmd
+++ b/documentation/news.qmd
@@ -2,6 +2,11 @@
title: "News"
---
+# EHDEN HMB v0.1.7
+
+* Correct event in time to procedure intervention
+
+
# EHDEN HMB v0.1.6
* Minor bug fix to treatment patterns analysis