From ed71c67f09c06e8ceee48a72208fcdb4cc664e81 Mon Sep 17 00:00:00 2001 From: FHIR Team Date: Tue, 29 Oct 2024 09:45:08 -0700 Subject: [PATCH] Add support for checking the cardinality of Reference data types PiperOrigin-RevId: 691054613 --- .../google/fhir/core/fhir_path/fhir_path_validator.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/google-fhir-core/google/fhir/core/fhir_path/fhir_path_validator.py b/google-fhir-core/google/fhir/core/fhir_path/fhir_path_validator.py index d24edad..0daa8d0 100644 --- a/google-fhir-core/google/fhir/core/fhir_path/fhir_path_validator.py +++ b/google-fhir-core/google/fhir/core/fhir_path/fhir_path_validator.py @@ -834,9 +834,13 @@ def _encode_required_field( if constraint_key in self._options.skip_keys: return None # Allows users to skip required field constraints. - # Early-exit if any types overlap with `_SKIP_TYPE_CODES`. + # Early-exit if any types overlap with `_SKIP_TYPE_CODES`. Reference types + # are not fully supported but do support cardinality constraints, so + # we add them back here. type_codes = _utils.element_type_codes(element) - if not _SKIP_TYPE_CODES.isdisjoint(type_codes): + if 'Reference' not in type_codes and not _SKIP_TYPE_CODES.isdisjoint( + type_codes + ): return None result = self._encode_fhir_path_builder_constraint(