pathling 9.3.1__tar.gz → 9.4.0.dev0__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.
- {pathling-9.3.1 → pathling-9.4.0.dev0}/PKG-INFO +1 -1
- {pathling-9.3.1 → pathling-9.4.0.dev0}/pathling/_version.py +2 -2
- {pathling-9.3.1 → pathling-9.4.0.dev0}/pathling/context.py +61 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/.gitignore +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/LICENSE +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/README.md +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/examples/bulk.py +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/examples/data/bundles/Bennett146_Swaniawski813_704c9750-f6e6-473b-ee83-fbd48e07fe3f.json +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/examples/data/bundles/Dino214_Parisian75_40d82b80-b682-cd8b-da6d-396809878641.json +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/examples/data/csv/conditions.csv +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/examples/data/resources/Condition.ndjson +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/examples/data/resources/Patient.ndjson +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/examples/designation.py +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/examples/display.py +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/examples/encode_bundles.py +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/examples/encode_resources.py +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/examples/fhir_search.py +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/examples/fhir_view.py +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/examples/member_of.py +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/examples/property_of.py +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/examples/subsumes.py +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/examples/translate.py +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/pathling/__init__.py +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/pathling/bulk.py +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/pathling/coding.py +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/pathling/core.py +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/pathling/datasink.py +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/pathling/datasource.py +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/pathling/fhir.py +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/pathling/functions.py +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/pathling/spark.py +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/pathling/udfs.py +0 -0
- {pathling-9.3.1 → pathling-9.4.0.dev0}/pyproject.toml +0 -0
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
# Auto generated from POM project version.
|
|
3
3
|
# Please do not modify.
|
|
4
4
|
#
|
|
5
|
-
__version__="9.
|
|
6
|
-
__java_version__="9.
|
|
5
|
+
__version__="9.4.0.dev0"
|
|
6
|
+
__java_version__="9.4.0-SNAPSHOT"
|
|
7
7
|
__scala_version__="2.13"
|
|
8
8
|
__delta_version__="4.0.0"
|
|
9
9
|
__hadoop_version__="3.4.1"
|
|
@@ -33,6 +33,14 @@ if TYPE_CHECKING:
|
|
|
33
33
|
__all__ = ["PathlingContext"]
|
|
34
34
|
|
|
35
35
|
|
|
36
|
+
def _convert_java_value(value):
|
|
37
|
+
"""Converts a Java value from Py4J to an equivalent Python type."""
|
|
38
|
+
if isinstance(value, (str, int, float, bool)):
|
|
39
|
+
return value
|
|
40
|
+
# For other types (e.g., Java BigDecimal, Row), convert to string.
|
|
41
|
+
return str(value)
|
|
42
|
+
|
|
43
|
+
|
|
36
44
|
class StorageType:
|
|
37
45
|
MEMORY: str = "memory"
|
|
38
46
|
DISK: str = "disk"
|
|
@@ -415,6 +423,59 @@ class PathlingContext:
|
|
|
415
423
|
jcolumn = self._jpc.fhirPathToColumn(resource_type, fhirpath_expression)
|
|
416
424
|
return Column(jcolumn)
|
|
417
425
|
|
|
426
|
+
def evaluate_fhirpath(
|
|
427
|
+
self,
|
|
428
|
+
resource_type: str,
|
|
429
|
+
resource_json: str,
|
|
430
|
+
fhirpath_expression: str,
|
|
431
|
+
context_expression: Optional[str] = None,
|
|
432
|
+
variables: Optional[dict] = None,
|
|
433
|
+
) -> dict:
|
|
434
|
+
"""
|
|
435
|
+
Evaluates a FHIRPath expression against a single FHIR resource and returns
|
|
436
|
+
materialised typed results.
|
|
437
|
+
|
|
438
|
+
The resource is encoded into a one-row Spark Dataset internally, and the
|
|
439
|
+
existing FHIRPath engine is used to evaluate the expression. Results are
|
|
440
|
+
collected and returned as typed values.
|
|
441
|
+
|
|
442
|
+
Example usage::
|
|
443
|
+
|
|
444
|
+
pc = PathlingContext.create(spark)
|
|
445
|
+
result = pc.evaluate_fhirpath("Patient", patient_json, "name.family")
|
|
446
|
+
for value in result["results"]:
|
|
447
|
+
print(f"{value['type']}: {value['value']}")
|
|
448
|
+
|
|
449
|
+
:param resource_type: the FHIR resource type (e.g., "Patient", "Observation")
|
|
450
|
+
:param resource_json: the FHIR resource as a JSON string
|
|
451
|
+
:param fhirpath_expression: the FHIRPath expression to evaluate
|
|
452
|
+
:param context_expression: an optional context expression; if provided, the main
|
|
453
|
+
expression is composed with the context expression
|
|
454
|
+
:param variables: optional named variables available via %variable syntax, or None
|
|
455
|
+
:return: a dict with ``results`` (list of dicts with ``type`` and ``value``
|
|
456
|
+
keys) and ``expectedReturnType`` (string)
|
|
457
|
+
:raises: Exception if the expression is invalid or evaluation fails
|
|
458
|
+
"""
|
|
459
|
+
jresult = self._jpc.evaluateFhirPath(
|
|
460
|
+
resource_type,
|
|
461
|
+
resource_json,
|
|
462
|
+
fhirpath_expression,
|
|
463
|
+
context_expression,
|
|
464
|
+
variables,
|
|
465
|
+
)
|
|
466
|
+
# Convert Java FhirPathResult to Python dict.
|
|
467
|
+
results = []
|
|
468
|
+
for jtyped_value in jresult.getResults():
|
|
469
|
+
value = jtyped_value.getValue()
|
|
470
|
+
# Convert Java types to Python types.
|
|
471
|
+
if value is not None:
|
|
472
|
+
value = _convert_java_value(value)
|
|
473
|
+
results.append({"type": jtyped_value.getType(), "value": value})
|
|
474
|
+
return {
|
|
475
|
+
"results": results,
|
|
476
|
+
"expectedReturnType": jresult.getExpectedReturnType(),
|
|
477
|
+
}
|
|
478
|
+
|
|
418
479
|
def search_to_column(self, resource_type: str, search_expression: str) -> Column:
|
|
419
480
|
"""
|
|
420
481
|
Converts a FHIR search expression to a boolean filter column.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|