Skip to content

feat(labs): NASS-1879: Lab test secondary results#9012

Open
tcodling wants to merge 28 commits intomainfrom
cursor/NASS-1879-lab-test-secondary-results-139d
Open

feat(labs): NASS-1879: Lab test secondary results#9012
tcodling wants to merge 28 commits intomainfrom
cursor/NASS-1879-lab-test-secondary-results-139d

Conversation

@tcodling
Copy link
Contributor

@tcodling tcodling commented Jan 16, 2026

Changes

This PR introduces support for secondary results for lab tests (NASS-1879).

Key changes include:

  • Reference Data: Added a supportsSecondaryResults boolean field to LabTestType (default false) to control if a lab test type can have a secondary result.
  • Data Model: Added a secondaryResult text field to LabTest to store the secondary result.
  • UI for Results Entry: A new "Secondary result" column is available in the lab test results entry modal, appearing only for lab test types that support it.
  • UI for Results Display:
    • Secondary results are displayed in the lab test result details modal.
    • A tooltip shows the secondary result when hovering over the primary result in the lab request results table.
  • PDF Printout: Secondary results are included in brackets next to the primary result in the PDF printout.

Deploys

  • Deploy to Tamanu Internal

Tests

  • Run E2E Tests

Remember to...

  • ...write or update tests
  • ...add UI screenshots and testing notes to the Linear issue
  • ...add any manual upgrade steps to the Linear issue
  • ...update the config reference, settings reference, or any relevant runbook(s)
  • ...call out additions or changes to config files for the deployment team to take note of

Linear Issue: NASS-1879

Open in Cursor Open in Web


Note

Medium Risk
Touches schema and syncable lab models plus result-entry UI validation and API authorization checks; failures could impact lab result editing/display across clients, but changes are additive and gated by a default-off flag.

Overview
Adds data-model support for recording an additional lab test value by introducing lab_test_types.supports_secondary_results (non-null, default false) and lab_tests.secondary_result (nullable), with accompanying DBT docs and Sequelize/TypeORM migrations.

Updates lab result workflows to surface this field end-to-end: the web results entry modal conditionally shows a Secondary result column (disabled when unsupported) and adds validation requiring a primary result if a secondary result is entered; result display (details modal, results table tooltip) and PDF printout now include the secondary value when supported.

Extends the facility-server PUT labRequest/:id/tests permission check to treat changes to secondaryResult the same as primary result changes for LabTestResult authorization.

Written by Cursor Bugbot for commit b316c17. This will update automatically on new commits. Configure here.

cursoragent and others added 3 commits January 16, 2026 01:44
- Add supportsSecondaryResults field to LabTestType model (default: false)
- Add secondaryResult field to LabTest model (text, nullable)
- Include migrations for both server and mobile databases
- Update TypeScript model definitions for server and mobile

Co-authored-by: thomascodling <thomascodling@bes.au>
- Add secondary result input field in LabTestResultsModal (shown only when lab test type supports it)
- Display secondary result in LabTestResultModal details view
- Add tooltip on hover in lab results table to show secondary result
- Show secondary result in brackets in PDF printout

Co-authored-by: thomascodling <thomascodling@bes.au>
- Add supportsSecondaryResults to ILabTestType interface
- Add secondaryResult to ILabTest interface

Co-authored-by: thomascodling <thomascodling@bes.au>
@cursor
Copy link

cursor bot commented Jan 16, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @tcodling, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the system's capability to handle more nuanced lab test data by introducing support for secondary results. This involves fundamental changes to the data models, ensuring that the application can store this new information, and comprehensive updates to the user interface and reporting features to display and manage these secondary results effectively. The changes provide a more complete picture of lab test outcomes where additional data points are relevant.

Highlights

  • Data Model Extension: Introduced a supportsSecondaryResults boolean field to LabTestType and a secondaryResult text field to LabTest across both database and mobile models to store and manage additional lab test information.
  • User Interface Enhancements: Updated the UI for lab test results entry to include a conditional 'Secondary result' column, and enhanced result display modals and tables to show secondary results, including a tooltip on hover.
  • PDF Printout Integration: Secondary results are now incorporated into the PDF printouts, appearing in brackets next to the primary result for relevant lab tests.
  • Database Migrations: New database migrations have been added for both the main application and mobile to correctly add the supports_secondary_results and secondary_result columns to their respective tables.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for secondary results for lab tests, with comprehensive changes across the database, mobile, and web applications. The implementation is solid, with new fields added via migrations, models updated accordingly, and UI components adjusted to display and edit the new data. The conditional logic based on the supportsSecondaryResults flag is consistently applied. I've included a couple of suggestions to improve the efficiency of the mobile database migrations.

