Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 10 additions & 8 deletions jsx/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import PropTypes from 'prop-types';
import {Link} from 'react-router-dom';
import {mapFormOptions} from './helpers.js';

import Modal from '../../../jsx/Modal'; // Temporary CBIGR Override for 26.0
import Loader from '../../../jsx/Loader'; // Temporary CBIGR Override for 26.0
import Modal from '../../../jsx/Modal'; // Temporary CBIGR Override for 26.0
import Loader from '../../../jsx/Loader'; // Temporary CBIGR Override for 26.0
import {
SelectElement,
TextboxElement,
NumericElement,
TextareaElement,
CTA,
} from '../../../jsx/Form'; // Temporary CBIGR Override for 26.0
} from '../../../jsx/Form'; // Temporary CBIGR Override for 26.0
import ContainerParentForm from './containerParentForm';

/**
Expand Down Expand Up @@ -356,11 +356,13 @@ function Globals(props) {
/>
<InlineField
label='Visit Label'
value={options.sessions[specimen.sessionId].label}
value={specimen.sessionLabel}
link={
loris.BaseURL+'/instrument_list/?candID='+
specimen.candidateId+'&sessionID='+
specimen.sessionId
options.sessions[specimen.sessionId]
? loris.BaseURL+'/instrument_list/?candID='+
specimen.candidateId+'&sessionID='+
specimen.sessionId
: null
}
/>
</div>
Expand Down Expand Up @@ -673,7 +675,7 @@ InlineField.propTypes = {
pencil: PropTypes.node.isRequired,
editValue: PropTypes.func.isRequired,
loading: PropTypes.bool.isRequired,
link: PropTypes.string.isRequired,
link: PropTypes.string,
value: PropTypes.string.isRequired,
};

Expand Down
9 changes: 5 additions & 4 deletions jsx/specimenForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
import SpecimenProcessForm from './processForm';
import ContainerParentForm from './containerParentForm';
import {ListForm, ListItem} from './listForm';
import Modal from '../../../jsx/Modal'; // Temporary CBIGR Override for 26.0
import Modal from '../../../jsx/Modal'; // Temporary CBIGR Override for 26.0
import {mapFormOptions, clone} from './helpers.js';
import {
SearchableDropdown,
Expand All @@ -12,7 +12,7 @@ import {
CheckboxElement,
DateElement,
ButtonElement,
} from '../../../jsx/Form'; // Temporary CBIGR Override for 26.0
} from '../../../jsx/Form'; // Temporary CBIGR Override for 26.0

const initialState = {
list: {},
Expand Down Expand Up @@ -58,6 +58,7 @@ class SpecimenForm extends React.Component {
.map((item) => item.specimen.id);
current.candidateId = specimen.candidateId;
current.sessionId = specimen.sessionId;
current.sessionLabel = specimen.sessionLabel;
current.typeId = specimen.typeId;
current.originId = container.originId;
current.centerId = container.centerId;
Expand Down Expand Up @@ -224,7 +225,7 @@ class SpecimenForm extends React.Component {
/>
<StaticElement
label="Visit Label"
text={options.sessions[sessionId].label}
text={current.sessionLabel}
/>
</>
);
Expand All @@ -237,7 +238,7 @@ class SpecimenForm extends React.Component {
}
return acc;
}, {})
: {};
: {};
const mappedSessions = mapFormOptions(sessionsObject, 'label');
const candidates = mapFormOptions(
this.props.options.candidates, 'pscid'
Expand Down
28 changes: 28 additions & 0 deletions php/specimen.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Specimen implements
* @var string $candidatePSCID
* @var int $candidateAge
* @var int $sessionId
* @var string $sessionLabel
* @var \CenterID $sessionCenterId
* @var int $poolId
* @var Collection $collection
Expand All @@ -78,6 +79,7 @@ class Specimen implements
private $candidatePSCID;
private $candidateAge;
private $sessionId;
private $sessionLabel;
private $sessionCenterId;
private $poolId;
private $collection;
Expand Down Expand Up @@ -410,6 +412,31 @@ class Specimen implements
return $this->sessionId;
}

/**
* Sets the visit label of the candidate's session/timepoint in which the
* specimen was collected.
*
* @param string $sessionLabel the visit label of the specimen's session
* of collection
*
* @return void
*/
public function setSessionLabel(string $sessionLabel) : void
{
$this->sessionLabel = $sessionLabel;
}

/**
* Gets the visit label of the candidate's session/timepoint in which the
* specimen was collected.
*
* @return ?string
*/
public function getSessionLabel() : ?string
{
return $this->sessionLabel;
}

/**
* Sets the Centeer of the candidate's session/timepoint in which the specimen
* was collected.
Expand Down Expand Up @@ -691,6 +718,7 @@ class Specimen implements
'candidatePSCID' => $this->candidatePSCID,
'candidateAge' => $this->candidateAge,
'sessionId' => $this->sessionId,
'sessionLabel' => $this->sessionLabel,
'sessionCenterId' => $this->sessionCenterId,
'poolId' => $this->poolId,
'collection' => $this->collection->jsonSerialize(),
Expand Down
16 changes: 10 additions & 6 deletions php/specimendao.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class SpecimenDAO extends \LORIS\Data\ProvisionerInstance
c.PSCID as CandidatePSCID,
bs.SessionID,
s.CenterID as SessionCenterID,
s.Visit_Label as SessionLabel,
(
SELECT FLOOR(DATEDIFF(s.Date_visit, c.DoB)/365.25)
) as CandidateAge,
Expand Down Expand Up @@ -374,7 +375,7 @@ class SpecimenDAO extends \LORIS\Data\ProvisionerInstance
public function getProtocolAttributes() : array
{
$query = "
SELECT
SELECT
bsp.SpecimenProtocolID as protocolId,
bsa.SpecimenAttributeID as attributeId,
bsa.Label as label,
Expand All @@ -389,17 +390,17 @@ class SpecimenDAO extends \LORIS\Data\ProvisionerInstance
USING (SpecimenAttributeID)
ORDER BY bsp.SpecimenProtocolID, bspa.OrderIndex
";

$result = $this->db->pselect($query, []);
$protocolAttributes = [];

foreach ($result as $row) {
$protocolId = $row['protocolId'];
// Ensure the protocol exists in the array
if (!isset($protocolAttributes[$protocolId])) {
$protocolAttributes[$protocolId] = [];
}

// Add the attribute data, keeping the order intact
$protocolAttributes[$protocolId][] = [
'id' => $row['attributeId'],
Expand All @@ -410,9 +411,9 @@ class SpecimenDAO extends \LORIS\Data\ProvisionerInstance
'orderIndex' => (int) $row['orderIndex'],
];
}

return $protocolAttributes;
}
}

/**
* Queries all rows from the biobank_specimen_protocol_attribute_rel table
Expand Down Expand Up @@ -733,6 +734,9 @@ class SpecimenDAO extends \LORIS\Data\ProvisionerInstance
if (isset($data['SessionID'])) {
$specimen->setSessionId((int) $data['SessionID']);
}
if (isset($data['SessionLabel'])) {
$specimen->setSessionLabel((string) $data['SessionLabel']);
}
if (isset($data['SessionID'])) {
$specimen->setSessionCenterId(
new \CenterID(
Expand Down