From ba70310deb9fead8d4904406223b880277413eba Mon Sep 17 00:00:00 2001 From: Dmitry Shutov Date: Wed, 27 Jul 2022 17:12:10 +0700 Subject: [PATCH] Convert expression result list to comma-separated string Ref: #33 --- app/operations/utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/operations/utils.py b/app/operations/utils.py index 2c9aa9f..c4905a0 100644 --- a/app/operations/utils.py +++ b/app/operations/utils.py @@ -93,8 +93,11 @@ def resolve_string_template(i, env, encode_result=False): for exp in exprs: data = fhirpath({}, exp["var"][2:-2], env) if len(data) > 0: - # TODO: pass comma separated values for x-fhir-query - vs[exp["var"]] = quote(str(data[0])) if encode_result else str(data[0]) + # NOTE: http://build.fhir.org/ig/HL7/sdc/expressions.html#x-fhir-query-enhancements + # If the expression resolves to a collection of more than one value, + # the substitution will be a list of comma-separated values (i.e. behaving as 'or'). + search_str = ",".join(data) + vs[exp["var"]] = quote(search_str) if encode_result else search_str else: vs[exp["var"]] = "" res = i