Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for now() FHIR Path version of Now(). #53

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions parser/operators.go
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,17 @@ func (p *Parser) loadSystemOperators() error {
}
},
},
{
name: "now",
operands: [][]types.IType{{}},
model: func() model.IExpression {
return &model.Now{
NaryExpression: &model.NaryExpression{
Expression: model.ResultType(types.DateTime),
},
}
},
},
{
name: "TimeOfDay",
operands: [][]types.IType{{}},
Expand Down
10 changes: 10 additions & 0 deletions parser/operators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,16 @@ func TestBuiltInFunctions(t *testing.T) {
},
},
},
{
name: "now()",
cql: "now()",
want: &model.Now{
NaryExpression: &model.NaryExpression{
Operands: []model.IExpression{},
Expression: model.ResultType(types.DateTime),
},
},
},
{
name: "TimeOfDay()",
cql: "TimeOfDay()",
Expand Down
12 changes: 12 additions & 0 deletions tests/enginetests/operator_datetime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,18 @@ func TestEvaluationTimestamp(t *testing.T) {
},
wantResult: newOrFatal(t, result.DateTime{Date: time.Date(2024, time.January, 1, 0, 0, 0, 1, time.UTC), Precision: model.MILLISECOND}),
},
{
name: "now() returns passed evaluation timestamp",
cql: "define TESTRESULT: now()",
evaluationTimestamp: time.Date(2024, time.January, 1, 0, 0, 0, 1, time.UTC),
wantModel: &model.Now{
NaryExpression: &model.NaryExpression{
Operands: []model.IExpression{},
Expression: model.ResultType(types.DateTime),
},
},
wantResult: newOrFatal(t, result.DateTime{Date: time.Date(2024, time.January, 1, 0, 0, 0, 1, time.UTC), Precision: model.MILLISECOND}),
},
{
name: "Time returns passed evaluation timestamp time components",
cql: "define TESTRESULT: TimeOfDay()",
Expand Down
Loading