@@ -4,48 +4,63 @@ function setupDicomForm(patientDict, callback) {
44 const studySelect = document . getElementById ( "studySelect" )
55 const serieSelect = document . getElementById ( "serieSelect" )
66
7- patientSelect . length = 1 ; // remove all options bar first
8- const patients = Array . from ( patientDict . values ( ) )
9- patientDict . forEach ( ( patient ) => {
7+ // Remove options
8+ var patients = [ ]
9+ var studies = [ ]
10+ var series = [ ]
11+ patientSelect . length = 1 ;
12+
13+ // Add patients
14+ for ( const key in patientDict ) {
15+ const patient = patientDict [ key ]
16+ patients . push ( patient )
1017 const value = patient . patientName + " - " + patient . patientDateOfBirth
1118 patientSelect . options [ patientSelect . options . length ] = new Option ( value , value ) ;
12- } )
19+ }
1320
1421 patientSelect . onchange = function ( ) {
15- studySelect . length = 1 ; // remove all options bar first
16- serieSelect . length = 1 ; // remove all options bar first
22+ // Remove options
23+ studies = [ ]
24+ series = [ ]
25+ studySelect . length = 1 ;
26+ serieSelect . length = 1 ;
27+
1728 if ( this . selectedIndex < 1 ) return ; // done
29+
30+ // Add underneath studies
1831 const patientId = this . selectedIndex - 1
1932 const patient = patients [ patientId ]
20- patient . studyDict . forEach ( ( study ) => {
33+ for ( const key in patient . studyDict ) {
34+ const study = patient . studyDict [ key ]
35+ studies . push ( study )
2136 const value = study . studyDescription + " - " + study . studyDate
2237 studySelect . options [ studySelect . options . length ] = new Option ( value , value ) ;
23- } )
38+ }
2439 }
2540 patientSelect . onchange ( ) ; // reset in case page is reloaded
2641
2742 studySelect . onchange = function ( ) {
28- serieSelect . length = 1 ; // remove all options bar first
43+ // Remove options
44+ series = [ ]
45+ serieSelect . length = 1 ;
46+
2947 if ( this . selectedIndex < 1 ) return ; // done
30- const patientId = patientSelect . selectedIndex - 1
31- const patient = patients [ patientId ]
32- const studies = Array . from ( patient . studyDict . values ( ) )
48+
49+ // Add underneath series
3350 const studyId = this . selectedIndex - 1
3451 const study = studies [ studyId ]
35- study . serieDict . forEach ( ( serie ) => {
52+ for ( const key in study . serieDict ) {
53+ const serie = study . serieDict [ key ]
54+ series . push ( serie )
3655 const value = serie . seriesDescription + " - " + serie . seriesModality
3756 serieSelect . options [ serieSelect . options . length ] = new Option ( value , value ) ;
38- } )
57+ }
3958 }
4059
4160 serieSelect . onchange = function ( ) {
4261 if ( this . selectedIndex < 1 ) return ; // done
43- const patientId = patientSelect . selectedIndex - 1
44- const patient = patients [ patientId ]
45- const studies = Array . from ( patient . studyDict . values ( ) )
46- const studyId = studySelect . selectedIndex - 1
47- const study = studies [ studyId ]
48- const series = Array . from ( study . serieDict . values ( ) )
62+
63+ // Return files for serie
4964 const serieId = this . selectedIndex - 1
5065 const serie = series [ serieId ]
5166 callback ( serie . files )
0 commit comments