diff --git a/SQL/0000-00-03-ConfigTables.sql b/SQL/0000-00-03-ConfigTables.sql index 12a007d6a89..f17cdad3e59 100644 --- a/SQL/0000-00-03-ConfigTables.sql +++ b/SQL/0000-00-03-ConfigTables.sql @@ -8,7 +8,7 @@ CREATE TABLE `ConfigSettings` ( `Description` varchar(255) DEFAULT NULL, `Visible` tinyint(1) DEFAULT '0', `AllowMultiple` tinyint(1) DEFAULT '0', - `DataType` ENUM('text', 'boolean', 'email', 'instrument', 'textarea', 'scan_type', 'lookup_center', 'path', 'web_path') DEFAULT NULL, + `DataType` ENUM('text','boolean','email','instrument','textarea','scan_type','date_format','lookup_center','path','web_path') DEFAULT NULL, `Parent` int(11) DEFAULT NULL, `Label` varchar(255) DEFAULT NULL, `OrderNumber` int(11) DEFAULT NULL, @@ -41,8 +41,8 @@ INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber) SELECT 'endYear', "End year for study recruitment or data collection", 1, 0, 'text', ID, 'End year', 6 FROM ConfigSettings WHERE Name="study"; INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber) SELECT 'ageMin', 'Minimum candidate age in years (0+)', 1, 0, 'text', ID, 'Minimum candidate age', 7 FROM ConfigSettings WHERE Name="study"; INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber) SELECT 'ageMax', 'Maximum candidate age in years', 1, 0, 'text', ID, 'Maximum candidate age', 8 FROM ConfigSettings WHERE Name="study"; -INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber) SELECT 'dobFormat', "Format of the Date of Birth", 1, 0, 'text', ID, 'DOB Format', 9 FROM ConfigSettings WHERE Name="study"; -INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber) SELECT 'dodFormat', 'Format of the Date of Death', 1, 0, 'text', ID, 'DOD Format', 10 FROM ConfigSettings WHERE Name="study"; +INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber) SELECT 'dobFormat', "Format of the Date of Birth", 1, 0, 'date_format', ID, 'DOB Format', 9 FROM ConfigSettings WHERE Name="study"; +INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber) SELECT 'dodFormat', 'Format of the Date of Death', 1, 0, 'date_format', ID, 'DOD Format', 10 FROM ConfigSettings WHERE Name="study"; INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber) SELECT 'useProband', "Enable for proband data collection", 1, 0, 'boolean', ID, 'Use proband', 11 FROM ConfigSettings WHERE Name="study"; INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber) SELECT 'useFamilyID', 'Enable if family members are recruited for the study', 1, 0, 'boolean', ID, 'Use family', 12 FROM ConfigSettings WHERE Name="study"; INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber) SELECT 'useExternalID', "Enable if data is used for blind data distribution, or from external data sources", 1, 0, 'boolean', ID, 'Use external ID', 13 FROM ConfigSettings WHERE Name="study"; @@ -179,8 +179,8 @@ INSERT INTO Config (ConfigID, Value) SELECT ID, "true" FROM ConfigSettings WHERE INSERT INTO Config (ConfigID, Value) SELECT ID, 0 FROM ConfigSettings WHERE Name="ImagingUploaderAutoLaunch"; INSERT INTO Config (ConfigID, Value) SELECT ID, "Modify this to your project's citation policy" FROM ConfigSettings WHERE Name="citation_policy"; INSERT INTO Config (ConfigID, Value) SELECT ID, "" FROM ConfigSettings WHERE Name="CSPAdditionalHeaders"; -INSERT INTO Config (ConfigID, Value) SELECT ID, "YMd" FROM ConfigSettings WHERE Name="dobFormat"; -INSERT INTO Config (ConfigID, Value) SELECT ID, "YMd" FROM ConfigSettings WHERE Name="dodFormat"; +INSERT INTO Config (ConfigID, Value) SELECT ID, "Ymd" FROM ConfigSettings WHERE Name="dobFormat"; +INSERT INTO Config (ConfigID, Value) SELECT ID, "Ymd" FROM ConfigSettings WHERE Name="dodFormat"; INSERT INTO Config (ConfigID, Value) SELECT ID, "/data/%PROJECTNAME%/data/" FROM ConfigSettings WHERE Name="imagePath"; diff --git a/SQL/New_patches/2020_06_16_Add_Date_Format_to_ConfigSettings_DataType.sql b/SQL/New_patches/2020_06_16_Add_Date_Format_to_ConfigSettings_DataType.sql new file mode 100644 index 00000000000..21cf02fc01e --- /dev/null +++ b/SQL/New_patches/2020_06_16_Add_Date_Format_to_ConfigSettings_DataType.sql @@ -0,0 +1,28 @@ +-- Add date_format option to DataType +ALTER TABLE ConfigSettings + MODIFY COLUMN `DataType` enum('text','boolean','email','instrument','textarea','scan_type','date_format','lookup_center','path','web_path') DEFAULT NULL; + +-- Update DataType of dobFormat +UPDATE ConfigSettings + SET DataType='date_format' WHERE Name='dobFormat'; + +-- Update DataType of dodFormat +UPDATE ConfigSettings + SET DataType='date_format' WHERE Name='dodFormat'; + +-- Convert old date casing combos to supported format +UPDATE Config SET Value='Ymd' + WHERE LOWER(Value)='ymd' + AND ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='dobFormat'); + +UPDATE Config SET Value='Ymd' + WHERE LOWER(Value)='ymd' + AND ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='dodFormat'); + +UPDATE Config SET Value='Ym' + WHERE LOWER(Value)='ym' + AND ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='dobFormat'); + +UPDATE Config SET Value='Ym' + WHERE LOWER(Value)='ym' + AND ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='dodFormat'); diff --git a/modules/candidate_parameters/ajax/formHandler.php b/modules/candidate_parameters/ajax/formHandler.php index b52da33065e..606cb75e038 100644 --- a/modules/candidate_parameters/ajax/formHandler.php +++ b/modules/candidate_parameters/ajax/formHandler.php @@ -547,7 +547,7 @@ function editCandidateDOB(\Database $db): void if (!empty($dob)) { $config = \NDB_Config::singleton(); $dobFormat = $config->getSetting('dobFormat'); - if ($dobFormat === 'YM') { + if ($dobFormat === 'Ym') { $strippedDate = date("Y-m", strtotime($dob))."-01"; } $db->update( @@ -581,7 +581,7 @@ function editCandidateDOD(\Database $db): void if (!empty($dod)) { $config = \NDB_Config::singleton(); $dodFormat = $config->getSetting('dodFormat'); - if ($dodFormat === 'YM') { + if ($dodFormat === 'Ym') { $strippedDate = $dod->format('Y-m-01'); } else { $dodString = $dod->format('Y-m-d'); diff --git a/modules/configuration/php/configuration.class.inc b/modules/configuration/php/configuration.class.inc index c3c411b8f31..2ee51ff3d7d 100644 --- a/modules/configuration/php/configuration.class.inc +++ b/modules/configuration/php/configuration.class.inc @@ -61,6 +61,12 @@ class Configuration extends \NDB_Form $scan_types[$val] = $val; } + $date_format = [ + '' => '', + 'Ymd' => 'Ymd (EX: 2015-12-28)', + 'Ym' => 'Ym (EX: 2015-12)' + ]; + $instruments = \Utility::getAllInstruments(); $instruments[''] = ''; @@ -69,6 +75,7 @@ class Configuration extends \NDB_Form $this->tpl_data['instruments'] = $instruments; $this->tpl_data['sandbox'] = $config->getSetting("sandbox"); $this->tpl_data['scan_types'] = $scan_types; + $this->tpl_data['date_format'] = $date_format; $this->tpl_data['lookup_center'] = [ '' => '', 'PatientID' => 'PatientID', diff --git a/modules/configuration/templates/form_configuration.tpl b/modules/configuration/templates/form_configuration.tpl index 6cde8307d5b..d03f35cc3d2 100644 --- a/modules/configuration/templates/form_configuration.tpl +++ b/modules/configuration/templates/form_configuration.tpl @@ -28,6 +28,14 @@ {/function} +{function name=createDateFormat} + +{/function} + {function name=createLookUpCenterNameUsing}