Skip to content

Commit

Permalink
[NDB_BVL_Instrument] Cleanup duplicate method definition for _addMeta…
Browse files Browse the repository at this point in the history
…dataFields() (#8956)

This will allow for easier maintenance of the method
  • Loading branch information
zaliqarosli authored Nov 15, 2023
1 parent ccb3f60 commit 62dee27
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 56 deletions.
7 changes: 4 additions & 3 deletions php/libraries/NDB_BVL_Instrument.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,6 @@ abstract class NDB_BVL_Instrument extends NDB_Page
$this->instanceData = $newData;
}


/**
* Adds metadata fields (such as Examiner and Date_taken) to the
* current form
Expand All @@ -850,7 +849,9 @@ abstract class NDB_BVL_Instrument extends NDB_Page
*/
function _addMetadataFields(): void
{
$config = \NDB_Config::singleton();
$factory = \NDB_Factory::singleton();
$config = $factory->config();

$dateOptions = [
'language' => 'en',
'format' => 'YMd',
Expand All @@ -864,7 +865,7 @@ abstract class NDB_BVL_Instrument extends NDB_Page

$this->addBasicDate('Date_taken', 'Date of Administration', $dateOptions);

if (strrpos($this->testName, '_proband') === false) {
if (strrpos($this->testName ?? '', '_proband') === false) {
if (!$this->postMortem) {
$this->addScoreColumn(
'Candidate_Age',
Expand Down
53 changes: 0 additions & 53 deletions php/libraries/NDB_BVL_Instrument_LINST.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -64,59 +64,6 @@ class NDB_BVL_Instrument_LINST extends \NDB_BVL_Instrument

$this->form = new \LorisForm();
}
/**
* Adds metadata fields (such as Examiner and Date_taken) to the
* current form
*
* @return void
* @access private
*/
function _addMetadataFields(): void
{
$factory = \NDB_Factory::singleton();
$config = $factory->config();

$dateOptions = [
'language' => 'en',
'format' => 'YMd',
'minYear' => $config->getSetting('startYear'),
'maxYear' => $config->getSetting('endYear'),
'addEmptyOption' => true,
'emptyOptionValue' => null,
];

$this->dateOptions = $dateOptions;

$this->addBasicDate('Date_taken', 'Date of Administration', $dateOptions);

if (strrpos($this->testName ?? '', '_proband') === false) {
if (!$this->postMortem) {
$this->addScoreColumn(
'Candidate_Age',
'Candidate Age (Months)'
);
} else {
$this->addScoreColumn(
'Candidate_Age',
'Candidate Age at Death (Months)'
);
}
$this->addScoreColumn(
'Window_Difference',
'Window Difference (+/- Days)'
);
}
$examiners = $this->_getExaminerNames();
$this->addSelect('Examiner', 'Examiner', $examiners);

$this->addRule(
'Date_taken',
'Date of Administration is required',
'required'
);

$this->addRule('Examiner', 'Examiner is required', 'required');
}

/**
* This runs the XIN rules on all the elements on the current page to ensure
Expand Down

0 comments on commit 62dee27

Please # to comment.