Skip to content

Commit b61559c

Browse files
committed
feat: add function to split the group and $ off of the subject id in export
1 parent 50e4dc7 commit b61559c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ type ExpandDataType =
3838
success: false;
3939
};
4040

41+
function afterFirstDollar(str: string) {
42+
const match = /\$(.*)/.exec(str);
43+
if (!match) return str;
44+
if (!match[1]) return str;
45+
return match[1];
46+
}
47+
4148
@Injectable()
4249
export class InstrumentRecordsService {
4350
constructor(
@@ -180,7 +187,7 @@ export class InstrumentRecordsService {
180187
sessionId: record.session.id,
181188
sessionType: record.session.type,
182189
subjectAge: record.subject.dateOfBirth ? yearsPassed(record.subject.dateOfBirth) : null,
183-
subjectId: record.subject.id,
190+
subjectId: afterFirstDollar(record.subject.id),
184191
subjectSex: record.subject.sex,
185192
timestamp: record.date.toISOString(),
186193
value: measureValue
@@ -203,7 +210,7 @@ export class InstrumentRecordsService {
203210
sessionId: record.session.id,
204211
sessionType: record.session.type,
205212
subjectAge: record.subject.dateOfBirth ? yearsPassed(record.subject.dateOfBirth) : null,
206-
subjectId: record.subject.id,
213+
subjectId: afterFirstDollar(record.subject.id),
207214
subjectSex: record.subject.sex,
208215
timestamp: record.date.toISOString(),
209216
value: arrayEntry.measureValue

0 commit comments

Comments
 (0)