fhirpathpy 2.0.0__tar.gz → 2.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/PKG-INFO +33 -8
  2. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/README.md +32 -8
  3. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/__init__.py +1 -1
  4. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/engine/util.py +1 -1
  5. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/LICENSE.md +0 -0
  6. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/engine/__init__.py +0 -0
  7. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/engine/evaluators/__init__.py +0 -0
  8. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/engine/invocations/__init__.py +0 -0
  9. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/engine/invocations/aggregate.py +0 -0
  10. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/engine/invocations/collections.py +0 -0
  11. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/engine/invocations/combining.py +0 -0
  12. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/engine/invocations/constants.py +0 -0
  13. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/engine/invocations/datetime.py +0 -0
  14. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/engine/invocations/equality.py +0 -0
  15. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/engine/invocations/existence.py +0 -0
  16. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/engine/invocations/filtering.py +0 -0
  17. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/engine/invocations/logic.py +0 -0
  18. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/engine/invocations/math.py +0 -0
  19. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/engine/invocations/misc.py +0 -0
  20. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/engine/invocations/navigation.py +0 -0
  21. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/engine/invocations/strings.py +0 -0
  22. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/engine/invocations/subsetting.py +0 -0
  23. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/engine/invocations/types.py +0 -0
  24. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/engine/nodes.py +0 -0
  25. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/models/__init__.py +0 -0
  26. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/models/dstu2/choiceTypePaths.json +0 -0
  27. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/models/dstu2/path2Type.json +0 -0
  28. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/models/dstu2/pathsDefinedElsewhere.json +0 -0
  29. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/models/dstu2/type2Parent.json +0 -0
  30. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/models/r4/choiceTypePaths.json +0 -0
  31. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/models/r4/path2Type.json +0 -0
  32. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/models/r4/pathsDefinedElsewhere.json +0 -0
  33. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/models/r4/type2Parent.json +0 -0
  34. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/models/r5/choiceTypePaths.json +0 -0
  35. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/models/r5/path2Type.json +0 -0
  36. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/models/r5/pathsDefinedElsewhere.json +0 -0
  37. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/models/r5/type2Parent.json +0 -0
  38. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/models/stu3/choiceTypePaths.json +0 -0
  39. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/models/stu3/path2Type.json +0 -0
  40. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/models/stu3/pathsDefinedElsewhere.json +0 -0
  41. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/models/stu3/type2Parent.json +0 -0
  42. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/parser/ASTPathListener.py +0 -0
  43. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/parser/FHIRPath.g4 +0 -0
  44. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/parser/README.md +0 -0
  45. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/parser/__init__.py +0 -0
  46. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/parser/generated/FHIRPath.interp +0 -0
  47. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/parser/generated/FHIRPath.tokens +0 -0
  48. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/parser/generated/FHIRPathLexer.interp +0 -0
  49. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/parser/generated/FHIRPathLexer.py +0 -0
  50. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/parser/generated/FHIRPathLexer.tokens +0 -0
  51. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/parser/generated/FHIRPathListener.py +0 -0
  52. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/parser/generated/FHIRPathParser.py +0 -0
  53. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/fhirpathpy/parser/generated/__init__.py +0 -0
  54. {fhirpathpy-2.0.0 → fhirpathpy-2.0.1}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fhirpathpy
3
- Version: 2.0.0
3
+ Version: 2.0.1
4
4
  Summary: FHIRPath implementation in Python
5
5
  Keywords: fhir,fhirpath
6
6
  Author-email: "beda.software" <fhirpath@beda.software>
@@ -82,7 +82,7 @@ patient = {
82
82
  }
83
83
 
84
84
  # Evaluating FHIRPath
85
- result = evaluate(patient, "Patient.name.where(use='usual').given.first()", [])
85
+ result = evaluate(patient, "Patient.name.where(use='usual').given.first()", {})
86
86
  # result: `['Jim']`
