@@ -195,7 +195,7 @@ const MapProject = () => {
195195 const [ repo , setRepo ] = React . useState ( false )
196196 const [ repoVersion , setRepoVersion ] = React . useState ( false )
197197 const [ mappedSources , setMappedSources ] = React . useState ( [ ] )
198- const [ CIELMappedSources , setCIELMappedSources ] = React . useState ( [ ] )
198+ const [ bridgeMappedSources , setBridgeMappedSources ] = React . useState ( { } )
199199 const [ locales , setLocales ] = React . useState ( [ ] )
200200 const [ isLoadingLocales , setIsLoadingLocales ] = React . useState ( false )
201201 const [ versions , setVersions ] = React . useState ( [ ] )
@@ -239,7 +239,8 @@ const MapProject = () => {
239239 const canScispacy = Boolean ( canBridge && SCISPACY_API_URL && toggles . SCISPACY_LOINC_TOGGLE === true )
240240 const isMultiAlgo = algosSelected . length > 1
241241 const scispacyEnabled = find ( algosSelected , { type : 'ocl-scispacy' } )
242- const bridgeEnabled = find ( algosSelected , { type : 'ocl-ciel-bridge' } )
242+ const bridgeAlgo = find ( algosSelected , a => [ 'ocl-bridge' , 'ocl-ciel-bridge' ] . includes ( a . type ) )
243+ const bridgeEnabled = Boolean ( bridgeAlgo )
243244
244245 const baseAlgos = useAlgos ( t , toggles )
245246 const [ apiAlgos , setApiAlgos ] = React . useState ( [ ] ) ;
@@ -257,8 +258,12 @@ const MapProject = () => {
257258 const response = await service . get ( ) ;
258259 const _algos = response ?. data ?. results || [ ]
259260 setApiAlgos ( _algos ) ;
260- if ( find ( _algos , { type : 'ocl-ciel-bridge' } ) )
261- fetchMappedSources ( '/orgs/CIEL/sources/CIEL/latest/' , setCIELMappedSources )
261+ const bridgeAlgoFromApi = find ( _algos , a => [ 'ocl-bridge' , 'ocl-ciel-bridge' ] . includes ( a . type ) )
262+ if ( bridgeAlgoFromApi ) {
263+ const bridgeUrl = bridgeAlgoFromApi . target_repo_url || '/orgs/CIEL/sources/CIEL/'
264+ fetchMappedSources ( bridgeUrl + 'latest/' , sources =>
265+ setBridgeMappedSources ( prev => ( { ...prev , [ bridgeUrl ] : sources } ) ) )
266+ }
262267 } catch {
263268 // pass
264269 }
@@ -1224,7 +1229,7 @@ const MapProject = () => {
12241229 forEach ( _selectedAlgos , algo => {
12251230 if ( [ 'custom' , 'ocl-search' , 'ocl-semantic' ] . includes ( algo . type ) )
12261231 algoPromises . push ( processWithConcurrency ( repo , algo , rowsToProcess ) ) ;
1227- else if ( algo . type === 'ocl-ciel-bridge' && canBridge )
1232+ else if ( [ 'ocl-bridge' , 'ocl-ciel-bridge' ] . includes ( algo . type ) && canBridge )
12281233 algoPromises . push ( fetchBulkBridgeCandidates ( rowsToProcess , algo ) )
12291234 else if ( algo . type === 'ocl-scispacy' && canScispacy )
12301235 algoPromises . push ( fetchBulkScispacyCandidates ( rowsToProcess , algo ) )
@@ -1485,7 +1490,7 @@ const MapProject = () => {
14851490 const getBulkBridgeCandidatesButtonLabel = ( ) => {
14861491 const effectiveEnd = loadingMatches ? _now : bridgeCandidatesEndedAt ;
14871492 const matchingDuration = getMatchingDuration ( bridgeCandidatesStartedAt , effectiveEnd )
1488- if ( loadingMatches || allCandidatesRef . current [ 'ocl-ciel- bridge'] ?. length )
1493+ if ( loadingMatches || Object . keys ( allCandidatesRef . current ) . some ( k => k . includes ( ' bridge') && allCandidatesRef . current [ k ] ?. length ) )
14891494 return `${ t ( 'map_project.bridge_candidates' ) } (${ matchingDuration } )`
14901495 return t ( 'map_project.bridge_candidates' )
14911496 }
@@ -1704,7 +1709,7 @@ const MapProject = () => {
17041709 __candidates = times ( CANDIDATES_LIMIT , i => __candidates [ i ] )
17051710 forEach ( __candidates , ( candidate , i ) => {
17061711 if ( candidate ?. id ) {
1707- const isBridge = algoId === 'ocl-ciel- bridge'
1712+ const isBridge = algoId . includes ( ' bridge')
17081713 candidates [ `__result_${ algoKey } _${ twoDigit ( i + 1 ) } __` ] = candidate ?. id ?
17091714 (
17101715 isBridge ?
@@ -2135,7 +2140,7 @@ const MapProject = () => {
21352140 fetchOCLOrCustomCandidates ( algoDef , _row , offset , _retired , _filters , onResponse )
21362141 } else if ( algoDef . type === 'ocl-scispacy' ) {
21372142 fetchScispacyCandidates ( __row , scrollToBottom , forceReload , false , onResponse )
2138- } else if ( algoDef . type === 'ocl-ciel-bridge' ) {
2143+ } else if ( [ 'ocl-bridge' , 'ocl-ciel-bridge' ] . includes ( algoDef . type ) ) {
21392144 fetchBridgeCandidates ( __row , offset , _retired , scrollToBottom , _filters , forceReload , false , onResponse )
21402145 }
21412146 } else {
@@ -2265,7 +2270,8 @@ const MapProject = () => {
22652270
22662271 const fetchBridgeCandidates = ( _row , offset = 0 , _retired , scrollToBottom , _filters , forceReload = false , isBulk = false , callback ) => {
22672272 let __row = isEmpty ( _row ) ? row : _row
2268- const existingCandidates = find ( allCandidatesRef . current [ 'ocl-ciel-bridge' ] , c => c . row . __index === __row . __index ) ?. results
2273+ const bridgeAlgoId = bridgeAlgo ?. id || 'ocl-ciel-bridge'
2274+ const existingCandidates = find ( allCandidatesRef . current [ bridgeAlgoId ] , c => c . row . __index === __row . __index ) ?. results
22692275 if ( ! isBulk && ! forceReload && offset === 0 && ! _retired && existingCandidates ?. length > 0 ) {
22702276 setTimeout ( ( ) => highlightTexts ( existingCandidates , null , false ) , 100 )
22712277 return
@@ -2284,8 +2290,8 @@ const MapProject = () => {
22842290 callback ( candidates , payload )
22852291 } ,
22862292 ( response , errorMsg ) => {
2287- markAlgo ( __row . __index , 'ocl-ciel-bridge' , - 2 )
2288- log ( { action : 'algo_failed' , extras : { algo : 'ocl-ciel-bridge' } } , __row . __index )
2293+ markAlgo ( __row . __index , bridgeAlgoId , - 2 )
2294+ log ( { action : 'algo_failed' , extras : { algo : bridgeAlgoId } } , __row . __index )
22892295 setAlert ( { message : response ?. detail || errorMsg , severity : 'error' } )
22902296 setIsLoadingInDecisionView ( false )
22912297 }
@@ -2296,7 +2302,7 @@ const MapProject = () => {
22962302 const algo = algoId ? getAlgoDef ( algoId ) : null
22972303 if ( algo ?. lookup_required && ( lookupConfig ?. url || repoVersion . url ) && candidates && isArray ( candidates ) && candidates . length ) {
22982304 candidates . forEach ( concept => {
2299- if ( algo . type === 'ocl-ciel-bridge' ) {
2305+ if ( [ 'ocl-bridge' , 'ocl-ciel-bridge' ] . includes ( algo . type ) ) {
23002306 forEach ( concept . mappings , mapping => {
23012307 lookupCode ( mapping . cascade_target_concept_code )
23022308 } )
@@ -2624,6 +2630,7 @@ const MapProject = () => {
26242630 isLoadingLocales = { isLoadingLocales }
26252631 bridgeEnabled = { bridgeEnabled }
26262632 canBridge = { canBridge }
2633+ isCoreUser = { isCoreUser }
26272634 canScispacy = { canScispacy }
26282635 scispacyEnabled = { scispacyEnabled }
26292636 setAIAssistantColumns = { setAIAssistantColumns }
@@ -2637,16 +2644,20 @@ const MapProject = () => {
26372644 return permissionDenied ? < Error403 /> : (
26382645 < div className = 'col-xs-12 padding-0' style = { { borderRadius : '10px' , width : 'calc(100vw - 32px)' } } >
26392646 {
2640- Boolean ( repoVersion ?. url ) && CIELMappedSources . length > 0 &&
2641- < BridgeMatch
2642- service = { getMatchAPIService ( ) }
2643- repo = { repoVersion }
2644- bridgeRepoURL = '/orgs/CIEL/sources/CIEL/'
2645- limit = { CANDIDATES_LIMIT }
2646- user = { user }
2647- ref = { bridgeRef }
2648- mappedRepoURLs = { CIELMappedSources . map ( source => source . url ) }
2649- />
2647+ ( ( ) => {
2648+ const bridgeUrl = bridgeAlgo ?. target_repo_url || '/orgs/CIEL/sources/CIEL/'
2649+ const mappedSrcs = bridgeMappedSources [ bridgeUrl ] || [ ]
2650+ return Boolean ( repoVersion ?. url ) && mappedSrcs . length > 0 &&
2651+ < BridgeMatch
2652+ service = { getMatchAPIService ( ) }
2653+ repo = { repoVersion }
2654+ bridgeRepoURL = { bridgeUrl }
2655+ limit = { CANDIDATES_LIMIT }
2656+ user = { user }
2657+ ref = { bridgeRef }
2658+ mappedRepoURLs = { mappedSrcs . map ( source => source . url ) }
2659+ />
2660+ } ) ( )
26502661 }
26512662 {
26522663 loadingProject &&
0 commit comments