From 6e7988d50f47bad7f96a96b9c42d9fbebf997203 Mon Sep 17 00:00:00 2001 From: Angelica Ochoa <15623749+ao508@users.noreply.github.com> Date: Fri, 5 May 2023 16:24:55 -0400 Subject: [PATCH] Default F sample type abbreviation Signed-off-by: Angelica Ochoa <15623749+ao508@users.noreply.github.com> --- .../service/CmoLabelGeneratorService.java | 2 ++ .../impl/CmoLabelGeneratorServiceImpl.java | 26 ++++++++++++------- .../LabelGenMessageHandlingServiceImpl.java | 1 - .../smile/CmoLabelGeneratorServiceTest.java | 11 ++++++-- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/mskcc/smile/service/CmoLabelGeneratorService.java b/src/main/java/org/mskcc/smile/service/CmoLabelGeneratorService.java index b70094a..a44362f 100644 --- a/src/main/java/org/mskcc/smile/service/CmoLabelGeneratorService.java +++ b/src/main/java/org/mskcc/smile/service/CmoLabelGeneratorService.java @@ -19,4 +19,6 @@ Status generateSampleStatus(String requestId, IgoSampleManifest sampleManifest, Status generateSampleStatus(SampleMetadata sampleMetadata, List existingSamples) throws JsonProcessingException; Boolean igoSampleRequiresLabelUpdate(String newCmoLabel, String existingCmoLabel); + String resolveSampleTypeAbbreviation(String specimenTypeValue, String sampleOriginValue, + String cmoSampleClassValue); } diff --git a/src/main/java/org/mskcc/smile/service/impl/CmoLabelGeneratorServiceImpl.java b/src/main/java/org/mskcc/smile/service/impl/CmoLabelGeneratorServiceImpl.java index f61e430..9c302f7 100644 --- a/src/main/java/org/mskcc/smile/service/impl/CmoLabelGeneratorServiceImpl.java +++ b/src/main/java/org/mskcc/smile/service/impl/CmoLabelGeneratorServiceImpl.java @@ -172,11 +172,6 @@ public String generateCmoSampleLabel(String requestId, IgoSampleManifest sampleM // resolve sample type abbreviation String sampleTypeAbbreviation = resolveSampleTypeAbbreviation(sampleManifest); - if (sampleTypeAbbreviation == null) { - LOG.error("Could not resolve sample type abbreviation from specimen type," - + " sample origin, or sample class: " + sampleManifest.toString()); - return null; - } // resolve the sample counter value to use for the cmo label Integer sampleCounter = resolveSampleIncrementValue(sampleManifest.getIgoId(), existingSamples); @@ -253,7 +248,9 @@ public Status generateSampleStatus(String requestId, IgoSampleManifest sampleMan Status sampleStatus = new Status(); Map validationReport = new HashMap<>(); - if (resolveSampleTypeAbbreviation(sampleManifest) == null) { + String sampleTypeAbbreviation = resolveSampleTypeAbbreviation(sampleManifest); + if (sampleTypeAbbreviation == null + || sampleTypeAbbreviation.equals("F")) { validationReport.put("sample type abbreviation", "could not resolve based on specimenType, sampleOrigin, or sampleClass"); } @@ -276,8 +273,10 @@ public Status generateSampleStatus(SampleMetadata sampleMetadata, Status sampleStatus = new Status(); Map validationReport = new HashMap<>(); - if (resolveSampleTypeAbbreviation(sampleMetadata.getSampleClass(), - sampleMetadata.getSampleOrigin(), sampleMetadata.getSampleType()) == null) { + String sampleTypeAbbreviation = resolveSampleTypeAbbreviation(sampleMetadata.getSampleClass(), + sampleMetadata.getSampleOrigin(), sampleMetadata.getSampleType()); + if (sampleTypeAbbreviation == null + || sampleTypeAbbreviation.equals("F")) { validationReport.put("sample type abbreviation", "could not resolve based on specimenType, sampleOrigin, or sampleClass"); } @@ -361,7 +360,8 @@ private String resolveNucleicAcidAbbreviation(IgoSampleManifest sampleManifest) return resolveNucleicAcidAbbreviation(sampleTypeString, recipe, naToExtract); } - private String resolveSampleTypeAbbreviation(String specimenTypeValue, String sampleOriginValue, + @Override + public String resolveSampleTypeAbbreviation(String specimenTypeValue, String sampleOriginValue, String cmoSampleClassValue) { try { SpecimenType specimenType = SpecimenType.fromValue(specimenTypeValue); @@ -389,7 +389,13 @@ private String resolveSampleTypeAbbreviation(String specimenTypeValue, String sa // if abbreviation is still not resolved then try to resolve from sample class CmoSampleClass sampleClass = CmoSampleClass.fromValue(cmoSampleClassValue); - return SAMPLE_CLASS_ABBREV_MAP.get(sampleClass); + String sampleTypeAbbreviation = SAMPLE_CLASS_ABBREV_MAP.get(sampleClass); + if (sampleTypeAbbreviation == null) { + LOG.warn("Could not resolve sample type abbreviation from specimen type," + + " sample origin, or sample class - using default 'F' "); + return "F"; + } + return sampleTypeAbbreviation; } /** diff --git a/src/main/java/org/mskcc/smile/service/impl/LabelGenMessageHandlingServiceImpl.java b/src/main/java/org/mskcc/smile/service/impl/LabelGenMessageHandlingServiceImpl.java index 532544e..dd942bd 100644 --- a/src/main/java/org/mskcc/smile/service/impl/LabelGenMessageHandlingServiceImpl.java +++ b/src/main/java/org/mskcc/smile/service/impl/LabelGenMessageHandlingServiceImpl.java @@ -28,7 +28,6 @@ import org.mskcc.smile.model.igo.IgoSampleManifest; import org.mskcc.smile.service.CmoLabelGeneratorService; import org.mskcc.smile.service.MessageHandlingService; -import org.mskcc.smile.service.util.RequestStatusLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; diff --git a/src/test/java/org/mskcc/smile/CmoLabelGeneratorServiceTest.java b/src/test/java/org/mskcc/smile/CmoLabelGeneratorServiceTest.java index 397981c..0ed4cfa 100644 --- a/src/test/java/org/mskcc/smile/CmoLabelGeneratorServiceTest.java +++ b/src/test/java/org/mskcc/smile/CmoLabelGeneratorServiceTest.java @@ -182,7 +182,7 @@ public void testCmoLabelGenForExistingSampleWithPatientCorrection() // if the cmo label before the update is C-MP789JR-X001-d Assert.assertEquals("C-newPatient-X001-d02", newCmoLabel); - + Status sampleStatus = cmoLabelGeneratorService.generateSampleStatus( updatedSample, existingSamples); Assert.assertEquals(Boolean.TRUE, sampleStatus.getValidationStatus()); @@ -226,7 +226,7 @@ public void testCmoLabelGenForSampleWithOtherSpecimenType() // should return null string String newCmoLabel = cmoLabelGeneratorService.generateCmoSampleLabel( updatedSample, existingSamples); - Assert.assertNull(newCmoLabel); + Assert.assertEquals("C-MP789JR-F001-d01", newCmoLabel); Status sampleStatus = cmoLabelGeneratorService.generateSampleStatus( updatedSample, existingSamples); @@ -270,6 +270,13 @@ public void testCmoCelllineLabelGenerationUpdates() { sampleUpdatedNaExtractLabel, sampleExpectedLabel)); } + @Test + public void testDefaultSampleTypeAbbreviation() { + String sampleTypeAbbrev = cmoLabelGeneratorService.resolveSampleTypeAbbreviation("RapidAutopsy", + "Cerebrospinal Fluid", "Other"); + Assert.assertTrue(sampleTypeAbbrev.equals("F")); + } + private IgoSampleManifest getSampleMetadata(String igoId, String cmoPatientId, SpecimenType specimenType, NucleicAcid naToExtract, String investigatorSampleId) { IgoSampleManifest sample = new IgoSampleManifest();