From 5aec754e88ff0c4bfa29ce83a75654ceb054dec0 Mon Sep 17 00:00:00 2001 From: nanli-emory Date: Fri, 5 Apr 2024 10:23:58 -0400 Subject: [PATCH] has series status and check series based on slides status --- apps/dicom-connect/table.css | 20 +++- apps/dicom-connect/table.js | 191 +++++++++++++++++++++++++++-------- 2 files changed, 170 insertions(+), 41 deletions(-) diff --git a/apps/dicom-connect/table.css b/apps/dicom-connect/table.css index 60b99f205..786b61235 100644 --- a/apps/dicom-connect/table.css +++ b/apps/dicom-connect/table.css @@ -235,8 +235,26 @@ nav li:not(.active):hover{ margin-bottom: 0; } +.icon-center { + text-align: center!important +} /* .main-container { max-height: calc(100% - 199px); overflow-x: hidden; overflow-y: auto; -} */ \ No newline at end of file +} */ + +.loader { + -webkit-animation: spin 2s linear infinite; + animation: spin 2s linear infinite; +} + +@-webkit-keyframes spin { + 0% { -webkit-transform: rotate(0deg); } + 100% { -webkit-transform: rotate(360deg); } +} + +@keyframes spin { + 0% { transform: rotate(0deg); } + 100% { transform: rotate(360deg); } +} \ No newline at end of file diff --git a/apps/dicom-connect/table.js b/apps/dicom-connect/table.js index 37ad3fe3f..050f80295 100644 --- a/apps/dicom-connect/table.js +++ b/apps/dicom-connect/table.js @@ -2,16 +2,21 @@ * static variables */ -const sources = { - 'j4care': 'https://development.j4care.com:11443/dcm4chee-arc/aets/DCM4CHEE/rs', - 'dicomweb': 'https://dicomwebproxy-bqmq3usc3a-uc.a.run.app/dicomWeb' -} +const sources = [{ + 'name':'j4care', + 'url':'https://development.j4care.com:11443/dcm4chee-arc/aets/DCM4CHEE/rs' + +},{ + 'name': 'google', + 'url': 'https://dicomwebproxy-bqmq3usc3a-uc.a.run.app/dicomWeb' +}] // const j4careStudiesUrl = 'https://development.j4care.com:11443/dcm4chee-arc/aets/DCM4CHEE/rs' // const dicomWebStudiesUrl = 'https://dicomwebproxy-bqmq3usc3a-uc.a.run.app/dicomWeb' /** * global variables */ +isAllSeriesSynced = false; const datatableConfig = { scrollX: true, @@ -23,6 +28,16 @@ const datatableConfig = { const page_states = { + sources: { + data: [{ + 'name':'j4care', + 'url':'https://development.j4care.com:11443/dcm4chee-arc/aets/DCM4CHEE/rs' + + },{ + 'name': 'google', + 'url': 'https://dicomwebproxy-bqmq3usc3a-uc.a.run.app/dicomWeb' + }], + }, studies: { data: null, }, @@ -32,7 +47,7 @@ const page_states = { instances: { data: null, }, - status: 'studies', // 'studies, series, instsances' + status: 'sources', // 'sources, studies, series, instsances' } var studies = [] @@ -72,17 +87,17 @@ function sanitize(string) { } - function initialize() { const params = getUrlVars(); console.log('params') console.log(params) - - if(params.status=='series'&¶ms.studyId) { // series table + // store + const store = new Store('../../../data/'); + if(params.status=='studies'&¶ms.source){ page_states.status = params.status; - - - } else if(params.status=='instances'&¶ms.studyId&¶ms.seriesId) { // isntasnces table + }else if(params.status=='series'&¶ms.source&¶ms.studyId) { // series table + page_states.status = params.status; + } else if(params.status=='instances'&¶ms.source&¶ms.studyId&¶ms.seriesId) { // isntasnces table page_states.status = params.status; } @@ -92,28 +107,40 @@ function initialize() { // // switch (page_states.status) { + case 'sources': + $('#breadcrumb').append(``); + function generateLink (data, type, row) { + return `${row.name}`; + } + datatable = $('#datatable').DataTable({ + ... datatableConfig, + 'data': page_states[page_states.status].data, + 'columns': [ + {data: 'name', title: 'Name', render:generateLink} + ] + }); + + break; case 'studies': + + //get source info + var idx = sources.findIndex(elt=>elt.name==params.source) + var src = sources[idx] + // create breadcrumb for studies - $('#breadcrumb').append(``); + $('#breadcrumb').append(``); + $('#breadcrumb').append(``); // get all studies - const Promises = []; - Promises.push(getStudies(sources.j4care)); - Promises.push(getStudies(sources.dicomweb)); - Promise.all(Promises) - .then(function(data) { - // get studies from j4care and dicomweb - const j4careStudies = data[0]; - const dicomWebStudies = data[1]; - + + getStudies(src.url).then(function(data) { // mapping and merge - j4careStudies.forEach(elt=>elt.source='j4care') - dicomWebStudies.forEach(elt=>elt.source='dicomweb') - page_states[page_states.status].data = [...j4careStudies, ...dicomWebStudies]//studiesTransformer([...j4careStudies, ...dicomWebStudies]) + data.forEach(elt=>elt.source=src.name) + page_states[page_states.status].data = data // ${baseUrl}/studies/${studyId}/series function generateLink (data, type, row) { const studyId = row['0020000D']['Value'][0] - return `${studyId}`; + return `${studyId}`; } datatable = $('#datatable').DataTable({ ... datatableConfig, @@ -128,66 +155,137 @@ function initialize() { break; case 'series': + //get source info + var idx = sources.findIndex(elt=>elt.name==params.source) + var src = sources[idx] + // create breadcrumb for series - $('#breadcrumb').append(``); + $('#breadcrumb').append(``); + $('#breadcrumb').append(``); $('#breadcrumb').append(``); // get all series - getSeries(sources[params.source], params.studyId).then(function(data) { + + + getSeries(src.url, params.studyId).then(function(data) { // add source and study id data.forEach(elt=>{ - elt.source=params.source + elt.source=src.name elt.studyId=params.studyId - + elt.status='loading' // 'loading', 'unsync', 'syncing', 'done' }) page_states[page_states.status].data = data function generateLink (data, type, row) { const seriesId = row['0020000E']['Value'][0] - return `${seriesId}`; + if (row.status !='done') return seriesId + return `${seriesId}`; } - console.log(data) + function generateStatus (data, type, row) { + switch (row.status) { + case 'loading': + // return spin + return '
'; + case 'unsync': + // return btn + const seriesId = row['0020000E']['Value'][0] + return `
`; + case 'syncing': + // return downloading + // return '
'; + return `
` + case 'done': + // return url + + return '
'; + + default: + + return '
'; + } + } datatable = $('#datatable').DataTable({ ... datatableConfig, 'data': page_states[page_states.status].data, 'columns': [ - {data: '0020000E.Value.0', title: 'Series Id', render: generateLink}, + {data: 'status', title: 'Status', render: generateStatus}, + {data: '0020000E.Value.0', title: 'Series Id',render:generateLink }, {data: '00080060.Value.0', title: 'Modality'}, {data: 'source', title: 'Source'}, {data: 'studyId', title: 'study Id'} ] - }); + }); + + // set interval to check series status + var updateSeriesStatus = setInterval(async function() { + // get slides status + const query = { + 'dicomSource': params.source, + } + // ('dicomSource', 'study', 'series', 'instance' + const slides = await store.findSlide(null, null, params.studyId, null, query) + // update series data + datatable.data().each(function (d) { + d['0020000E']['Value'][0] + const idx = slides.findIndex(slide=>d['0020000E']['Value'][0]==slide.series) + if (idx!=-1) { + d.status = slides[idx].dicomSync + } + }); + + // invalidate all rows and redraw + datatable.rows().invalidate().draw(); + const series = page_states[page_states.status].data + if (series.map(s=>s.status).every(status=>status!='unsync'&&status!='syncing')) { // clear interval if all synced + console.log('clear'); + clearInterval(updateSeriesStatus); + } + console.log('running') + }, 1000); }) break; case 'instances': + //get source info + var idx = sources.findIndex(elt=>elt.name==params.source) + var src = sources[idx] // create breadcrumb for instances const backSeriesUrl = `../dicom-connect/table.html?source=${params.source}&status=series&studyId=${params.studyId}` - $('#breadcrumb').append(``); + $('#breadcrumb').append(``); + $('#breadcrumb').append(``); $('#breadcrumb').append(``); $('#breadcrumb').append(``); - getInstances(sources[params.source], params.studyId, params.seriesId).then(function(data) { - console.log(data) + + + + + getInstances(src.url, params.studyId, params.seriesId).then(function(data) { + // add status data.forEach(elt=>{ elt.source=params.source elt.studyId=params.studyId elt.seriesId=params.seriesId + }) + console.log(data) page_states[page_states.status].data = data function generateLink (data, type, row) { - const {studyId, seriesId, source}= row + const {studyId, seriesId, status}= row const instanceId = row['00080018']['Value'][0] - return `${instanceId}`; + if (status=='done') return instanceId + return `${instanceId}`; } + datatable = $('#datatable').DataTable({ ... datatableConfig, 'data': page_states[page_states.status].data, 'columns': [ - {data: '0020000D.Value.0', title: 'Instance Id', render: generateLink}, + {data: '00080018.Value.0', title: 'Instance Id', render: generateLink}, {data: 'source', title: 'Source'}, {data: 'seriesId', title: 'Series Id'}, - {data: 'studyId', title: 'study Id'} + {data: 'studyId', title: 'Study Id'}, + ] }); }) @@ -202,3 +300,16 @@ function initialize() { $(document).ready(function() { initialize(); }); + + +function syncSeries(source, studyId, seriesId) { + console.log(`syncSeries: ${source}, ${studyId}, ${seriesId}`) +} + +function checkSeriesStatus() { + const series = page_states[page_states.status].data + series.map() + +} +// table.rows.add( dataset ).draw(). +