Skip to content

Commit

Permalink
Fix revsiable flag when saving or updating samples (#924)
Browse files Browse the repository at this point in the history
Signed-off-by: Angelica Ochoa <[email protected]>
  • Loading branch information
ao508 authored Mar 30, 2023
1 parent 2a08454 commit 68897d4
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ public class SampleServiceImpl implements SmileSampleService {
@Transactional(rollbackFor = {Exception.class})
public SmileSample saveSmileSample(SmileSample
sample) throws Exception {
// sample to return
SmileSample toReturn;
fetchAndLoadPatientDetails(sample);
SmileSample existingSample =
sampleRepository.findSampleByPrimaryId(sample.getPrimarySampleAlias());
if (existingSample == null) {
UUID newSampleId = sampleRepository.save(sample).getSmileSampleId();
sample.setSmileSampleId(newSampleId);
return sample;
toReturn = sample;
} else {
// populate existing sample details and check if there are actual updates to persist
getDetailedSmileSample(existingSample);
Expand Down Expand Up @@ -88,10 +90,12 @@ public SmileSample saveSmileSample(SmileSample
existingSample.getPatient().getSmilePatientId());
existingSample.setPatient(sample.getPatient());
}
sampleRepository.updateRevisableBySampleId(existingSample.getSmileSampleId(), Boolean.TRUE);
sampleRepository.save(existingSample);
return existingSample;
toReturn = existingSample;
}
// update revisable to true for sample
sampleRepository.updateRevisableBySampleId(toReturn.getSmileSampleId(), Boolean.TRUE);
return toReturn;
}

/**
Expand Down

0 comments on commit 68897d4

Please sign in to comment.