From 4f7676580c441f2e2c6eaec8a37218f58613584f Mon Sep 17 00:00:00 2001 From: "Sampath K. Settipalli" Date: Mon, 9 Sep 2024 08:47:43 -0500 Subject: [PATCH 1/4] PEPPER-1388 . remove angio study redirect from pancan --- .../pancan/PancanAngioRedirectRemoval.java | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 pepper-apis/studybuilder-cli/src/main/java/org/broadinstitute/ddp/studybuilder/task/pancan/PancanAngioRedirectRemoval.java diff --git a/pepper-apis/studybuilder-cli/src/main/java/org/broadinstitute/ddp/studybuilder/task/pancan/PancanAngioRedirectRemoval.java b/pepper-apis/studybuilder-cli/src/main/java/org/broadinstitute/ddp/studybuilder/task/pancan/PancanAngioRedirectRemoval.java new file mode 100644 index 0000000000..6d9a3bb200 --- /dev/null +++ b/pepper-apis/studybuilder-cli/src/main/java/org/broadinstitute/ddp/studybuilder/task/pancan/PancanAngioRedirectRemoval.java @@ -0,0 +1,81 @@ +package org.broadinstitute.ddp.studybuilder.task.pancan; + +import com.typesafe.config.Config; +import lombok.extern.slf4j.Slf4j; +import org.broadinstitute.ddp.db.DBUtils; +import org.broadinstitute.ddp.db.dao.JdbiUmbrellaStudy; +import org.broadinstitute.ddp.exception.DDPException; +import org.broadinstitute.ddp.studybuilder.task.CustomTask; +import org.jdbi.v3.core.Handle; +import org.jdbi.v3.sqlobject.SqlObject; +import org.jdbi.v3.sqlobject.customizer.Bind; +import org.jdbi.v3.sqlobject.statement.SqlQuery; +import org.jdbi.v3.sqlobject.statement.SqlUpdate; + +import java.nio.file.Path; + +@Slf4j +public class PancanAngioRedirectRemoval implements CustomTask { + + private Path cfgPath; + private Config studyCfg; + private Config varsCfg; + private SqlHelper sqlHelper; + + @Override + public void init(Path cfgPath, Config studyCfg, Config varsCfg) { + this.cfgPath = cfgPath; + this.studyCfg = studyCfg; + this.varsCfg = varsCfg; + } + + @Override + public void run(Handle handle) { + var studyDto = handle.attach(JdbiUmbrellaStudy.class).findByStudyGuid(studyCfg.getString("study.guid")); + if (!studyDto.getGuid().equals("cmi-pancan")) { + throw new DDPException("This task is only for the pancan study!"); + } + + sqlHelper = handle.attach(SqlHelper.class); + + //find and delete the ANGIO study redirect workflow transition + long workflowTransitionId = sqlHelper.findPancanAngioStudyRedirectWorkflowId(); + DBUtils.checkDelete(1, sqlHelper.updatePancanAngioRedirectPex(workflowTransitionId)); + log.info("Deleted workflow transition with ID: {}", workflowTransitionId); + + //update pex expressions to remove ANGIO (C_SARCOMAS_ANGIOSARCOMA) + int rowCount = sqlHelper.updatePancanAngioRedirectPex(); + log.info("Updated {} rows in expression table", rowCount); + } + + + private interface SqlHelper extends SqlObject { + + @SqlQuery("select trans.workflow_transition_id\n" + + " from workflow_transition as trans\n" + + " join umbrella_study as s on s.umbrella_study_id = trans.umbrella_study_id\n" + + " join workflow_state as next_state on next_state.workflow_state_id = trans.next_state_id\n" + + " join workflow_state_type as next_state_type on next_state_type.workflow_state_type_id = next_state.workflow_state_type_id\n" + + " left join workflow_activity_state as next_act_state on next_act_state.workflow_state_id = next_state.workflow_state_id\n" + + " left join expression as expr on expr.expression_id = trans.precondition_expression_id\n" + + " left join workflow_study_redirect_state as next_redirect_state on next_redirect_state.workflow_state_id = next_state.workflow_state_id\n" + + " where s.guid = 'cmi-pancan'\n" + + " and trans.is_active\n" + + " and next_state_type.workflow_state_type_code = 'STUDY_REDIRECT'\n" + + " and study_guid = 'ANGIO'") + long findPancanAngioStudyRedirectWorkflowId(); + + @SqlUpdate("delete workflow_transition " + + "from workflow_transition " + + "where workflow_transition_id = :workflowTransitionId") + int updatePancanAngioRedirectPex(@Bind("workflowTransitionId") long workflowTransitionId); + + @SqlUpdate("update expression " + + "set expression_text = REPLACE(expression_text, '\"C_SARCOMAS_ANGIOSARCOMA\",', '') " + + "where expression_text like '%hasOptionStartsWith(\"C_SARCOMAS_ANGIOSARCOMA\", \"C_GASTRO_ESOPHAGEAL_CANCER\"%' ") + int updatePancanAngioRedirectPex(); + + } + + +} From c89cf4b67a2759d680141c8315aed5b328a4f80b Mon Sep 17 00:00:00 2001 From: "Sampath K. Settipalli" Date: Mon, 9 Sep 2024 09:34:03 -0500 Subject: [PATCH 2/4] PEPPER-1388 . remove angio study redirect from pancan --- .../studybuilder-cli/studies/pancan/subs.conf | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pepper-apis/studybuilder-cli/studies/pancan/subs.conf b/pepper-apis/studybuilder-cli/studies/pancan/subs.conf index 70117b4e57..b45ce4dc1f 100644 --- a/pepper-apis/studybuilder-cli/studies/pancan/subs.conf +++ b/pepper-apis/studybuilder-cli/studies/pancan/subs.conf @@ -177,7 +177,7 @@ ) || (user.studies["cmi-pancan"].forms["PREQUAL"].questions["PRIMARY_CANCER_LIST_CHILD"].numChildAnswers("PRIMARY_CANCER_CHILD") > 1 - && user.studies["cmi-pancan"].forms["PREQUAL"].questions["PRIMARY_CANCER_LIST_CHILD"].children["PRIMARY_CANCER_CHILD"].answers.hasOptionStartsWith("C_SARCOMAS_ANGIOSARCOMA", "C_GASTRO_ESOPHAGEAL_CANCER", "C_GASTRO_GASTRIC_STOMACH_CANCER", "C_GENITOURINARY_PROSTATE", "C_BREAST_") + && user.studies["cmi-pancan"].forms["PREQUAL"].questions["PRIMARY_CANCER_LIST_CHILD"].children["PRIMARY_CANCER_CHILD"].answers.hasOptionStartsWith("C_GASTRO_ESOPHAGEAL_CANCER", "C_GASTRO_GASTRIC_STOMACH_CANCER", "C_GENITOURINARY_PROSTATE", "C_BREAST_") ) ) """, @@ -193,17 +193,17 @@ ) && !( (user.studies["cmi-pancan"].forms["PREQUAL"].questions["PRIMARY_CANCER_LIST_SELF"].numChildAnswers("PRIMARY_CANCER_SELF") > 1 - && user.studies["cmi-pancan"].forms["PREQUAL"].questions["PRIMARY_CANCER_LIST_SELF"].children["PRIMARY_CANCER_SELF"].answers.hasOptionStartsWith("C_SARCOMAS_ANGIOSARCOMA", "C_GASTRO_ESOPHAGEAL_CANCER", "C_GASTRO_GASTRIC_STOMACH_CANCER", "C_GENITOURINARY_PROSTATE", "C_BREAST_") + && user.studies["cmi-pancan"].forms["PREQUAL"].questions["PRIMARY_CANCER_LIST_SELF"].children["PRIMARY_CANCER_SELF"].answers.hasOptionStartsWith("C_GASTRO_ESOPHAGEAL_CANCER", "C_GASTRO_GASTRIC_STOMACH_CANCER", "C_GENITOURINARY_PROSTATE", "C_BREAST_") ) || (user.studies["cmi-pancan"].forms["PREQUAL"].questions["PRIMARY_CANCER_LIST_CHILD"].numChildAnswers("PRIMARY_CANCER_CHILD") > 1 - && user.studies["cmi-pancan"].forms["PREQUAL"].questions["PRIMARY_CANCER_LIST_CHILD"].children["PRIMARY_CANCER_CHILD"].answers.hasOptionStartsWith("C_SARCOMAS_ANGIOSARCOMA", "C_GASTRO_ESOPHAGEAL_CANCER", "C_GASTRO_GASTRIC_STOMACH_CANCER", "C_GENITOURINARY_PROSTATE", "C_BREAST_") + && user.studies["cmi-pancan"].forms["PREQUAL"].questions["PRIMARY_CANCER_LIST_CHILD"].children["PRIMARY_CANCER_CHILD"].answers.hasOptionStartsWith("C_GASTRO_ESOPHAGEAL_CANCER", "C_GASTRO_GASTRIC_STOMACH_CANCER", "C_GENITOURINARY_PROSTATE", "C_BREAST_") ) ) ) || ( user.studies["cmi-pancan"].forms["PREQUAL"].questions["PRIMARY_CANCER_LIST_SELF"].numChildAnswers("PRIMARY_CANCER_SELF") == 1 && user.studies["cmi-pancan"].forms["PREQUAL"].questions["PRIMARY_CANCER_LIST_SELF"].children["PRIMARY_CANCER_SELF"] - .answers.hasOptionStartsWith("C_SARCOMAS_ANGIOSARCOMA", "C_GASTRO_ESOPHAGEAL_CANCER", "C_GASTRO_GASTRIC_STOMACH_CANCER") + .answers.hasOptionStartsWith("C_GASTRO_ESOPHAGEAL_CANCER", "C_GASTRO_GASTRIC_STOMACH_CANCER") && !user.studies["cmi-pancan"].forms["PREQUAL"].questions["DESCRIBE"].answers.hasOption("CHILD_DIAGNOSED") && user.profile.language() == "en" ) @@ -542,7 +542,7 @@ """, "addchild_has_cmi_legacy": """ (user.studies["cmi-pancan"].forms["ADD_CHILD"].questions["PRIMARY_CANCER_LIST_ADD_CHILD"].numChildAnswers("PRIMARY_CANCER_ADD_CHILD") > 1 - && user.studies["cmi-pancan"].forms["ADD_CHILD"].questions["PRIMARY_CANCER_LIST_ADD_CHILD"].children["PRIMARY_CANCER_ADD_CHILD"].answers.hasOptionStartsWith("C_SARCOMAS_ANGIOSARCOMA", "C_GASTRO_ESOPHAGEAL_CANCER", "C_GASTRO_GASTRIC_STOMACH_CANCER", "C_GENITOURINARY_PROSTATE", "C_BREAST_") + && user.studies["cmi-pancan"].forms["ADD_CHILD"].questions["PRIMARY_CANCER_LIST_ADD_CHILD"].children["PRIMARY_CANCER_ADD_CHILD"].answers.hasOptionStartsWith("C_GASTRO_ESOPHAGEAL_CANCER", "C_GASTRO_GASTRIC_STOMACH_CANCER", "C_GENITOURINARY_PROSTATE", "C_BREAST_") ) """, "addchild_is_not_redirect": """ @@ -552,7 +552,7 @@ ) && !( (user.studies["cmi-pancan"].forms["ADD_CHILD"].questions["PRIMARY_CANCER_LIST_ADD_CHILD"].numChildAnswers("PRIMARY_CANCER_ADD_CHILD") > 1 - && user.studies["cmi-pancan"].forms["ADD_CHILD"].questions["PRIMARY_CANCER_LIST_ADD_CHILD"].children["PRIMARY_CANCER_ADD_CHILD"].answers.hasOptionStartsWith("C_SARCOMAS_ANGIOSARCOMA", "C_GASTRO_ESOPHAGEAL_CANCER", "C_GASTRO_GASTRIC_STOMACH_CANCER", "C_GENITOURINARY_PROSTATE", "C_BREAST_") + && user.studies["cmi-pancan"].forms["ADD_CHILD"].questions["PRIMARY_CANCER_LIST_ADD_CHILD"].children["PRIMARY_CANCER_ADD_CHILD"].answers.hasOptionStartsWith("C_GASTRO_ESOPHAGEAL_CANCER", "C_GASTRO_GASTRIC_STOMACH_CANCER", "C_GENITOURINARY_PROSTATE", "C_BREAST_") ) ) ) From ce15f7e920d4ef0e530fa2cee46233878fad19cb Mon Sep 17 00:00:00 2001 From: "Sampath K. Settipalli" Date: Mon, 9 Sep 2024 09:54:22 -0500 Subject: [PATCH 3/4] PEPPER-1388 . remove angio study redirect from pancan --- .../pancan/PancanAngioRedirectRemoval.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pepper-apis/studybuilder-cli/src/main/java/org/broadinstitute/ddp/studybuilder/task/pancan/PancanAngioRedirectRemoval.java b/pepper-apis/studybuilder-cli/src/main/java/org/broadinstitute/ddp/studybuilder/task/pancan/PancanAngioRedirectRemoval.java index 6d9a3bb200..9c0793d040 100644 --- a/pepper-apis/studybuilder-cli/src/main/java/org/broadinstitute/ddp/studybuilder/task/pancan/PancanAngioRedirectRemoval.java +++ b/pepper-apis/studybuilder-cli/src/main/java/org/broadinstitute/ddp/studybuilder/task/pancan/PancanAngioRedirectRemoval.java @@ -51,18 +51,18 @@ public void run(Handle handle) { private interface SqlHelper extends SqlObject { - @SqlQuery("select trans.workflow_transition_id\n" + - " from workflow_transition as trans\n" + - " join umbrella_study as s on s.umbrella_study_id = trans.umbrella_study_id\n" + - " join workflow_state as next_state on next_state.workflow_state_id = trans.next_state_id\n" + - " join workflow_state_type as next_state_type on next_state_type.workflow_state_type_id = next_state.workflow_state_type_id\n" + - " left join workflow_activity_state as next_act_state on next_act_state.workflow_state_id = next_state.workflow_state_id\n" + - " left join expression as expr on expr.expression_id = trans.precondition_expression_id\n" + - " left join workflow_study_redirect_state as next_redirect_state on next_redirect_state.workflow_state_id = next_state.workflow_state_id\n" + - " where s.guid = 'cmi-pancan'\n" + - " and trans.is_active\n" + - " and next_state_type.workflow_state_type_code = 'STUDY_REDIRECT'\n" + - " and study_guid = 'ANGIO'") + @SqlQuery("select trans.workflow_transition_id " + + " from workflow_transition as trans " + + " join umbrella_study as s on s.umbrella_study_id = trans.umbrella_study_id " + + " join workflow_state as next_state on next_state.workflow_state_id = trans.next_state_id " + + " join workflow_state_type as next_state_type on next_state_type.workflow_state_type_id = next_state.workflow_state_type_id " + + " left join workflow_activity_state as next_act_state on next_act_state.workflow_state_id = next_state.workflow_state_id " + + " left join expression as expr on expr.expression_id = trans.precondition_expression_id " + + " left join workflow_study_redirect_state as next_redirect_state on next_redirect_state.workflow_state_id = next_state.workflow_state_id " + + " where s.guid = 'cmi-pancan' " + + " and trans.is_active " + + " and next_state_type.workflow_state_type_code = 'STUDY_REDIRECT' " + + " and study_guid = 'ANGIO'") long findPancanAngioStudyRedirectWorkflowId(); @SqlUpdate("delete workflow_transition " From 679d809f53996547633eb750e0702c5a2598af91 Mon Sep 17 00:00:00 2001 From: "Sampath K. Settipalli" Date: Mon, 9 Sep 2024 10:10:00 -0500 Subject: [PATCH 4/4] PEPPER-1388 . remove angio study redirect from pancan --- .../task/pancan/PancanAngioRedirectRemoval.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pepper-apis/studybuilder-cli/src/main/java/org/broadinstitute/ddp/studybuilder/task/pancan/PancanAngioRedirectRemoval.java b/pepper-apis/studybuilder-cli/src/main/java/org/broadinstitute/ddp/studybuilder/task/pancan/PancanAngioRedirectRemoval.java index 9c0793d040..2a4a7b3d5c 100644 --- a/pepper-apis/studybuilder-cli/src/main/java/org/broadinstitute/ddp/studybuilder/task/pancan/PancanAngioRedirectRemoval.java +++ b/pepper-apis/studybuilder-cli/src/main/java/org/broadinstitute/ddp/studybuilder/task/pancan/PancanAngioRedirectRemoval.java @@ -55,14 +55,17 @@ private interface SqlHelper extends SqlObject { + " from workflow_transition as trans " + " join umbrella_study as s on s.umbrella_study_id = trans.umbrella_study_id " + " join workflow_state as next_state on next_state.workflow_state_id = trans.next_state_id " - + " join workflow_state_type as next_state_type on next_state_type.workflow_state_type_id = next_state.workflow_state_type_id " - + " left join workflow_activity_state as next_act_state on next_act_state.workflow_state_id = next_state.workflow_state_id " - + " left join expression as expr on expr.expression_id = trans.precondition_expression_id " - + " left join workflow_study_redirect_state as next_redirect_state on next_redirect_state.workflow_state_id = next_state.workflow_state_id " + + " join workflow_state_type as next_state_type on next_state_type.workflow_state_type_id " + + " = next_state.workflow_state_type_id " + + " left join workflow_activity_state as next_act_state on next_act_state.workflow_state_id " + + " = next_state.workflow_state_id " + + " left join expression as expr on expr.expression_id = trans.precondition_expression_id " + + " left join workflow_study_redirect_state as next_redirect_state on " + + " next_redirect_state.workflow_state_id = next_state.workflow_state_id " + " where s.guid = 'cmi-pancan' " - + " and trans.is_active " - + " and next_state_type.workflow_state_type_code = 'STUDY_REDIRECT' " - + " and study_guid = 'ANGIO'") + + " and trans.is_active " + + " and next_state_type.workflow_state_type_code = 'STUDY_REDIRECT' " + + " and study_guid = 'ANGIO'") long findPancanAngioStudyRedirectWorkflowId(); @SqlUpdate("delete workflow_transition "