From 51e46624619697f844cf6abbfc067288961fb2a2 Mon Sep 17 00:00:00 2001 From: cmadjar Date: Tue, 21 Feb 2023 15:35:40 -0500 Subject: [PATCH] removed tabs from mri violation module remove noDynamicDataTable fix the filter not working for resolution status update test plan --- .../mri_violations/jsx/mriViolationsIndex.js | 57 ++---- .../mri_violations/jsx/resolvedViolations.js | 190 ------------------ ...{unresolvedViolations.js => violations.js} | 81 +++++++- .../mri_violations/php/provisioner.class.inc | 17 +- .../php/resolved_violations.class.inc | 104 ---------- .../php/resolvedviolation.class.inc | 62 ------ .../resolvedviolationsprovisioner.class.inc | 125 ------------ modules/mri_violations/test/TestPlan.md | 22 +- 8 files changed, 105 insertions(+), 553 deletions(-) delete mode 100644 modules/mri_violations/jsx/resolvedViolations.js rename modules/mri_violations/jsx/{unresolvedViolations.js => violations.js} (72%) delete mode 100644 modules/mri_violations/php/resolved_violations.class.inc delete mode 100644 modules/mri_violations/php/resolvedviolation.class.inc delete mode 100644 modules/mri_violations/php/resolvedviolationsprovisioner.class.inc diff --git a/modules/mri_violations/jsx/mriViolationsIndex.js b/modules/mri_violations/jsx/mriViolationsIndex.js index 9240d84b4d1..8fdd235c8ec 100644 --- a/modules/mri_violations/jsx/mriViolationsIndex.js +++ b/modules/mri_violations/jsx/mriViolationsIndex.js @@ -1,12 +1,8 @@ -import {Tabs, TabPane} from 'Tabs'; import Loader from 'Loader'; import FilterableDataTable from 'FilterableDataTable'; import React, {useEffect, useState} from 'react'; -import {formatColumnUnresolved, unresolvedFilters} - from './unresolvedViolations.js'; -import {formatColumnResolved, resolvedFilters} - from './resolvedViolations.js'; +import {formatColumn, violationFilters} from './violations.js'; import ProtocolModal from './protocolModal.js'; @@ -20,10 +16,6 @@ import ProtocolModal from './protocolModal.js'; function MRIViolationsIndex(props) { const [fieldOptions, setFieldOptions] = useState({}); const [violationModal, setViolationModal] = useState(false); - const tabs = [ - {id: 'notresolved', label: 'Not Resolved'}, - {id: 'resolved', label: 'Resolved'}, - ]; const mapper = columnMapper(fieldOptions); @@ -35,33 +27,18 @@ function MRIViolationsIndex(props) { return
{violationsModal} - - - - - - - - +
; } @@ -106,7 +83,6 @@ function ViolationsTable(props) { fields={props.fields} getFormattedCell={props.formatter} getMappedCell={props.mapper} - noDynamicTable={props.noDynamicTable} />; } @@ -142,11 +118,8 @@ window.addEventListener('load', () => { root.render( + dataURL={`${loris.BaseURL}/mri_violations/?format=json`} + />, ); }); diff --git a/modules/mri_violations/jsx/resolvedViolations.js b/modules/mri_violations/jsx/resolvedViolations.js deleted file mode 100644 index 8bb0befd96a..00000000000 --- a/modules/mri_violations/jsx/resolvedViolations.js +++ /dev/null @@ -1,190 +0,0 @@ -/** - * Return a list of filter objects shared between tabs - * - * @param {object} fieldoptions - the dynamic field options - * @return {array} - */ -export function resolvedFilters(fieldoptions) { - return [ - { - label: 'Resolution Status', show: true, filter: { - name: 'resolutionStatus', - type: 'select', - options: { - 'reran': 'Reran', - 'emailed': 'emailed site/pending', - 'inserted': 'Inserted', - 'rejected': 'Rejected', - 'inserted_flag': 'Inserted with flag', - 'other': 'Other', - }, - }, - }, - { - label: 'Project', show: true, filter: { - name: 'project', - type: 'select', - options: fieldoptions.projects, - }, - }, - { - label: 'Cohort', show: true, filter: { - name: 'cohort', - type: 'select', - options: fieldoptions.cohorts, - }, - }, - { - label: 'Patient Name', show: true, filter: { - name: 'patientName', - type: 'text', - }, - }, - { - label: 'Site', show: true, filter: { - name: 'site', - type: 'select', - options: fieldoptions.sites, - }, - }, - { - label: 'Time Run', show: true, filter: { - name: 'timeRun', - type: 'date', - }, - }, - { - label: 'Image File', show: true, filter: { - name: 'mincFile', - type: 'text', - }, - }, - { - label: 'Series Description or Scan Type', show: true, filter: { - name: 'seriesOrType', - type: 'text', - }, - }, - { - label: 'Problem', show: true, filter: { - name: 'problem', - type: 'select', - options: { - 'CandID and PSCID do not match database': 'Candidate Mismatch', - 'Could not identify scan type': 'Could not identify scan type', - 'Protocol Violation': 'MRI Protocol Check violation', - }, - }, - }, - { - label: 'Series UID', show: false, filter: { - name: 'seriesUID', - type: 'text', - }, - }, - {label: 'hash', show: false}, - {label: 'JoinID', show: false}, - {label: 'SiteID', show: false}, - ]; -} - -/** - * Modify behaviour of specified column cells in the Data Table component - * - * @param {function} mapper - A data mapper for dynamic columns - * @param {function} setPage - a callback to set the current page - * @return {function} a formated table cell formatter - */ -export function formatColumnResolved(mapper, setPage) { - const Mapper = (column, cell, rowData, rowHeaders) => { - cell = mapper(column, cell); - // Create the mapping between rowHeaders and rowData in a row object. - const fontColor = {color: '#FFFFFF'}; - let resolutionStatusStyle; - let resolutionStatus; - - if (column === 'Problem' && cell === 'Protocol Violation') { - return ( - - setPage({ - ViolationType: 'protocolcheck', - PatientName: rowData['Patient Name'], - SeriesUID: rowData['Series UID'], - TarchiveID: rowData['TarchiveID'], - CandID: rowData.CandId, - }) - }>Protocol Violation - - ); - } - if ( - column === 'Problem' && - cell === 'Could not identify scan type' - ) { - const seriesDescription - = rowData['Series Description or Scan Type']; - return ( - - setPage({ - ViolationType: 'protocolviolation', - PatientName: rowData['Patient Name'], - SeriesUID: rowData['Series UID'], - TarchiveID: rowData['TarchiveId'], - CandID: rowData.CandID, - PSCID: rowData.PSCID, - TimeRun: rowData['Time Run'], - SeriesDescription: seriesDescription, - })}>Could not identify scan type - - ); - } - if (column === 'Resolution Status') { - switch (rowData['Resolution Status']) { - case 'unresolved': - resolutionStatusStyle = 'label-danger'; - resolutionStatus = 'Unresolved'; - break; - - case 'reran': - resolutionStatusStyle = 'label-success'; - resolutionStatus = 'Reran'; - break; - - case 'emailed': - resolutionStatusStyle = 'label-info'; - resolutionStatus = 'Emailed site/pending'; - break; - - case 'rejected': - resolutionStatusStyle = 'label-danger'; - resolutionStatus = 'Rejected'; - break; - - case 'inserted': - resolutionStatusStyle = 'label-warning'; - resolutionStatus = 'Inserted'; - break; - - case 'other': - resolutionStatusStyle = 'label-primary'; - resolutionStatus = 'Other'; - break; - - case 'inserted_flag': - resolutionStatusStyle = 'label-default'; - resolutionStatus = 'Inserted with flag'; - break; - } - - return ( - - {resolutionStatus} - - ); - } - return {cell}; - }; - return Mapper; -} diff --git a/modules/mri_violations/jsx/unresolvedViolations.js b/modules/mri_violations/jsx/violations.js similarity index 72% rename from modules/mri_violations/jsx/unresolvedViolations.js rename to modules/mri_violations/jsx/violations.js index a8f0bb720af..de7ed0ace9f 100644 --- a/modules/mri_violations/jsx/unresolvedViolations.js +++ b/modules/mri_violations/jsx/violations.js @@ -1,10 +1,10 @@ /** - * Return a list of filter objects shared between tabs + * Return a list of filter objects for the violation module. * * @param {object} fieldoptions - The dynamic field options * @return {array} */ -export function unresolvedFilters(fieldoptions) { +export function violationFilters(fieldoptions) { let problemtypes = {}; if (fieldoptions.problemtypes) { for (const ptype of fieldoptions.problemtypes) { @@ -64,6 +64,21 @@ export function unresolvedFilters(fieldoptions) { options: problemtypes, }, }, + { + label: 'Resolution Status', show: true, filter: { + name: 'resolutionStatus', + type: 'select', + options: { + 'unresolved': 'Unresolved', + 'reran': 'Reran', + 'emailed': 'emailed site/pending', + 'inserted': 'Inserted', + 'rejected': 'Rejected', + 'inserted_flag': 'Inserted with flag', + 'other': 'Other', + }, + }, + }, { label: 'Series UID', show: false, filter: { name: 'seriesUID', @@ -72,18 +87,17 @@ export function unresolvedFilters(fieldoptions) { }, {label: 'hash', show: false}, {label: 'JoinID', show: false}, - {label: 'Resolution Status', show: false}, {label: 'TarchiveID', show: false}, {label: 'CandID', show: false}, {label: 'PSCID', show: false}, - // Add fake column for dropdown - {label: 'Resolution Status', show: true}, + // Add fake column for resolution dropdown + {label: 'Select Resolution', show: true}, ]; } /** - * Returns a formatter to handle the unresolved violations + * Returns a formatter to handle the violations * * @param {function} mapper - a data mapper to map from ID to display * @param {function} setPage - a callback to set the current page @@ -91,10 +105,14 @@ export function unresolvedFilters(fieldoptions) { * a resolution status is selected * @return {function} a formatter callback which uses mapper for data mapping */ -export function formatColumnUnresolved(mapper, setPage, resolvePostURL) { +export function formatColumn(mapper, setPage, resolvePostURL) { const Mapper = function(column, cell, rowData, rowHeaders) { cell = mapper(column, cell); // Create the mapping between rowHeaders and rowData in a row object. + let fontColor = {color: '#FFFFFF'}; + let resolutionStatusStyle; + let resolutionStatus; + if (column === 'Type of Problem' && cell === 'Protocol Violation') { return ( @@ -133,19 +151,59 @@ export function formatColumnUnresolved(mapper, setPage, resolvePostURL) { ); } if (column === 'Resolution Status') { + switch (rowData['Resolution Status']) { + case 'unresolved': + fontColor = {color: '#000000'}; + resolutionStatus = 'Unresolved'; + break; + + case 'reran': + resolutionStatusStyle = 'label-success'; + resolutionStatus = 'Reran'; + break; + + case 'emailed': + resolutionStatusStyle = 'label-info'; + resolutionStatus = 'Emailed site/pending'; + break; + + case 'rejected': + resolutionStatusStyle = 'label-danger'; + resolutionStatus = 'Rejected'; + break; + + case 'inserted': + resolutionStatusStyle = 'label-warning'; + resolutionStatus = 'Inserted'; + break; + + case 'other': + resolutionStatusStyle = 'label-primary'; + resolutionStatus = 'Other'; + break; + + case 'inserted_flag': + resolutionStatusStyle = 'label-default'; + resolutionStatus = 'Inserted with flag'; + break; + } + return ( + + {resolutionStatus} + + ); + } + if (column === 'Select Resolution') { const hashName = rowData.hash; return (