public static Quantity fromUcum(String v, String code) { Quantity res = new Quantity(); res.setValue(new BigDecimal(v)); res.setSystem("http://unitsofmeasure.org"); res.setCode(code); return res; }
private List<Base> funcToQuantity(ExecutionContext context, List<Base> focus, ExpressionNode exp) { List<Base> result = new ArrayList<Base>(); if (focus.size() == 1) { if (focus.get(0) instanceof Quantity) result.add(focus.get(0)); else if (focus.get(0) instanceof StringType) { Quantity q = parseQuantityString(focus.get(0).primitiveValue()); if (q != null) result.add(q.noExtensions()); } else if (focus.get(0) instanceof IntegerType) { result.add(new Quantity().setValue(new BigDecimal(focus.get(0).primitiveValue())).setSystem("http://unitsofmeasure.org").setCode("1").noExtensions()); } else if (focus.get(0) instanceof DecimalType) { result.add(new Quantity().setValue(new BigDecimal(focus.get(0).primitiveValue())).setSystem("http://unitsofmeasure.org").setCode("1").noExtensions()); } } return result; }
} else { if (Utilities.isDecimal(s)) return new Quantity().setValue(new BigDecimal(s)).setSystem("http://unitsofmeasure.org").setCode("1"); else return null;
/** * Convenience constructor * * @param theComparator The {@link #setComparator(QuantityComparator) comparator} * @param theValue The {@link #setValue(BigDecimal) value} * @param theSystem The {@link #setSystem(String)} (the code system for the units} * @param theCode The {@link #setCode(String)} (the code for the units} * @param theUnit The {@link #setUnit(String)} (the human readable display name for the units} */ public Quantity(QuantityComparator theComparator, double theValue, String theSystem, String theCode, String theUnit) { setValue(theValue); setComparator(theComparator); setSystem(theSystem); setCode(theCode); setUnit(theUnit); }
/** * Convenience constructor * * @param theComparator The {@link #setComparator(QuantityComparator) comparator} * @param theValue The {@link #setValue(BigDecimal) value} * @param theSystem The {@link #setSystem(String)} (the code system for the units} * @param theCode The {@link #setCode(String)} (the code for the units} * @param theUnit The {@link #setUnit(String)} (the human readable display name for the units} */ public Quantity(QuantityComparator theComparator, long theValue, String theSystem, String theCode, String theUnit) { setValue(theValue); setComparator(theComparator); setSystem(theSystem); setCode(theCode); setUnit(theUnit); } /**
private Base pairToQty(Pair p) { return new Quantity().setValue(new BigDecimal(p.getValue().toString())).setSystem("http://unitsofmeasure.org").setCode(p.getCode()).noExtensions(); }
public org.hl7.fhir.r4.model.Quantity convertQuantity(org.hl7.fhir.instance.model.Quantity src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.r4.model.Quantity tgt = new org.hl7.fhir.r4.model.Quantity(); copyElement(src, tgt); tgt.setValue(src.getValue()); tgt.setComparator(convertQuantityComparator(src.getComparator())); tgt.setUnit(src.getUnit()); tgt.setSystem(src.getSystem()); tgt.setCode(src.getCode()); return tgt; }
} else ucum = lexer.readConstant("units"); result.setConstant(new Quantity().setValue(new BigDecimal(result.getConstant().primitiveValue())).setSystem("http://unitsofmeasure.org").setCode(ucum));
public static org.hl7.fhir.r4.model.Quantity convertQuantity(org.hl7.fhir.dstu2016may.model.Quantity src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.r4.model.Quantity tgt = new org.hl7.fhir.r4.model.Quantity(); copyElement(src, tgt); if (src.hasValue()) tgt.setValue(src.getValue()); tgt.setComparator(convertQuantityComparator(src.getComparator())); if (src.hasUnit()) tgt.setUnit(src.getUnit()); if (src.hasSystem()) tgt.setSystem(src.getSystem()); if (src.hasCode()) tgt.setCode(src.getCode()); return tgt; }
public static Quantity fromUcum(String v, String code) { Quantity res = new Quantity(); res.setValue(new BigDecimal(v)); res.setSystem("http://unitsofmeasure.org"); res.setCode(code); return res; }
private List<Base> funcToQuantity(ExecutionContext context, List<Base> focus, ExpressionNode exp) { List<Base> result = new ArrayList<Base>(); if (focus.size() == 1) { if (focus.get(0) instanceof Quantity) result.add(focus.get(0)); else if (focus.get(0) instanceof StringType) { Quantity q = parseQuantityString(focus.get(0).primitiveValue()); if (q != null) result.add(q.noExtensions()); } else if (focus.get(0) instanceof IntegerType) { result.add(new Quantity().setValue(new BigDecimal(focus.get(0).primitiveValue())).setSystem("http://unitsofmeasure.org").setCode("1").noExtensions()); } else if (focus.get(0) instanceof DecimalType) { result.add(new Quantity().setValue(new BigDecimal(focus.get(0).primitiveValue())).setSystem("http://unitsofmeasure.org").setCode("1").noExtensions()); } } return result; }
} else { if (Utilities.isDecimal(s)) return new Quantity().setValue(new BigDecimal(s)).setSystem("http://unitsofmeasure.org").setCode("1"); else return null;
/** * Convenience constructor * * @param theComparator The {@link #setComparator(QuantityComparator) comparator} * @param theValue The {@link #setValue(BigDecimal) value} * @param theSystem The {@link #setSystem(String)} (the code system for the units} * @param theCode The {@link #setCode(String)} (the code for the units} * @param theUnit The {@link #setUnit(String)} (the human readable display name for the units} */ public Quantity(QuantityComparator theComparator, double theValue, String theSystem, String theCode, String theUnit) { setValue(theValue); setComparator(theComparator); setSystem(theSystem); setCode(theCode); setUnit(theUnit); }
/** * Convenience constructor * * @param theComparator The {@link #setComparator(QuantityComparator) comparator} * @param theValue The {@link #setValue(BigDecimal) value} * @param theSystem The {@link #setSystem(String)} (the code system for the units} * @param theCode The {@link #setCode(String)} (the code for the units} * @param theUnit The {@link #setUnit(String)} (the human readable display name for the units} */ public Quantity(QuantityComparator theComparator, long theValue, String theSystem, String theCode, String theUnit) { setValue(theValue); setComparator(theComparator); setSystem(theSystem); setCode(theCode); setUnit(theUnit); } /**
private Base pairToQty(Pair p) { return new Quantity().setValue(new BigDecimal(p.getValue().toString())).setSystem("http://unitsofmeasure.org").setCode(p.getCode()).noExtensions(); }
public org.hl7.fhir.r4.model.Quantity convertQuantity(org.hl7.fhir.instance.model.Quantity src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.r4.model.Quantity tgt = new org.hl7.fhir.r4.model.Quantity(); copyElement(src, tgt); tgt.setValue(src.getValue()); tgt.setComparator(convertQuantityComparator(src.getComparator())); tgt.setUnit(src.getUnit()); tgt.setSystem(src.getSystem()); tgt.setCode(src.getCode()); return tgt; }
} else ucum = lexer.readConstant("units"); result.setConstant(new Quantity().setValue(new BigDecimal(result.getConstant().primitiveValue())).setSystem("http://unitsofmeasure.org").setCode(ucum));
public static org.hl7.fhir.r4.model.Quantity convertQuantity(org.hl7.fhir.dstu2016may.model.Quantity src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.r4.model.Quantity tgt = new org.hl7.fhir.r4.model.Quantity(); copyElement(src, tgt); if (src.hasValue()) tgt.setValue(src.getValue()); tgt.setComparator(convertQuantityComparator(src.getComparator())); if (src.hasUnit()) tgt.setUnit(src.getUnit()); if (src.hasSystem()) tgt.setSystem(src.getSystem()); if (src.hasCode()) tgt.setCode(src.getCode()); return tgt; }