-
Notifications
You must be signed in to change notification settings - Fork 3
Query customizer for HL7 Pivot tables #881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release25.7-SNAPSHOT
Are you sure you want to change the base?
Query customizer for HL7 Pivot tables #881
Conversation
There was a problem hiding this 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" /> |
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
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.
| <javaCustomizer class="org.labkey.ehr.table.DefaultEHRCustomizer" /> |
| @@ -1,5 +1,6 @@ | |||
| select Id, | |||
| date, | |||
| obr.ANIMAL_ID || '-' || CAST(obr.OBSERVATION_DATE_TM AS VARCHAR) as key, | |||
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
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.
| obr.ANIMAL_ID || '-' || CAST(obr.OBSERVATION_DATE_TM AS VARCHAR) as key, | |
| Id || '-' || CAST(date AS VARCHAR) as key, |
| SELECT | ||
| obr.ANIMAL_ID as id, | ||
| obr.OBSERVATION_DATE_TM as date, | ||
| obr.ANIMAL_ID || '-' || CAST(obr.OBSERVATION_DATE_TM AS VARCHAR) as key, |
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
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.
| 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, |
| SELECT | ||
| obr.ANIMAL_ID as id, | ||
| obr.OBSERVATION_DATE_TM as date, | ||
| obr.ANIMAL_ID || '-' || CAST(obr.OBSERVATION_DATE_TM AS VARCHAR) as key, |
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
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.
| 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, |
| <metadata> | ||
| <tables xmlns="http://labkey.org/data/xml"> | ||
| <table tableName="HL7SurveillancePivot" tableDbType="NOT_IN_DB"> | ||
| <javaCustomizer class="org.labkey.ehr.table.DefaultEHRCustomizer" /> |
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
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.
| <javaCustomizer class="org.labkey.ehr.table.DefaultEHRCustomizer" /> |
| SELECT | ||
| obr.ANIMAL_ID as id, | ||
| obr.OBSERVATION_DATE_TM as date, | ||
| obr.ANIMAL_ID || '-' || CAST(obr.OBSERVATION_DATE_TM AS VARCHAR) as key, |
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
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.
| 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, |
| @@ -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, | |||
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
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.
| 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, |
| @@ -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, | |||
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
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.
| 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, |
| <metadata> | ||
| <tables xmlns="http://labkey.org/data/xml"> | ||
| <table tableName="HL7BiochemistryPivot" tableDbType="NOT_IN_DB"> | ||
| <javaCustomizer class="org.labkey.ehr.table.DefaultEHRCustomizer" /> |
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
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.
| <javaCustomizer class="org.labkey.ehr.table.DefaultEHRCustomizer" /> |
| <metadata> | ||
| <tables xmlns="http://labkey.org/data/xml"> | ||
| <table tableName="HL7MiscPivot" tableDbType="NOT_IN_DB"> | ||
| <javaCustomizer class="org.labkey.ehr.table.DefaultEHRCustomizer" /> |
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
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.
| <javaCustomizer class="org.labkey.ehr.table.DefaultEHRCustomizer" /> |
Rationale
Added calculated at-time columns for assignments and accounts to HL7 Pivot tables. Started creating qviews for routine lab results.