public SimpleQuantity castToSimpleQuantity(Base b) throws FHIRException { if (b instanceof SimpleQuantity) return (SimpleQuantity) b; else if (b instanceof Quantity) { Quantity q = (Quantity) b; SimpleQuantity sq = new SimpleQuantity(); sq.setValueElement(q.getValueElement()); sq.setComparatorElement(q.getComparatorElement()); sq.setUnitElement(q.getUnitElement()); sq.setSystemElement(q.getSystemElement()); sq.setCodeElement(q.getCodeElement()); return sq; } else throw new FHIRException( "Unable to convert a " + b.getClass().getName() + " to an SimpleQuantity"); }