public SimpleQuantity makeSimpleQuantityFromPQ(Element pq, String units) throws Exception { if (pq == null) return null; SimpleQuantity qty = new SimpleQuantity(); String n = pq.getAttribute("value").replace(",", "").trim(); try { qty.setValue(new BigDecimal(n)); } catch (Exception e) { throw new Exception("Unable to process value '"+n+"'", e); } units = Utilities.noString(pq.getAttribute("unit")) ? units : pq.getAttribute("unit"); if (!Utilities.noString(units)) { if (ucumSvc == null || ucumSvc.validate(units) != null) qty.setUnit(units); else { qty.setCode(units); qty.setSystem("http://unitsofmeasure.org"); qty.setUnit(ucumSvc.getCommonDisplay(units)); } } return qty; }
private DecimalType qtyToCanonical(Quantity q) { if (!"http://unitsofmeasure.org".equals(q.getSystem())) return null; try { Pair p = new Pair(new Decimal(q.getValue().toPlainString()), q.getCode()); Pair c = worker.getUcumService().getCanonicalForm(p); return new DecimalType(c.getValue().asDecimal()); } catch (UcumException e) { return null; } }
Pair p; try { p = worker.getUcumService().multiply(pl, pr); result.add(pairToQty(p)); } catch (UcumException e) {
String message = ucumService.validate(unit); if (message != null) {
public Quantity makeQuantityFromPQ(Element pq, String units) throws Exception { if (pq == null) return null; Quantity qty = new Quantity(); String n = pq.getAttribute("value").replace(",", "").trim(); try { qty.setValue(new BigDecimal(n)); } catch (Exception e) { throw new Exception("Unable to process value '"+n+"'", e); } units = Utilities.noString(pq.getAttribute("unit")) ? units : pq.getAttribute("unit"); if (!Utilities.noString(units)) { if (ucumSvc == null || ucumSvc.validate(units) != null) qty.setUnit(units); else { qty.setCode(units); qty.setSystem("http://unitsofmeasure.org"); qty.setUnit(ucumSvc.getCommonDisplay(units)); } } return qty; }
Pair p; try { p = worker.getUcumService().multiply(pl, pr); result.add(pairToQty(p)); } catch (UcumException e) {
private DecimalType qtyToCanonical(Quantity q) { if (!"http://unitsofmeasure.org".equals(q.getSystem())) return null; try { Pair p = new Pair(new Decimal(q.getValue().toPlainString()), q.getCode()); Pair c = worker.getUcumService().getCanonicalForm(p); return new DecimalType(c.getValue().asDecimal()); } catch (UcumException e) { return null; } }
public Quantity makeQuantityFromPQ(Element pq, String units) throws Exception { if (pq == null) return null; Quantity qty = new Quantity(); String n = pq.getAttribute("value").replace(",", "").trim(); try { qty.setValue(new BigDecimal(n)); } catch (Exception e) { throw new Exception("Unable to process value '"+n+"'", e); } units = Utilities.noString(pq.getAttribute("unit")) ? units : pq.getAttribute("unit"); if (!Utilities.noString(units)) { if (ucumSvc == null || ucumSvc.validate(units) != null) qty.setUnit(units); else { qty.setCode(units); qty.setSystem("http://unitsofmeasure.org"); qty.setUnit(ucumSvc.getCommonDisplay(units)); } } return qty; }
Pair p; try { p = worker.getUcumService().multiply(pl, pr); result.add(pairToQty(p)); } catch (UcumException e) {
public SimpleQuantity makeSimpleQuantityFromPQ(Element pq, String units) throws Exception { if (pq == null) return null; SimpleQuantity qty = new SimpleQuantity(); String n = pq.getAttribute("value").replace(",", "").trim(); try { qty.setValue(new BigDecimal(n)); } catch (Exception e) { throw new Exception("Unable to process value '"+n+"'", e); } units = Utilities.noString(pq.getAttribute("unit")) ? units : pq.getAttribute("unit"); if (!Utilities.noString(units)) { if (ucumSvc == null || ucumSvc.validate(units) != null) qty.setUnit(units); else { qty.setCode(units); qty.setSystem("http://unitsofmeasure.org"); qty.setUnit(ucumSvc.getCommonDisplay(units)); } } return qty; }
Pair p; try { p = worker.getUcumService().multiply(pl, pr); result.add(pairToQty(p)); } catch (UcumException e) {