diff --git a/pepper-apis/dsm-core/src/main/java/org/broadinstitute/dsm/db/OncHistoryDetail.java b/pepper-apis/dsm-core/src/main/java/org/broadinstitute/dsm/db/OncHistoryDetail.java index f7b407c929..86d4d4eb99 100644 --- a/pepper-apis/dsm-core/src/main/java/org/broadinstitute/dsm/db/OncHistoryDetail.java +++ b/pepper-apis/dsm-core/src/main/java/org/broadinstitute/dsm/db/OncHistoryDetail.java @@ -91,6 +91,7 @@ public class OncHistoryDetail implements HasDdpInstanceId { public static final String STATUS_RETURNED = "returned"; public static final String STATUS_REQUEST = "request"; public static final String STATUS_UNABLE_TO_OBTAIN = "unableToObtain"; + public static final String UNABLE_OBTAIN_TISSUE = "unableObtainTissue"; public static final String PROBLEM_INSUFFICIENT_PATH = "insufficientPath"; public static final String PROBLEM_INSUFFICIENT_SHL = "insufficientSHL"; public static final String PROBLEM_NO_E_SIGN = "noESign"; diff --git a/pepper-apis/dsm-core/src/main/java/org/broadinstitute/dsm/model/elastic/export/generate/OncHistoryDetailUnableObtainTissueStrategy.java b/pepper-apis/dsm-core/src/main/java/org/broadinstitute/dsm/model/elastic/export/generate/OncHistoryDetailUnableObtainTissueStrategy.java index 7b9799e3d9..98349d6bbb 100644 --- a/pepper-apis/dsm-core/src/main/java/org/broadinstitute/dsm/model/elastic/export/generate/OncHistoryDetailUnableObtainTissueStrategy.java +++ b/pepper-apis/dsm-core/src/main/java/org/broadinstitute/dsm/model/elastic/export/generate/OncHistoryDetailUnableObtainTissueStrategy.java @@ -1,7 +1,12 @@ package org.broadinstitute.dsm.model.elastic.export.generate; +import lombok.extern.slf4j.Slf4j; +import org.broadinstitute.dsm.db.OncHistoryDetail; + +import java.util.HashMap; import java.util.Map; +@Slf4j public class OncHistoryDetailUnableObtainTissueStrategy extends UnableObtainTissueStrategy { public OncHistoryDetailUnableObtainTissueStrategy(GeneratorPayload generatorPayload) { @@ -11,7 +16,9 @@ public OncHistoryDetailUnableObtainTissueStrategy(GeneratorPayload generatorPayl @Override public Map generate() { if (isUnableToObtain()) { - return Map.of(); + Map resultMap = new HashMap<>(); + resultMap.put(OncHistoryDetail.STATUS_REQUEST, OncHistoryDetail.UNABLE_OBTAIN_TISSUE); + return resultMap; } return super.generate(); } diff --git a/pepper-apis/dsm-core/src/main/java/org/broadinstitute/dsm/model/patch/BasePatch.java b/pepper-apis/dsm-core/src/main/java/org/broadinstitute/dsm/model/patch/BasePatch.java index 7f4ea8b744..ebf500216c 100644 --- a/pepper-apis/dsm-core/src/main/java/org/broadinstitute/dsm/model/patch/BasePatch.java +++ b/pepper-apis/dsm-core/src/main/java/org/broadinstitute/dsm/model/patch/BasePatch.java @@ -13,6 +13,7 @@ import lombok.NonNull; import org.apache.commons.lang3.StringUtils; import org.broadinstitute.dsm.db.DDPInstance; +import org.broadinstitute.dsm.db.OncHistoryDetail; import org.broadinstitute.dsm.db.dao.ddp.onchistory.OncHistoryDetailDaoImpl; import org.broadinstitute.dsm.db.dao.ddp.participant.ParticipantDataDao; import org.broadinstitute.dsm.db.dao.queue.EventDao; @@ -233,7 +234,7 @@ protected boolean isNameValuePairs() { protected List setWorkflowRelatedFields(@NonNull Patch patch) { List nameValues = new ArrayList<>(); if (patch.getNameValue().getValue() == null) { - // if the date that was sent in is null, we don't want to set the workflow fields + // if the value that was sent in is null, we don't want to set the workflow fields return nameValues; } //mr request workflow @@ -279,18 +280,17 @@ protected List setWorkflowRelatedFields(@NonNull Patch patch) { patch.getNameValues(), patch.getDdpParticipantId()), "sent")); } } - } else if (patch.getNameValue().getName().equals("oD.unableObtainTissue") && !(boolean) patch.getNameValue().getValue()) { - boolean hasReceivedDate = new OncHistoryDetailDaoImpl().hasReceivedDate(getOncHistoryDetailId(patch)); - - if (hasReceivedDate) { - nameValues.add(setAdditionalValue("oD.request", - new Patch(patch.getId(), PARTICIPANT_ID, patch.getParentId(), patch.getUser(), patch.getNameValue(), - patch.getNameValues(), patch.getDdpParticipantId()), "received")); - } else { - nameValues.add(setAdditionalValue("oD.request", - new Patch(patch.getId(), PARTICIPANT_ID, patch.getParentId(), patch.getUser(), patch.getNameValue(), - patch.getNameValues(), patch.getDdpParticipantId()), "sent")); - } + } else if (patch.getNameValue().getName().equals("oD.unableObtainTissue")) { + // if unable to obtain tissue, set request to "unable to obtain" + // if not unable to obtain, check if received date exists, if so set request to "received", otherwise set to "sent" + String status = (boolean) patch.getNameValue().getValue() + ? OncHistoryDetail.UNABLE_OBTAIN_TISSUE + : new OncHistoryDetailDaoImpl().hasReceivedDate(getOncHistoryDetailId(patch)) + ? "received" + : "sent"; + nameValues.add(setAdditionalValue("oD.request", + new Patch(patch.getId(), PARTICIPANT_ID, patch.getParentId(), patch.getUser(), patch.getNameValue(), + patch.getNameValues(), patch.getDdpParticipantId()), status)); } return nameValues; }