Skip to content

Commit

Permalink
[timepoint] Add Default Site to Dropdown (#9408)
Browse files Browse the repository at this point in the history
In the create timepoint module, adds a candidate's most recent
site as the default site for the "Site" dropdown.
  • Loading branch information
victori444 authored Jan 23, 2025
1 parent 03656d5 commit ea75fa4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions modules/create_timepoint/jsx/createTimepointIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ class CreateTimepoint extends React.Component {
if (data.psc) {
state.form.options.psc = data.psc;
state.form.display.psc = true;
if (data.defaultpsc) {
state.form.value.psc = data.defaultpsc;
}
}
// Populate the select options for project.
if (data.project) {
Expand Down
14 changes: 14 additions & 0 deletions modules/create_timepoint/php/timepoint.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,20 @@ class Timepoint extends \NDB_Page implements ETagCalculator
}
if (empty($values['psc'])) {
unset($values['psc']);
} else {
// Suggested site is the site of the last registered visit
$DB = $this->loris->getDatabaseConnection();

$query = "
SELECT CenterID
FROM session
WHERE CandID=:cid AND Date_visit IS NOT NULL
ORDER BY Date_visit DESC LIMIT 1
";
$where = ['cid' => $values['candID']];
$result = iterator_to_array($DB->pselect($query, $where));

$values['defaultpsc'] = $result[0]['CenterID'];
}

return new \LORIS\Http\Response\JsonResponse(
Expand Down

0 comments on commit ea75fa4

Please sign in to comment.