Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Instrument] Rename Data_entry_completion_status & move to its own column in flag #6876

Merged
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
bb42927
Move Data_entry_completion_status to its own column in flag
CamilleBeau Jul 29, 2020
be188ef
Code convention
CamilleBeau Jul 29, 2020
5b291f9
Fix order
CamilleBeau Jul 29, 2020
721652e
Changelog
CamilleBeau Aug 13, 2020
87ea93f
Reforming
CamilleBeau Aug 13, 2020
bed3b12
bugfix
CamilleBeau Aug 13, 2020
80042c9
Address dave's comment & phpcbf
CamilleBeau Aug 18, 2020
e7b1cdb
Fixing, add remode column script, adding rb changes
CamilleBeau Aug 25, 2020
b2ba6c4
Accidental RB changes
CamilleBeau Sep 1, 2020
788dd13
Test + imaging_qc query
CamilleBeau Sep 2, 2020
59acb48
testtest remove column
CamilleBeau Sep 2, 2020
d8742b5
Test + null Data values
CamilleBeau Sep 9, 2020
1372d93
travis fail 'Equals sign not aligned correctly'
CamilleBeau Sep 22, 2020
24ce9ef
fix unit test
kongtiaowang Sep 18, 2020
a3c7188
Nonstatic instrument data
CamilleBeau Nov 25, 2020
c99ccd4
phpcs fixes
CamilleBeau Nov 25, 2020
21b0b4d
travis fix expected values
CamilleBeau Nov 25, 2020
92df8c7
Remove field from test data
CamilleBeau Nov 25, 2020
aa15811
Spacing
CamilleBeau Nov 25, 2020
b3d2f40
Adding back data_entry_completion_status to array
CamilleBeau Nov 26, 2020
ba4d3e6
Addressing Ridas comments. Still todo: conflict resolver tables
CamilleBeau Dec 7, 2020
b13cdf1
rm print statement + edit query imaging_qc
CamilleBeau Dec 7, 2020
1f8d469
delete from conflict resolver tables
CamilleBeau Dec 8, 2020
41fcee8
call to db typo
CamilleBeau Dec 8, 2020
4d41456
rename column
CamilleBeau Dec 17, 2020
ac1fc21
Add RB changes + replace functions
CamilleBeau Dec 17, 2020
7dfaf85
code convention changes
CamilleBeau Dec 17, 2020
3dfddea
Typo in default val
CamilleBeau Dec 17, 2020
814ba4d
Update php/libraries/NDB_BVL_Instrument.class.inc
CamilleBeau Dec 17, 2020
b6a4de5
Fix expected val
CamilleBeau Dec 17, 2020
722a930
Update test/unittests/NDB_BVL_Instrument_Test.php
CamilleBeau Dec 17, 2020
c0c0060
Merge branch 'main' into 2020_07_29_Data_entry_completion_status_flag…
ridz1208 Jul 6, 2021
0d746c2
Update NDB_BVL_Instrument.class.inc
ridz1208 Jul 6, 2021
3b3b27c
Update php/libraries/NDB_BVL_Instrument.class.inc
CamilleBeau Jul 12, 2021
6c0d6f4
Update php/libraries/NDB_BVL_Instrument.class.inc
CamilleBeau Jul 12, 2021
1d5154a
Update php/libraries/NDB_BVL_InstrumentStatus_ControlPanel.class.inc
CamilleBeau Jul 12, 2021
3cff0d2
Update tools/single_use/Set_Required_elements_completed_flag.php
CamilleBeau Jul 12, 2021
3c3b19d
rm rb file & changes to scripts
CamilleBeau Jul 12, 2021
a54e6cf
Merge branch '2020_07_29_Data_entry_completion_status_flag_column' of…
CamilleBeau Jul 12, 2021
1e916f0
Fix changelog, instrument library, set required elements script
CamilleBeau Jul 12, 2021
2ee22a3
Merge branch 'main' into 2020_07_29_Data_entry_completion_status_flag…
CamilleBeau Jul 12, 2021
cdea9da
phpcs
CamilleBeau Jul 12, 2021
423581f
Merge branch '2020_07_29_Data_entry_completion_status_flag_column' of…
CamilleBeau Jul 12, 2021
56a379d
Update raisinbread/RB_files/RB_consent.sql
CamilleBeau Jul 26, 2021
b976453
Update tools/single_use/Set_Required_elements_completed_flag.php
CamilleBeau Jul 26, 2021
7bac7a7
Merge branch 'main' of https://github.com/aces/Loris into 2020_07_29_…
CamilleBeau Aug 16, 2021
1d131c2
Fix single use toold
CamilleBeau Aug 16, 2021
00fd233
Fix set script
CamilleBeau Aug 16, 2021
e91665b
Merge branch '2020_07_29_Data_entry_completion_status_flag_column' of…
CamilleBeau Aug 16, 2021
d4a6d49
phpcs
CamilleBeau Aug 16, 2021
e5f69ef
Merge branch 'main' of https://github.com/aces/Loris into 2020_07_29_…
CamilleBeau Sep 8, 2021
715cbf0
update pt 1
CamilleBeau Sep 8, 2021
bdcbe5c
Add confirm argument to script
CamilleBeau Sep 8, 2021
42964ee
Fix fn name
CamilleBeau Sep 8, 2021
738f26c
Rm printout for each data point
CamilleBeau Oct 15, 2021
64e7f2b
Set instrDECS to null
CamilleBeau Oct 15, 2021
3c110ce
Consider null as incomplete
CamilleBeau Oct 18, 2021
d58a856
More specific script doc
CamilleBeau Oct 20, 2021
fe6a0c3
Update tools/single_use/Remove_Data_entry_completion_status_instr_col…
CamilleBeau Oct 29, 2021
be1144a
Clearer note
CamilleBeau Oct 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ requesting a new account and will be displayed in the User Accounts module (PR #
- Candidate's age can be retrieved from the Candidate class in days, months, or years (PR #5945)
- Addition of autoSelect prop to React SelectElement allows for auto-selection of only available select option (PR #6156)
- An `AcquisitionDate` field has been added to the `files` table (PR #6892)
- Data_entry_completion_status given its own column in flag, and renamed to Required_elements_completed (PR #6876)
- The default value of the ScannerID field of the mri_protocol table is now NULL instead of 0 (PR #7496).
#### Bug Fixes
- The default value of the `ScannerID` field of the `mri_protocol` table is now `NULL` instead of `0`. This means that if a protocol is valid on all the study's scanners, then `ScannerID` of the protocol should be set to `NULL` (PR #7496)
Expand All @@ -45,6 +46,8 @@ requesting a new account and will be displayed in the User Accounts module (PR #
### Notes For Existing Projects
- New function Candidate::getSubjectForMostRecentVisit replaces Utility::getSubprojectIDUsingCandID, adding ability to determine which subproject a candidate belongs to given their most recent visit.
- LINST instrument class was modified to implement the getFullName() and getSubtestList() functions thus making entries in the test_names and instrument_subtests tables respectively unnecessary for LINST instruments (PR #7169)
- The `Data_entry_completion_status` column of instrument tables has been migrated to its own column in flag, and renamed to `Required_elements_completed`. After script `Set_Required_elements_completed_flag.php` is run, projects will need to delete the `Data_entry_completion_status` column of instrument tables. This can be accomplished by running `Remove_Data_entry_completion_status_instr_column.php`, and then sourcing the patch generated by this script.
- Make sure to replace all instances of `_setDataEntryCompletionStatus`, `_determineDataEntryCompletionStatus`, and `updateDataEntryCompletionStatus` functions with their newly named counterparts, `_setRequiredElementsCompletedFlag`, `_determineRequiredElementsCompletedFlag`, `updateRequiredElementsCompletedFlag`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this. Replace them where?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is meant to be a note for projects to replace these functions in case they are calling them in any overrides

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I re-worded it to be more clear

- Deprecation of `begintable` and `endtable` elements in LINST instruments
- Deletion of `dateTimeFields` variable in instrument class. all references to this variable should be removed from project instruments.
- Deletion of `monthYearFields` variable in instrument class. all references to this variable should be removed from project instruments.
Expand Down
3 changes: 2 additions & 1 deletion SQL/0000-00-00-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ CREATE TABLE `flag` (
`Test_name` varchar(255) NOT NULL default '',
`CommentID` varchar(255) NOT NULL default '',
`Data_entry` enum('In Progress','Complete') default NULL,
`Required_elements_completed` enum('Y','N') NOT NULL default 'N',
`Administration` enum('None','Partial','All') default NULL,
`Validity` enum('Questionable','Invalid','Valid') default NULL,
`Exclusion` enum('Fail','Pass') default NULL,
Expand Down Expand Up @@ -892,7 +893,7 @@ CREATE TABLE `mri_violations_log` (
PRIMARY KEY (`LogID`),
CONSTRAINT `FK_tarchive_mriViolationsLog_1`
FOREIGN KEY (`TarchiveID`) REFERENCES `tarchive` (`TarchiveID`),
CONSTRAINT `FK_mri_checks_group_1`
CONSTRAINT `FK_mri_checks_group_1`
FOREIGN KEY (`MriProtocolChecksGroupID`) REFERENCES `mri_protocol_checks_group` (`MriProtocolChecksGroupID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DELETE FROM conflicts_resolved WHERE FieldName='Data_entry_completion_status';
CamilleBeau marked this conversation as resolved.
Show resolved Hide resolved

DELETE FROM conflicts_unresolved WHERE FieldName='Data_entry_completion_status';
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE flag
ADD COLUMN `Required_elements_completed` enum('Y','N') NOT NULL default 'N';
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class Instrument extends Endpoint implements \LORIS\Middleware\ETagCalculator
$this->_instrument->clearInstrument();
$this->_instrument->_saveValues($data[$instrumentname]);
$this->_instrument->score();
$this->_instrument->updateDataEntryCompletionStatus();
$this->_instrument->updateRequiredElementsCompletedFlag();
} catch (\Throwable $e) {
error_log($e->getMessage());
return new \LORIS\Http\Response\JSON\InternalServerError();
Expand Down Expand Up @@ -223,7 +223,7 @@ class Instrument extends Endpoint implements \LORIS\Middleware\ETagCalculator
$instrumentname = $this->_instrument->testName;
$this->_instrument->_saveValues($data[$instrumentname]);
$this->_instrument->score();
$this->_instrument->updateDataEntryCompletionStatus();
$this->_instrument->updateRequiredElementsCompletedFlag();
} catch (\Throwable $e) {
error_log($e->getMessage());
return new \LORIS\Http\Response\JSON\InternalServerError();
Expand Down
2 changes: 1 addition & 1 deletion modules/imaging_qc/php/imaging_qc.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class Imaging_QC extends \NDB_Menu_Filter
" (SELECT title FROM subproject WHERE SubprojectID=s.SubprojectID)
as subproject,".
" CASE
WHEN m.Data_entry_completion_status='Incomplete' THEN 'Incomplete'
WHEN f.Required_elements_completed='N' THEN 'Incomplete'
ELSE 'Complete'
END AS mri_parameter_form,
CASE
Expand Down
69 changes: 40 additions & 29 deletions php/libraries/NDB_BVL_Instrument.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ abstract class NDB_BVL_Instrument extends NDB_Page
'Testdate',
'Window_Difference',
'Candidate_Age',
'Data_entry_completion_status',
];

/**
Expand Down Expand Up @@ -590,7 +589,7 @@ abstract class NDB_BVL_Instrument extends NDB_Page
if ($this->form->validate()) {
$this->form->process([&$this, '_saveValues'], true);
$this->score();
$this->updateDataEntryCompletionStatus();
$this->updateRequiredElementsCompletedFlag();
} else {
$submittedData = $this->form->getSubmitValues();

Expand Down Expand Up @@ -622,14 +621,14 @@ abstract class NDB_BVL_Instrument extends NDB_Page
*
* @return void
*/
public function updateDataEntryCompletionStatus(): void
public function updateRequiredElementsCompletedFlag(): void
{
// determine the data entry completion status, and store that in
// determine the required elements completed flag, and store that in
// the database
$dataEntryCompletionStatus
= $this->_determineDataEntryCompletionStatus();
$this->_setDataEntryCompletionStatus(
$dataEntryCompletionStatus
$requiredElementsCompletedFlag
= $this->_determineRequiredElementsCompletedFlag();
$this->_setRequiredElementsCompletedFlag(
$requiredElementsCompletedFlag
);
}

Expand Down Expand Up @@ -1482,15 +1481,15 @@ abstract class NDB_BVL_Instrument extends NDB_Page
}

/**
* Determines what the data entry status flag should be set to
* Determines what the required elements completed flag should be set to
*
* @return string Either 'Complete' or 'Incomplete'
* @return string Either 'Y' or 'N'
*/
function _determineDataEntryCompletionStatus(): string
function _determineRequiredElementsCompletedFlag(): string
{
// don't bother checking anything if the required elements array is empty
if (empty($this->_requiredElements)) {
return 'Complete';
return 'Y';
}

$allData = $this->getInstanceData();
Expand All @@ -1502,45 +1501,58 @@ abstract class NDB_BVL_Instrument extends NDB_Page
if ((is_null($allData[$field] ?? null) || $allData[$field] === "")
&& empty($allData[$statusField])
) {
return 'Incomplete';
return 'N';
}
}

return 'Complete';
return 'Y';
}


/**
* Gets the data entry completion status for this instrument
*
* @return string Either 'Complete' or 'Incomplete'
* @return string Either 'Y' or 'N'
*/
function getDataEntryCompletionStatus(): string
function getRequiredElementsCompletedFlag(): string
{
$data = $this->getInstanceData();
return $data["Data_entry_completion_status"];
$db = Database::singleton();
$status = $db->pselectOne(
"SELECT Required_elements_completed FROM flag WHERE CommentID=:CID",
['CID' => $this->getCommentID()]
);
if ($status !== 'Y' && $status !== 'N') {
throw new LorisException(
"Invalid Data entry completion status encountered"
);
}
return $status;
}


/**
* Sets the data entry completion status
*
* @param string $status The status - either 'Complete'
* or 'Incomplete'
* @param string $status The status - either 'Y'
* or 'N'
*
* @return void
*/
function _setDataEntryCompletionStatus(string $status): void
function _setRequiredElementsCompletedFlag(string $status): void
{
if (!in_array($status, ['Complete', 'Incomplete'])) {
if (!in_array($status, ['Y', 'N'], true)) {
throw new InvalidArgumentException(
"Invalid status passed to _setDataEntryCompletionStatus - "
"Invalid status passed to _setRequiredElementsCompleted - "
. "'$status' should have been either "
. "'Complete' or 'Incomplete'<br>\n"
. "'Y' or 'N'<br>\n"
);
}

$this->_save(["Data_entry_completion_status" => $status]);
$DB = Database::singleton();
$DB->update(
"flag",
["Required_elements_completed" => $status],
['CommentID' => $this->getCommentID()]
);
}

/**
Expand Down Expand Up @@ -2313,9 +2325,6 @@ abstract class NDB_BVL_Instrument extends NDB_Page
case 'CommentID':
case 'UserID':
continue 2;
case 'Data_entry_completion_status':
$values[$row['COLUMN_NAME']] = 'Incomplete';
break;
default:
$values[$row['COLUMN_NAME']] = null;
}
Expand All @@ -2325,6 +2334,8 @@ abstract class NDB_BVL_Instrument extends NDB_Page

// Clear data out of the flag table's Data column
$db->update('flag', ['Data'=>null], ['CommentID' => $this->commentID]);
$this->_setRequiredElementsCompletedFlag('N');

$prepQ = $db->prepare(
"DELETE FROM conflicts_unresolved
WHERE (CommentId1=:CID OR CommentId2=:CID)"
Expand Down
5 changes: 3 additions & 2 deletions php/libraries/NDB_BVL_InstrumentStatus_ControlPanel.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,10 @@ class NDB_BVL_InstrumentStatus_ControlPanel extends NDB_BVL_InstrumentStatus
if (isset($this->instrument)) {
if ($showLink == true) {
$CompStatus
= $this->instrument->getDataEntryCompletionStatus();
= $this->instrument
->getRequiredElementsCompletedFlag();

$showLink = $CompStatus == 'Complete';
$showLink = $CompStatus === 'Y';

if (!$showLink) {
$this->tpl_data['data_entry'][$i]['tooltip']
Expand Down
Loading