From d6d6443b14d1151ffb3b14b9c10b3457f899006d Mon Sep 17 00:00:00 2001 From: Jose Costa Teixeira <16153168+costateixeira@users.noreply.github.com> Date: Sat, 4 Apr 2026 21:36:02 +0200 Subject: [PATCH 1/4] Use getOrDownloadFile for UCUM loading, consistent with all other sources MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UCUM was the only terminology source using a path relative to the app root instead of resolving from the terminology-cache folder via getOrDownloadFile. This made config inconsistent — UCUM required `data/terminology-cache/` prefix while LOINC, SNOMED, etc. did not. Now `ucum:ucum-essence-2.2.xml` works the same as `loinc:loinc-2.81-b.db`. Co-Authored-By: Claude Opus 4.6 (1M context) --- tx/library.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tx/library.js b/tx/library.js index 4bea49f9..a59db1a2 100644 --- a/tx/library.js +++ b/tx/library.js @@ -489,18 +489,18 @@ class Library { } async loadUcum(details, isDefault, mode) { + const ucumFN = await this.getOrDownloadFile(details); if (mode === "fetch" || mode === "npm") { return; } - const source = path.join(__dirname, '..', details); - const ucumEssenceXml = readFileSync(source, 'utf8'); + const ucumEssenceXml = readFileSync(ucumFN, 'utf8'); const ucumService = new UcumService(); await ucumService.init(ucumEssenceXml); const ucum = new UcumCodeSystemFactory(this.i18n, ucumService); await ucum.load(); - this.registerProvider(source, ucum, isDefault); + this.registerProvider(ucumFN, ucum, isDefault); } async loadLoinc(details, isDefault, mode) { From d3b3af4365b8d6f31b93ee75ec5eec747cb67cfe Mon Sep 17 00:00:00 2001 From: Jose Costa Teixeira <16153168+costateixeira@users.noreply.github.com> Date: Sat, 4 Apr 2026 22:13:24 +0200 Subject: [PATCH 2/4] Update test/dev configs for new UCUM loading path Copy ucum-essence.xml to defaults/data/terminology-cache/ and update test-cases.yml and tx.fhir.org.yml to use the cache-relative path, consistent with the new getOrDownloadFile behavior. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../data/terminology-cache/ucum-essence.xml | 2059 +++++++++++++++++ tx/fixtures/test-cases.yml | 2 +- tx/tx.fhir.org.yml | 2 +- 3 files changed, 2061 insertions(+), 2 deletions(-) create mode 100644 defaults/data/terminology-cache/ucum-essence.xml diff --git a/defaults/data/terminology-cache/ucum-essence.xml b/defaults/data/terminology-cache/ucum-essence.xml new file mode 100644 index 00000000..ec61d23c --- /dev/null +++ b/defaults/data/terminology-cache/ucum-essence.xml @@ -0,0 +1,2059 @@ + + + + yotta + Y + 1 × 1024 + + + + zetta + Z + 1 × 1021 + + + + exa + E + 1 × 1018 + + + + peta + P + 1 × 1015 + + + + tera + T + 1 × 1012 + + + + giga + G + 1 × 109 + + + + mega + M + 1 × 106 + + + + kilo + k + 1 × 103 + + + + hecto + h + 1 × 102 + + + + deka + da + 1 × 101 + + + + deci + d + 1 × 10-1 + + + + centi + c + 1 × 10-2 + + + + milli + m + 1 × 10-3 + + + + micro + μ + 1 × 10-6 + + + + nano + n + 1 × 10-9 + + + + pico + p + 1 × 10-12 + + + + femto + f + 1 × 10-15 + + + + atto + a + 1 × 10-18 + + + + zepto + z + 1 × 10-21 + + + + yocto + y + 1 × 10-24 + + + + meter + m + length + + + second + s + time + + + gram + g + mass + + + radian + rad + plane angle + + + kelvin + K + temperature + + + coulomb + C + electric charge + + + candela + cd + luminous intensity + + + the number ten for arbitrary powers + 10 + number + 10 + + + the number ten for arbitrary powers + 10 + number + 10 + + + the number pi + π + number + π + + + percent + % + fraction + 1 + + + parts per thousand + ppth + fraction + 1 + + + parts per million + ppm + fraction + 1 + + + parts per billion + ppb + fraction + 1 + + + parts per trillion + pptr + fraction + 1 + + + mole + mol + amount of substance + 6.02214076 + + + steradian + sr + solid angle + 1 + + + hertz + Hz + frequency + 1 + + + newton + N + force + 1 + + + pascal + Pa + pressure + 1 + + + joule + J + energy + 1 + + + watt + W + power + 1 + + + ampère + A + electric current + 1 + + + volt + V + electric potential + 1 + + + farad + F + electric capacitance + 1 + + + ohm + Ω + electric resistance + 1 + + + siemens + S + electric conductance + 1 + + + weber + Wb + magnetic flux + 1 + + + degree Celsius + °C + temperature + + + + + + tesla + T + magnetic flux density + 1 + + + henry + H + inductance + 1 + + + lumen + lm + luminous flux + 1 + + + lux + lx + illuminance + 1 + + + becquerel + Bq + radioactivity + 1 + + + gray + Gy + energy dose + 1 + + + sievert + Sv + dose equivalent + 1 + + + gon + grade + + g + + plane angle + 0.9 + + + degree + ° + plane angle + 2 + + + minute + ' + plane angle + 1 + + + second + '' + plane angle + 1 + + + liter + l + volume + 1 + + + liter + L + volume + 1 + + + are + a + area + 100 + + + minute + min + time + 60 + + + hour + h + time + 60 + + + day + d + time + 24 + + + tropical year + at + + time + 365.24219 + + + mean Julian year + aj + + time + 365.25 + + + mean Gregorian year + ag + + time + 365.2425 + + + year + a + time + 1 + + + week + wk + time + 7 + + + synodal month + mos + + time + 29.53059 + + + mean Julian month + moj + + time + 1 + + + mean Gregorian month + mog + + time + 1 + + + month + mo + time + 1 + + + tonne + t + mass + 1 × 103 + + + + bar + bar + pressure + 1 × 105 + + + + unified atomic mass unit + u + mass + 1.66053906660 × 10-24 + + + + electronvolt + eV + energy + 1 + + + astronomic unit + AU + length + 149597.870691 + + + parsec + pc + length + 3.085678 × 1016 + + + + velocity of light + + c + + velocity + 299792458 + + + Planck constant + + h + + action + 6.62607015 × 10-34 + + + + Boltzmann constant + + k + + (unclassified) + 1.380649 × 10-23 + + + + permittivity of vacuum + + ε + 0 + + + + electric permittivity + 8.854187817 × 10-12 + + + + permeability of vacuum + + μ + 0 + + + + magnetic permeability + 1 + + + elementary charge + + e + + electric charge + 1.602176634 × 10-19 + + + + electron mass + + m + e + + + + mass + 9.1093837139 × 10-31 + + + + proton mass + + m + p + + + + mass + 1.67262192595 × 10-27 + + + + Newtonian constant of gravitation + + G + + (unclassified) + 6.67430 × 10-11 + + + + standard acceleration of free fall + + gn + + + acceleration + 9.80665 + + + standard atmosphere + atm + pressure + 101325 + + + light-year + l.y. + length + 1 + + + gram-force + gf + force + 1 + + + pound force + lbf + force + 1 + + + Kayser + K + lineic number + 1 + + + Gal + Gal + acceleration + 1 + + + dyne + dyn + force + 1 + + + erg + erg + energy + 1 + + + Poise + P + dynamic viscosity + 1 + + + Biot + Bi + electric current + 10 + + + Stokes + St + kinematic viscosity + 1 + + + Maxwell + Mx + flux of magnetic induction + 1 × 10-8 + + + + Gauss + Gs + magnetic flux density + 1 × 10-4 + + + + Oersted + Oe + magnetic field intensity + 250 + + + Gilbert + Gb + magnetic tension + 1 + + + stilb + sb + lum. intensity density + 1 + + + Lambert + L + brightness + 1 + + + phot + ph + illuminance + 1 × 10-4 + + + + Curie + Ci + radioactivity + 3.7 × 1010 + + + + Roentgen + R + ion dose + 2.58 × 10-4 + + + + radiation absorbed dose + RAD + energy dose + 100 + + + radiation equivalent man + REM + dose equivalent + 1 + + + inch + in + length + 2.54 + + + foot + ft + length + 12 + + + yard + yd + length + 3 + + + mile + mi + length + 5280 + + + fathom + fth + depth of water + 6 + + + nautical mile + n.mi + length + 1852 + + + knot + knot + velocity + 1 + + + square inch + area + 1 + + + square foot + area + 1 + + + square yard + area + 1 + + + cubic inch + volume + 1 + + + cubic foot + volume + 1 + + + cubic yard + cu.yd + volume + 1 + + + board foot + volume + 144 + + + cord + volume + 128 + + + mil + mil + length + 1 × 10-3 + + + + circular mil + circ.mil + area + 1 + + + hand + hd + height of horses + 4 + + + foot + ftus + + length + 1200 + + + yard + length + 3 + + + inch + length + 1 + + + rod + length + 16.5 + + + Gunter's chain + Surveyor's chain + length + 4 + + + link for Gunter's chain + length + 1 + + + Ramden's chain + Engineer's chain + length + 100 + + + link for Ramden's chain + length + 1 + + + fathom + length + 6 + + + furlong + length + 40 + + + mile + length + 8 + + + acre + area + 160 + + + square rod + area + 1 + + + square mile + area + 1 + + + section + area + 1 + + + township + area + 36 + + + mil + length + 1 × 10-3 + + + + inch + length + 2.539998 + + + foot + length + 12 + + + rod + length + 16.5 + + + Gunter's chain + length + 4 + + + link for Gunter's chain + length + 1 + + + fathom + length + 6 + + + pace + length + 2.5 + + + yard + length + 3 + + + mile + length + 5280 + + + nautical mile + length + 6080 + + + knot + velocity + 1 + + + acre + area + 4840 + + + Queen Anne's wine gallon + fluid volume + 231 + + + barrel + fluid volume + 42 + + + quart + fluid volume + 1 + + + pint + fluid volume + 1 + + + gill + fluid volume + 1 + + + fluid ounce + oz fl + fluid volume + 1 + + + fluid dram + fluid volume + 1 + + + minim + fluid volume + 1 + + + cord + fluid volume + 128 + + + bushel + dry volume + 2150.42 + + + historical winchester gallon + dry volume + 1 + + + peck + dry volume + 1 + + + dry quart + dry volume + 1 + + + dry pint + dry volume + 1 + + + tablespoon + volume + 1 + + + teaspoon + volume + 1 + + + cup + volume + 16 + + + metric fluid ounce + oz fl + fluid volume + 30 + + + metric cup + volume + 240 + + + metric teaspoon + volume + 5 + + + metric tablespoon + volume + 15 + + + gallon + volume + 4.54609 + + + peck + volume + 2 + + + bushel + volume + 4 + + + quart + volume + 1 + + + pint + volume + 1 + + + gill + volume + 1 + + + fluid ounce + volume + 1 + + + fluid dram + volume + 1 + + + minim + volume + 1 + + + grain + mass + 64.79891 + + + pound + lb + mass + 7000 + + + ounce + oz + mass + 1 + + + dram + mass + 1 + + + short hundredweight + U.S. hundredweight + mass + 100 + + + long hundredweight + British hundredweight + mass + 112 + + + short ton + U.S. ton + mass + 20 + + + long ton + British ton + mass + 20 + + + stone + British stone + mass + 14 + + + pennyweight + mass + 24 + + + ounce + mass + 20 + + + pound + mass + 12 + + + scruple + mass + 20 + + + dram + drachm + mass + 3 + + + ounce + mass + 8 + + + pound + mass + 12 + + + metric ounce + mass + 28 + + + line + length + 1 + + + point + length + 1 + + + pica + length + 12 + + + Printer's point + length + 0.013837 + + + Printer's pica + length + 12 + + + pied + French foot + length + 32.48 + + + pouce + French inch + length + 1 + + + ligne + French line + length + 1 + + + didot + Didot's point + length + 1 + + + cicero + Didot's pica + length + 12 + + + degree Fahrenheit + °F + temperature + + + + + + degree Rankine + °R + temperature + 5 + + + degree Réaumur + °Ré + temperature + + + + + + calorie at 15 °C + cal15°C + + energy + 4.18580 + + + calorie at 20 °C + cal20°C + + energy + 4.18190 + + + mean calorie + calm + + energy + 4.19002 + + + international table calorie + calIT + + energy + 4.1868 + + + thermochemical calorie + calth + + energy + 4.184 + + + calorie + cal + energy + 1 + + + nutrition label Calories + Cal + energy + 1 + + + British thermal unit at 39 °F + Btu39°F + + energy + 1.05967 + + + British thermal unit at 59 °F + Btu59°F + + energy + 1.05480 + + + British thermal unit at 60 °F + Btu60°F + + energy + 1.05468 + + + mean British thermal unit + Btum + + energy + 1.05587 + + + international table British thermal unit + BtuIT + + energy + 1.05505585262 + + + thermochemical British thermal unit + Btuth + + energy + 1.054350 + + + British thermal unit + btu + energy + 1 + + + horsepower + power + 550 + + + tex + tex + linear mass density (of textile thread) + 1 + + + Denier + den + linear mass density (of textile thread) + 1 + + + meter of water column + m H + 2 + O + pressure + 9.80665 + + + meter of mercury column + m Hg + pressure + 133.3220 + + + inch of water column + in H + 2 + O + pressure + 1 + + + inch of mercury column + in Hg + pressure + 1 + + + peripheral vascular resistance unit + P.R.U. + fluid resistance + 1 + + + Wood unit + Wood U. + fluid resistance + 1 + + + diopter + dpt + refraction of a lens + 1 + + + prism diopter + PD + refraction of a prism + + + + + + percent of slope + % + slope + + + + + + mesh + lineic number + 1 + + + Charrière + french + Ch + gauge of catheters + 1 + + + drop + drp + volume + 1 + + + Hounsfield unit + HF + x-ray attenuation + 1 + + + metabolic equivalent + MET + metabolic cost of physical activity + 3.5 + + + homeopathic potency of decimal series (retired) + X + homeopathic potency (retired) + + + + + + homeopathic potency of centesimal series (retired) + C + homeopathic potency (retired) + + + + + + homeopathic potency of millesimal series (retired) + M + homeopathic potency (retired) + + + + + + homeopathic potency of quintamillesimal series (retired) + Q + homeopathic potency (retired) + + + + + + homeopathic potency of decimal hahnemannian series + X + homeopathic potency (Hahnemann) + 1 + + + homeopathic potency of centesimal hahnemannian series + C + homeopathic potency (Hahnemann) + 1 + + + homeopathic potency of millesimal hahnemannian series + M + homeopathic potency (Hahnemann) + 1 + + + homeopathic potency of quintamillesimal hahnemannian series + Q + homeopathic potency (Hahnemann) + 1 + + + homeopathic potency of decimal korsakovian series + X + homeopathic potency (Korsakov) + 1 + + + homeopathic potency of centesimal korsakovian series + C + homeopathic potency (Korsakov) + 1 + + + homeopathic potency of millesimal korsakovian series + M + homeopathic potency (Korsakov) + 1 + + + homeopathic potency of quintamillesimal korsakovian series + Q + homeopathic potency (Korsakov) + 1 + + + equivalents + eq + amount of substance + 1 + + + osmole + osm + amount of substance (dissolved particles) + 1 + + + pH + pH + acidity + + + + + + gram percent + g% + mass concentration + 1 + + + Svedberg unit + S + sedimentation coefficient + 1 + + + high power field + HPF + view area in microscope + 1 + + + low power field + LPF + view area in microscope + 100 + + + katal + kat + catalytic activity + 1 + + + Unit + U + catalytic activity + 1 + + + international unit + IU + arbitrary + 1 + + + international unit + i.U. + arbitrary + 1 + + + arbitrary unit + arb. U + arbitrary + 1 + + + United States Pharmacopeia unit + U.S.P. + arbitrary + 1 + + + GPL unit + biologic activity of anticardiolipin IgG + 1 + + + MPL unit + biologic activity of anticardiolipin IgM + 1 + + + APL unit + biologic activity of anticardiolipin IgA + 1 + + + Bethesda unit + biologic activity of factor VIII inhibitor + 1 + + + anti factor Xa unit + biologic activity of factor Xa inhibitor (heparin) + 1 + + + Todd unit + biologic activity antistreptolysin O + 1 + + + Dye unit + biologic activity of amylase + 1 + + + Somogyi unit + biologic activity of amylase + 1 + + + Bodansky unit + biologic activity of phosphatase + 1 + + + King-Armstrong unit + biologic activity of phosphatase + 1 + + + Kunkel unit + arbitrary biologic activity + 1 + + + Mac Lagan unit + arbitrary biologic activity + 1 + + + tuberculin unit + biologic activity of tuberculin + 1 + + + 50% cell culture infectious dose + CCID50 + + biologic activity (infectivity) of an infectious agent preparation + 1 + + + 50% tissue culture infectious dose + TCID50 + + biologic activity (infectivity) of an infectious agent preparation + 1 + + + 50% embryo infectious dose + EID50 + + biologic activity (infectivity) of an infectious agent preparation + 1 + + + plaque forming units + PFU + amount of an infectious agent + 1 + + + focus forming units + FFU + amount of an infectious agent + 1 + + + colony forming units + CFU + amount of a proliferating organism + 1 + + + index of reactivity + IR + amount of an allergen calibrated through in-vivo testing using the Stallergenes® method + 1 + + + bioequivalent allergen unit + BAU + amount of an allergen calibrated through in-vivo testing based on the ID50EAL method of (intradermal dilution for 50mm sum of erythema diameters + 1 + + + allergen unit + AU + procedure defined amount of an allergen using some reference standard + 1 + + + allergen unit for Ambrosia artemisiifolia + Amb a 1 U + procedure defined amount of the major allergen of ragweed + 1 + + + protein nitrogen unit + PNU + procedure defined amount of a protein substance + 1 + + + Limit of flocculation + Lf + procedure defined amount of an antigen substance + 1 + + + D-antigen unit + + procedure defined amount of a poliomyelitis d-antigen substance + 1 + + + fibrinogen equivalent unit + + amount of fibrinogen broken down into the measured d-dimers + 1 + + + ELISA unit + + arbitrary ELISA unit + 1 + + + Ehrlich unit + + Ehrlich unit + 1 + + + neper + Np + level + + + + + + bel + B + level + + + + + + bel sound pressure + B(SPL) + pressure level + + + + + + bel volt + B(V) + electric potential level + + + + + + bel millivolt + B(mV) + electric potential level + + + + + + bel microvolt + B(μV) + electric potential level + + + + + + bel 10 nanovolt + B(10 nV) + electric potential level + + + + + + bel watt + B(W) + power level + + + + + + bel kilowatt + B(kW) + power level + + + + + + stere + st + volume + 1 + + + Ångström + Å + length + 0.1 + + + barn + b + action area + 100 + + + technical atmosphere + at + pressure + 1 + + + mho + mho + electric conductance + 1 + + + pound per square inch + psi + pressure + 1 + + + circle + circ + plane angle + 2 + + + sphere + sph + solid angle + 4 + + + metric carat + ctm + + mass + 0.2 + + + carat of gold alloys + ct + Au + + + mass fraction + 1 + + + Smoot + + length + 67 + + + meter per square seconds per square root of hertz + + amplitude spectral density + + + + + + Nephelometric Turbidity Unit + + turbidity + 1 + + + Formazin Nephelometric Unit + + turbidity + 1 + + + bit + bits + + amount of information + + + + + + bit + bit + amount of information + 1 + + + byte + B + amount of information + 8 + + + baud + Bd + signal transmission rate + 1 + + + kibi + Ki + 1024 + + + mebi + Mi + 1048576 + + + gibi + Gi + 1073741824 + + + tebi + Ti + 1099511627776 + + \ No newline at end of file diff --git a/tx/fixtures/test-cases.yml b/tx/fixtures/test-cases.yml index f96edb64..9c14ff82 100644 --- a/tx/fixtures/test-cases.yml +++ b/tx/fixtures/test-cases.yml @@ -8,7 +8,7 @@ sources: - internal:areacode - internal:mimetypes - internal:usstates - - ucum:tx/data/ucum-essence.xml + - ucum:ucum-essence.xml - loinc:loinc-2.81-b.db - snomed!:sct_intl_20250201.cache - snomed:sct_test_20250814.cache diff --git a/tx/tx.fhir.org.yml b/tx/tx.fhir.org.yml index 839a64b0..78a24a6f 100644 --- a/tx/tx.fhir.org.yml +++ b/tx/tx.fhir.org.yml @@ -10,7 +10,7 @@ sources: - internal:usstates - internal:urls - internal:hgvs - - ucum:tx/data/ucum-essence.xml + - ucum:ucum-essence.xml - loinc:loinc-2.77-a.db - loinc!:loinc-2.81-b.db - rxnorm:rxnorm_03022026.db From 6cfadd9815f0e3de467898135c80ee383e043eaa Mon Sep 17 00:00:00 2001 From: Jose Costa Teixeira <16153168+costateixeira@users.noreply.github.com> Date: Sat, 4 Apr 2026 22:33:19 +0200 Subject: [PATCH 3/4] update loinc version in test cases --- tx/fixtures/test-cases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tx/fixtures/test-cases.yml b/tx/fixtures/test-cases.yml index eaf0769b..2452c7fe 100644 --- a/tx/fixtures/test-cases.yml +++ b/tx/fixtures/test-cases.yml @@ -9,7 +9,7 @@ sources: - internal:mimetypes - internal:usstates - ucum:ucum-essence.xml - - loinc:loinc-2.81-b.db + - loinc:loinc-2.82.db - snomed!:sct_intl_20250201.cache - snomed:sct_test_20250814.cache - omop:omop_v20250227.db From 9f3384df22accbf5e8e0db091549372a3acb10d9 Mon Sep 17 00:00:00 2001 From: Jose Costa Teixeira Date: Sat, 4 Apr 2026 21:54:39 +0100 Subject: [PATCH 4/4] Update loinc reference in test cases --- tx/fixtures/test-cases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tx/fixtures/test-cases.yml b/tx/fixtures/test-cases.yml index 2452c7fe..f3d6261a 100644 --- a/tx/fixtures/test-cases.yml +++ b/tx/fixtures/test-cases.yml @@ -9,7 +9,7 @@ sources: - internal:mimetypes - internal:usstates - ucum:ucum-essence.xml - - loinc:loinc-2.82.db + - loinc!:loinc-2.82.db - snomed!:sct_intl_20250201.cache - snomed:sct_test_20250814.cache - omop:omop_v20250227.db