From 7c27cf12a4397f3e405e21c8864c0158a97178a2 Mon Sep 17 00:00:00 2001 From: Andy Lassiter Date: Wed, 24 Jul 2024 10:57:56 -0600 Subject: [PATCH] PIXI-144: Use PET scan time for session time if PET modality instead of using the earliest scan time (#17) --- .../sessionBuilder/InveonSessionBuilder.java | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/nrg/xnatx/plugins/pixi/inveon/sessionBuilder/InveonSessionBuilder.java b/src/main/java/org/nrg/xnatx/plugins/pixi/inveon/sessionBuilder/InveonSessionBuilder.java index 62603ac..2eacf02 100644 --- a/src/main/java/org/nrg/xnatx/plugins/pixi/inveon/sessionBuilder/InveonSessionBuilder.java +++ b/src/main/java/org/nrg/xnatx/plugins/pixi/inveon/sessionBuilder/InveonSessionBuilder.java @@ -98,23 +98,25 @@ public XnatImagesessiondataBean call() throws Exception { sessionBean.setSubjectId(subject); sessionBean.setLabel(label); - // Set session date to earliest scan date - Optional 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 sessionDate = sessionBean.getScans_scan().stream() + .filter(s -> s.getModality().equalsIgnoreCase(modality)) + .map(XnatImagescandataI::getStartDate) + .map(d -> (Date) d) + .distinct() + .sorted() + .findFirst(); Optional 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;