@@ -148,41 +148,20 @@ export class InstrumentRecordsService {
148148 instrument = ( await this . instrumentsService . findById ( record . instrumentId ) ) as ScalarInstrument ;
149149 instruments . set ( record . instrumentId , instrument ) ;
150150 }
151- for ( const [ dataKey , dataValue ] of Object . entries ( record . data as object [ ] ) ) {
152- if ( typeof dataValue === 'object' && dataValue && JSON . stringify ( dataValue ) ) {
153- for ( const [ , subDataValue ] of Object . entries ( dataValue ) ) {
154- // eslint-disable-next-line max-depth
155- for ( const [ superSubKey , superSubValue ] of Object . entries ( subDataValue as object ) ) {
156- data . push ( {
157- instrumentEdition : instrument . internal . edition ,
158- instrumentName : instrument . internal . name ,
159- measure : superSubKey ,
160- sessionDate : record . session . date . toISOString ( ) ,
161- sessionId : record . session . id ,
162- sessionType : record . session . type ,
163- subjectAge : record . subject . dateOfBirth ? yearsPassed ( record . subject . dateOfBirth ) : null ,
164- subjectId : record . subject . id ,
165- subjectSex : record . subject . sex ,
166- timestamp : record . date . toISOString ( ) ,
167- value : JSON . stringify ( superSubValue )
168- } ) ;
169- }
170- }
171151
172- continue ;
173- }
152+ for ( const [ measureKey , measureValue ] of Object . entries ( record . computedMeasures ) ) {
174153 data . push ( {
175154 instrumentEdition : instrument . internal . edition ,
176155 instrumentName : instrument . internal . name ,
177- measure : dataKey ,
156+ measure : measureKey ,
178157 sessionDate : record . session . date . toISOString ( ) ,
179158 sessionId : record . session . id ,
180159 sessionType : record . session . type ,
181160 subjectAge : record . subject . dateOfBirth ? yearsPassed ( record . subject . dateOfBirth ) : null ,
182161 subjectId : record . subject . id ,
183162 subjectSex : record . subject . sex ,
184163 timestamp : record . date . toISOString ( ) ,
185- value : dataValue as InstrumentMeasureValue
164+ value : measureValue
186165 } ) ;
187166 }
188167 }
0 commit comments