@tcodling tcodling changed the title Lab test secondary results feat(labs): NASS-1879: Lab test secondary results Jan 16, 2026
@tcodling tcodling marked this pull request as ready for review January 16, 2026 02:27
@tcodling
Copy link
Contributor Author

bugbot run

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

referenceDataId={labTestTypeId}
referenceDataCategory="labTestType"
/>
<ConditionalTooltip
Copy link
Contributor Author

@tcodling tcodling Jan 18, 2026

Choose a reason for hiding this comment

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

This tooltop is the only change. The rest is formatting

@github-actions
Copy link

github-actions bot commented Jan 18, 2026

@github-actions
Copy link

github-actions bot commented Jan 18, 2026

🍹 up on tamanu-on-k8s/bes/tamanu-on-k8s/cursor-nass-1879-lab-test-secondary-results-139d

Pulumi report
  Updating (bes/cursor-nass-1879-lab-test-secondary-results-139d)

View Live: https://app.pulumi.com/bes/tamanu-on-k8s/cursor-nass-1879-lab-test-secondary-results-139d/updates/11

Downloading plugin random-4.19.0: done
Installing plugin random-4.19.0: starting
Installing plugin random-4.19.0: done

@ Updating....
  pulumi:pulumi:Stack tamanu-on-k8s-cursor-nass-1879-lab-test-secondary-results-139d running 
@ Updating.....
  pulumi:pulumi:Stack tamanu-on-k8s-cursor-nass-1879-lab-test-secondary-results-139d running read pulumi:pulumi:StackReference bes/k8s-core/tamanu-internal-main
  pulumi:pulumi:Stack tamanu-on-k8s-cursor-nass-1879-lab-test-secondary-results-139d running Using tailscale proxy https://k8s-operator-tamanu-internal-main.tail53aef.ts.net
@ Updating....
  pulumi:pulumi:Stack tamanu-on-k8s-cursor-nass-1879-lab-test-secondary-results-139d running read kubernetes:core/v1:Namespace tamanu-cursor-nass-1879-lab-test-secondary-results-139d
  pulumi:pulumi:Stack tamanu-on-k8s-cursor-nass-1879-lab-test-secondary-results-139d running read pulumi:pulumi:StackReference bes/k8s-core/tamanu-internal-main
  pulumi:pulumi:Stack tamanu-on-k8s-cursor-nass-1879-lab-test-secondary-results-139d running read pulumi:pulumi:StackReference bes/core/tamanu-internal
@ Updating....
  pulumi:pulumi:Stack tamanu-on-k8s-cursor-nass-1879-lab-test-secondary-results-139d running read pulumi:pulumi:StackReference bes/core/tamanu-internal
  pulumi:pulumi:Stack tamanu-on-k8s-cursor-nass-1879-lab-test-secondary-results-139d running read kubernetes:core/v1:Namespace tamanu-cursor-nass-1879-lab-test-secondary-results-139d
  pulumi:pulumi:Stack tamanu-on-k8s-cursor-nass-1879-lab-test-secondary-results-139d running Waiting for central-db...
  pulumi:pulumi:Stack tamanu-on-k8s-cursor-nass-1879-lab-test-secondary-results-139d running Waiting for facility-1-db...
  pulumi:pulumi:Stack tamanu-on-k8s-cursor-nass-1879-lab-test-secondary-results-139d running Waiting for facility-2-db...
  pulumi:pulumi:Stack tamanu-on-k8s-cursor-nass-1879-lab-test-secondary-results-139d running read kubernetes:core/v1:ConfigMap actual-provisioning
@ Updating....
  pulumi:pulumi:Stack tamanu-on-k8s-cursor-nass-1879-lab-test-secondary-results-139d running read kubernetes:core/v1:ConfigMap actual-provisioning
  pulumi:pulumi:Stack tamanu-on-k8s-cursor-nass-1879-lab-test-secondary-results-139d running Secret central-db-superuser not found or not ready: Error: HTTP-Code: 404
  pulumi:pulumi:Stack tamanu-on-k8s-cursor-nass-1879-lab-test-secondary-results-139d running Message: Unknown API Status Code!
  pulumi:pulumi:Stack tamanu-on-k8s-cursor-nass-1879-lab-test-secondary-results-139d running Body: "{\"kind\":\"Status\",\"apiVersion\":\"v1\",\"metadata\":{},\"status\":\"Failure\",\"message\":\"secrets \\\"central-db-superuser\\\" not found\",\"reason\":\"NotFound\",\"details\":{\"name\":\"central-db-superuser\",\"kind\":\"secrets\"},\"code\":404}
