Required Date column for demographic dataset in a study without timepoints

General Server Forum (Inactive)
Required Date column for demographic dataset in a study without timepoints olnerdybastid  2018-04-30 20:09
Status: Closed

Lately I've been curious as to why there is a requirement for a date column in demographic datasets in LabKey, and whether there is any way I might bypass this requirement. A number of the datasets we collect are demographic in nature, so having to arbitrarily add a date is not ideal. Is there a safe workaround for this, either by modifying the table in Postgres directly (which I'm guessing voids my warranty and is a very bad idea) or by making edits to some underlying XML for our demographic datasets?

Relatedly, in non-demographic datasets we collect where records ARE tied to a specific date, is there a way for me to redefine one of my dataset's existing datetime fields to serve as part of the table's multi-column key (instead of the generic 'Date' column that comes standard with every Dataset) ? For instance, let's say I have a dataset where each row is uniquely identified by both a SubjectID and a datetime field we call 'ChartReviewDate'. Rather than have to populate the 'Date' column with the value from 'ChartReviewDate', is there a way for me to rename 'Date' to something more informative/modify the header so a more descriptive name appears in the grid view?

Jon (LabKey DevOps) responded:  2018-05-04 21:07

What type of study are you working with? Visit-based? Date-based? Continuous?

Visit-based studies, although still having a date field for demographics datasets, is not a required value to input. Date-based and Continuous studies however do require the date.

Although we do have a feature that allows the ability to have default values populate in fields, but unfortunately it doesn't appear that the date field allows this for study datasets.

It might be possible to use a trigger script to populate a date value for you ahead of time, but when it comes to datasets, only individually inserted rows would work with trigger scripts, so bulk uploads would not be affected by trigger scripts.


olnerdybastid responded:  2018-05-08 19:28
Thanks for confirming. My study is Continuous, so it sounds like I'll need to keep assigning dates for the time being. From what I could tell doing a bit of testing, default values don't populate on API insert, so I suppose it wouldn't help me much anyway even if the date field supported this since nearly all my datasets are imported via API. Using trigger scripts sounds like the way to go on this.

Regarding the second part of my question, do you know if there's any flexibility regarding the variable name/default display name of the 'date' column in non-demo datasets? AS far as I could tell, I can't change this from the UI, but I'm wondering if editing the relevant parts of datasets_metadata.xml (example below) would get me there:

      <column columnName="date">
Jon (LabKey DevOps) responded:  2018-05-18 14:09

Although the XML metadata does provide some extended functionality, the underlying code may not allow this to work the way you expect it to, but certainly feel free to give it a try and let us know if your testing was successful.