From e39a5357e49cae2b0e6a4addd41275e6bd2c616c Mon Sep 17 00:00:00 2001 From: ao508 <15623749+ao508@users.noreply.github.com> Date: Wed, 27 Dec 2023 10:52:40 -0500 Subject: [PATCH] Patient DMP ID lookup (#1070) Signed-off-by: Angelica Ochoa <15623749+ao508@users.noreply.github.com> --- .../org/mskcc/smile/model/SmilePatient.java | 18 ++++++++++++++++++ .../service/impl/CrdbMappingServiceImpl.java | 4 +++- .../smile/service/impl/SampleServiceImpl.java | 14 ++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/model/src/main/java/org/mskcc/smile/model/SmilePatient.java b/model/src/main/java/org/mskcc/smile/model/SmilePatient.java index 00240def..177c9b53 100644 --- a/model/src/main/java/org/mskcc/smile/model/SmilePatient.java +++ b/model/src/main/java/org/mskcc/smile/model/SmilePatient.java @@ -122,6 +122,24 @@ public Boolean hasPatientAlias(PatientAlias patientAlias) { return Boolean.FALSE; } + /** + * Determines whether Patient has a patient alias matching the namespace provided. + * @param patientAliasNamespace + * @return Boolean + */ + public Boolean hasPatientAlias(String patientAliasNamespace) { + if (patientAliases == null) { + patientAliases = new ArrayList<>(); + return Boolean.FALSE; + } + for (PatientAlias alias : patientAliases) { + if (alias.getNamespace().equalsIgnoreCase(patientAliasNamespace)) { + return Boolean.TRUE; + } + } + return Boolean.FALSE; + } + @Override public String toString() { return ToStringBuilder.reflectionToString(this); diff --git a/service/src/main/java/org/mskcc/smile/service/impl/CrdbMappingServiceImpl.java b/service/src/main/java/org/mskcc/smile/service/impl/CrdbMappingServiceImpl.java index 31f1b938..a72d5a7f 100644 --- a/service/src/main/java/org/mskcc/smile/service/impl/CrdbMappingServiceImpl.java +++ b/service/src/main/java/org/mskcc/smile/service/impl/CrdbMappingServiceImpl.java @@ -67,7 +67,9 @@ public Object call() { @Override public CrdbMappingModel getCrdbMappingModelByInputId(String inputId) throws Exception { //Add check for if the input query starts with "C-" then remove it (replace with empty string) - inputId.replace("C-", ""); + if (inputId.startsWith("C-")) { + inputId.replace("C-", ""); + } Callable task = new Callable() { @Override public Object call() { diff --git a/service/src/main/java/org/mskcc/smile/service/impl/SampleServiceImpl.java b/service/src/main/java/org/mskcc/smile/service/impl/SampleServiceImpl.java index aeb58114..baf71847 100644 --- a/service/src/main/java/org/mskcc/smile/service/impl/SampleServiceImpl.java +++ b/service/src/main/java/org/mskcc/smile/service/impl/SampleServiceImpl.java @@ -16,9 +16,11 @@ import org.mskcc.smile.model.SmilePatient; import org.mskcc.smile.model.SmileRequest; import org.mskcc.smile.model.SmileSample; +import org.mskcc.smile.model.internal.CrdbMappingModel; import org.mskcc.smile.model.web.PublishedSmileSample; import org.mskcc.smile.model.web.SmileSampleIdMapping; import org.mskcc.smile.persistence.neo4j.SmileSampleRepository; +import org.mskcc.smile.service.CrdbMappingService; import org.mskcc.smile.service.SmilePatientService; import org.mskcc.smile.service.SmileRequestService; import org.mskcc.smile.service.SmileSampleService; @@ -43,6 +45,10 @@ public class SampleServiceImpl implements SmileSampleService { @Autowired private SmilePatientService patientService; + @Autowired + private CrdbMappingService crdbMappingService; + + private static final Log LOG = LogFactory.getLog(SampleServiceImpl.class); private final ObjectMapper mapper = new ObjectMapper(); @@ -149,6 +155,14 @@ public SmileSample saveSmileSample(SmileSample public SmileSample fetchAndLoadPatientDetails(SmileSample sample) throws Exception { SampleMetadata sampleMetadata = sample.getLatestSampleMetadata(); SmilePatient patient = sample.getPatient(); + if (!patient.hasPatientAlias("dmpId")) { + CrdbMappingModel result = + crdbMappingService.getCrdbMappingModelByInputId(patient.getCmoPatientId().getValue()); + if (result != null) { + PatientAlias alias = new PatientAlias(result.getDmpId(), "dmpId"); + patient.addPatientAlias(alias); + } + } // handle the scenario where a patient node does not already exist in the database // to prevent any null pointer exceptions (a situation that had arose in some test dmp sample cases)