Skip to content

Commit

Permalink
Use constant datetime point for the entire expression evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
m0rl committed Feb 10, 2024
1 parent 8b579c9 commit c99543f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
16 changes: 16 additions & 0 deletions fhirpathpy/engine/invocations/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
from datetime import datetime


class SystemTime:
"""
System date/time should not change during an evaluation of a FHIRPath
expression. It remains the same for the entire expression evaluation.
"""

expressionExecutionDateTime = datetime.now()

def now(self):
return self.expressionExecutionDateTime


class Constants:
"""
These are values that should not change during an evaluation of a FHIRPath
Expand All @@ -18,3 +33,4 @@ def reset(self):


constants = Constants()
systemtime = SystemTime()
4 changes: 1 addition & 3 deletions fhirpathpy/engine/invocations/datetime.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from datetime import datetime as systemtime

from fhirpathpy.engine.invocations.constants import constants
from fhirpathpy.engine.invocations.constants import constants, systemtime
from fhirpathpy.engine.nodes import FP_DateTime, FP_Time


Expand Down

0 comments on commit c99543f

Please sign in to comment.