Skip to content

Commit

Permalink
PIXI-144: Use PET scan time for session time if PET modality instead …
Browse files Browse the repository at this point in the history
…of using the earliest scan time (#17)
  • Loading branch information
andylassiter authored Jul 24, 2024
1 parent 1365287 commit 7c27cf1
Showing 1 changed file with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,25 @@ public XnatImagesessiondataBean call() throws Exception {
sessionBean.setSubjectId(subject);
sessionBean.setLabel(label);

// Set session date to earliest scan date
Optional<Date> sessionDate = sessionBean.getScans_scan().stream()
.map(XnatImagescandataI::getStartDate)
.map(d -> (Date) d)
.distinct()
.sorted()
.findFirst();
String modality = hasPET ? "PET" : "CT";

sessionDate.ifPresent(sessionBean::setDate);
Optional<Date> sessionDate = sessionBean.getScans_scan().stream()
.filter(s -> s.getModality().equalsIgnoreCase(modality))
.map(XnatImagescandataI::getStartDate)
.map(d -> (Date) d)
.distinct()
.sorted()
.findFirst();

Optional<Date> sessionTime = sessionBean.getScans_scan().stream()
.map(XnatImagescandataI::getStarttime)
.map(d -> (Date) d)
.distinct()
.sorted()
.findFirst();
.filter(s -> s.getModality().equalsIgnoreCase(modality))
.map(XnatImagescandataI::getStarttime)
.map(d -> (Date) d)
.distinct()
.sorted()
.findFirst();

sessionDate.ifPresent(sessionBean::setDate);
sessionTime.ifPresent(sessionBean::setTime);

return sessionBean;
Expand Down

0 comments on commit 7c27cf1

Please sign in to comment.