Linking by SpecimenID jeckels  2012-07-26 15:45
Status: Closed
 
Hi Jen,

I think that the basic pieces are in place to support this, but the system doesn't automatically wire it up. Doing it manually should be possible and a nice feature to support, but it's somewhat tricky.

One of the difficulties here is that in the physical database the primary key for specimen data is a RowId column, an auto-incrementing INT. Within a study, the GlobalUniqueId will be unique. However, despite the column's name, it's possible for studies in different projects/folders to reuse the same GlobalUniqueId.

To hack something together, here's what I'd recommend trying:

1. Create a custom query, SpecimenDetailWrapper:

SELECT *
FROM SpecimenDetail

2. In the XML Metadata tab in the query editor, set this following as the metadata for the SpecimenDetailWrapper query. It makes the GlobalUniqueId field the sole key field, so that you'll be able to use it as a lookup target.

<ns:tables xmlns:ns="http://labkey.org/data/xml">
  <ns:table tableName="SpecimenDetailWrapper" tableDbType="NOT_IN_DB">
  
    <ns:columns>
      <ns:column columnName="ParticipantId">
        <ns:isKeyField>false</ns:isKeyField>
      </ns:column>
      <ns:column columnName="Visit">
        <ns:isKeyField>false</ns:isKeyField>
      </ns:column>
      <ns:column columnName="RowId">
        <ns:isKeyField>false</ns:isKeyField>
      </ns:column>
      <ns:column columnName="Available">
        <ns:isKeyField>false</ns:isKeyField>
      </ns:column>
      <ns:column columnName="GlobalUniqueId">
        <ns:isKeyField>true</ns:isKeyField>
      </ns:column>
    </ns:columns>
    <ns:titleColumn>GlobalUniqueId</ns:titleColumn>
  </ns:table>
</ns:tables>

3. Save your query and metadata.
4. In your dataset, point your SpecimenId column at the SpecimenDetailWrapper query as its lookup target.

This will let you customize the view and add columns from the specimen data. I'm not sure it will support your scenario of editing specimen requests, but it might.

Thanks,
Josh