87
87
  ```
88
88
 
@@ -97,11 +97,11 @@ path (string): fhirpath expression, sample 'Patient.name.given'
97
97
 
98
98
  context (dict): a hash of variable name/value pairs.
99
99
 
100
- model (dict): The "model" data object specific to a domain, e.g. R4.
100
+ model (dict): The "model" data object specific to a domain, e.g. R4. See Using data models documentation below.
101
101
 
102
- options (dict) - Custom options (see the documentation below)
102
+ options (dict) - Custom options.
103
103
 
104
- options.userInvocationTable - a user invocation table used to replace any existing functions or define new ones (see User-defined functions documentation below)
104
+ options.userInvocationTable - a user invocation table used to replace any existing functions or define new ones. See User-defined functions documentation below.
105
105
 
106
106
  ## compile
107
107
  Returns a function that takes a resource and an optional context hash (see "evaluate"), and returns the result of evaluating the given FHIRPath expression on that resource. The advantage of this function over "evaluate" is that if you have multiple resources, the given FHIRPath expression will only be parsed once
@@ -110,14 +110,38 @@ Returns a function that takes a resource and an optional context hash (see "eval
110
110
 
111
111
  path (string) - the FHIRPath expression to be parsed.
112
112
 
113
- model (dict) - The "model" data object specific to a domain, e.g. R4.
113
+ model (dict) - The "model" data object specific to a domain, e.g. R4. See Using data models documentation below.
114
114
 
115
115
  options (dict) - Custom options
116
116
 
117
- options.userInvocationTable - a user invocation table used to replace any existing functions or define new ones (see User-defined functions documentation below)
117
+ options.userInvocationTable - a user invocation table used to replace any existing functions or define new ones. See User-defined functions documentation below.
118
+
119
+ ## Using data models
120
+
121
+ The fhirpathpy library comes with pre-defined data models for FHIR versions DSTU2, STU3, R4, and R5. These models can be used within your project.
122
+
123
+ Example:
124
+ ```python
125
+ from fhirpathpy.models import models
126
+
127
+
128
+ r4_model = models["r4"]
129
+
130
+ patient = {
131
+ "resourceType": "Patient",
132
+ "deceasedBoolean": false,
133
+ }
134
+
135
+ result = evaluate(patient, "Patient.deceased", {}, r4_model)
136
+
137
+ # result: `[False]`
138
+ ```
118
139
 
119
140
  ## User-defined functions
120
141
 
142
+ The FHIRPath specification includes a set of built-in functions. However, if you need to extend the functionality by adding custom logic, you can define your own functions by providing a table of user-defined functions.
143
+
144
+ Example:
121
145
  ```python
