Skip to content

Commit

Permalink
test dmpId (#732)
Browse files Browse the repository at this point in the history
* test dmpId

Signed-off-by: Divya Madala <[email protected]>

* working changes

Signed-off-by: Divya Madala <[email protected]>

* matcher

Signed-off-by: Divya Madala <[email protected]>
  • Loading branch information
divyamadala30 authored Jul 8, 2022
1 parent 881b210 commit 1fe506f
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.mskcc.smile.commons.JsonComparator;
Expand All @@ -28,6 +30,7 @@

@Component
public class SampleServiceImpl implements SmileSampleService {
private static final Pattern DMP_PATIENT_ID = Pattern.compile("P-\\d*");
@Autowired
private JsonComparator jsonComparator;

Expand Down Expand Up @@ -139,6 +142,13 @@ public SmileSample fetchAndLoadPatientDetails(SmileSample sample) throws Excepti
// in the database and removing the former sample-to-patient relationship
if (patientByLatestCmoId == null) {
SmilePatient newPatient = new SmilePatient(sampleMetadata.getCmoPatientId(), "cmoId");
//if this sample is a clinical sample, we would also need to add dmpId
if (sample.getSampleCategory().equals("clinical")) {
Matcher matcher = DMP_PATIENT_ID.matcher(sampleMetadata.getPrimaryId());
if (matcher.find()) {
newPatient.addPatientAlias(new PatientAlias(matcher.group(), "dmpId"));
}
}
patientService.savePatientMetadata(newPatient);
sample.setPatient(newPatient);
// remove sample-to-patient relationship from former patient node
Expand Down

0 comments on commit 1fe506f

Please sign in to comment.