Skip to content

Commit

Permalink
Issue #111: add studygroup and start-datetime to returned data
Browse files Browse the repository at this point in the history
  • Loading branch information
drtyyj committed Apr 15, 2024
1 parent 46edaad commit c29528d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ public static ParticipantDTO toDTO(Participant participant) {
return new ParticipantDTO(
participant.id(),
participant.alias(),
ParticipantStatusDTO.fromValue(participant.status())
ParticipantStatusDTO.fromValue(participant.status()),
participant.studyGroupId(),
BaseTransformers.toOffsetDateTime(participant.start())
);
}

Expand Down
6 changes: 5 additions & 1 deletion src/main/java/io/redlink/more/data/model/Participant.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package io.redlink.more.data.model;

import java.time.Instant;

public record Participant(
int id,
String alias,
String status
String status,
Integer studyGroupId,
Instant start
) {}
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ public class StudyRepository {
"WHERE study_id = :study_id AND participant_id = :participant_id AND status = :oldStatus::participant_status";

private static final String SQL_LIST_PARTICIPANTS_BY_STUDY =
"SELECT participant_id, alias, status FROM participants " +
"SELECT participant_id, alias, status, study_group_id, start FROM participants " +
"WHERE study_id = ?";

private static final String SQL_LIST_PARTICIPANTS_BY_STUDY_AND_GROUP =
"SELECT participant_id, alias, status FROM participants " +
"WHERE study_id = ? AND (study_group_id IS NULL OR study_group_id = ?)";
"SELECT participant_id, alias, status, study_group_id, start FROM participants " +
"WHERE study_id = ? AND study_group_id = ?";

private static final String GET_OBSERVATION_PROPERTIES_FOR_PARTICIPANT =
"SELECT properties FROM participant_observation_properties " +
Expand Down Expand Up @@ -367,7 +367,9 @@ private static RowMapper<Participant> getParticipantRowMapper() {
return (rs, rowNul) -> new Participant(
rs.getInt("participant_id"),
rs.getString("alias"),
rs.getString("status")
rs.getString("status"),
rs.getInt("study_group_id"),
toInstant(rs.getTimestamp("start"))
);
}

Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/openapi/ExternalAPI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,18 @@ components:
type: string
status:
$ref: '#/components/schemas/ParticipantStatus'
studyGroup:
type: integer
format: int32
start:
type: string
format: date-time
required:
- participantId
- alias
- status
- studyGroup
- start

ParticipantStatus:
type: string
Expand Down

0 comments on commit c29528d

Please sign in to comment.