From 36c76eee8c193ee4c0bc5d1a6bfc7453f5f07b52 Mon Sep 17 00:00:00 2001 From: Enola Knezevic Date: Wed, 5 Feb 2025 18:36:38 +0100 Subject: [PATCH 1/4] workaround for messed up AST --- src/cql.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cql.rs b/src/cql.rs index fc9f2b2..c61092c 100644 --- a/src/cql.rs +++ b/src/cql.rs @@ -70,7 +70,7 @@ fn generate_cql(ast: ast::Ast) -> Result { cql = cql.replace("{{lists}}", lists.as_str()); - if retrieval_criteria.is_empty() { + if retrieval_criteria.is_empty() || retrieval_criteria=="()" { cql = cql.replace("{{retrieval_criteria}}", "true"); //()? } else { let formatted_retrieval_criteria = format!("({})", retrieval_criteria); From 634911ff9d59fffaa8cad60cf743414f6929ce0c Mon Sep 17 00:00:00 2001 From: Enola Knezevic Date: Thu, 6 Feb 2025 11:06:48 +0100 Subject: [PATCH 2/4] additional security against AST changes --- src/cql.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cql.rs b/src/cql.rs index c61092c..3bde597 100644 --- a/src/cql.rs +++ b/src/cql.rs @@ -70,7 +70,7 @@ fn generate_cql(ast: ast::Ast) -> Result { cql = cql.replace("{{lists}}", lists.as_str()); - if retrieval_criteria.is_empty() || retrieval_criteria=="()" { + if retrieval_criteria.is_empty() || retrieval_criteria.replace("(","").replace(")", "").replace(" ", "") == "" { //to deal with an empty criteria tree of an arbitrary depth cql = cql.replace("{{retrieval_criteria}}", "true"); //()? } else { let formatted_retrieval_criteria = format!("({})", retrieval_criteria); From 71bb13b1b387eaf18d2f82bf40edfdda5f35521c Mon Sep 17 00:00:00 2001 From: Enola Knezevic Date: Thu, 6 Feb 2025 15:00:34 +0100 Subject: [PATCH 3/4] beautification + test --- src/cql.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cql.rs b/src/cql.rs index 3bde597..aa67d28 100644 --- a/src/cql.rs +++ b/src/cql.rs @@ -70,7 +70,7 @@ fn generate_cql(ast: ast::Ast) -> Result { cql = cql.replace("{{lists}}", lists.as_str()); - if retrieval_criteria.is_empty() || retrieval_criteria.replace("(","").replace(")", "").replace(" ", "") == "" { //to deal with an empty criteria tree of an arbitrary depth + if retrieval_criteria.is_empty() || retrieval_criteria.chars().all(|c| [' ', '(', ')'].contains(&c)) { //to deal with an empty criteria tree of an arbitrary depth cql = cql.replace("{{retrieval_criteria}}", "true"); //()? } else { let formatted_retrieval_criteria = format!("({})", retrieval_criteria); @@ -394,6 +394,8 @@ mod test { const CURRENT: &str = r#"{"ast":{"operand":"OR","children":[{"operand":"AND","children":[{"operand":"OR","children":[{"key":"gender","type":"EQUALS","system":"","value":"male"}]},{"operand":"OR","children":[{"key":"diagnosis","type":"EQUALS","system":"http://fhir.de/CodeSystem/dimdi/icd-10-gm","value":"C61"}]},{"operand":"OR","children":[{"key":"donor_age","type":"BETWEEN","system":"","value":{"min":10,"max":90}}]}]},{"operand":"AND","children":[{"operand":"OR","children":[{"key":"sampling_date","type":"BETWEEN","system":"","value":{"min":"1900-01-01","max":"2024-10-25"}}]},{"operand":"OR","children":[{"key":"storage_temperature","type":"EQUALS","system":"","value":"temperature2to10"}]}]}]},"id":"53b4414e-75e4-401b-b794-20a2936e1be5"}"#; + const VAFAN: &str = r#"{"ast":{"nodeType":"branch","operand":"OR","children":[{"nodeType":"branch","operand":"AND","children":[]}]},"id":"0b29f6d1-4e6a-4679-9212-3327e498b304__search__0b29f6d1-4e6a-4679-9212-3327e498b304"}"#; + #[test] fn test_common() { // maybe nothing here @@ -444,6 +446,11 @@ mod test { include_str!("../resources/test/result_empty.cql").to_string() ); + pretty_assertions::assert_eq!( + generate_cql(serde_json::from_str(VAFAN).unwrap()).unwrap(), + include_str!("../resources/test/result_empty.cql").to_string() + ); + pretty_assertions::assert_eq!( generate_cql(serde_json::from_str(CURRENT).unwrap()).unwrap(), include_str!("../resources/test/result_current.cql").to_string() From 4f431eaf4b79cc6eb52677794595ed6175376444 Mon Sep 17 00:00:00 2001 From: Enola Knezevic Date: Thu, 6 Feb 2025 15:10:04 +0100 Subject: [PATCH 4/4] release info --- CHANGELOG.md | 12 +++++++++++- Cargo.toml | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a0510e..360045e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,14 @@ -# Samply.Focus v0.10.0 2024-12-11 +# Samply.Focus v0.11.0 2025-02-?? + +## Major changes +* Querying EUCAIM API v1 +* CQL generation supports empty AST of an arbitary debth + +## Minor changes +?? + + +# Samply.Focus v0.10.0 2025-02-03 ## Major changes * Laplace-rs version 0.5.0 (includes a statrs breaking change) diff --git a/Cargo.toml b/Cargo.toml index 38c0c33..e64d4db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "focus" -version = "0.10.0" +version = "0.11.0" edition = "2021" license = "Apache-2.0"