Skip to content

Conversation

@HenriRabalais
Copy link
Collaborator

@HenriRabalais HenriRabalais commented Oct 29, 2025

Description

This Pull Request resolves (1) database foreign key mismatches introduced in LORIS v27, (2) includes SQL modifications for a feature for ordering specimen attributes that was accidentally omitted from the original Biobank PR, and (3) corrects a reference to Candidate diagnoses.

Primary changes include:

  1. Fix CandidateID References (Resolves [Biobank] "Candid" and tables need to match CandidateID after 27 update #10037): Updates all Biobank queries that previously referenced CandID to correctly use the new LORIS v27 standard, CandidateID. This includes:
    • modules/biobank/php/optionsendpoint.class.inc
    • modules/biobank/php/specimendao.class.inc
  2. Database Migration (OrderIndex): Adds the OrderIndex column and a UNIQUE constraint (UK_SpecimenProtocolId_OrderIndex) to the biobank_specimen_protocol_attribute_rel table. The patch (2025-10-29_add-order-index-to-specimen-protocols.sql) uses a safe, multi-step migration pattern (NULL-add, populate, enforce NOT NULL/UNIQUE) to prevent data loss or breakage on existing installations.
  3. Diagnosis/Evolution Endpoint Fix: Corrects an error in OptionsEndpoint to pull from diagnosis_evolution instead of the deprecated diagnosis table for biobank-related lookups.

Testing Plan

1. Database Changes

  • Test on Clean Install (No Data):
    1. Start with a clean LORIS database setup.
    2. Run the Biobank module installation and schema creation (which uses SQL/0000-00-06-BiobankTables.sql).
    3. Expected: The biobank_specimen_protocol_attribute_rel table should be created successfully with the OrderIndex INT UNSIGNED NOT NULL column and the UK_SpecimenProtocolId_OrderIndex constraint.
  • Test on Existing Install (with Data):
    1. Start with a database that has an older version of the Biobank tables (without OrderIndex) and existing entries in biobank_specimen_protocol_attribute_rel.
    2. Run the new patch: 2025-10-29_add-order-index-to-specimen-protocols.sql.
    3. Expected: The patch should execute successfully, adding the column and then populating existing rows with unique sequential OrderIndex values (starting at 0) for each SpecimenProtocolID group, finally enforcing the constraints.

2. Biobank Module

  • CandidateID Fix:
    1. Log in as a user with appropriate permissions.
    2. Access the Biobank module interface.
    3. Attempt to fetch candidates or specimens.
    4. Expected: Candidate and Specimen data should load correctly, demonstrating that the CandidateID reference changes in specimendao.class.inc are correct.
  • Diagnosis Fix:
    1. Verify that the options endpoint for diagnosis/evolution is correctly populating data.
    2. Expected: The system should pull correct, non-empty options for related tables, confirming the update from diagnosis to diagnosis_evolution in optionsendpoint.class.inc is functional.

Closes: #10037

@github-actions github-actions bot added Language: SQL PR or issue that update SQL code Language: PHP PR or issue that update PHP code labels Oct 29, 2025
@HenriRabalais HenriRabalais added the Category: Bug PR or issue that aims to report or fix a bug label Oct 29, 2025
@driusan
Copy link
Collaborator

driusan commented Oct 29, 2025

@HenriRabalais can you fix the static tests then assign to @kongtiaowang ?

FROM
candidate c
LEFT JOIN session s
ON s.CandidateID=c.CandID
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think thats correct.

@jeffersoncasimir correct me if I'm wrong but this should be

Suggested change
ON s.CandidateID=c.CandID
ON s.CandidateID=c.ID

While row 143 stays as is!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, I changed any join to use c.ID instead of c.CandID.

@github-actions github-actions bot added the Language: Javascript PR or issue that update Javascript code label Oct 29, 2025
@kongtiaowang
Copy link
Contributor

kongtiaowang commented Oct 29, 2025

@HenriRabalais Good job! now it is loading. Two tiny bugs need to be fixed.

{pageCount} and {totalCount}
截屏2025-10-29 下午1 58 27

missing "container type"
截屏2025-10-29 下午1 58 14.

@HenriRabalais
Copy link
Collaborator Author

thanks for testing @kongtiaowang !

I'm looking into the pageCount and totalCount and issue and I'm not really sure why it's happening. Have you seen this before in LORIS?

As for the empty field, those values are pulled from the shipment_container table and should be defined by whatever project is using the biobank. Do you want me to insert default values in the database schema? Or should they go into some form of raisinbread data?

@kongtiaowang
Copy link
Contributor

@HenriRabalais - Please insert default values in the database schema and RB will be fine. This is my first time see "pageCount and totalCount "issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Category: Bug PR or issue that aims to report or fix a bug Language: Javascript PR or issue that update Javascript code Language: PHP PR or issue that update PHP code Language: SQL PR or issue that update SQL code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Biobank] "Candid" and tables need to match CandidateID after 27 update

4 participants