@@ -23,10 +23,10 @@ import DialogTitle from '@material-ui/core/DialogTitle';
2323import Button from '@material-ui/core/Button' ;
2424import Grid from '@material-ui/core/Grid' ;
2525import CdiscLibraryContext from 'constants/cdiscLibraryContext.js' ;
26- import getCodeListData from 'utils/getCodeListData.js' ;
2726import Loading from 'components/utils/loading.js' ;
2827import SearchInTable from 'components/utils/searchInTable.js' ;
2928import GeneralTable from 'components/utils/generalTable.js' ;
29+ import { getGeneralTableDataFromCodeList } from 'utils/codeListUtils.js' ;
3030import { dummyRequest } from 'utils/cdiscLibraryUtils.js' ;
3131import { getDecode } from 'utils/defineStructureUtils.js' ;
3232import {
@@ -141,54 +141,6 @@ const loadFromStdCodeList = (codeLists, codeListOid) => {
141141 } ;
142142} ;
143143
144- const loadFromCodeLists = ( codeLists , codeListOid , defineVersion ) => {
145- let codeList = codeLists [ codeListOid ] ;
146- let codeListType = codeList . codeListType ;
147- let data = [ ] ;
148- let header = [ ] ;
149-
150- let codeListTable , codeListTitle , isDecoded , isRanked , isCcoded ;
151- if ( codeList ) {
152- if ( codeList . codeListType === 'external' ) {
153- codeListTitle = codeList . name ;
154- header = [
155- { id : 'dictionary' , label : 'Dictionary' , key : true } ,
156- { id : 'version' , label : 'Version' } ,
157- { id : 'ref' , label : 'Ref' } ,
158- { id : 'Href' , label : 'Href' } ,
159- ] ;
160- data . push ( codeList . externalCodeList ) ;
161- } else {
162- ( { codeListTable, codeListTitle, isDecoded, isRanked, isCcoded } = getCodeListData ( codeList , defineVersion ) ) ;
163- data = codeListTable ;
164-
165- header = [
166- { id : 'oid' , label : 'oid' , hidden : true , key : true } ,
167- { id : 'value' , label : 'Coded Value' } ,
168- ] ;
169-
170- if ( isDecoded === true ) {
171- header . push ( { id : 'decode' , label : 'Decode' } ) ;
172- }
173-
174- if ( isCcoded === true ) {
175- header . push ( { id : 'ccode' , label : 'C-Code' } ) ;
176- }
177-
178- if ( isRanked === true ) {
179- header . push ( { id : 'rank' , label : 'Rank' } ) ;
180- }
181- }
182- }
183-
184- return {
185- codeListTitle,
186- codeListType,
187- data,
188- header,
189- } ;
190- } ;
191-
192144const ModalCodeListTable = ( props ) => {
193145 const dispatch = useDispatch ( ) ;
194146 let classes = getStyles ( ) ;
@@ -252,7 +204,7 @@ const ModalCodeListTable = (props) => {
252204 } else {
253205 codeLists = odm . study . metaDataVersion . codeLists ;
254206 let defineVersion = odm . study . metaDataVersion . defineVersion ;
255- setTableData ( loadFromCodeLists ( codeLists , props . codeListOid , defineVersion ) ) ;
207+ setTableData ( getGeneralTableDataFromCodeList ( codeLists [ props . codeListOid ] , defineVersion ) ) ;
256208 }
257209 }
258210 } , [ props , odm , stdCodeLists , cl , retry ] ) ;
0 commit comments