--- type: "fhirpath-operator" title: "FHIRPath Operator: implies (implies)" operator: "implies" category: "Boolean Logic" section: "6.5.5" source: "fhirpath/operations.json" --- # FHIRPath Operator: implies (implies) If the left operand evaluates to `true`, this operator returns the boolean evaluation of the right operand. If the left operand evaluates to `false`, this operator returns `true`. Otherwise, this operator returns `true` if the right operand evaluates to `true`, and the empty collection (`{ }`) otherwise. |implies |true |false |empty | | - | - | - | - | |**true** |`true` |`false` |empty (`{ }`) | |**false** |`true` |`true` |`true` | |**empty** |`true` |empty (`{ }`) |empty (`{ }`) | {:.grid} The implies operator is useful for testing conditionals. For example, if a given name is present, then a family name must be as well: ``` fhirpath Patient.name.given.exists() implies Patient.name.family.exists() CareTeam.onBehalfOf.exists() implies (CareTeam.member.resolve() is Practitioner) StructureDefinition.contextInvariant.exists() implies StructureDefinition.type = 'Extension' ``` Note carefully that if the left side of an implies evaluates to empty, the result of the operation is the right side. This is often not the intended result, so the use of operators that ensure a value (such as `~`, instead of `=`) is recommended for testing boolean conditions, as illustrated in the following examples: ``` fhirpath Medication.status ~ 'active' implies form.exists() // if using the following expression in a constraint, it won't have the expected behavior of only requiring form if status was active. // (using equal '=' would evaluate and return the right argument if the left argument (status) is missing from the input) Medication.status = 'active' implies form.exists() // bad constraint expression // More complex conditions (type ~ 'incident' and severity ~ 'high') implies reviewDate.exists() // Works with boolean too, but not special-cased wasNotGiven ~ true implies reasonNotGiven.exists() ``` Note that implies may use short-circuit evaluation in the case that the first operand evaluates to `false`. ## Summary - **Category**: Boolean Logic - **Section**: `6.5.5` - **Left Argument**: `Boolean` - **Right Argument**: `Boolean` - **Return Type**: `Boolean` - **Empty Input Result**: `empty` - **Errors on Multiple Input**: `false` ## Description If the left operand evaluates to `true`, returns the boolean evaluation of the right operand. If the left operand evaluates to `false`, returns `true`. Otherwise, returns `true` if the right operand evaluates to `true`, and empty collection otherwise. ## Type Mapping - `Boolean-Boolean`