Skip to content

Commit 152ed94

Browse files
author
Rupert Westenthaler
committed
This changes the initialization for the data health for new participants so that also occurrencies of already started but still ongoing observations are created
1 parent e830058 commit 152ed94

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

studymanager-services/src/main/java/io/redlink/more/studymanager/scheduling/UpsertOccurredObservationsCron.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,17 @@ private void upsertOccurredObservations(Study study) {
6262
}
6363
ctx.putStudy(study);
6464
List<Participant> participants = participantService.listParticipants(study.getStudyId());
65-
Instant lastOccurredObservation = occurredObservationService.getLatestStartTime(study.getStudyId());
6665
//NOTE: use now + 1min for current because:
6766
// 1. we truncatedTo(ChronoUnit.MINUTES) all Instants and
6867
// 2. we check with start.isBefore(current)
6968
// doing so will include all Observations that start in the current minute
7069
Instant current = Instant.now().plus(1, ChronoUnit.MINUTES).truncatedTo(ChronoUnit.MINUTES);
71-
LOGGER.debug("Upsert Occurred Observations for Study(id: {}) and timeperiode(start:{}, end:{})", study.getStudyId(), lastOccurredObservation, current);
70+
LOGGER.debug("Upsert Occurred Observations for Study(id: {}) ", study.getStudyId());
7271
participants.stream()
7372
.filter(participant -> participant.getStatus() == Participant.Status.ACTIVE)
7473
.forEach(participant -> {
74+
Instant lastOccurredObservation = occurredObservationService.getLatestStartTime(study.getStudyId(), participant.getParticipantId());
75+
LOGGER.debug("Upsert Occurred Observations for Study(id: {}) Participant(id: {}) and timeperiode(start:{}, end:{})", study.getStudyId(), participant.getParticipantId(), lastOccurredObservation, current);
7576
ctx.putParticipant(participant);
7677
//NOTE: from, to are currently not supported
7778
var timeline = calendarService.getTimeline(study, participant, null, null, null, null, null);

studymanager-services/src/main/java/io/redlink/more/studymanager/service/OccurredObservationService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ public OccurredObservation update(OccurredObservation occurredObservation) {
4040
/**
4141
* The latest start time of any {@link OccurredObservation} for the parst studyId
4242
* @param studyId the study id
43+
* @param participantId the participantId
4344
* @return the latest start time or <code>null</code> if no {@link OccurredObservation} is present for the study
4445
*/
45-
public Instant getLatestStartTime(long studyId) {
46-
return repository.getLatestStartTime(studyId, null, null, null, null);
46+
public Instant getLatestStartTime(long studyId, int participantId) {
47+
return repository.getLatestStartTime(studyId, participantId, null, null, null);
4748
}
4849

4950
/**

0 commit comments

Comments
 (0)