Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEPPER-1388 remove angio from pancan redirect #2933

Merged
merged 4 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
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 "
+ " 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 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();

}


}
12 changes: 6 additions & 6 deletions pepper-apis/studybuilder-cli/studies/pancan/subs.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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_")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file changes are just to keep config in sync with what patch is doing and patch doest use this file.

&& 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_")
)
)
""",
Expand All @@ -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"
)
Expand Down Expand Up @@ -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": """
Expand All @@ -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_")
)
)
)
Expand Down
Loading