From 3368ae1f0dc664c8e4e514ef7942fe3d70cbbd93 Mon Sep 17 00:00:00 2001 From: Stephan Vedder Date: Tue, 17 Dec 2024 09:41:16 +0100 Subject: [PATCH] fix(qido-rs): allow multiple tags for includefield query parameter --- src/api/qido/service.rs | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/api/qido/service.rs b/src/api/qido/service.rs index ccfebf7..c02b21b 100644 --- a/src/api/qido/service.rs +++ b/src/api/qido/service.rs @@ -180,10 +180,15 @@ impl<'a> Visitor<'a> for IncludeFieldVisitor { if v.to_lowercase() == "all" { Ok(IncludeField::All) } else { - let entry = StandardDataDictionary - .by_expr(v) - .ok_or_else(|| E::custom(format!("unknown tag {v}")))?; - Ok(IncludeField::List(vec![entry.tag()])) + v.split(',') + .map(|v| { + let entry = StandardDataDictionary + .by_expr(v) + .ok_or_else(|| E::custom(format!("unknown tag {v}")))?; + Ok(entry.tag()) + }) + .collect::, _>>() + .map(IncludeField::List) } } @@ -298,6 +303,24 @@ mod tests { ); } + #[test] + fn parse_query_params_multiple_includefield() { + let uri = + Uri::from_static("http://test?offset=1&limit=42&includefield=PatientWeight,00100010"); + let Query(params) = Query::::try_from_uri(&uri).unwrap(); + + assert_eq!( + params, + QueryParameters { + offset: 1, + limit: 42, + include_field: IncludeField::List(vec![tags::PATIENT_WEIGHT, tags::PATIENT_NAME]), + match_criteria: MatchCriteria(vec![]), + fuzzy_matching: false, + } + ); + } + #[test] fn parse_query_params_default() { let uri = Uri::from_static("http://test");