Skip to content

Commit c26feeb

Browse files
authored
Merge pull request #1141 from david-roper/add_group_to_export
Add group to export
2 parents f8ce429 + b0bf8ca commit c26feeb

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

apps/api/src/instrument-records/instrument-records.service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { Model } from '@douglasneuroinformatics/libnest';
44
import { linearRegression } from '@douglasneuroinformatics/libstats';
55
import { Injectable, UnprocessableEntityException } from '@nestjs/common';
66
import type { ScalarInstrument } from '@opendatacapture/runtime-core';
7+
import { DEFAULT_GROUP_NAME } from '@opendatacapture/schemas/core';
78
import type {
89
CreateInstrumentRecordData,
910
InstrumentRecord,
@@ -158,6 +159,8 @@ export class InstrumentRecordsService {
158159
sessionId: record.session.id,
159160
sessionType: record.session.type,
160161
subjectAge: record.subject.dateOfBirth ? yearsPassed(record.subject.dateOfBirth) : null,
162+
// eslint-disable-next-line perfectionist/sort-objects
163+
groupId: record.subject.groupIds[0] ?? DEFAULT_GROUP_NAME,
161164
subjectId: record.subject.id,
162165
subjectSex: record.subject.sex,
163166
timestamp: record.date.toISOString(),

apps/web/src/features/session/components/StartSessionForm/StartSessionForm.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { Form } from '@douglasneuroinformatics/libui/components';
44
import { useTranslation } from '@douglasneuroinformatics/libui/hooks';
55
import type { FormTypes } from '@opendatacapture/runtime-core';
6+
import { DEFAULT_GROUP_NAME } from '@opendatacapture/schemas/core';
67
import type { Group } from '@opendatacapture/schemas/group';
78
import { $SessionType } from '@opendatacapture/schemas/session';
89
import type { CreateSessionData } from '@opendatacapture/schemas/session';
@@ -253,7 +254,7 @@ export const StartSessionForm = ({ currentGroup, initialValues, readOnly, onSubm
253254
});
254255
} else {
255256
subjectId = encodeScopedSubjectId(subjectId, {
256-
groupName: currentGroup?.name ?? 'root'
257+
groupName: currentGroup?.name ?? DEFAULT_GROUP_NAME
257258
});
258259
}
259260
await onSubmit({

packages/schemas/src/core/core.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import type { Json, JsonLiteral, Language } from '@opendatacapture/runtime-core'
66
import type { Simplify } from 'type-fest';
77
import { z } from 'zod';
88

9+
export const DEFAULT_GROUP_NAME = 'root';
10+
911
export type AppAction = z.infer<typeof $AppAction>;
1012
export const $AppAction = z.enum(['create', 'delete', 'manage', 'read', 'update']);
1113

packages/schemas/src/instrument-records/instrument-records.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export const $InstrumentRecord = $BaseModel.extend({
4545
export type InstrumentRecord = z.infer<typeof $InstrumentRecord>;
4646

4747
export type InstrumentRecordsExport = {
48+
groupId: string;
4849
instrumentEdition: number;
4950
instrumentName: string;
5051
measure: string;

0 commit comments

Comments
 (0)