From 1d9e4cecb7b7a127bd440eaea07c0836d378d1f2 Mon Sep 17 00:00:00 2001 From: Michael C Greene Date: Thu, 22 Apr 2021 15:59:10 -0600 Subject: [PATCH 1/2] Ucum service for validating units --- .../fhir/services/rest/UCUMController.java | 31 + .../service/UCUMValidationService.java | 34 + .../src/main/resources/ucum/ucum-essence.xml | 2079 +++++++++++++++++ .../services/rest/UCUMControllerTest.java | 28 + .../service/UCUMValidationServiceTest.java | 25 + 5 files changed, 2197 insertions(+) create mode 100644 mat-fhir-services/src/main/java/gov/cms/mat/fhir/services/rest/UCUMController.java create mode 100644 mat-fhir-services/src/main/java/gov/cms/mat/fhir/services/service/UCUMValidationService.java create mode 100644 mat-fhir-services/src/main/resources/ucum/ucum-essence.xml create mode 100644 mat-fhir-services/src/test/java/gov/cms/mat/fhir/services/rest/UCUMControllerTest.java create mode 100644 mat-fhir-services/src/test/java/gov/cms/mat/fhir/services/service/UCUMValidationServiceTest.java diff --git a/mat-fhir-services/src/main/java/gov/cms/mat/fhir/services/rest/UCUMController.java b/mat-fhir-services/src/main/java/gov/cms/mat/fhir/services/rest/UCUMController.java new file mode 100644 index 000000000..eda9c8839 --- /dev/null +++ b/mat-fhir-services/src/main/java/gov/cms/mat/fhir/services/rest/UCUMController.java @@ -0,0 +1,31 @@ +package gov.cms.mat.fhir.services.rest; + +import gov.cms.mat.fhir.services.service.UCUMValidationService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; + +@RestController +@RequestMapping(path = "/ucum") +@Tag(name = "UCUM-Controller", + description = "API for validating ucum codes") +@Slf4j +@RequiredArgsConstructor +public class UCUMController { + private final UCUMValidationService ucumValidationService; + + @Operation(summary = "Validate", + description = "Validate the ucum unit") + @GetMapping("/{unit}") + public Boolean validateCode(@PathVariable("unit") String unit) { + return ucumValidationService.validate(URLDecoder.decode(unit, StandardCharsets.UTF_8)); + } +} diff --git a/mat-fhir-services/src/main/java/gov/cms/mat/fhir/services/service/UCUMValidationService.java b/mat-fhir-services/src/main/java/gov/cms/mat/fhir/services/service/UCUMValidationService.java new file mode 100644 index 000000000..4ae436fbb --- /dev/null +++ b/mat-fhir-services/src/main/java/gov/cms/mat/fhir/services/service/UCUMValidationService.java @@ -0,0 +1,34 @@ +package gov.cms.mat.fhir.services.service; + +import org.fhir.ucum.UcumEssenceService; +import org.fhir.ucum.UcumService; +import org.springframework.beans.InvalidPropertyException; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.io.Resource; +import org.springframework.stereotype.Service; + +import javax.annotation.PostConstruct; + +@Service +public class UCUMValidationService { + @Value("classpath:ucum/ucum-essence.xml") + private Resource resource; + + private UcumService ucumService; + + @PostConstruct + private void postConstruct() { + try { + ucumService = new UcumEssenceService(resource.getInputStream()); + } catch (Exception e) { + throw new InvalidPropertyException(this.getClass(), "resource", e.getMessage()); + } + } + + public Boolean validate(String unit) { + String result = ucumService.validate(unit); + + //Returns:null if valid + return result == null; + } +} diff --git a/mat-fhir-services/src/main/resources/ucum/ucum-essence.xml b/mat-fhir-services/src/main/resources/ucum/ucum-essence.xml new file mode 100644 index 000000000..658384803 --- /dev/null +++ b/mat-fhir-services/src/main/resources/ucum/ucum-essence.xml @@ -0,0 +1,2079 @@ + + + + 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.0221367 + + + 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 + + + + + degree + ° + plane angle + 2 + + + gon + grade + g + + plane angle + 0.9 + + + 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.6605402 × 10-24 + + + + + + astronomic unit + AU + length + 149597.870691 + + + parsec + pc + length + 3.085678 × 1016 + + + + velocity of light + + c + + velocity + 299792458 + + + Planck constant + + h + + action + 6.6260755 × 10-34 + + + + Boltzmann constant + + k + + (unclassified) + 1.380658 × 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.60217733 × 10-19 + + + + + + electronvolt + eV + energy + 1 + + + electron mass + + m + e + + + + mass + 9.1093897 × 10-28 + + + + proton mass + + m + p + + + + mass + 1.6726231 × 10-24 + + + + Newtonian constant of gravitation + + G + + (unclassified) + 6.67259 × 10-11 + + + + standard acceleration of free fall + + gn + + + acceleration + 9.80665 + + + + Torr + Torr + pressure + 133.322 + + + standard atmosphere + atm + pressure + 101325 + + + light-year + l.y. + length + 1 + + + gram-force + gf + 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 + + + + + pound force + lbf + force + 1 + + + ounce + oz + mass + 1 + + + dram + mass + 1 + + + short hundredweight + U.S. hundredweight + mass + 100 + + + long hunderdweight + 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 + + + arbitary 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 callibrated through in-vivo testing using the Stallergenes® method. + 1 + + + bioequivalent allergen unit + BAU + amount of an allergen callibrated 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 sqare inch + psi + pressure + 1 + + + circle + circ + plane angle + 2 + + + spere + 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 + + + + + + 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/mat-fhir-services/src/test/java/gov/cms/mat/fhir/services/rest/UCUMControllerTest.java b/mat-fhir-services/src/test/java/gov/cms/mat/fhir/services/rest/UCUMControllerTest.java new file mode 100644 index 000000000..45bc3bd71 --- /dev/null +++ b/mat-fhir-services/src/test/java/gov/cms/mat/fhir/services/rest/UCUMControllerTest.java @@ -0,0 +1,28 @@ +package gov.cms.mat.fhir.services.rest; + +import gov.cms.mat.fhir.services.service.UCUMValidationService; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +@ExtendWith(MockitoExtension.class) +class UCUMControllerTest { + @Mock + UCUMValidationService ucumValidationService; + + @InjectMocks + private UCUMController ucumController; + + @Test + void validateCode() { + when(ucumValidationService.validate("K")).thenReturn(Boolean.TRUE); + assertEquals(Boolean.TRUE, ucumController.validateCode("K")); + verify(ucumValidationService).validate("K"); + } +} \ No newline at end of file diff --git a/mat-fhir-services/src/test/java/gov/cms/mat/fhir/services/service/UCUMValidationServiceTest.java b/mat-fhir-services/src/test/java/gov/cms/mat/fhir/services/service/UCUMValidationServiceTest.java new file mode 100644 index 000000000..503a8e1b1 --- /dev/null +++ b/mat-fhir-services/src/test/java/gov/cms/mat/fhir/services/service/UCUMValidationServiceTest.java @@ -0,0 +1,25 @@ +package gov.cms.mat.fhir.services.service; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +@SpringBootTest(classes = {UCUMValidationService.class}) +@ActiveProfiles("test") +class UCUMValidationServiceTest { + @Autowired + UCUMValidationService ucumValidationService; + + @Test + void validateOK() { + assertEquals(Boolean.TRUE, ucumValidationService.validate("m")); + } + + @Test + void validateBAD() { + assertEquals(Boolean.FALSE, ucumValidationService.validate("BAD_BOY")); + } +} \ No newline at end of file From afc0abddb5ca4b0a20e8df73fd1dcaa405da1e5d Mon Sep 17 00:00:00 2001 From: Michael C Greene Date: Fri, 23 Apr 2021 11:36:33 -0600 Subject: [PATCH 2/2] Codacity: Ucum service Post construct method private --- .../mat/fhir/services/service/UCUMValidationService.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mat-fhir-services/src/main/java/gov/cms/mat/fhir/services/service/UCUMValidationService.java b/mat-fhir-services/src/main/java/gov/cms/mat/fhir/services/service/UCUMValidationService.java index 4ae436fbb..ebc7656d6 100644 --- a/mat-fhir-services/src/main/java/gov/cms/mat/fhir/services/service/UCUMValidationService.java +++ b/mat-fhir-services/src/main/java/gov/cms/mat/fhir/services/service/UCUMValidationService.java @@ -1,6 +1,7 @@ package gov.cms.mat.fhir.services.service; import org.fhir.ucum.UcumEssenceService; +import org.fhir.ucum.UcumException; import org.fhir.ucum.UcumService; import org.springframework.beans.InvalidPropertyException; import org.springframework.beans.factory.annotation.Value; @@ -8,6 +9,7 @@ import org.springframework.stereotype.Service; import javax.annotation.PostConstruct; +import java.io.IOException; @Service public class UCUMValidationService { @@ -17,10 +19,10 @@ public class UCUMValidationService { private UcumService ucumService; @PostConstruct - private void postConstruct() { + void postConstruct() { try { ucumService = new UcumEssenceService(resource.getInputStream()); - } catch (Exception e) { + } catch (UcumException | IOException e) { throw new InvalidPropertyException(this.getClass(), "resource", e.getMessage()); } }