"
  pulumi:pulumi:Stack tamanu-on-k8s-cursor-nass-1879-lab-test-secondary-results-139d running Headers: {"audit-id":"b3124a7a-b6db-4341-a071-c82696d82a59","cache-control":"no-cache, private","connection":"close","content-length":"214","content-type":"application/json","date":"Tue, 03 Feb 2026 01:09:24 GMT","x-kubernetes-pf-flowschema-uid":"3fb296fc-e46b-45d1-9306-057e37ddd229","x-kubernetes-pf-prioritylevel-uid":"feccf24d-a074-4fa8-aa6f-db82477fc2f5"}
  pulumi:pulumi:Stack tamanu-on-k8s-cursor-nass-1879-lab-test-secondary-results-139d running Secret facility-1-db-superuser not found or not ready: Error: HTTP-Code: 404
  pulumi:pulumi:Stack tamanu-on-k8s-cursor-nass-1879-lab-test-secondary-results-139d running Message: Unknown API Status Code!
  pulumi:pulumi:Stack tamanu-on-k8s-cursor-nass-1879-lab-test-secondary-results-139d running Body: "{\"kind\":\"Status\",\"apiVersion\":\"v1\",\"metadata\":{},\"status\":\"Failure\",\"message\":\"secrets \\\"facility-1-db-superuser\\\" not found\",\"reason\":\"NotFound\",\"details\":{\"name\":\"facility-1-db-superuser\",\"kind\":\"secrets\"},\"code\":404}
"
  pulumi:pulumi:Stack tamanu-on-k8s-cursor-nass-1879-lab-test-secondary-results-139d running Headers: {"audit-id":"b5f64082-6f48-465b-936d-6ce07628e2a9","cache-control":"no-cache, private","connection":"close","content-length":"220","content-type":"application/json","date":"Tue, 03 Feb 2026 01:09:24 GMT","x-kubernetes-pf-flowschema-uid":"3fb296fc-e46b-45d1-9306-057e37ddd229","x-kubernetes-pf-prioritylevel-uid":"feccf24d-a074-4fa8-aa6f-db82477fc2f5"}
  pulumi:pulumi:Stack tamanu-on-k8s-cursor-nass-1879-lab-test-secondary-results-139d running Secret facility-2-db-superuser not found or not ready: Error: HTTP-Code: 404
  pulumi:pulumi:Stack tamanu-on-k8s-cursor-nass-1879-lab-test-secondary-results-139d running Message: Unknown API Status Code!
  pulumi:pulumi:Stack tamanu-on-k8s-cursor-nass-1879-lab-test-secondary-results-139d running Body: "{\"kind\":\"Status\",\"apiVersion\":\"v1\",\"metadata\":{},\"status\":\"Failure\",\"message\":\"secrets \\\"facility-2-db-superuser\\\" not found\",\"reason\":\"NotFound\",\"details\":{\"name\":\"facility-2-db-superuser\",\"kind\":\"secrets\"},\"code\":404}
"
  pulumi:pulumi:Stack tamanu-on-k8s-cursor-nass-1879-lab-test-secondary-results-139d running Headers: {"audit-id":"6aebc42f-920d-485b-95cf-3a977b325eea","cache-control":"no-cache, private","connection":"close","content-length":"220","content-type":"application/json","date":"Tue, 03 Feb 2026 01:09:24 GMT","x-kubernetes-pf-flowschema-uid":"3fb296fc-e46b-45d1-9306-057e37ddd229","x-kubernetes-pf-prioritylevel-uid":"feccf24d-a074-4fa8-aa6f-db82477fc2f5"}
@ Updating....
  pulumi:pulumi:Stack tamanu-on-k8s-cursor-nass-1879-lab-test-secondary-results-139d  16 messages
