Skip to content

Conversation

@spamhurts
Copy link
Collaborator

Rationale

Added calculated at-time columns for assignments and accounts to HL7 Pivot tables. Started creating qviews for routine lab results.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds calculated at-time columns (assignments and accounts) and age columns to HL7 Pivot tables through both Java customizer code and query XML configuration changes. It also introduces a composite key field for each pivot table and creates a new query view (qview) for routine chemistry results.

Changes:

  • Added Java customizer logic to append assignment and age calculated columns to HL7 pivot tables
  • Added composite key fields (id + date concatenation) to all HL7 pivot table SQL queries
  • Configured key field metadata and added DefaultEHRCustomizer to all HL7 pivot table query.xml files
  • Created a new RoutineChemistry.qview.xml file with specific column selections for biochemistry results
  • Applied ltrim/rtrim to TestName in HL7BiochemistryPivot for whitespace handling

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 19 comments.

Show a summary per file
File Description
SNPRC_EHRCustomizer.java Added logic to detect HL7 pivot tables and append assignment and age calculated columns
HL7BiochemistryPivot.sql Added key field and trimmed TestName in the IN clause
HL7BiochemistryPivot.query.xml Added DefaultEHRCustomizer and key field configuration
HL7CulturePivot.sql Added key field composed of id and date
HL7CulturePivot.query.xml Added DefaultEHRCustomizer and key field configuration
HL7HematologyPivot.sql Added key field composed of id and date
HL7HematologyPivot.query.xml Added DefaultEHRCustomizer and key field configuration
HL7HistologyPivot.sql Added key field composed of id and date
HL7HistologyPivot.query.xml Added DefaultEHRCustomizer and key field configuration
HL7MiscPivot.sql Added key field composed of id and date
HL7MiscPivot.query.xml Added DefaultEHRCustomizer and key field configuration
HL7ParasitologyPivot.sql Added key field composed of id and date
HL7ParasitologyPivot.query.xml Added DefaultEHRCustomizer and key field configuration
HL7SurveillancePivot.sql Added key field but with incorrect column references
HL7SurveillancePivot.query.xml Added DefaultEHRCustomizer and key field configuration
HL7UnknownPivot.sql Added key field composed of id and date
HL7UnknownPivot.query.xml Added DefaultEHRCustomizer and key field configuration
HL7UrinalysisPivot.sql Added key field composed of id and date
HL7Urinalysis.query.xml Added DefaultEHRCustomizer and key field configuration
RoutineChemistry.qview.xml New query view defining specific columns for routine chemistry results

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

<metadata>
<tables xmlns="http://labkey.org/data/xml">
<table tableName="HL7UnknownPivot" tableDbType="NOT_IN_DB">
<javaCustomizer class="org.labkey.ehr.table.DefaultEHRCustomizer" />
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

This table now has two customizers being applied: DefaultEHRCustomizer from the XML configuration and SNPRC_EHRCustomizer from the Java code (lines 207-212 of SNPRC_EHRCustomizer.java). Both customizers may attempt to add assignment and age columns, potentially causing conflicts or duplicate columns. Verify that these customizers work together correctly without creating duplicate calculated columns.

Suggested change
<javaCustomizer class="org.labkey.ehr.table.DefaultEHRCustomizer" />

Copilot uses AI. Check for mistakes.
@@ -1,5 +1,6 @@
select Id,
date,
obr.ANIMAL_ID || '-' || CAST(obr.OBSERVATION_DATE_TM AS VARCHAR) as key,
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

The key field references undefined columns. The query selects from snprc_ehr.HL7SurveillancePivotInner which doesn't have an alias obr, and the columns are already aliased as Id and date in that inner query. Change obr.ANIMAL_ID to Id and obr.OBSERVATION_DATE_TM to date to match the existing column names in the SELECT list.

Suggested change
obr.ANIMAL_ID || '-' || CAST(obr.OBSERVATION_DATE_TM AS VARCHAR) as key,
Id || '-' || CAST(date AS VARCHAR) as key,

Copilot uses AI. Check for mistakes.
SELECT
obr.ANIMAL_ID as id,
obr.OBSERVATION_DATE_TM as date,
obr.ANIMAL_ID || '-' || CAST(obr.OBSERVATION_DATE_TM AS VARCHAR) as key,
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

