@Override QuantityParam newInstance() { return new QuantityParam(); }
@Search() public List<Observation> getObservationsByQuantity( @RequiredParam(name=Observation.SP_VALUE_QUANTITY) QuantityParam theQuantity) { List<Observation> retVal = new ArrayList<Observation>(); ParamPrefixEnum prefix = theQuantity.getPrefix(); BigDecimal value = theQuantity.getValue(); String units = theQuantity.getUnits(); // .. Apply these parameters .. // ... populate ... return retVal; } //END SNIPPET: quantity
if (quantity.getSystem() == null && quantity.getUnits() == null) { if (getValue().equals(quantity.getValue())) { retval = true; } else if (quantity.getSystem() == null) { if (getUnits().equalsIgnoreCase(quantity.getUnits()) && getValue().equals(quantity.getValue())) { retval = true; } else if (quantity.getUnits() == null) { if (getSystem().equalsIgnoreCase(quantity.getSystem()) && getValue().equals(quantity.getValue())) { retval = true; if (getSystem().equalsIgnoreCase(quantity.getSystem()) && getUnits().equalsIgnoreCase(quantity.getUnits()) && getValue().equals(quantity.getValue())) { retval = true;
@Override public String toString() { ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE); b.append("prefix", getPrefix()); b.append("value", myValue); b.append("system", mySystem); b.append("units", myUnits); if (getMissing() != null) { b.append("missing", getMissing()); } return b.toString(); }
/** * Returns a new param containing the same value as this param, but with the type copnverted * to {@link QuantityParam}. This is useful if you are using reference parameters and want to handle * chained parameters of different types in a single method. * <p> * See <a href="http://jamesagnew.github.io/hapi-fhir/doc_rest_operations.html#dynamic_chains">Dynamic Chains</a> * in the HAPI FHIR documentation for an example of how to use this method. * </p> */ public QuantityParam toQuantityParam(FhirContext theContext) { QuantityParam retVal = new QuantityParam(); retVal.setValueAsQueryToken(theContext, null, null, getValueAsQueryToken(theContext)); return retVal; }
} else if (theParam instanceof QuantityParam) { QuantityParam param = (QuantityParam) theParam; systemValue = param.getSystem(); unitsValue = param.getUnits(); cmpValue = param.getPrefix(); valueValue = param.getValue(); } else { throw new IllegalArgumentException("Invalid quantity type: " + theParam.getClass());
@Override String doGetValueAsQueryToken(FhirContext theContext) { StringBuilder b = new StringBuilder(); if (getPrefix() != null) { b.append(ParameterUtil.escapeWithDefault(getPrefix().getValue())); } b.append(ParameterUtil.escapeWithDefault(getValueAsString())); b.append('|'); b.append(ParameterUtil.escapeWithDefault(mySystem)); b.append('|'); b.append(ParameterUtil.escapeWithDefault(myUnits)); return b.toString(); }
@Override void doSetValueAsQueryToken(FhirContext theContext, String theParamName, String theQualifier, String theValue) { clear(); if (theValue == null) { return; } List<String> parts = ParameterUtil.splitParameterString(theValue, '|', true); if (parts.size() > 0 && StringUtils.isNotBlank(parts.get(0))) { String value = super.extractPrefixAndReturnRest(parts.get(0)); setValue(value); } if (parts.size() > 1 && StringUtils.isNotBlank(parts.get(1))) { setSystem(parts.get(1)); } if (parts.size() > 2 && StringUtils.isNotBlank(parts.get(2))) { setUnits(parts.get(2)); } }
private void clean(String theParamName, List<List<? extends IQueryParameterType>> theAndOrParams) { for (int andListIdx = 0; andListIdx < theAndOrParams.size(); andListIdx++) { List<? extends IQueryParameterType> nextOrList = theAndOrParams.get(andListIdx); for (int orListIdx = 0; orListIdx < nextOrList.size(); orListIdx++) { IQueryParameterType nextOr = nextOrList.get(orListIdx); boolean hasNoValue = false; if (nextOr.getMissing() != null) { continue; } if (nextOr instanceof QuantityParam) { if (isBlank(((QuantityParam) nextOr).getValueAsString())) { hasNoValue = true; } } if (hasNoValue) { ourLog.debug("Ignoring empty parameter: {}", theParamName); nextOrList.remove(orListIdx); orListIdx--; } } if (nextOrList.isEmpty()) { theAndOrParams.remove(andListIdx); andListIdx--; } } }
} else if (theParam instanceof QuantityParam) { QuantityParam param = (QuantityParam) theParam; systemValue = param.getSystem(); unitsValue = param.getUnits(); cmpValue = param.getPrefix(); valueValue = param.getValue(); } else { throw new IllegalArgumentException("Invalid quantity type: " + theParam.getClass());
/** * Constructor * * @param thePrefix * The comparator, or <code>null</code> for an equals comparator * @param theValue * A quantity value * @param theSystem * The unit system * @param theUnits * The unit code */ public QuantityParam(ParamPrefixEnum thePrefix, long theValue, String theSystem, String theUnits) { setPrefix(thePrefix); setValue(theValue); setSystem(theSystem); setUnits(theUnits); }
@Override String doGetValueAsQueryToken(FhirContext theContext) { StringBuilder b = new StringBuilder(); if (getPrefix() != null) { b.append(ParameterUtil.escapeWithDefault(getPrefix().getValue())); } b.append(ParameterUtil.escapeWithDefault(getValueAsString())); b.append('|'); b.append(ParameterUtil.escapeWithDefault(mySystem)); b.append('|'); b.append(ParameterUtil.escapeWithDefault(myUnits)); return b.toString(); }
@Override public String toString() { ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE); b.append("prefix", getPrefix()); b.append("value", myValue); b.append("system", mySystem); b.append("units", myUnits); if (getMissing() != null) { b.append("missing", getMissing()); } return b.toString(); }
/** * Returns a new param containing the same value as this param, but with the type copnverted * to {@link QuantityParam}. This is useful if you are using reference parameters and want to handle * chained parameters of different types in a single method. * <p> * See <a href="http://jamesagnew.github.io/hapi-fhir/doc_rest_operations.html#dynamic_chains">Dynamic Chains</a> * in the HAPI FHIR documentation for an example of how to use this method. * </p> */ public QuantityParam toQuantityParam(FhirContext theContext) { QuantityParam retVal = new QuantityParam(); retVal.setValueAsQueryToken(theContext, null, null, getValueAsQueryToken(theContext)); return retVal; }
@Override void doSetValueAsQueryToken(FhirContext theContext, String theParamName, String theQualifier, String theValue) { clear(); if (theValue == null) { return; } List<String> parts = ParameterUtil.splitParameterString(theValue, '|', true); if (parts.size() > 0 && StringUtils.isNotBlank(parts.get(0))) { String value = super.extractPrefixAndReturnRest(parts.get(0)); setValue(value); } if (parts.size() > 1 && StringUtils.isNotBlank(parts.get(1))) { setSystem(parts.get(1)); } if (parts.size() > 2 && StringUtils.isNotBlank(parts.get(2))) { setUnits(parts.get(2)); } }
/** * Constructor * * @param thePrefix * The comparator, or <code>null</code> for an equals comparator * @param theValue * A quantity value * @param theSystem * The unit system * @param theUnits * The unit code */ public QuantityParam(ParamPrefixEnum thePrefix, BigDecimal theValue, String theSystem, String theUnits) { setPrefix(thePrefix); setValue(theValue); setSystem(theSystem); setUnits(theUnits); }
@Override public IQueryParameterType toQueryParameterType() { return new QuantityParam(null, getValue(), getSystem(), getUnits()); }
/** * Constructor * * @param thePrefix * The comparator, or <code>null</code> for an equals comparator * @param theValue * A quantity value * @param theSystem * The unit system * @param theUnits * The unit code */ public QuantityParam(ParamPrefixEnum thePrefix, double theValue, String theSystem, String theUnits) { setPrefix(thePrefix); setValue(theValue); setSystem(theSystem); setUnits(theUnits); }
break; case QUANTITY: qp = new QuantityParam(); break; case STRING: