diff --git a/fhirpathpy/engine/invocations/strings.py b/fhirpathpy/engine/invocations/strings.py index 58997aa..37a47d0 100644 --- a/fhirpathpy/engine/invocations/strings.py +++ b/fhirpathpy/engine/invocations/strings.py @@ -125,6 +125,9 @@ def decode(ctx, coll, format): def join(ctx, coll, separator=""): + if not coll: + return [] + stringValues = [] for n in coll: d = util.get_data(n) diff --git a/tests/cases/5.6_string_manipulation.yaml b/tests/cases/5.6_string_manipulation.yaml index 4f4de3d..75f164d 100644 --- a/tests/cases/5.6_string_manipulation.yaml +++ b/tests/cases/5.6_string_manipulation.yaml @@ -275,6 +275,10 @@ tests: expression: "('a'|'b'|'c').join()" result: ['abc'] + - desc: '** join on empty input collection' + expression: Functions.str.empty.join(',') + result: [] + - desc: '** join string with date throws error' expression: "('a'|'2023-05-28'.toDate()|'c').join(',')" error: true