The key field is composed only of id and date concatenation, but the query groups by additional columns (MESSAGE_ID, PROCEDURE_NAME, PROCEDURE_ID, COMMENT) which means multiple rows can have the same key value. This will cause issues since the key field is marked as isKeyField in the query.xml file. Consider including additional distinguishing fields in the key formula to ensure uniqueness, or reconsider whether this composite key is appropriate for the data structure.

Suggested change
obr.ANIMAL_ID || '-' || CAST(obr.OBSERVATION_DATE_TM AS VARCHAR) as key,
obr.ANIMAL_ID
|| '-' || CAST(obr.OBSERVATION_DATE_TM AS VARCHAR)
|| '-' || COALESCE(CAST(obr.MESSAGE_ID AS VARCHAR), '')
|| '-' || COALESCE(CAST(obr.PROCEDURE_ID AS VARCHAR), '')
|| '-' || COALESCE(COALESCE (lp.ServiceId.ServiceName, obr.PROCEDURE_NAME), '')
|| '-' || COALESCE(nte.COMMENT, '') as key,

Copilot uses AI. Check for mistakes.
SELECT
obr.ANIMAL_ID as id,
obr.OBSERVATION_DATE_TM as date,
obr.ANIMAL_ID || '-' || CAST(obr.OBSERVATION_DATE_TM AS VARCHAR) as key,
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

The key field is composed only of id and date concatenation, but the query groups by additional columns (MESSAGE_ID, PROCEDURE_NAME, PROCEDURE_ID, COMMENT) which means multiple rows can have the same key value. This will cause issues since the key field is marked as isKeyField in the query.xml file. Consider including additional distinguishing fields in the key formula to ensure uniqueness, or reconsider whether this composite key is appropriate for the data structure.

Suggested change
obr.ANIMAL_ID || '-' || CAST(obr.OBSERVATION_DATE_TM AS VARCHAR) as key,
obr.ANIMAL_ID
|| '-' || CAST(obr.OBSERVATION_DATE_TM AS VARCHAR)
|| '-' || CAST(obr.MESSAGE_ID AS VARCHAR)
|| '-' || CAST(obr.SET_ID AS VARCHAR)
|| '-' || COALESCE(COALESCE (lp.ServiceId.ServiceName, obr.PROCEDURE_NAME), '')
|| '-' || CAST(obr.PROCEDURE_ID AS VARCHAR)
|| '-' || COALESCE(nte.COMMENT, '') as key,

Copilot uses AI. Check for mistakes.
<metadata>
<tables xmlns="http://labkey.org/data/xml">
<table tableName="HL7SurveillancePivot" tableDbType="NOT_IN_DB">
<javaCustomizer class="org.labkey.ehr.table.DefaultEHRCustomizer" />
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

This table now has two customizers being applied: DefaultEHRCustomizer from the XML configuration and SNPRC_EHRCustomizer from the Java code (lines 207-212 of SNPRC_EHRCustomizer.java). Both customizers may attempt to add assignment and age columns, potentially causing conflicts or duplicate columns. Verify that these customizers work together correctly without creating duplicate calculated columns.

Suggested change
<javaCustomizer class="org.labkey.ehr.table.DefaultEHRCustomizer" />

Copilot uses AI. Check for mistakes.
SELECT
obr.ANIMAL_ID as id,
obr.OBSERVATION_DATE_TM as date,
obr.ANIMAL_ID || '-' || CAST(obr.OBSERVATION_DATE_TM AS VARCHAR) as key,
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

The key field is composed only of id and date concatenation, but the query groups by additional columns (MESSAGE_ID, PROCEDURE_NAME, PROCEDURE_ID, COMMENT) which means multiple rows can have the same key value. This will cause issues since the key field is marked as isKeyField in the query.xml file. Consider including additional distinguishing fields in the key formula to ensure uniqueness, or reconsider whether this composite key is appropriate for the data structure.

Suggested change
obr.ANIMAL_ID || '-' || CAST(obr.OBSERVATION_DATE_TM AS VARCHAR) as key,
obr.ANIMAL_ID || '-' || CAST(obr.OBSERVATION_DATE_TM AS VARCHAR)
|| '-' || COALESCE(CAST(obr.MESSAGE_ID AS VARCHAR), '')
|| '-' || COALESCE(CAST(obr.PROCEDURE_ID AS VARCHAR), '')
|| '-' || COALESCE(CAST(obr.SET_ID AS VARCHAR), '')
|| '-' || COALESCE(nte.COMMENT, '') as key,

