Functional Weave
Code in TypeScript

health.egfr@1.0.1

vectors.json

3,760 bytes · view raw

[
  { "name": "woman, 50, creatinine at the knot (0.7 mg/dL): 142 × 0.9938^50 × 1.012 = 105.3", "args": [0.7, "mg-per-dl", 50, "female"], "expect": { "value": 105.3, "reported": 105 } },
  { "name": "man, 50, creatinine at the knot (0.9 mg/dL): 104.0", "args": [0.9, "mg-per-dl", 50, "male"], "expect": { "value": 104.0, "reported": 104 } },
  { "name": "man, 60, 1.0 mg/dL: above the knot, exponent -1.200", "args": [1.0, "mg-per-dl", 60, "male"], "expect": { "value": 86.2, "reported": 86 } },
  { "name": "man, 60, 80 µmol/L (0.905 mg/dL)", "args": [80, "umol-per-l", 60, "male"], "expect": { "value": 97.1, "reported": 97 } },
  { "name": "woman, 30, 62 µmol/L: 118.97 is 119.0", "args": [62, "umol-per-l", 30, "female"], "expect": { "value": 119.0, "reported": 119 } },
  { "name": "woman, 75, 1.2 mg/dL: CKD stage G3a territory", "args": [1.2, "mg-per-dl", 75, "female"], "expect": { "value": 47.2, "reported": 47 } },
  { "name": "woman, 70, 100 µmol/L", "args": [100, "umol-per-l", 70, "female"], "expect": { "value": 52.3, "reported": 52 } },
  { "name": "man, 45, 150 µmol/L", "args": [150, "umol-per-l", 45, "male"], "expect": { "value": 50.1, "reported": 50 } },
  { "name": "man, 80, 300 µmol/L: 17.56 reports as 18", "args": [300, "umol-per-l", 80, "male"], "expect": { "value": 17.6, "reported": 18 } },
  { "name": "woman, 25, 0.5 mg/dL: below the knot, exponent -0.241", "args": [0.5, "mg-per-dl", 25, "female"], "expect": { "value": 133.4, "reported": 133 } },
  { "name": "man, 18, 0.6 mg/dL: 143.4993 is 143.5 to one place but reports as 143, not 144", "args": [0.6, "mg-per-dl", 18, "male"], "expect": { "value": 143.5, "reported": 143 } },
  { "name": "88.4 µmol/L is exactly 1 mg/dL", "args": [88.4, "umol-per-l", 40, "male"], "expect": { "value": 97.6, "reported": 98 } },
  { "name": "61.88 µmol/L is the female knot, 0.7 mg/dL", "args": [61.88, "umol-per-l", 40, "female"], "expect": { "value": 112.1, "reported": 112 } },
  { "name": "79.56 µmol/L is the male knot, 0.9 mg/dL", "args": [79.56, "umol-per-l", 40, "male"], "expect": { "value": 110.7, "reported": 111 } },
  { "name": "man, 65, 3.0 mg/dL: stage G4", "args": [3.0, "mg-per-dl", 65, "male"], "expect": { "value": 22.3, "reported": 22 } },
  { "name": "woman, 55, 700 µmol/L: kidney failure range", "args": [700, "umol-per-l", 55, "female"], "expect": { "value": 5.6, "reported": 6 } },
  { "name": "the oldest accepted age", "args": [1.5, "mg-per-dl", 120, "male"], "expect": { "value": 36.5, "reported": 36 } },
  { "name": "the youngest accepted age", "args": [0.8, "mg-per-dl", 18, "female"], "expect": { "value": 109.5, "reported": 109 } },
  { "name": "a child is refused: the equation is for adults", "args": [0.5, "mg-per-dl", 17, "male"], "expectError": "ageYears must be a whole number from 18 to 120" },
  { "name": "a fractional age is refused", "args": [0.9, "mg-per-dl", 50.5, "male"], "expectError": "ageYears must be a whole number from 18 to 120" },
  { "name": "µmol/L entered with the mg/dL unit is refused, not read as 80 mg/dL", "args": [80, "mg-per-dl", 60, "male"], "expectError": "creatinine must be a number from 0.1 to 45 mg-per-dl" },
  { "name": "mg/dL entered with the µmol/L unit is refused, not read as 0.9 µmol/L", "args": [0.9, "umol-per-l", 60, "male"], "expectError": "creatinine must be a number from 10 to 4000 umol-per-l" },
  { "name": "zero creatinine is refused", "args": [0, "umol-per-l", 60, "male"], "expectError": "creatinine must be a number" },
  { "name": "an unknown unit is refused", "args": [80, "mmol/L", 60, "male"], "expectError": "unit must be umol-per-l or mg-per-dl" },
  { "name": "an unknown sex code is refused", "args": [80, "umol-per-l", 60, "F"], "expectError": "sex must be female or male" }
]