@@ -1209,21 +1209,21 @@ const DictApp = (function () {
12091209 return ;
12101210 }
12111211
1212- // Group by source system for per-system CSV files
1213- var bySource = { } ;
1214- matchingData . forEach ( function ( row ) {
1215- var src = row . _source || 'cdw' ;
1216- if ( ! bySource [ src ] ) bySource [ src ] = [ ] ;
1217- bySource [ src ] . push ( row ) ;
1218- } ) ;
1219-
12201212 var desiredCount = matchingData . filter ( function ( r ) { return r . desired ; } ) . length ;
12211213 var totalCount = matchingData . length ;
12221214
12231215 // 1. Download the data CSV(s)
1224- if ( type === 'dx' ) {
1225- var result = CsvDownload . download ( matchingData , 'dx' , null , projectName , false ) ;
1216+ // dx and medication use a single combined file; other types split by source system
1217+ if ( type === 'dx' || type === 'medication' ) {
1218+ var result = CsvDownload . download ( matchingData , type , null , projectName , false ) ;
12261219 } else {
1220+ // Group by source system for per-system CSV files
1221+ var bySource = { } ;
1222+ matchingData . forEach ( function ( row ) {
1223+ var src = row . _source || 'cdw' ;
1224+ if ( ! bySource [ src ] ) bySource [ src ] = [ ] ;
1225+ bySource [ src ] . push ( row ) ;
1226+ } ) ;
12271227 var results = CsvDownload . downloadAll ( bySource , type , projectName , false ) ;
12281228 }
12291229
@@ -1249,7 +1249,7 @@ const DictApp = (function () {
12491249 }
12501250
12511251 // 3. Toast summary
1252- if ( type === 'dx' ) {
1252+ if ( type === 'dx' || type === 'medication' ) {
12531253 if ( result ) {
12541254 var msg = 'Downloaded ' + result . filename + ' (' + totalCount + ' rows, ' + desiredCount + ' marked desired)' ;
12551255 if ( keywords . length > 0 ) msg += ' + search-terms manifest' ;
0 commit comments