Copilot uses AI. Check for mistakes.
@@ -1,5 +1,6 @@
SELECT obr.ANIMAL_ID as id,
obr.OBSERVATION_DATE_TM as date,
obr.ANIMAL_ID || '-' || CAST(obr.OBSERVATION_DATE_TM AS VARCHAR) as key,
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

The key field is composed only of id and date concatenation, but the query groups by additional columns (MESSAGE_ID, PROCEDURE_NAME, PROCEDURE_ID, COMMENT) which means multiple rows can have the same key value. This will cause issues since the key field is marked as isKeyField in the query.xml file. Consider including additional distinguishing fields in the key formula to ensure uniqueness, or reconsider whether this composite key is appropriate for the data structure.

Suggested change
obr.ANIMAL_ID || '-' || CAST(obr.OBSERVATION_DATE_TM AS VARCHAR) as key,
obr.ANIMAL_ID
|| '-' || CAST(obr.OBSERVATION_DATE_TM AS VARCHAR)
|| '-' || COALESCE(obr.MESSAGE_ID, '')
|| '-' || COALESCE(CAST(obr.SET_ID AS VARCHAR), '')
|| '-' || COALESCE(CAST(obr.PROCEDURE_ID AS VARCHAR), '')
|| '-' || COALESCE(CAST(nte.COMMENT AS VARCHAR), '')
as key,

Copilot uses AI. Check for mistakes.
@@ -1,5 +1,6 @@
SELECT obr.ANIMAL_ID as id,
obr.OBSERVATION_DATE_TM as date,
obr.ANIMAL_ID || '-' || CAST(obr.OBSERVATION_DATE_TM AS VARCHAR) as key,
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

The key field is composed only of id and date concatenation, but the query groups by additional columns (MESSAGE_ID, PROCEDURE_NAME, PROCEDURE_ID, COMMENT) which means multiple rows can have the same key value. This will cause issues since the key field is marked as isKeyField in the query.xml file. Consider including additional distinguishing fields in the key formula to ensure uniqueness, or reconsider whether this composite key is appropriate for the data structure.

Suggested change
obr.ANIMAL_ID || '-' || CAST(obr.OBSERVATION_DATE_TM AS VARCHAR) as key,
obr.ANIMAL_ID || '-' || CAST(obr.OBSERVATION_DATE_TM AS VARCHAR) || '-' ||
CAST(obr.MESSAGE_ID AS VARCHAR) || '-' || CAST(obr.PROCEDURE_ID AS VARCHAR) || '-' ||
COALESCE (lp.ServiceId.ServiceName, obr.PROCEDURE_NAME) || '-' || COALESCE(nte.COMMENT, '') as key,

Copilot uses AI. Check for mistakes.
<metadata>
<tables xmlns="http://labkey.org/data/xml">
<table tableName="HL7BiochemistryPivot" tableDbType="NOT_IN_DB">
<javaCustomizer class="org.labkey.ehr.table.DefaultEHRCustomizer" />
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

This table now has two customizers being applied: DefaultEHRCustomizer from the XML configuration and SNPRC_EHRCustomizer from the Java code (lines 207-212 of SNPRC_EHRCustomizer.java). Both customizers may attempt to add assignment and age columns, potentially causing conflicts or duplicate columns. Verify that these customizers work together correctly without creating duplicate calculated columns.

Suggested change
<javaCustomizer class="org.labkey.ehr.table.DefaultEHRCustomizer" />

Copilot uses AI. Check for mistakes.
<metadata>
<tables xmlns="http://labkey.org/data/xml">
<table tableName="HL7MiscPivot" tableDbType="NOT_IN_DB">
<javaCustomizer class="org.labkey.ehr.table.DefaultEHRCustomizer" />
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

This table now has two customizers being applied: DefaultEHRCustomizer from the XML configuration and SNPRC_EHRCustomizer from the Java code (lines 207-212 of SNPRC_EHRCustomizer.java). Both customizers may attempt to add assignment and age columns, potentially causing conflicts or duplicate columns. Verify that these customizers work together correctly without creating duplicate calculated columns.

Suggested change
<javaCustomizer class="org.labkey.ehr.table.DefaultEHRCustomizer" />

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants