11import { parentPort } from 'worker_threads' ;
22
33import { yearsPassed } from '@douglasneuroinformatics/libjs' ;
4- import type { InstrumentMeasureValue } from '@opendatacapture/runtime-core' ;
4+ import type { FormTypes , InstrumentMeasureValue } from '@opendatacapture/runtime-core' ;
55import { DEFAULT_GROUP_NAME } from '@opendatacapture/schemas/core' ;
6- import { $RecordArrayFieldValue } from '@opendatacapture/schemas/instrument' ;
76import type { InstrumentRecordsExport } from '@opendatacapture/schemas/instrument-records' ;
87import { removeSubjectIdScope } from '@opendatacapture/subject-utils' ;
98
@@ -12,7 +11,7 @@ import type { ChunkCompleteData, InitData, ParentMessage, RecordType } from './t
1211type ExpandDataType =
1312 | {
1413 measure : string ;
15- measureValue : InstrumentMeasureValue ;
14+ measureValue : FormTypes . RecordArrayFieldValue | InstrumentMeasureValue ;
1615 success : true ;
1716 }
1817 | {
@@ -26,19 +25,21 @@ function expandData(listEntry: any[]): ExpandDataType[] {
2625 throw new Error ( 'Record Array is Empty' ) ;
2726 }
2827 for ( const objectEntry of Object . values ( listEntry ) ) {
29- for ( const [ dataKey , dataValue ] of Object . entries ( objectEntry as { [ key : string ] : any } ) ) {
30- const parseResult = $RecordArrayFieldValue . safeParse ( dataValue ) ;
31- if ( ! parseResult . success ) {
32- validRecordArrayList . push ( {
33- message : `Error interpreting value ${ dataValue } and record array key ${ dataKey } ` ,
34- success : false
35- } ) ;
36- }
28+ for ( const [ dataKey , dataValue ] of Object . entries (
29+ objectEntry as { [ key : string ] : FormTypes . RecordArrayFieldValue }
30+ ) ) {
3731 validRecordArrayList . push ( {
3832 measure : dataKey ,
39- measureValue : parseResult . data ,
33+ measureValue : dataValue ,
4034 success : true
4135 } ) ;
36+
37+ // if (!parseResult.success) {
38+ // validRecordArrayList.push({
39+ // message: `Error interpreting value ${dataValue} and record array key ${dataKey}`,
40+ // success: false
41+ // });
42+ // }
4243 }
4344 }
4445 return validRecordArrayList ;
@@ -141,6 +142,7 @@ let initData: Map<
141142
142143function handleInit ( data : InitData ) {
143144 initData = new Map ( data . map ( ( instrument ) => [ instrument . id , instrument ] ) ) ;
145+ return { success : true } ;
144146}
145147
146148function handleChunkComplete ( _data : ChunkCompleteData ) {
@@ -214,6 +216,7 @@ function handleChunkComplete(_data: ChunkCompleteData) {
214216}
215217
216218parentPort ! . on ( 'message' , ( message : ParentMessage ) => {
219+ console . log ( message ) ;
217220 switch ( message . type ) {
218221 case 'CHUNK_COMPLETE' :
219222 return handleChunkComplete ( message . data ) ;
0 commit comments