View raw Markdown
type: fhirpath-functionfunction: roundcategory: Mathsection: 5.8.8source: fhirpath/functions.json

FHIRPath Function: round

{:.stu}

Discussion on this topic If you have specific proposals or feedback please log a change request. {: .stu-note }

Rounds the input to the nearest whole number using a traditional round (i.e. to the nearest whole number), meaning that a decimal value greater than or equal to 0.5 and less than 1.0 will round to 1, and a decimal value less than or equal to -0.5 and greater than -1.0 will round to -1. If specified, the precision argument determines the decimal place at which the rounding will occur. If not specified, the rounding will default to 0 decimal places. {:.stu}

If specified, the number of digits of precision must be >= 0 or the evaluation will end and signal an error to the calling environment. {:.stu}

Accepts input types of Decimal, or Quantity. {:.stu}

When used with a Decimal input type, the result is an Decimal.<br/> When used with a Quantity, the result is a Quantity with the same units. {:.stu}

When used with Integer or Long, the arguments will be implicitly converted to Decimal before evaluation. {:.stu}

If the input collection is empty, the result is empty. {:.stu}

If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment. {:.stu}

1.round() // 1
3.14159.round(3) // 3.142

{:.stu}

Summary

Description

Rounds the input to the nearest whole number using a traditional round (i.e. to the nearest whole number), meaning that a decimal value greater than or equal to 0.5 and less than 1.0 will round to 1, and a decimal value less than or equal to -0.5 and greater than -1.0 will round to -1. If specified, the precision argument determines the decimal place at which the rounding will occur. If not specified, the rounding will default to 0 decimal places.

Arguments

Type Mapping

Example

1.round() // 1
3.14159.round(3) // 3.142