From 88845976f42ccfe3d77fe9757c5b38e5e362bfd1 Mon Sep 17 00:00:00 2001 From: "Sampath K. Settipalli" Date: Tue, 27 Aug 2024 11:21:27 -0500 Subject: [PATCH] PEPPER-1364 . Additional PHI Manifest changes --- .../phimanifest/PhiManifestService.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/pepper-apis/dsm-core/src/main/java/org/broadinstitute/dsm/service/phimanifest/PhiManifestService.java b/pepper-apis/dsm-core/src/main/java/org/broadinstitute/dsm/service/phimanifest/PhiManifestService.java index 57feb2fe85..bb5b0a5af2 100644 --- a/pepper-apis/dsm-core/src/main/java/org/broadinstitute/dsm/service/phimanifest/PhiManifestService.java +++ b/pepper-apis/dsm-core/src/main/java/org/broadinstitute/dsm/service/phimanifest/PhiManifestService.java @@ -36,6 +36,8 @@ public class PhiManifestService { public static final String SOMATIC_CONSENT_TUMOR_PEDIATRIC_QUESTION_STABLE_ID = "SOMATIC_CONSENT_TUMOR_PEDIATRIC"; public static final String SOMATIC_ASSENT_ADDENDUM_QUESTION_STABLE_ID = "SOMATIC_ASSENT_ADDENDUM"; + public static final String CONSENT_SUSPENDED = "CONSENT_SUSPENDED"; + public static final String CONSENT_ACTIVITY_CODE = "CONSENT"; public static final String CONSENT_ADDENDUM_ACTIVITY_ACTIVITY_CODE = "CONSENT_ADDENDUM"; public static final String LMS_QUESTION_SOMATIC_CONSENT_ADDENDUM_TUMOR_STABLE_ID = "SOMATIC_CONSENT_ADDENDUM_TUMOR"; public static final String OS2_QUESTION_SOMATIC_CONSENT_ADDENDUM_TUMOR_STABLE_ID = "SOMATIC_CONSENT_TUMOR"; @@ -73,7 +75,7 @@ public PhiManifestReportRoute.PhiManifestResponse generateReport(String ddpParti * Creates a PhiManifest from the information in participant and in a clinical order */ public static PhiManifest generateDataForReport(@NonNull ElasticSearchParticipantDto participant, @NonNull List orders, - @NonNull DDPInstanceDto ddpInstanceDto) { + @NonNull DDPInstanceDto ddpInstanceDto) { //This method assumes that each order has at most 1 Tumor and at most 1 Normal sample, which is a correct assumption based on // clinical ordering criteria currently in place PhiManifest phiManifest = new PhiManifest(); @@ -166,7 +168,7 @@ private static String convertBooleanToYesNo(boolean b) { */ public static String convertBooleanActivityAnswerToString(Optional answer) { if (answer.isPresent() && answer.get() instanceof Boolean) { - return convertBooleanToYesNo((Boolean)answer.get()); + return convertBooleanToYesNo((Boolean) answer.get()); } else { if (answer.isPresent()) { return answer.get().toString(); @@ -209,15 +211,23 @@ private boolean hasParticipantConsentedToSharedLearning(ElasticSearchParticipant } String dateOfBirth = participant.getDsm().get().getDateOfBirth(); String dateOfMajority = (String) participant.getDsm().get().getDateOfMajority(); - if (StringUtils.isBlank(dateOfMajority) || DateTimeUtil.isAdult(dateOfMajority)) { - return (Boolean)getAdultParticipantConsentedToTumorAnswer(participant, ddpInstanceDto.getStudyGuid()) + String participantStatus = participant.getStatus().orElse(""); + if (StringUtils.isBlank(dateOfMajority) || participant.hasCompletedActivity(CONSENT_ACTIVITY_CODE)) { + //self adult enrollment + return (Boolean) getAdultParticipantConsentedToTumorAnswer(participant, ddpInstanceDto.getStudyGuid()) .orElse(false); + } else { + //pediatric or aged-up in lost to followup + return isPediatricValidForPHI(participant, dateOfBirth, participantStatus); } + } + + private static boolean isPediatricValidForPHI(ElasticSearchParticipantDto participant, String dateOfBirth, String participantStatus) { int age = DateTimeUtil.calculateAgeInYears(dateOfBirth); boolean hasCompletedPediatricConsentAddendum = participant.hasCompletedActivity(CONSENT_ADDENDUM_PEDIATRICS_ACTIVITY_CODE); if (hasCompletedPediatricConsentAddendum) { - if (age >= 7) { + if (age >= 7 || participantStatus.equalsIgnoreCase(CONSENT_SUSPENDED)) { return participant.checkAnswerToActivity(CONSENT_ADDENDUM_PEDIATRICS_ACTIVITY_CODE, SOMATIC_CONSENT_TUMOR_PEDIATRIC_QUESTION_STABLE_ID, true) && participant.checkAnswerToActivity( CONSENT_ADDENDUM_PEDIATRICS_ACTIVITY_CODE, SOMATIC_ASSENT_ADDENDUM_QUESTION_STABLE_ID, true);