-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d7f02ba
commit 91a8ebe
Showing
4 changed files
with
98 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from fhirpathpy.engine.nodes import TypeInfo | ||
|
||
def type_fn(ctx, coll): | ||
return [TypeInfo.from_value(value) for value in coll] | ||
|
||
|
||
def is_fn(ctx, coll, type_info): | ||
if not coll: | ||
return [] | ||
if len(coll) > 1: | ||
raise ValueError(f"Expected singleton on left side of 'is', got {coll}") | ||
return TypeInfo.from_value(coll[0]).is_(type_info) | ||
|
||
|
||
def as_fn(ctx, coll, type_info): | ||
if not coll: | ||
return [] | ||
if len(coll) > 1: | ||
raise ValueError(f"Expected singleton on left side of 'as', got {coll}") | ||
return coll if TypeInfo.from_value(coll[0]).is_(type_info) else [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters