Skip to content

Add ABG structured lab template with auto-calculated oxygenation indices in Labs tab#14

Closed
Copilot wants to merge 3 commits into
mainfrom
copilot/add-abg-labs-tab
Closed

Add ABG structured lab template with auto-calculated oxygenation indices in Labs tab#14
Copilot wants to merge 3 commits into
mainfrom
copilot/add-abg-labs-tab

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 22, 2026

Adds an ABG template to the Labs tab with required parameters and built-in oxygenation calculations. The change also surfaces the requested normal-value guidance (including age-adjusted references) directly in the ABG workflow.

  • ABG template added to structured labs

    • New template: UST - ABG
    • Fields included:
      • pH, pCO2 (mmHg), pO2 (mmHg), HCO3 (mmol/L), a/A, A-aDO2 (mmHg), Actual FiO2 (%), pO2/FiO2, Desired FiO2 (%)
  • Auto-calculations implemented

    • pO2/FiO2 is computed from:
      • pO2 / (Actual FiO2 / 100)
    • Desired FiO2 is computed from:
      • (Actual FiO2 * Desired PaO2) / Actual PaO2
    • Added optional Desired PaO2 input; defaults to 60 when blank.
    • Computed fields are rendered as auto-calculated/read-only in the ABG form.
  • Normal-value guidance in ABG UI

    • Added reviewer text in the ABG panel:
      • a/AO2 NV: ≥0.75
      • A-aDO2 NV: 15+ [(# of decades above 30) *3]
      • P/F ratio NV: <60 yo: 400; >60 yo: 400 – [(# of yrs above 60) *5]
    • Also displays age-based computed normal references for the currently focused patient:
      • A-aDO2 ≈ 15 + floor((age - 30)/10) * 3
      • P/F ratio ≈ 400 if age <= 60, else 400 - (age - 60) * 5
  • Docs / user guidance updates

    • Settings → How to use: added ABG calculator tip.
    • README Labs tab description updated to include ABG structured template support.
    • Version bumped to 1.1.20.
// ABG calculations used by the template
const pFValue = pO2 / (actualFiO2 / 100)
const desiredFiO2 = (actualFiO2 * (desiredPaO2 ?? 60)) / pO2
Original prompt

This section details on the original issue you should resolve

<issue_title>Add "ABG" - LABS tab</issue_title>
<issue_description>Include a new template for ABG (Arterial Blood Gas), with the following parameters included

pH, pCO2 (mmHg), pO2 (mmHg), HCO3 (mmol/L), a/A, A-aDO2 (mmHg), Actual FiO2 (%), pO2/FiO2, Desired FiO2 (%)

Special rules:

  1. pO2/FiO2 should automatically be calculated using the following formula: pO2 / FiO2
  • FiO2 in this case is expressed as a decimal, eg pO2: 80, FiO2 20% --> pO2/FiO2 = 80 / 0.2 = 400
  • Note that the FiO2 that the user will type in is as a "whole number as percentage", eg "FiO2: 20%", and since the calculation uses the decimal version of this number --> the actual calculation for the computer might look more like: "pO2 / (FiO2/100)" to get "pO2 / 0.2" as the calculation
  1. Desired FiO2 should automatically be calculated using the following formula: Desired FiO2 = [(Actual FiO2) * (Desired PaO2)] / (Actual PaO2)
  • Actual FiO2 and PaO2 is given by the user (PaO2 and pO2 are the same)
  • Desired PaO2 is 60 by default if the field is left blank
  • FiO2 in this case is expressed as a "whole number as percentage", eg Desired FiO2 = (20% * 60) / 120 = 40%
  1. Indicate the normal value for a/A, which is >=0.75

  2. Indicate the normal value for A-aDO2, which is calculated using the following:

Rule Used

Normal A–a gradient approximation:

Normal A–a ≈ 15 + [(# of decades above 30) × 3]


Step 1: Determine Decades Above 30

For a 35-year-old:

  • Decades above 30 = 0
    (Because a full decade above 30 has not been completed)

Step 2: Apply Formula

Normal A–a ≈ 15 + (0 × 3)

Normal A–a ≈ 15 mmHg


Important Nuance

This formula uses whole decades only:

  • Age 31–39 → 15 mmHg
  • Age 40–49 → 18 mmHg
  • Age 50–59 → 21 mmHg
  1. Indicate the normal value for PaO2/FiO2, which is calculated as follows

Age-Adjusted Calculation Rule

For Patients < 60 Years Old

Value = 400


For Patients > 60 Years Old

Value = 400 – [(# of years above 60) × 5]


Example

Age 65:

Value = 400 – [(65 − 60) × 5]
Value = 400 – (5 × 5)
Value = 400 – 25
Value = 375

  1. Display the following text (mainly as a reviewer for the user) regarding the formula for the oxygenation indices:
  • a/AO2 NV: ≥0.75
  • A-aDO2 NV: 15+ [(# of decades above 30) *3]
  • P/F ratio NV: <60 yo: 400; >60 yo: 400 – [(# of yrs above 60) *5]</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 22, 2026 13:19
Co-authored-by: CSfromCS <42040696+CSfromCS@users.noreply.github.com>
Co-authored-by: CSfromCS <42040696+CSfromCS@users.noreply.github.com>
Copilot AI changed the title [WIP] Add ABG template to LABS tab Add ABG structured lab template with auto-calculated oxygenation indices in Labs tab Feb 22, 2026
Copilot AI requested a review from CSfromCS February 22, 2026 13:22
@CSfromCS CSfromCS closed this Feb 25, 2026
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.

Add "ABG" - LABS tab

2 participants