Skip to content

Commit

Permalink
fix(qido-rs): allow multiple tags for includefield query parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
feliwir committed Dec 17, 2024
1 parent 6837f13 commit 3368ae1
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions src/api/qido/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Result<Vec<_>, _>>()
.map(IncludeField::List)
}
}

Expand Down Expand Up @@ -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::<QueryParameters>::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");
Expand Down

0 comments on commit 3368ae1

Please sign in to comment.