1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#[test]
fn test_boolean_validation_improvements() {
// Test case that should pass: comparison operation
let view_with_comparison = r#"{
"resourceType": "ViewDefinition",
"resource": "Patient",
"select": [
{
"column": [
{
"name": "id",
"path": "id",
"type": "id"
}
]
}
],
"where": [
{
"path": "active = true"
}
]
}"#;
// Test case that should fail: simple member access that might not be boolean
let view_with_simple_member = r#"{
"resourceType": "ViewDefinition",
"resource": "Patient",
"select": [
{
"column": [
{
"name": "id",
"path": "id",
"type": "id"
}
]
}
],
"where": [
{
"path": "name.family"
}
]
}"#;
// Test case that should pass: boolean function
let view_with_boolean_function = r#"{
"resourceType": "ViewDefinition",
"resource": "Patient",
"select": [
{
"column": [
{
"name": "id",
"path": "id",
"type": "id"
}
]
}
],
"where": [
{
"path": "name.exists()"
}
]
}"#;
// Parse as FHIR resources directly to test validation
println!("Testing comparison operation (should pass):");
let view_def1: Result<helios_fhir::r4::ViewDefinition, _> =
serde_json::from_str(view_with_comparison);
assert!(
view_def1.is_ok(),
"Should parse ViewDefinition successfully"
);
println!("Testing simple member access 'name.family' (should fail):");
let view_def2: Result<helios_fhir::r4::ViewDefinition, _> =
serde_json::from_str(view_with_simple_member);
assert!(
view_def2.is_ok(),
"Should parse ViewDefinition successfully"
);
println!("Testing boolean function 'name.exists()' (should pass):");
let view_def3: Result<helios_fhir::r4::ViewDefinition, _> =
serde_json::from_str(view_with_boolean_function);
assert!(
view_def3.is_ok(),
"Should parse ViewDefinition successfully"
);
// Note: The actual validation happens when creating SofViewDefinition from parsed FHIR resources
// This test just ensures our changes don't break basic parsing
}