@@ -9,7 +9,7 @@ const {parseReportSortQuery} = require('../../libs/queryOperations');
99const db = require ( '../../models' ) ;
1010const logger = require ( '../../log' ) ;
1111const { getUserProjects} = require ( '../../libs/helperFunctions' ) ;
12- const { removeKeys} = require ( '../../libs/helperFunctions' ) ;
12+ const { removeKeys, cleanSampleInfo , cleanSeqQC } = require ( '../../libs/helperFunctions' ) ;
1313
1414const { hasAccessToNonProdReports,
1515 hasAccessToUnreviewedReports, isAdmin} = require ( '../../libs/helperFunctions' ) ;
@@ -54,22 +54,11 @@ router.route('/schema')
5454 } )
5555 . post ( async ( req , res ) => {
5656 if ( req . body . sampleInfo ) {
57- // Clean sampleInfo input
58- const cleanSampleInfo = [ ] ;
59- for ( const sampleInfoObject of req . body . sampleInfo ) {
60- cleanSampleInfo . push (
61- {
62- sample : ( sampleInfoObject . Sample ) ? sampleInfoObject . Sample : sampleInfoObject . sample ,
63- pathoTc : ( sampleInfoObject [ 'Patho TC' ] ) ? sampleInfoObject [ 'Patho TC' ] : sampleInfoObject . pathoTc ,
64- biopsySite : ( sampleInfoObject [ 'Biopsy Site' ] ) ? sampleInfoObject [ 'Biopsy Site' ] : sampleInfoObject . biopsySite ,
65- biopsyType : ( sampleInfoObject [ 'Biopsy Type' ] ) ? sampleInfoObject [ 'Biopsy Type' ] : sampleInfoObject . biopsyType ,
66- sampleName : ( sampleInfoObject [ 'Sample Name' ] ) ? sampleInfoObject [ 'Sample Name' ] : sampleInfoObject . sampleName ,
67- primarySite : ( sampleInfoObject [ 'Primary Site' ] ) ? sampleInfoObject [ 'Primary Site' ] : sampleInfoObject . primarySite ,
68- collectionDate : ( sampleInfoObject [ 'Collection Date' ] ) ? sampleInfoObject [ 'Collection Date' ] : sampleInfoObject . collectionDate ,
69- } ,
70- ) ;
71- }
72- req . body . sampleInfo = cleanSampleInfo ;
57+ req . body . sampleInfo = cleanSampleInfo ( req . body . sampleInfo ) ;
58+ }
59+
60+ if ( req . body . seqQC ) {
61+ req . body . seqQC = cleanSeqQC ( req . body . seqQC ) ;
7362 }
7463
7564 try {
@@ -380,29 +369,16 @@ router.route('/')
380369 }
381370
382371 if ( req . body . sampleInfo ) {
383- // Clean sampleInfo input
384- const cleanSampleInfo = [ ] ;
385- for ( const sampleInfoObject of req . body . sampleInfo ) {
386- cleanSampleInfo . push (
387- {
388- sample : ( sampleInfoObject . Sample ) ? sampleInfoObject . Sample : sampleInfoObject . sample ,
389- pathoTc : ( sampleInfoObject [ 'Patho TC' ] ) ? sampleInfoObject [ 'Patho TC' ] : sampleInfoObject . pathoTc ,
390- biopsySite : ( sampleInfoObject [ 'Biopsy Site' ] ) ? sampleInfoObject [ 'Biopsy Site' ] : sampleInfoObject . biopsySite ,
391- biopsyType : ( sampleInfoObject [ 'Biopsy Type' ] ) ? sampleInfoObject [ 'Biopsy Type' ] : sampleInfoObject . biopsyType ,
392- sampleName : ( sampleInfoObject [ 'Sample Name' ] ) ? sampleInfoObject [ 'Sample Name' ] : sampleInfoObject . sampleName ,
393- primarySite : ( sampleInfoObject [ 'Primary Site' ] ) ? sampleInfoObject [ 'Primary Site' ] : sampleInfoObject . primarySite ,
394- collectionDate : ( sampleInfoObject [ 'Collection Date' ] ) ? sampleInfoObject [ 'Collection Date' ] : sampleInfoObject . collectionDate ,
395- } ,
396- ) ;
397- }
398- req . body . sampleInfo = cleanSampleInfo ;
372+ req . body . sampleInfo = cleanSampleInfo ( req . body . sampleInfo ) ;
399373 }
400374
401375 if ( req . body . seqQC ) {
376+ req . body . seqQC = cleanSeqQC ( req . body . seqQC ) ;
377+
402378 req . body . dataType = req . body . seqQC . filter (
403- ( item ) => { return item . Sample ?. startsWith ( 'Tumour' ) ; } ,
379+ ( item ) => { return item . sample ?. startsWith ( 'Tumour' ) ; } ,
404380 ) . map (
405- ( item ) => { return item . Sample . replace ( / ^ T u m o u r \s + / i, '' ) ; } ,
381+ ( item ) => { return item . sample . replace ( / ^ T u m o u r \s + / i, '' ) ; } ,
406382 ) . join ( ', ' ) ;
407383 }
408384
0 commit comments