643 introduced the Sample and Container tables in order to address the shortcomings of the Biospecimen table. Now we need a way to populate these tables. And since a sample and container may be derived from a biospecimen, we can auto-populate them.
Approach
Each time a biospecimen is created or updated via an HTTP POST/PATCH, derive the sample and container from the input biospecimen and update sample/container tables.
Sample, Container Management
Find Sample - check if a sample already exists for this biospecimen
Use a specific set of biospecimen attributes to uniquely identify the sample:
Closing for now. New approach is to implement the Sample table only. This is an MVP to meet Portal Beta requirements. Will try to autopopulate the Sample table from Biospecimens similar to approach here
Motivation
643 introduced the Sample and Container tables in order to address the shortcomings of the Biospecimen table. Now we need a way to populate these tables. And since a sample and container may be derived from a biospecimen, we can auto-populate them.
Approach
Each time a biospecimen is created or updated via an HTTP POST/PATCH, derive the sample and container from the input biospecimen and update sample/container tables.
Sample, Container Management
Find Sample - check if a sample already exists for this biospecimen
sample_event_key = concat(participant_id, external_sample_id, age_at_event_days)
analyte_type
composition
source_text_tissue_type
source_text_anatomic_site
preservation_method
method_of_sample_procurement
concentration_mg_per_ml
Create Sample - if the sample does not exist - create it using the relevant subset of biospecimen attributes
participant_id
external_sample_id
volume_ul
Update Sample - if the sample exists - update it using the relevant subset of biospecimen attributes
Find Container - check if a container already exists for this biospecimen
biospecimen_id
Create Container - if the container does not exist - create it using the relevant subset of biospecimen attributes
sample_id
specimen_status
volume_ul
Update Container - if the container exists - update it using the relevant subset of biospecimen attributes
Sum Volume - update the the sample's
volume_ul
field with the sum of it's container volumes