malac-utils 1.2.0__tar.gz → 1.3.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.
- {malac-utils-1.2.0/malac_utils.egg-info → malac_utils-1.3.1}/PKG-INFO +3 -2
- malac_utils-1.3.1/malac/utils/__init__.py +2 -0
- {malac-utils-1.2.0 → malac_utils-1.3.1}/malac/utils/date.py +2 -1
- {malac-utils-1.2.0 → malac_utils-1.3.1}/malac/utils/fhirpath.py +31 -2
- {malac-utils-1.2.0 → malac_utils-1.3.1/malac_utils.egg-info}/PKG-INFO +3 -2
- {malac-utils-1.2.0 → malac_utils-1.3.1}/pyproject.toml +1 -1
- malac-utils-1.2.0/malac/utils/__init__.py +0 -2
- {malac-utils-1.2.0 → malac_utils-1.3.1}/LICENSE +0 -0
- {malac-utils-1.2.0 → malac_utils-1.3.1}/README.md +0 -0
- {malac-utils-1.2.0 → malac_utils-1.3.1}/malac_utils.egg-info/SOURCES.txt +0 -0
- {malac-utils-1.2.0 → malac_utils-1.3.1}/malac_utils.egg-info/dependency_links.txt +0 -0
- {malac-utils-1.2.0 → malac_utils-1.3.1}/malac_utils.egg-info/requires.txt +0 -0
- {malac-utils-1.2.0 → malac_utils-1.3.1}/malac_utils.egg-info/top_level.txt +0 -0
- {malac-utils-1.2.0 → malac_utils-1.3.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: malac-utils
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.1
|
|
4
4
|
Summary: Mapping Language Compiler Utils
|
|
5
5
|
Author-email: cdeHealth-Team <contact-project+cdehealth-malac-hd-52276676-issue-@incoming.gitlab.com>
|
|
6
6
|
Project-URL: Homepage, https://gitlab.com/cdehealth/malac-hd
|
|
@@ -24,6 +24,7 @@ Requires-Python: >=3.10
|
|
|
24
24
|
Description-Content-Type: text/markdown
|
|
25
25
|
License-File: LICENSE
|
|
26
26
|
Requires-Dist: python-dateutil>=2.8.2
|
|
27
|
+
Dynamic: license-file
|
|
27
28
|
|
|
28
29
|
# MaLaC Utils
|
|
29
30
|
|
|
@@ -10,6 +10,7 @@ class PartialDate:
|
|
|
10
10
|
return self.value
|
|
11
11
|
|
|
12
12
|
def parse(datestr):
|
|
13
|
+
datestr = getattr(datestr, "value", datestr)
|
|
13
14
|
if re.search("^[0-9]{1,6}$", datestr):
|
|
14
15
|
if len(datestr) > 4:
|
|
15
16
|
return PartialDate(datestr[0:4] + "-" + datestr[4:])
|
|
@@ -18,4 +19,4 @@ def parse(datestr):
|
|
|
18
19
|
elif len(datestr.split("-")) == 2:
|
|
19
20
|
return PartialDate(datestr)
|
|
20
21
|
else:
|
|
21
|
-
return dateutil.parser.parse(datestr)
|
|
22
|
+
return dateutil.parser.parse(datestr)
|
|
@@ -121,6 +121,8 @@ class FHIRPathUtils(object):
|
|
|
121
121
|
result = getattr(val, key[:-10]) or []
|
|
122
122
|
if result != [] and len(attrs) == 1 and options.get("strip", False):
|
|
123
123
|
result = str(result).strip()
|
|
124
|
+
if result == "":
|
|
125
|
+
result = []
|
|
124
126
|
result = result if isinstance(result, list) else [result]
|
|
125
127
|
if len(attrs) == 1:
|
|
126
128
|
return result
|
|
@@ -130,7 +132,7 @@ class FHIRPathUtils(object):
|
|
|
130
132
|
def string_value(self, val):
|
|
131
133
|
if isinstance(val, str):
|
|
132
134
|
return val
|
|
133
|
-
elif isinstance(val, self.model.string) or isinstance(val, self.model.uri) or isinstance(val, self.model.code):
|
|
135
|
+
elif isinstance(val, self.model.string) or isinstance(val, self.model.uri) or isinstance(val, self.model.code) or isinstance(val, self.model.canonical) or isinstance(val, self.model.id):
|
|
134
136
|
return val.value
|
|
135
137
|
elif isinstance(val, self.model.div):
|
|
136
138
|
tmp = io.StringIO()
|
|
@@ -505,7 +507,7 @@ class FHIRPathUtils(object):
|
|
|
505
507
|
if val == [] or regex == []:
|
|
506
508
|
return []
|
|
507
509
|
else:
|
|
508
|
-
return [re.fullmatch(
|
|
510
|
+
return [re.fullmatch(regex, val) is not None]
|
|
509
511
|
|
|
510
512
|
def contains(self, val, other):
|
|
511
513
|
val = self.string_value(val)
|
|
@@ -515,6 +517,24 @@ class FHIRPathUtils(object):
|
|
|
515
517
|
else:
|
|
516
518
|
return [other in val]
|
|
517
519
|
|
|
520
|
+
def replace(self, val, pattern, substitution):
|
|
521
|
+
val = self.string_value(val)
|
|
522
|
+
pattern = self.string_value(self.single_value(pattern, str, self.model.string))
|
|
523
|
+
substitution = self.string_value(self.single_value(substitution, str, self.model.string))
|
|
524
|
+
if val == [] or pattern == [] or substitution == []:
|
|
525
|
+
return []
|
|
526
|
+
else:
|
|
527
|
+
return [val.replace(pattern, substitution)]
|
|
528
|
+
|
|
529
|
+
def replaceMatches(self, val, regex, substitution):
|
|
530
|
+
val = self.string_value(val)
|
|
531
|
+
regex = self.string_value(self.single_value(regex, str, self.model.string))
|
|
532
|
+
substitution = self.string_value(self.single_value(substitution, str, self.model.string))
|
|
533
|
+
if val == [] or regex == [] or substitution == []:
|
|
534
|
+
return []
|
|
535
|
+
else:
|
|
536
|
+
return [re.sub(regex, substitution, val)]
|
|
537
|
+
|
|
518
538
|
def startswith(self, val, other):
|
|
519
539
|
val = self.string_value(val)
|
|
520
540
|
other = self.string_value(self.single_value(other, str, self.model.string))
|
|
@@ -551,6 +571,13 @@ class FHIRPathUtils(object):
|
|
|
551
571
|
if other == []:
|
|
552
572
|
other = ""
|
|
553
573
|
return [val + other]
|
|
574
|
+
|
|
575
|
+
def split(self, val, separator):
|
|
576
|
+
val = self.string_value(self.single_value(val))
|
|
577
|
+
separator = self.string_value(self.single_value(separator))
|
|
578
|
+
if val == [] or separator == []:
|
|
579
|
+
return []
|
|
580
|
+
return val.split(separator)
|
|
554
581
|
|
|
555
582
|
def skip(self, val, count):
|
|
556
583
|
count = self.single_value(count, int, self.model.integer)
|
|
@@ -999,6 +1026,8 @@ class FHIRPathUtils(object):
|
|
|
999
1026
|
result = val.value
|
|
1000
1027
|
else:
|
|
1001
1028
|
result = str(val)
|
|
1029
|
+
elif isinstance(val, dateutil.PartialDate):
|
|
1030
|
+
result = val.isoformat()
|
|
1002
1031
|
else:
|
|
1003
1032
|
result = False
|
|
1004
1033
|
return [result]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: malac-utils
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.1
|
|
4
4
|
Summary: Mapping Language Compiler Utils
|
|
5
5
|
Author-email: cdeHealth-Team <contact-project+cdehealth-malac-hd-52276676-issue-@incoming.gitlab.com>
|
|
6
6
|
Project-URL: Homepage, https://gitlab.com/cdehealth/malac-hd
|
|
@@ -24,6 +24,7 @@ Requires-Python: >=3.10
|
|
|
24
24
|
Description-Content-Type: text/markdown
|
|
25
25
|
License-File: LICENSE
|
|
26
26
|
Requires-Dist: python-dateutil>=2.8.2
|
|
27
|
+
Dynamic: license-file
|
|
27
28
|
|
|
28
29
|
# MaLaC Utils
|
|
29
30
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|