Skip to content

Commit

Permalink
Imaging files removal (migrated in #7402)
Browse files Browse the repository at this point in the history
  • Loading branch information
laemtl committed Aug 16, 2021
1 parent 21703b0 commit ae38fa4
Show file tree
Hide file tree
Showing 15 changed files with 291 additions and 299 deletions.
5 changes: 3 additions & 2 deletions modules/conflict_resolver/jsx/conflictResolverIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,9 @@ window.addEventListener('load', () => {
);
// Prevent tab switching
const refresh = setInterval(function() {
if (document.getElementById('tab-ResolvedConflicts')) {
$('#tab-ResolvedConflicts').click(function(event) {
let resolvedTab = document.getElementById('tab-ResolvedConflicts');
if (resolvedTab) {
resolvedTab.addEventListener('click', function(event) {
event.preventDefault();
window.location.href = loris.BaseURL
+ '/conflict_resolver/resolved_conflicts/';
Expand Down
5 changes: 3 additions & 2 deletions modules/conflict_resolver/jsx/resolvedConflictsIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,9 @@ window.addEventListener('load', () => {
);
// Prevent tab switching
const refresh = setInterval(function() {
if (document.getElementById('tab-ResolvedConflicts')) {
$('#tab-UnresolvedConflicts').click(function(event) {
let unresolvedTab = document.getElementById('tab-UnresolvedConflicts');
if (unresolvedTab) {
unresolvedTab.addEventListener('click', function(event) {
event.preventDefault();
window.location.href = loris.BaseURL + '/conflict_resolver/';
return false;
Expand Down
49 changes: 39 additions & 10 deletions modules/conflict_resolver/php/conflict_resolver.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class Conflict_Resolver extends \NDB_Menu_Filter_Form
$TableName = $row['TableName'];

$Instrument = \NDB_BVL_Instrument::factory(
$this->loris,
$TableName,
$row['CommentId1'],
'',
Expand All @@ -154,6 +155,7 @@ class Conflict_Resolver extends \NDB_Menu_Filter_Form
}

$Instrument = \NDB_BVL_Instrument::factory(
$this->loris,
$TableName,
$row['CommentId2'],
'',
Expand Down Expand Up @@ -229,9 +231,6 @@ class Conflict_Resolver extends \NDB_Menu_Filter_Form
$this->query .= ' AND session.CenterID IN (' . $site_arr . ')';
}

$proj_arr = implode(",", $user->getProjectIDs());
$this->query .= " AND session.ProjectID IN ($proj_arr)";

$this->group_by = '';
$this->order_by = 'conflicts_unresolved.TableName, session.Visit_label';
$this->headers = [
Expand All @@ -257,6 +256,8 @@ class Conflict_Resolver extends \NDB_Menu_Filter_Form
function setup()
{
parent::setup();
// Create user object
$user = \NDB_Factory::singleton()->user();

// Get instruments
$instruments = \Utility::getAllInstruments();
Expand All @@ -265,17 +266,34 @@ class Conflict_Resolver extends \NDB_Menu_Filter_Form
$visits = \Utility::getVisitList();
$visits = array_merge(['' => 'All'], $visits);

// Get sites
if ($user->hasPermission('access_all_profiles')) {
// get the list of study sites - to be replaced by the Site object
$sites = \Utility::getSiteList();
foreach ($sites as $key => $site) {
unset($sites[$key]);
$sites[$site] = $site;
}
if (is_array($sites)) {
$sites = ['' => 'All'] + $sites;
}
} else {
// allow only to view own site data
$sites = $user->getStudySites();
foreach ($sites as $key => $site) {
unset($sites[$key]);
$sites[$site] = $site;
}
$sites = ['' => 'All User Sites'] + $sites;
}

$labelOptions = [
'addEmptyOption' => true,
'emptyOptionValue' => '',
];

// Add form elements
$this->addSelect(
'site',
'For Site:',
['' => 'All'] + $this->getSiteOptions(false)
);
$this->addSelect('site', 'For Site:', $sites);
$this->addSelect('instrument', 'Instrument:', $instruments, $labelOptions);
$this->addSelect('visitLabel', 'Visit label:', $visits);
$this->addBasicText(
Expand All @@ -297,7 +315,14 @@ class Conflict_Resolver extends \NDB_Menu_Filter_Form
]
);
$this->addBasicText('question', 'Question:');
$this->addSelect('project', 'Project: ', $this->getProjectOptions(false));

// Project list, if applicable
$list_of_projects = [];
$projectList = \Utility::getProjectList();
foreach (array_values($projectList) as $value) {
$list_of_projects[$value] = $value;
}
$this->addSelect('project', 'Project: ', $list_of_projects);
}

/**
Expand Down Expand Up @@ -383,8 +408,12 @@ class Conflict_Resolver extends \NDB_Menu_Filter_Form
$unanonymized = parent::toArray();
$data = [];

$value1Index = array_search('Value1', $unanonymized['Headers']);
$value2Index = array_search('Value2', $unanonymized['Headers']);
foreach ($unanonymized['Data'] as &$row) {
$data[] = $row;
$row[$value1Index] = str_replace('{@}', ', ', $row[$value1Index]);
$row[$value2Index] = str_replace('{@}', ', ', $row[$value2Index]);
$data[] = $row;
}
return [
'Headers' => $unanonymized['Headers'],
Expand Down
50 changes: 41 additions & 9 deletions modules/conflict_resolver/php/resolved_conflicts.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ class Resolved_Conflicts extends \NDB_Menu_Filter
$this->query .= ' AND session.CenterID IN (' . $site_arr . ')';
}

$proj_arr = implode(",", $user->getProjectIDs());
$this->query .= " AND session.ProjectID IN ($proj_arr)";

$this->group_by = '';
$this->order_by = 'conflicts_resolved.TableName, session.Visit_label';

Expand Down Expand Up @@ -110,6 +107,8 @@ class Resolved_Conflicts extends \NDB_Menu_Filter
function setup()
{
parent::setup();
// Create user object
$user = \NDB_Factory::singleton()->user();

// Get instruments
$instruments = \Utility::getAllInstruments();
Expand All @@ -118,17 +117,34 @@ class Resolved_Conflicts extends \NDB_Menu_Filter
$visits = \Utility::getVisitList();
$visits = array_merge(['' => 'All'], $visits);

// Get sites
if ($user->hasPermission('access_all_profiles')) {
// get the list of study sites - to be replaced by the Site object
$sites = \Utility::getSiteList();
foreach ($sites as $key => $site) {
unset($sites[$key]);
$sites[$site] = $site;
}
if (is_array($sites)) {
$sites = ['' => 'All'] + $sites;
}
} else {
// allow only to view own site data
$sites = $user->getStudySites();
foreach ($sites as $key => $site) {
unset($sites[$key]);
$sites[$site] = $site;
}
$sites = ['' => 'All User Sites'] + $sites;
}

$labelOptions = [
'addEmptyOption' => true,
'emptyOptionValue' => '',
];

// Add form elements
$this->addSelect(
'site',
'For Site:',
['' => 'All'] + $this->getSiteOptions(false)
);
$this->addSelect('site', 'For Site:', $sites);
$this->addSelect('instrument', 'Instrument:', $instruments, $labelOptions);
$this->addSelect('visitLabel', 'Visit label:', $visits);
$this->addBasicText(
Expand All @@ -151,7 +167,14 @@ class Resolved_Conflicts extends \NDB_Menu_Filter
);
$this->addBasicText('question', 'Question:');
$this->addBasicText('resolutionTimestamp', 'Resolution Timestamp:');
$this->addSelect('project', 'Project: ', $this->getProjectOptions(false));

// Project list, if applicable
$list_of_projects = [];
$projectList = \Utility::getProjectList();
foreach (array_values($projectList) as $value) {
$list_of_projects[$value] = $value;
}
$this->addSelect('project', 'Project: ', $list_of_projects);
}

/**
Expand Down Expand Up @@ -229,7 +252,16 @@ class Resolved_Conflicts extends \NDB_Menu_Filter
$unanonymized = parent::toArray();
$data = [];

$correctAnswerIndex = array_search(
'Correct Answer',
$unanonymized['Headers']
);
foreach ($unanonymized['Data'] as &$row) {
$row[$correctAnswerIndex] = str_replace(
'{@}',
', ',
$row[$correctAnswerIndex]
);
$data[] = $row;
}
return [
Expand Down
39 changes: 20 additions & 19 deletions modules/conflict_resolver/test/TestPlan.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
# Conflict Resolver Test Plan

1. Menu item and permissions [Automation Testing]
a) Menu item 'Clinical > Conflict Resolver' appears for users with permission 'Resolving conflicts'
b) Menu item loads the module page
c) Check for existence of 'Resolving conflicts' permission checkbox on 'User Accounts > Edit User'
Verify that the permission works as expected (hides menu item and blocks page access)
1. Menu item 'Clinical > Conflict Resolver' appears for users with permission 'Resolving conflicts'
2. Menu item loads the module page
3. Check for existence of 'Resolving conflicts' permission checkbox on 'User Accounts > Edit User'
Verify that the permission works as expected (hides menu item and blocks page access)
2. Verify the following conditions are required for creation of new unresolved conflict
to be instantiated in the module table:[Manual Testing]
a) Double data entry active on instrument
b) Instrument time-point must be entered twice
c) Mismatch of values on a given field
d) Candidate is not in 'Recycling Bin'
e) Instrument is marked Data Entry = 'Complete' for initial and double data entries
1. Double data entry active on instrument
2. Instrument time-point must be entered twice
3. Mismatch of values on a given field
4. Candidate is not in 'Recycling Bin'
5. Instrument is marked Data Entry = 'Complete' for initial and double data entries
3. Correct display of Unresolved conflicts:[Manual Testing]
a) Table displays list of unresolved conflicts
b) The 'Correct answer' field has dropdown menu containing a list of options for each row
c) Save & Reset buttons at bottom of table
d) Pagination [1 | 2 | 3 ...] appears at top and bottom when n > 20 and works, and maximum rows per page dropdown appears and works
e) Clicking on a column name sorts data properly
1. Table displays list of unresolved conflicts
2. The 'Correct answer' field has dropdown menu containing a list of options for each row
3. Save & Reset buttons at bottom of table
4. Pagination [1 | 2 | 3 ...] appears at top and bottom when n > 20 and works, and maximum rows per page dropdown appears and works
5. Clicking on a column name sorts data properly
4. Correct display of Resolved conflicts:[Manual Testing]
a) Use 'resolved conflicts' tab to switch views
b) Table displays resolved conflicts
c) Field 'Corrected answer' has a value
d) Pagination [1 | 2 | 3 ...] appears at top and bottom when n > 20 and works, and maximum rows per page dropdown appears and works
e) Clicking on a column name sorts data properly
1. Use 'resolved conflicts' tab to switch views
2. Table displays resolved conflicts
3. Field 'Corrected answer' has a value
4. Pagination [1 | 2 | 3 ...] appears at top and bottom when n > 20 and works, and maximum rows per page dropdown appears and works
5. Clicking on a column name sorts data properly
5. Filter for the specific parameter (Choose the one that applies):[Automation Testing]
- Select the right instrument from the 'All Instruments' drop-down
- Input the right DCCID
Expand Down Expand Up @@ -68,3 +68,4 @@
with the filters preset to filter for that instrument and visit
- Ensure that clicking on an instrument in the legend takes you to the conflict resolver
with the filter preset for that instrument (but no filter for visit)

21 changes: 11 additions & 10 deletions modules/conflict_resolver/test/conflict_resolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
use Facebook\WebDriver\WebDriverSelect;
use Facebook\WebDriver\WebDriverBy;
require_once __DIR__
require_once __DIR__
. "/../../../test/integrationtests/LorisIntegrationTest.class.inc";
/**
* Implements tests for conflict resolver
Expand Down Expand Up @@ -52,6 +52,7 @@ class ConflictResolverTestIntegrationTest extends LorisIntegrationTest
function setUp(): void
{
parent::setUp();
$this->setUpConfigSetting("useProjects", "true");
}
/**
* Delete testing data from database
Expand All @@ -62,6 +63,7 @@ function setUp(): void
function tearDown(): void
{
parent::tearDown();
$this->restoreConfigSetting("useProjects");
// if data not exist then insert the origin test data
$CommentId1 = $this->DB->pselectOne(
'SELECT CommentId1 FROM conflicts_unresolved
Expand Down Expand Up @@ -118,7 +120,6 @@ function testConflictResolverPermission()
function testFiltersForUnresolvedConflicts()
{
$this->safeGet($this->url . "/conflict_resolver/");

//testing data
$this->_filterTest(
self::$ForSite,
Expand All @@ -132,7 +133,7 @@ function testFiltersForUnresolvedConflicts()
self::$display,
self::$clearFilter,
'V1',
"displayed of 573"
"displayed of 576"
);
$this->_filterTest(
self::$CandID,
Expand All @@ -153,7 +154,7 @@ function testFiltersForUnresolvedConflicts()
self::$display,
self::$clearFilter,
'height_inches',
"displayed of 180"
"displayed of 181"
);
$this->_filterTest(
self::$Project,
Expand Down Expand Up @@ -184,7 +185,7 @@ function testFiltersForResolvedConflicts()
self::$display,
self::$clearFilter,
"V1",
"displayed of 32"
"displayed of 33"
);
$this->_filterTest(
self::$CandID,
Expand All @@ -205,7 +206,7 @@ function testFiltersForResolvedConflicts()
self::$display,
self::$clearFilter,
'date_taken',
"8 rows"
"9 rows"
);
$this->_filterTest(
self::$Timestamp,
Expand All @@ -229,9 +230,9 @@ function testSaveUnresolvedToResolved()
$this->url .
"/conflict_resolver/?candidateID=475906&instrument=radiology_review"
);
$element = "tr:nth-child(1) .form-control";
$btn = self::$saveBtn;
$row = self::$display;
$element = "tr:nth-child(1) .form-control";
$btn = self::$saveBtn;
$row = self::$display;
$el_dropdown = new WebDriverSelect(
$this->safeFindElement(WebDriverBy::cssSelector("$element"))
);
Expand All @@ -242,6 +243,6 @@ function testSaveUnresolvedToResolved()
WebDriverBy::cssSelector($row)
)->getText();
// 4 means there are 4 records under this site.
$this->assertStringContainsString("of 572", $bodyText);
$this->assertStringContainsString("of 575", $bodyText);
}
}
Loading

0 comments on commit ae38fa4

Please sign in to comment.