-
Notifications
You must be signed in to change notification settings - Fork 179
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
[user accounts] Fixing users being always inserted into examiner table upon save #3829
Changes from 10 commits
b8a37e4
c2e0bb1
e72ee5a
340e28f
4f78836
1d8bf97
970dc3c
0c661ea
6382ad5
797b3d7
e4cd8fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -254,6 +254,7 @@ class Edit_User extends \NDB_Form | |
} | ||
unset($values['CenterIDs']); | ||
// END multi-site UPDATE | ||
|
||
// EXAMINER UPDATE | ||
if ($editor->hasPermission('examiner_multisite')) { | ||
// get all fields that are related to examiners | ||
|
@@ -278,9 +279,6 @@ class Edit_User extends \NDB_Form | |
} | ||
} | ||
|
||
//modify examiner radiologist to be in the binary format 0-1 | ||
$ex_radiologist = $ex_radiologist === 'Y' ? 1 : 0; | ||
|
||
$examinerID = $DB->pselect( | ||
"SELECT e.examinerID | ||
FROM examiners e | ||
|
@@ -291,11 +289,14 @@ class Edit_User extends \NDB_Form | |
); | ||
|
||
// START EXAMINER UPDATE | ||
// If examiner not in table add him, | ||
// otherwise update the radiologist field and get the current sites | ||
$values = \Utility::nullifyEmpty($values, 'examiner_radiologist'); | ||
if (empty($examinerID)) { | ||
|
||
if (!empty($ex_radiologist) | ||
&& !empty($ex_pending) | ||
&& !empty($ex_curr_sites) | ||
&& empty($examinerID) | ||
) { | ||
// If examiner not in table and radiologist, pending and current | ||
// sites fields set add the examiner to the examiner table | ||
$ex_radiologist = $ex_radiologist === 'Y' ? 1 : 0; | ||
$DB->insert( | ||
'examiners', | ||
array( | ||
|
@@ -304,14 +305,30 @@ class Edit_User extends \NDB_Form | |
'userID' => $uid, | ||
) | ||
); | ||
$examinerID = $examinerID = $DB->pselectOne( | ||
$examinerID = $DB->pselectOne( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know why we need to extract the new examinerID here, it doesn't seem to be used. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cmadjar I was wrong about this, it is used 👍 |
||
"SELECT examinerID | ||
FROM examiners | ||
WHERE full_name=:fullName", | ||
FROM examiners | ||
WHERE full_name=:fullName", | ||
array('fullName' => $values['Real_name']) | ||
); | ||
} else { | ||
|
||
// } elseif (!empty($examinerID) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. commented code should not be submitted |
||
// && ((!empty($ex_radiologist) | ||
// && !empty($ex_pending) | ||
// && !empty($ex_curr_sites)) | ||
// || (empty($ex_radiologist) | ||
// && empty($ex_pending) | ||
// && empty($ex_curr_sites))) | ||
// ) { | ||
} elseif (!empty($examinerID) | ||
&& ((!empty($ex_radiologist) | ||
&& !empty($ex_pending) | ||
&& !empty($ex_curr_sites)) | ||
|| empty($ex_curr_sites)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cmadjar, addressing your most recent change, shouldn't the else if statement be:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @um4r12 , Thanks for the sugesstion. Actually, I tried that and it does not work as it is impossible to be in the following condition
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cmadjar is correct, its not ideal but is acceptable in the scope of this bugfix. a revap of the logic is def needed to prevent unsetting of all fields and to sync the validation checks to the processing. |
||
) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fault in logic above, if examiner ID exists, there is no way the examiner pending and approval can be reset to null (the columns in SQL are not nullable, examiners can not be deleted and there is no code below to handle that case) thus the last segment of this statemnt should be removed.
The possible cases are:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ridz1208 I changed the logic as you suggested. FYI, the following case is impossible:
But indeed, in case the requirements for data entry change in the form, probably best to simplify the 'or' part of the logic to Thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you are correct but that means that there is a bigger fautl in logic in the field validation in the front end. Thats def not within the scope of this PR since its not a bugfix but rather a minor revamp. This should do for the moment. I will try to test as soon as I can. |
||
// If examiner already exists in the examiner table AND | ||
// radiologist, pending and current sites fields all set or | ||
// unset update the examiner table with new values | ||
$ex_radiologist = $ex_radiologist === 'Y' ? 1 : 0; | ||
$DB->update( | ||
'examiners', | ||
array( | ||
|
@@ -327,8 +344,8 @@ class Edit_User extends \NDB_Form | |
//get existing sites for examiner | ||
$prev_sites = $DB->pselect( | ||
"SELECT centerID | ||
FROM examiners_psc_rel epr | ||
WHERE examinerID=:eid", | ||
FROM examiners_psc_rel epr | ||
WHERE examinerID=:eid", | ||
array("eid" => $examinerID) | ||
); | ||
|
||
|
@@ -337,14 +354,13 @@ class Edit_User extends \NDB_Form | |
array_push($ex_prev_sites, $center['centerID']); | ||
} | ||
} | ||
|
||
foreach ($ex_curr_sites as $k => $v) { | ||
|
||
//Check if examiner already in db for site | ||
$result = $DB->pselectRow( | ||
"SELECT epr.centerID | ||
FROM examiners_psc_rel epr | ||
WHERE epr.examinerID=:eid AND epr.centerID=:cid", | ||
FROM examiners_psc_rel epr | ||
WHERE epr.examinerID=:eid AND epr.centerID=:cid", | ||
array( | ||
"eid" => $examinerID, | ||
"cid" => $v, | ||
|
@@ -393,7 +409,6 @@ class Edit_User extends \NDB_Form | |
} | ||
unset($values['examiner_radiologist']); | ||
unset($values['examiner_pending']); | ||
|
||
//END EXAMINER UPDATE | ||
|
||
// make the set | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment explaining the condition here is a good idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done