122
146
  user_invocation_table = {
123
147
  "pow": {
@@ -132,7 +156,8 @@ result = evaluate(
132
156
  options={"userInvocationTable": user_invocation_table},
133
157
  )
134
158
 
135
- # result: [25, 36, 49]
159
+ # result: `[25, 36, 49]`
136
160
  ```
137
161
 
138
162
  It works similarly to [fhirpath.js](https://github.com/HL7/fhirpath.js/tree/master?tab=readme-ov-file#user-defined-functions)
163
+
@@ -51,7 +51,7 @@ patient = {
51
51
  }
52
52
 
53
53
  # Evaluating FHIRPath
54
- result = evaluate(patient, "Patient.name.where(use='usual').given.first()", [])
54
+ result = evaluate(patient, "Patient.name.where(use='usual').given.first()", {})
55
55
  # result: `['Jim']`
56
56
  ```
57
57
 
@@ -66,11 +66,11 @@ path (string): fhirpath expression, sample 'Patient.name.given'
66
66
 
67
67
  context (dict): a hash of variable name/value pairs.
68
68
 
69
- model (dict): The "model" data object specific to a domain, e.g. R4.
69
+ model (dict): The "model" data object specific to a domain, e.g. R4. See Using data models documentation below.
70
70
 
71
- options (dict) - Custom options (see the documentation below)
71
+ options (dict) - Custom options.
72
72
 
73
- options.userInvocationTable - a user invocation table used to replace any existing functions or define new ones (see User-defined functions documentation below)
73
+ options.userInvocationTable - a user invocation table used to replace any existing functions or define new ones. See User-defined functions documentation below.
74
74
 
75
75
  ## compile
76
76
  Returns a function that takes a resource and an optional context hash (see "evaluate"), and returns the result of evaluating the given FHIRPath expression on that resource. The advantage of this function over "evaluate" is that if you have multiple resources, the given FHIRPath expression will only be parsed once
@@ -79,14 +79,38 @@ Returns a function that takes a resource and an optional context hash (see "eval
79
79
 
80
80
  path (string) - the FHIRPath expression to be parsed.
81
81
 
82
- model (dict) - The "model" data object specific to a domain, e.g. R4.
82
+ model (dict) - The "model" data object specific to a domain, e.g. R4. See Using data models documentation below.
83
83
 
84
84
  options (dict) - Custom options
85
85
 
86
- options.userInvocationTable - a user invocation table used to replace any existing functions or define new ones (see User-defined functions documentation below)
86
+ options.userInvocationTable - a user invocation table used to replace any existing functions or define new ones. See User-defined functions documentation below.
87
+
88
+ ## Using data models
89
+
90
+ The fhirpathpy library comes with pre-defined data models for FHIR versions DSTU2, STU3, R4, and R5. These models can be used within your project.
91
+
92
+ Example:
93
+ ```python
94
+ from fhirpathpy.models import models
95
+
96
+
97
+ r4_model = models["r4"]
98
+
99
+ patient = {
100
+ "resourceType": "Patient",
101
+ "deceasedBoolean": false,
102
+ }
103
+
104
+ result = evaluate(patient, "Patient.deceased", {}, r4_model)
105
+
106
+ # result: `[False]`
107
+ ```
87
108
 
88
109
  ## User-defined functions
89
110
 
111
+ The FHIRPath specification includes a set of built-in functions. However, if you need to extend the functionality by adding custom logic, you can define your own functions by providing a table of user-defined functions.
112
+
113
+ Example:
90
114
  ```python
91
115
  user_invocation_table = {
92
116
  "pow": {
@@ -101,7 +125,7 @@ result = evaluate(
101
125
  options={"userInvocationTable": user_invocation_table},
102
126
  )
103
127
 
104
- # result: [25, 36, 49]
128
+ # result: `[25, 36, 49]`
105
129
  ```
106
130
 
107
- It works similarly to [fhirpath.js](https://github.com/HL7/fhirpath.js/tree/master?tab=readme-ov-file#user-defined-functions)
131
+ It works similarly to [fhirpath.js](https://github.com/HL7/fhirpath.js/tree/master?tab=readme-ov-file#user-defined-functions)
@@ -5,7 +5,7 @@ from fhirpathpy.engine.util import arraify, get_data, set_paths, process_user_in
5
5
  from fhirpathpy.engine.nodes import FP_Type, ResourceNode
6
6
 
7
7
  __title__ = "fhirpathpy"
8
- __version__ = "2.0.0"
8
+ __version__ = "2.0.1"
9
9
  __author__ = "beda.software"
10
10
  __license__ = "MIT"
11
11
  __copyright__ = "Copyright 2025 beda.software"
@@ -107,7 +107,7 @@ def process_user_invocation_table(table):
107
107
  return {
108
108
  name: {
109
109
  **entity,
110
- "fn": lambda ctx, inputs, *args: entity["fn"](
110
+ "fn": lambda ctx, inputs, *args, __fn__=entity["fn"]: __fn__(
111
111
  [get_data(i) for i in inputs], *args
112
112
  ),
113
113
  }
File without changes
File without changes