Diagnostics:
pulumi:pulumi:Stack (tamanu-on-k8s-cursor-nass-1879-lab-test-secondary-results-139d):
  Waiting for central-db...
  Waiting for facility-1-db...
  Waiting for facility-2-db...

  Using tailscale proxy https://k8s-operator-tamanu-internal-main.tail53aef.ts.net

  Secret central-db-superuser not found or not ready: Error: HTTP-Code: 404
  Message: Unknown API Status Code!
  Body: "{\"kind\":\"Status\",\"apiVersion\":\"v1\",\"metadata\":{},\"status\":\"Failure\",\"message\":\"secrets \\\"central-db-superuser\\\" not found\",\"reason\":\"NotFound\",\"details\":{\"name\":\"central-db-superuser\",\"kind\":\"secrets\"},\"code\":404}
"
  Headers: {"audit-id":"b3124a7a-b6db-4341-a071-c82696d82a59","cache-control":"no-cache, private","connection":"close","content-length":"214","content-type":"application/json","date":"Tue, 03 Feb 2026 01:09:24 GMT","x-kubernetes-pf-flowschema-uid":"3fb296fc-e46b-45d1-9306-057e37ddd229","x-kubernetes-pf-prioritylevel-uid":"feccf24d-a074-4fa8-aa6f-db82477fc2f5"}
  Secret facility-1-db-superuser not found or not ready: Error: HTTP-Code: 404
  Message: Unknown API Status Code!
  Body: "{\"kind\":\"Status\",\"apiVersion\":\"v1\",\"metadata\":{},\"status\":\"Failure\",\"message\":\"secrets \\\"facility-1-db-superuser\\\" not found\",\"reason\":\"NotFound\",\"details\":{\"name\":\"facility-1-db-superuser\",\"kind\":\"secrets\"},\"code\":404}
"
  Headers: {"audit-id":"b5f64082-6f48-465b-936d-6ce07628e2a9","cache-control":"no-cache, private","connection":"close","content-length":"220","content-type":"application/json","date":"Tue, 03 Feb 2026 01:09:24 GMT","x-kubernetes-pf-flowschema-uid":"3fb296fc-e46b-45d1-9306-057e37ddd229","x-kubernetes-pf-prioritylevel-uid":"feccf24d-a074-4fa8-aa6f-db82477fc2f5"}
  Secret facility-2-db-superuser not found or not ready: Error: HTTP-Code: 404
  Message: Unknown API Status Code!
  Body: "{\"kind\":\"Status\",\"apiVersion\":\"v1\",\"metadata\":{},\"status\":\"Failure\",\"message\":\"secrets \\\"facility-2-db-superuser\\\" not found\",\"reason\":\"NotFound\",\"details\":{\"name\":\"facility-2-db-superuser\",\"kind\":\"secrets\"},\"code\":404}
"
  Headers: {"audit-id":"6aebc42f-920d-485b-95cf-3a977b325eea","cache-control":"no-cache, private","connection":"close","content-length":"220","content-type":"application/json","date":"Tue, 03 Feb 2026 01:09:24 GMT","x-kubernetes-pf-flowschema-uid":"3fb296fc-e46b-45d1-9306-057e37ddd229","x-kubernetes-pf-prioritylevel-uid":"feccf24d-a074-4fa8-aa6f-db82477fc2f5"}

  [Pulumi Neo] Would you like help with these diagnostics?
  https://app.pulumi.com/bes/tamanu-on-k8s/cursor-nass-1879-lab-test-secondary-results-139d/updates/11?explainFailure

Outputs:
  urls: {
      Central      : "https://central.cursor-nass-1879-lab-test-secondary-results-139d.cd.tamanu.app"
      Facility- 1  : "https://facility-1.cursor-nass-1879-lab-test-secondary-results-139d.cd.tamanu.app"
      Facility- 2  : "https://facility-2.cursor-nass-1879-lab-test-secondary-results-139d.cd.tamanu.app"
      PatientPortal: "https://portal.cursor-nass-1879-lab-test-secondary-results-139d.cd.tamanu.app"
  }

Resources:
  67 unchanged

Duration: 6s

  

@tcodling
Copy link
Contributor Author

bugbot run

cursor[bot]

This comment was marked as outdated.

name={LAB_TEST_PROPERTIES.LAB_TEST_METHOD_ID}
component={SuggesterSelectField}
tabIndex={tabIndex(1, i)}
tabIndex={tabIndex(2, i)}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dev tested and these tab indexes work fine with the conditional column

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Copy link
Collaborator

@rohan-bes rohan-bes left a comment

Choose a reason for hiding this comment

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

Looks great! Nice stuff

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.

3 participants