Skip to content

Support affine unit conversions in unit_conversions.json #18

@BorisDelange

Description

@BorisDelange

units/unit_conversions.json currently stores only multiplicative conversion factors (target = factor × source). This works for most analytes but cannot represent affine conversions of the form target = factor × source + offset.

Known cases that need affine conversions

  • HbA1c: IFCC [mmol/mol] = (NGSP [%] − 2.152) / 0.0915 (derived from the NGSP-IFCC master equation, see concept set 184).
  • Temperature: Fahrenheit ↔ Celsius (°F = 9/5 × °C + 32).

For HbA1c, the conversion is currently documented in the concept set description and must be applied manually in downstream code.

Proposed change

Add an optional offset field to each conversion entry. When absent or 0, the conversion remains purely multiplicative — so the 372 existing entries are unaffected.

{
  "conceptId": 3004410,
  "sourceUnitConceptId": 8554,
  "sourceUnitCode": "%",
  "conversionFactor": 10.929,
  "offset": -23.52,
  "targetUnitConceptId": 9579,
  "targetUnitCode": "mmol/mol",
  ...
}

target = factor × source + offset

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions