malac-utils 1.1.1__tar.gz → 1.2.0__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.1.1/malac_utils.egg-info → malac-utils-1.2.0}/PKG-INFO +1 -1
- malac-utils-1.2.0/malac/utils/__init__.py +2 -0
- malac-utils-1.2.0/malac/utils/date.py +21 -0
- {malac-utils-1.1.1 → malac-utils-1.2.0}/malac/utils/fhirpath.py +10 -13
- {malac-utils-1.1.1 → malac-utils-1.2.0/malac_utils.egg-info}/PKG-INFO +1 -1
- {malac-utils-1.1.1 → malac-utils-1.2.0}/malac_utils.egg-info/SOURCES.txt +1 -0
- malac-utils-1.1.1/malac/utils/__init__.py +0 -2
- {malac-utils-1.1.1 → malac-utils-1.2.0}/LICENSE +0 -0
- {malac-utils-1.1.1 → malac-utils-1.2.0}/README.md +0 -0
- {malac-utils-1.1.1 → malac-utils-1.2.0}/malac_utils.egg-info/dependency_links.txt +0 -0
- {malac-utils-1.1.1 → malac-utils-1.2.0}/malac_utils.egg-info/requires.txt +0 -0
- {malac-utils-1.1.1 → malac-utils-1.2.0}/malac_utils.egg-info/top_level.txt +0 -0
- {malac-utils-1.1.1 → malac-utils-1.2.0}/pyproject.toml +0 -0
- {malac-utils-1.1.1 → malac-utils-1.2.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: malac-utils
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0
|
|
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
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import re
|
|
2
|
+
import dateutil.parser
|
|
3
|
+
|
|
4
|
+
class PartialDate:
|
|
5
|
+
|
|
6
|
+
def __init__(self, value):
|
|
7
|
+
self.value = value
|
|
8
|
+
|
|
9
|
+
def isoformat(self):
|
|
10
|
+
return self.value
|
|
11
|
+
|
|
12
|
+
def parse(datestr):
|
|
13
|
+
if re.search("^[0-9]{1,6}$", datestr):
|
|
14
|
+
if len(datestr) > 4:
|
|
15
|
+
return PartialDate(datestr[0:4] + "-" + datestr[4:])
|
|
16
|
+
else:
|
|
17
|
+
return PartialDate(datestr)
|
|
18
|
+
elif len(datestr.split("-")) == 2:
|
|
19
|
+
return PartialDate(datestr)
|
|
20
|
+
else:
|
|
21
|
+
return dateutil.parser.parse(datestr)
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import datetime
|
|
2
|
-
import dateutil
|
|
3
2
|
import inspect
|
|
4
3
|
import io
|
|
5
4
|
import re
|
|
@@ -7,7 +6,7 @@ import decimal
|
|
|
7
6
|
import math
|
|
8
7
|
from urllib.parse import urlparse
|
|
9
8
|
|
|
10
|
-
import dateutil
|
|
9
|
+
from . import date as dateutil
|
|
11
10
|
|
|
12
11
|
time_units = ["year", "years", "month", "months", "week", "weeks", "day", "days", "hour", "hours", "minute", "minutes", "second", "seconds", "millisecond", "milliseconds"]
|
|
13
12
|
|
|
@@ -131,7 +130,7 @@ class FHIRPathUtils(object):
|
|
|
131
130
|
def string_value(self, val):
|
|
132
131
|
if isinstance(val, str):
|
|
133
132
|
return val
|
|
134
|
-
elif isinstance(val, self.model.string) or isinstance(val, self.model.uri):
|
|
133
|
+
elif isinstance(val, self.model.string) or isinstance(val, self.model.uri) or isinstance(val, self.model.code):
|
|
135
134
|
return val.value
|
|
136
135
|
elif isinstance(val, self.model.div):
|
|
137
136
|
tmp = io.StringIO()
|
|
@@ -321,10 +320,8 @@ class FHIRPathUtils(object):
|
|
|
321
320
|
return []
|
|
322
321
|
else:
|
|
323
322
|
if isinstance(val_a, (str, self.model.string)) or isinstance(val_b, (str, self.model.string)):
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
elif isinstance(val_b, self.model.string):
|
|
327
|
-
val_b = val_b.value
|
|
323
|
+
val_a = self.string_value(val_a)
|
|
324
|
+
val_b = self.string_value(val_b)
|
|
328
325
|
return [val_a + val_b] # TODO check types and add support for quantity
|
|
329
326
|
|
|
330
327
|
def subtract(self, val_a, val_b):
|
|
@@ -547,8 +544,8 @@ class FHIRPathUtils(object):
|
|
|
547
544
|
return [-1]
|
|
548
545
|
|
|
549
546
|
def concat(self, val, other):
|
|
550
|
-
val = self.string_value(self.single_value(val
|
|
551
|
-
other = self.string_value(self.single_value(other
|
|
547
|
+
val = self.string_value(self.single_value(val))
|
|
548
|
+
other = self.string_value(self.single_value(other))
|
|
552
549
|
if val == []:
|
|
553
550
|
val = ""
|
|
554
551
|
if other == []:
|
|
@@ -740,7 +737,7 @@ class FHIRPathUtils(object):
|
|
|
740
737
|
key = val
|
|
741
738
|
elif isinstance(val, self.model.dateTime) or isinstance(val, datetime.datetime):
|
|
742
739
|
val = val.value if isinstance(val, self.model.dateTime) else val
|
|
743
|
-
key = dateutil.
|
|
740
|
+
key = dateutil.parse(val) if isinstance(val, str) else val
|
|
744
741
|
if isinstance(val, str):
|
|
745
742
|
prec = -1 * len(val.split(":"))
|
|
746
743
|
if key.tzinfo:
|
|
@@ -755,7 +752,7 @@ class FHIRPathUtils(object):
|
|
|
755
752
|
if isinstance(key, str):
|
|
756
753
|
prec = len(key.split("-"))
|
|
757
754
|
if prec == 3:
|
|
758
|
-
key = dateutil.
|
|
755
|
+
key = dateutil.parse(key).date()
|
|
759
756
|
else:
|
|
760
757
|
prec = 3
|
|
761
758
|
type_ = "date"
|
|
@@ -1107,7 +1104,7 @@ class FHIRPathUtils(object):
|
|
|
1107
1104
|
return []
|
|
1108
1105
|
elif isinstance(val, self.model.dateTime) or isinstance(val, datetime.datetime):
|
|
1109
1106
|
if isinstance(val, self.model.dateTime):
|
|
1110
|
-
result = self.model.date(value=dateutil.
|
|
1107
|
+
result = self.model.date(value=dateutil.parse(val.value).date().isoformat())
|
|
1111
1108
|
else:
|
|
1112
1109
|
result = self.model.date(value=val.date().isoformat())
|
|
1113
1110
|
return [result]
|
|
@@ -1142,7 +1139,7 @@ class FHIRPathUtils(object):
|
|
|
1142
1139
|
elif isinstance(val, self.model.string) or isinstance(val, str):
|
|
1143
1140
|
try:
|
|
1144
1141
|
if "T" in val or not "-" in val: # support for CDA dates
|
|
1145
|
-
return [self.model.dateTime(value=dateutil.
|
|
1142
|
+
return [self.model.dateTime(value=dateutil.parse(val).isoformat())]
|
|
1146
1143
|
else:
|
|
1147
1144
|
return [self.model.dateTime(value=datetime.datetime.strptime(val,"-".join("%Y-%m-%d".split("-")[:len(val.split("-"))])).isoformat())]
|
|
1148
1145
|
except:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: malac-utils
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|