Skip to content

Commit 6540178

Browse files
committed
feat: filter by study id in questionnaires
1 parent 31ad483 commit 6540178

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

.changeset/four-facts-end.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@quassel/frontend": patch
3+
"@quassel/backend": patch
4+
---
5+
6+
Filter by study id in questionnaires

apps/backend/src/research/questionnaires/questionnaires.controller.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,18 @@ export class QuestionnairesController {
3737
})
3838
@ApiQuery({ name: "sortOrder", enumName: "SortOrder", enum: SortOrder, required: false, description: "Sort order" })
3939
@ApiQuery({ name: "participantId", required: false, description: "Filter by participant ID" })
40+
@ApiQuery({ name: "studyId", required: false, description: "Filter by study ID" })
4041
@ApiQuery({ name: "studyTitle", required: false, description: "Filter by study title" })
4142
@ApiOperation({ summary: "Get all questionnairess" })
4243
@Serialize(QuestionnaireResponseDto)
4344
index(
4445
@Query("sortBy") sortBy?: QuestionnaireSortableField,
4546
@Query("sortOrder") sortOrder?: SortOrder,
4647
@Query("participantId") participantId?: number,
48+
@Query("studyId") studyId?: number,
4749
@Query("studyTitle") studyTitle?: string
4850
): Promise<QuestionnaireResponseDto[]> {
49-
return this.questionnairesService.findAll({ sortBy, sortOrder, participantId, studyTitle });
51+
return this.questionnairesService.findAll({ sortBy, sortOrder, participantId, studyId, studyTitle });
5052
}
5153

5254
@Get(":id")

apps/backend/src/research/questionnaires/questionnaires.service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,20 @@ export class QuestionnairesService {
5959
sortBy,
6060
sortOrder,
6161
participantId,
62+
studyId,
6263
studyTitle,
6364
}: {
6465
sortBy?: keyof QueryOrderMap<Questionnaire>;
6566
sortOrder?: SortOrder;
6667
participantId?: number;
68+
studyId?: number;
6769
studyTitle?: string;
6870
}) {
6971
return (
7072
await this.questionnaireRepository.findAll({
7173
where: {
7274
...(participantId && { participant: participantId }),
75+
...(studyId && { participant: { studies: { $some: { id: studyId } } } }),
7376
...(studyTitle && { participant: { studies: { $some: { title: { $fulltext: studyTitle } } } } }),
7477
},
7578
populate: ["participant"],

apps/frontend/src/routes/_auth/administration/questionnaires/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { paths } from "../../../../api.gen";
1010
type QuestionnaireFilter = {
1111
participantId?: string | number;
1212
studyTitle?: string;
13+
studyId?: string | number;
1314
};
1415

1516
function AdministrationQuestionnairesIndex() {
@@ -44,7 +45,8 @@ function AdministrationQuestionnairesIndex() {
4445
<form onSubmit={f.onSubmit(applyFilters)}>
4546
<Group align="flex-end">
4647
<NumberInput {...f.getInputProps("participantId")} label="Child ID" />
47-
<TextInput {...f.getInputProps("studyTitle")} label="Study" />
48+
<TextInput {...f.getInputProps("studyId")} label="Study ID" />
49+
<TextInput {...f.getInputProps("studyTitle")} label="Study Name" />
4850
<Button type="submit" variant="default" rightSection={<IconFilter size={20} />}>
4951
Filter
5052
</Button>

0 commit comments

Comments
 (0)