Skip to content

Commit

Permalink
Patient DMP ID lookup (#1070)
Browse files Browse the repository at this point in the history
Signed-off-by: Angelica Ochoa <[email protected]>
  • Loading branch information
ao508 authored Dec 27, 2023
1 parent 52c28b8 commit e39a535
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
18 changes: 18 additions & 0 deletions model/src/main/java/org/mskcc/smile/model/SmilePatient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object> task = new Callable<Object>() {
@Override
public Object call() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e39a535

Please sign in to comment.