From 62dee27da85794e31d1549937093e3c088661b9b Mon Sep 17 00:00:00 2001 From: Zaliqa Date: Wed, 15 Nov 2023 14:07:05 -0500 Subject: [PATCH] [NDB_BVL_Instrument] Cleanup duplicate method definition for _addMetadataFields() (#8956) This will allow for easier maintenance of the method --- php/libraries/NDB_BVL_Instrument.class.inc | 7 +-- .../NDB_BVL_Instrument_LINST.class.inc | 53 ------------------- 2 files changed, 4 insertions(+), 56 deletions(-) diff --git a/php/libraries/NDB_BVL_Instrument.class.inc b/php/libraries/NDB_BVL_Instrument.class.inc index a963eaabec0..b29043e4591 100644 --- a/php/libraries/NDB_BVL_Instrument.class.inc +++ b/php/libraries/NDB_BVL_Instrument.class.inc @@ -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 @@ -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', @@ -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', diff --git a/php/libraries/NDB_BVL_Instrument_LINST.class.inc b/php/libraries/NDB_BVL_Instrument_LINST.class.inc index 5b526b5b231..96c96641022 100644 --- a/php/libraries/NDB_BVL_Instrument_LINST.class.inc +++ b/php/libraries/NDB_BVL_Instrument_LINST.class.inc @@ -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