Changing dataset table metadata

LabKey Support Forum (Inactive)
Changing dataset table metadata Anthony Corbett  2012-10-29 08:59
Status: Closed
 
Thanks for the replies everyone! Wanted to share my solution for others to see and possibly get feedback from anyone interested.


My Solution to mapping a dataset row to a specific section (view) of a 'wiki' eCRF using the updateURL metadata:


Logical model:

1. An eCRF is composed of one or more sections (views); each section is a 1 to 1 mapping to a dataset.
2. At each visit (sequenceNum) 1 or more eCRFs are completed.
3. An eCRF can be used at 1 or more visits.


So, the relationship between an eCRFs and visits is many-to-many and at each valid cross product is a set of eCRF sections (datasets) to be displayed/populated.

The physical model for this then becomes a list (an associative entity) where each row represents a unique quadruple of the following pieces of information:

DataSetId, SequenceNum, eCRFwiki (Name), section (Name)

Example: 5001, -1, 'Enrollment', 'demographics'

This effectively mapping a visit/Dataset to an eCRF's section. With this mapping it is now possible to ask the question: For this LSID (dataset row) what eCRF section should be displayed?

And this is exactly how I've implemented my updateURL for all datasets:

<ns:tables xmlns:ns="http://labkey.org/data/xml">
  <ns:table tableName="Demographics" tableDbType="TABLE">
    <ns:updateUrl>wiki/page.view?name=eCRFRedirect&amp;lsid=${lsid}</ns:updateUrl>
  </ns:table>
</ns:tables>


As you can see the updateURL goes to a wiki page called 'eCRFRedirect' passing just the LSID of the row. This wiki page then does a lookup using the following query:

PARAMETERS (LSID VARCHAR)
SELECT
  crf.eCRFwiki, -- The wiki page name that represents the eCRF
  crf.section, -- The section (view) of the eCRF to be displayed
  CASE WHEN( crf.requiresParticipantId ) THEN( StudyData.ParticipantId ) ELSE( null ) END as ParticipantId, -- context for the view
  CASE WHEN( crf.requiresSequenceNum ) THEN( CAST(StudyData.SequenceNum as INTEGER) ) ELSE( null ) END as SequenceNum, -- context for the view
FROM StudyData
JOIN lists.eCRF_datasets crf on StudyData.DataSet.DataSetId = crf.DataSetId AND StudyData.SequenceNum = crf.SequenceNum
WHERE StudyData.lsid = LSID

This returns the eCRF (wiki page) name, the section, and 2 peices of optional context to be passed to the view: the ParticipantId and SequenceNum

After the query returns the row it will then build the URL and set window.location to this URL:

window.location = '/labkey/wiki/[containerPathToCRFs]/page.view?name=[eCRFwiki]#/[section]/[ParticipantId]/[SequenceNum]';

Following the example above: /labkey/wiki/myStudy/eCRFs/page.view?name=Enrollment#/demographics/B001
(SequenceNum is not used for this eCRF as it collected only demographic type data designated/hardcoded by SeqNum -1. If this was an eCRf that is used on more than one visit then I'd pass the SequenceNum also)



There is more abstraction that can be done here; for example, putting the controller as a column in the eCRF_datasets associate list so that the controller (say a different module) can be used for opening CRFs.

This is a start for us and I have hope that same day (when things settle down here) this can be added to a module with its own controller, schema, views instead of lists and wiki pages.


Would love to hear some feedback from anyone with better/cleaner ways to do something like this.


-
Anthony Corbett