@@ -6,6 +6,9 @@ import values from 'lodash/values'
66import isEmpty from 'lodash/isEmpty'
77import find from 'lodash/find'
88import get from 'lodash/get'
9+ import filter from 'lodash/filter'
10+ import keys from 'lodash/keys'
11+ import forEach from 'lodash/forEach'
912import compact from 'lodash/compact'
1013import MapButton from './MapButton'
1114import { URIToParentParams } from '../../common/utils'
@@ -21,6 +24,10 @@ const MappingDecisionResult = ({targetConcept, row, rowIndex, mapTypes, allMapTy
2124
2225 const getValue = field => {
2326 const col = find ( columns , col => col ?. label ?. toLowerCase ( ) == field . toLowerCase ( ) )
27+ return getValueFromColumn ( col , field )
28+ }
29+
30+ const getValueFromColumn = ( col , field ) => {
2431 let val
2532 if ( col ?. dataKey )
2633 val = row [ col . dataKey ]
@@ -29,13 +36,77 @@ const MappingDecisionResult = ({targetConcept, row, rowIndex, mapTypes, allMapTy
2936 return val
3037 }
3138
39+ const getLeftTitle = ( ) => {
40+ let title = ''
41+ const id = getValue ( 'ID' )
42+ const name = getValue ( 'name' )
43+ if ( id )
44+ title = `${ id } :`
45+ if ( name )
46+ title += name
47+ return title
48+ }
49+
50+ const getLeftMappings = ( ) => {
51+ let mappedCodes = { }
52+ filter ( columns , col => col ?. label ?. toLowerCase ( ) == 'Mapping: Code' . toLowerCase ( ) ) . forEach ( col => {
53+ const key = get ( keys ( col . targetSource ) , '0' ) || col . dataKey
54+ const value = getValueFromColumn ( col , '' )
55+ if ( value && key ) {
56+ if ( ! mappedCodes [ key ] )
57+ mappedCodes [ key ] = [ ]
58+ mappedCodes [ key ] . push ( value )
59+ }
60+ } )
61+ const mappings = getValue ( 'Mapping: List' )
62+ if ( mappings ) {
63+ mappings . split ( ',' ) . forEach ( combo => {
64+ let parts = combo . split ( ':' )
65+ const value = get ( parts , '1' )
66+ const key = get ( parts , '0' )
67+ if ( value && key ) {
68+ if ( ! mappedCodes [ key ] )
69+ mappedCodes [ key ] = [ ]
70+ mappedCodes [ key ] . push ( value )
71+ }
72+ } )
73+ }
74+ let mappedValues = [ ]
75+ forEach ( mappedCodes , ( code , source ) => {
76+ mappedValues . push ( `${ source } :${ code . join ( "," ) } ` )
77+ } )
78+
79+ return mappedValues . join ( ', ' )
80+ }
81+
82+ const getRightMappings = ( ) => {
83+ const { mappings } = targetConcept
84+ if ( mappings ?. length ) {
85+ let mappedCodes = { }
86+ forEach ( mappings , mapping => {
87+ if ( ! mappedCodes [ mapping . cascade_target_source_name ] )
88+ mappedCodes [ mapping . cascade_target_source_name ] = [ ]
89+ mappedCodes [ mapping . cascade_target_source_name ] . push ( mapping . cascade_target_concept_code )
90+ } )
91+ let mappedValues = [ ]
92+ forEach ( mappedCodes , ( code , source ) => {
93+ mappedValues . push ( `${ source } :${ code . join ( "," ) } ` )
94+ } )
95+
96+ return mappedValues . join ( ', ' )
97+ }
98+ }
99+
100+ const leftMappings = getLeftMappings ( )
101+ const rightMappings = getRightMappings ( )
102+
32103 return (
33104 < div className = 'col-xs-12 padding-0' style = { { display : 'flex' , margin : '8px 0' , justifyContent : 'space-between' } } >
34105 < div style = { { maxWidth : '45%' } } >
35106 < Typography component = 'span' sx = { { color : 'rgba(0, 0, 0, 0.6)' , fontSize : '12px' } } > Source Code</ Typography >
36107 < div className = 'col-xs-12 padding-0' >
37108 < ListItemText
38- primary = { getValue ( 'Name' ) }
109+ primary = { getLeftTitle ( ) }
39110 secondary = {
40111 < span style = { { fontSize : '12px' } } >
41112 {
@@ -46,6 +117,10 @@ const MappingDecisionResult = ({targetConcept, row, rowIndex, mapTypes, allMapTy
46117 hasDatatype &&
47118 < > Datatype: < i > { getValue ( 'Property: Datatype' ) || getValue ( 'datatype' ) } </ i > </ >
48119 }
120+ {
121+ leftMappings &&
122+ < > < br /> Mappings: < i > { leftMappings } </ i > </ >
123+ }
49124 </ span >
50125 }
51126 sx = { { marginTop : 0 , '.MuiListItemText-secondary' : { marginTop : '-4px' } } }
@@ -69,6 +144,10 @@ const MappingDecisionResult = ({targetConcept, row, rowIndex, mapTypes, allMapTy
69144 < span className = 'searchable' style = { { fontSize : '12px' } } >
70145 Class: < i > { targetConcept . concept_class } </ i > ,
71146 Datatype: < i > { targetConcept . datatype } </ i >
147+ {
148+ rightMappings &&
149+ < > < br /> Mappings: < i > { rightMappings } </ i > </ >
150+ }
72151 </ span >
73152 }
74153 sx = { { marginTop : 0 , '.MuiListItemText-secondary' : { marginTop : '-4px' } } }
@@ -95,6 +174,7 @@ const MappingDecisionResult = ({targetConcept, row, rowIndex, mapTypes, allMapTy
95174 < span className = 'searchable' style = { { fontSize : '12px' } } >
96175 Class: < i > { getFieldFromProposed ( 'class' ) } </ i > ,
97176 Datatype: < i > { getFieldFromProposed ( 'datatype' ) } </ i >
177+
98178 </ span >
99179 }
100180 sx = { { marginTop : 0 , '.MuiListItemText-secondary' : { marginTop : '-4px' } } }
0 commit comments