sdc-mapper 4.3.0__tar.gz → 4.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.
- {sdc_mapper-4.3.0/src/sdc_mapper.egg-info → sdc_mapper-4.3.1}/PKG-INFO +2 -2
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/README.md +1 -1
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/pyproject.toml +1 -1
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/src/sdc_mapper/__init__.py +1 -1
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/src/sdc_mapper/codes.py +19 -9
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1/src/sdc_mapper.egg-info}/PKG-INFO +2 -2
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/tests/test_codes.py +23 -0
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/LICENSE +0 -0
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/NOTICE +0 -0
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/setup.cfg +0 -0
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/src/sdc_mapper/cli.py +0 -0
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/src/sdc_mapper/contract.py +0 -0
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/src/sdc_mapper/engine.py +0 -0
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/src/sdc_mapper/gate.py +0 -0
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/src/sdc_mapper/log.py +0 -0
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/src/sdc_mapper/mapping.py +0 -0
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/src/sdc_mapper/mcp_server.py +0 -0
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/src/sdc_mapper/placement.py +0 -0
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/src/sdc_mapper/report.py +0 -0
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/src/sdc_mapper/resolve.py +0 -0
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/src/sdc_mapper/schemas/log-entry.schema.json +0 -0
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/src/sdc_mapper/schemas/mapping.schema.json +0 -0
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/src/sdc_mapper/schemas/sdc4.xsd +0 -0
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/src/sdc_mapper/service.py +0 -0
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/src/sdc_mapper.egg-info/SOURCES.txt +0 -0
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/src/sdc_mapper.egg-info/dependency_links.txt +0 -0
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/src/sdc_mapper.egg-info/entry_points.txt +0 -0
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/src/sdc_mapper.egg-info/requires.txt +0 -0
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/src/sdc_mapper.egg-info/top_level.txt +0 -0
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/tests/test_core.py +0 -0
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/tests/test_placement.py +0 -0
- {sdc_mapper-4.3.0 → sdc_mapper-4.3.1}/tests/test_service.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sdc-mapper
|
|
3
|
-
Version: 4.3.
|
|
3
|
+
Version: 4.3.1
|
|
4
4
|
Summary: The shared core of the Semantic Data Charter's Governed Data Record mappers: validate, resolve, map, and report every value; MCP server included.
|
|
5
5
|
Author: Axius SDC, Inc.
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -33,7 +33,7 @@ target could say it too. Every call is appended to a hash-chained log that holds
|
|
|
33
33
|
Each target format is its own package (`sdc-gdr2ubl`, `sdc-gdr2edifact`, `sdc-gdr2omop`, ...) registered under the
|
|
34
34
|
entry-point group `sdc_mapper.targets`. Outbound only. Apache 2.0.
|
|
35
35
|
|
|
36
|
-
**Status:** 4.3.
|
|
36
|
+
**Status:** 4.3.1. Five target mappers are released: `sdc-gdr2ubl` (OASIS UBL 2.3), `sdc-gdr2edifact` (UN/EDIFACT
|
|
37
37
|
D.24A), `sdc-gdr2omop` (OMOP CDM 5.4), `sdc-gdr2fhir` (HL7 FHIR R4) and `sdc-gdr2hl7v2` (HL7 v2.5.1).
|
|
38
38
|
|
|
39
39
|
## Use
|
|
@@ -11,7 +11,7 @@ target could say it too. Every call is appended to a hash-chained log that holds
|
|
|
11
11
|
Each target format is its own package (`sdc-gdr2ubl`, `sdc-gdr2edifact`, `sdc-gdr2omop`, ...) registered under the
|
|
12
12
|
entry-point group `sdc_mapper.targets`. Outbound only. Apache 2.0.
|
|
13
13
|
|
|
14
|
-
**Status:** 4.3.
|
|
14
|
+
**Status:** 4.3.1. Five target mappers are released: `sdc-gdr2ubl` (OASIS UBL 2.3), `sdc-gdr2edifact` (UN/EDIFACT
|
|
15
15
|
D.24A), `sdc-gdr2omop` (OMOP CDM 5.4), `sdc-gdr2fhir` (HL7 FHIR R4) and `sdc-gdr2hl7v2` (HL7 v2.5.1).
|
|
16
16
|
|
|
17
17
|
## Use
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "sdc-mapper"
|
|
7
|
-
version = "4.3.
|
|
7
|
+
version = "4.3.1"
|
|
8
8
|
description = "The shared core of the Semantic Data Charter's Governed Data Record mappers: validate, resolve, map, and report every value; MCP server included."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.12"
|
|
@@ -20,7 +20,7 @@ from .placement import JOIN, LOOKUP_TRANSFORMS, ClusterPlacement, Extra, Placeme
|
|
|
20
20
|
from .report import CoverageReport, IncompleteMapping, build_report
|
|
21
21
|
from .resolve import Exceptional, ResolvedRecord, ResolvedValue, Units, resolve
|
|
22
22
|
|
|
23
|
-
__version__ = "4.3.
|
|
23
|
+
__version__ = "4.3.1"
|
|
24
24
|
__all__ = [
|
|
25
25
|
"Engine", "CallResult", "Gate", "GateResult", "Recovery", "Log", "entry_hash", "Mapping", "MappingError", "Rule",
|
|
26
26
|
"load_mapping", "place", "Placement", "ClusterPlacement", "Extra", "JOIN", "join_depth", "LOOKUP_TRANSFORMS", "CodeRef", "code_of",
|
|
@@ -39,8 +39,14 @@ class CodeRef:
|
|
|
39
39
|
code: str
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
def code_of(iri: str | None) -> CodeRef | None:
|
|
43
|
-
"""The code an IRI names, or None (an IRI that names a whole code system, or a page about a variable).
|
|
42
|
+
def code_of(iri: str | None, code_lists: bool = True) -> CodeRef | None:
|
|
43
|
+
"""The code an IRI names, or None (an IRI that names a whole code system, or a page about a variable).
|
|
44
|
+
|
|
45
|
+
The code systems' own forms (LOINC, SNOMED CT, NCI Thesaurus) always read as codes. An IRI ending in `#code` reads
|
|
46
|
+
as an entry in a code list only with `code_lists`: that is how a model binds an enumerated value to a list (UBL's,
|
|
47
|
+
HL7's), but the same form also names a vocabulary term (`prov#Entity`) or an anchor on a page about a variable
|
|
48
|
+
(`DEMO_J.htm#SEQN`), which are not codes. 4.3.1: concept links read without it.
|
|
49
|
+
"""
|
|
44
50
|
if not iri:
|
|
45
51
|
return None
|
|
46
52
|
iri = iri.strip()
|
|
@@ -48,9 +54,10 @@ def code_of(iri: str | None) -> CodeRef | None:
|
|
|
48
54
|
m = form.match(iri)
|
|
49
55
|
if m:
|
|
50
56
|
return CodeRef(system, m.group(1))
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
if code_lists:
|
|
58
|
+
m = _FRAGMENT.match(iri)
|
|
59
|
+
if m:
|
|
60
|
+
return CodeRef(m.group(1), m.group(2))
|
|
54
61
|
return None
|
|
55
62
|
|
|
56
63
|
|
|
@@ -59,17 +66,19 @@ def _in(ref: CodeRef | None, system: str | None) -> bool:
|
|
|
59
66
|
|
|
60
67
|
|
|
61
68
|
def bound_code(value, system: str | None = None) -> CodeRef | None:
|
|
62
|
-
"""The code the model defines an enumerated value by, if it is one (in `system`, when given)
|
|
69
|
+
"""The code the model defines an enumerated value by, if it is one (in `system`, when given): a code system's
|
|
70
|
+
concept, or an entry in a code list."""
|
|
63
71
|
ref = code_of(value.code.defined_by) if getattr(value, "code", None) else None
|
|
64
72
|
return ref if _in(ref, system) else None
|
|
65
73
|
|
|
66
74
|
|
|
67
75
|
def linked_code(value, system: str | None = None, predicates=CONCEPT_LINKS) -> CodeRef | None:
|
|
68
|
-
"""The first code the component links to (in `system`, when given), by the predicates in order
|
|
76
|
+
"""The first code the component links to (in `system`, when given), by the predicates in order: a code system's
|
|
77
|
+
concept only, never a `#fragment` (a link names a concept; a fragment in a link is a term or a page anchor)."""
|
|
69
78
|
links = getattr(value, "links", None) or {}
|
|
70
79
|
for predicate in predicates:
|
|
71
80
|
for iri in links.get(predicate, []):
|
|
72
|
-
ref = code_of(iri)
|
|
81
|
+
ref = code_of(iri, code_lists=False)
|
|
73
82
|
if _in(ref, system):
|
|
74
83
|
return ref
|
|
75
84
|
return None
|
|
@@ -78,5 +87,6 @@ def linked_code(value, system: str | None = None, predicates=CONCEPT_LINKS) -> C
|
|
|
78
87
|
def model_codes(value) -> set[str]:
|
|
79
88
|
"""Every code the model names for a value: its enumeration value's definition and the component's concept links.
|
|
80
89
|
A target code that is one of these came from the model."""
|
|
81
|
-
refs = [bound_code(value)] + [code_of(i
|
|
90
|
+
refs = [bound_code(value)] + [code_of(i, code_lists=False)
|
|
91
|
+
for p in CONCEPT_LINKS for i in (getattr(value, "links", None) or {}).get(p, [])]
|
|
82
92
|
return {r.code for r in refs if r}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sdc-mapper
|
|
3
|
-
Version: 4.3.
|
|
3
|
+
Version: 4.3.1
|
|
4
4
|
Summary: The shared core of the Semantic Data Charter's Governed Data Record mappers: validate, resolve, map, and report every value; MCP server included.
|
|
5
5
|
Author: Axius SDC, Inc.
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -33,7 +33,7 @@ target could say it too. Every call is appended to a hash-chained log that holds
|
|
|
33
33
|
Each target format is its own package (`sdc-gdr2ubl`, `sdc-gdr2edifact`, `sdc-gdr2omop`, ...) registered under the
|
|
34
34
|
entry-point group `sdc_mapper.targets`. Outbound only. Apache 2.0.
|
|
35
35
|
|
|
36
|
-
**Status:** 4.3.
|
|
36
|
+
**Status:** 4.3.1. Five target mappers are released: `sdc-gdr2ubl` (OASIS UBL 2.3), `sdc-gdr2edifact` (UN/EDIFACT
|
|
37
37
|
D.24A), `sdc-gdr2omop` (OMOP CDM 5.4), `sdc-gdr2fhir` (HL7 FHIR R4) and `sdc-gdr2hl7v2` (HL7 v2.5.1).
|
|
38
38
|
|
|
39
39
|
## Use
|
|
@@ -82,3 +82,26 @@ def test_join_depth_orders_deferred_writes():
|
|
|
82
82
|
a, b, c = ("x:A", ()), ("x:B", JOIN), ("x:C", JOIN)
|
|
83
83
|
assert join_depth([a]) == -1 and join_depth([a, b]) == 1 and join_depth([b, a, c]) == 2
|
|
84
84
|
assert LOOKUP_TRANSFORMS == {"binding", "link"}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@pytest.mark.parametrize("iri", ["https://wwwn.cdc.gov/Nchs/Nhanes/2017-2018/DEMO_J.htm#SEQN",
|
|
88
|
+
"http://www.w3.org/ns/prov#Entity", "http://www.w3.org/2000/01/rdf-schema#label"])
|
|
89
|
+
def test_a_term_or_a_page_anchor_is_no_concept_code(iri, tmp_path):
|
|
90
|
+
"""4.3.1: a `#fragment` in a concept link is a vocabulary term or an anchor on a page, not a code."""
|
|
91
|
+
assert code_of(iri, code_lists=False) is None
|
|
92
|
+
rs = resolved()
|
|
93
|
+
v = _value_with(rs, links={"http://www.w3.org/2004/02/skos/core#exactMatch": [iri, "https://loinc.org/8480-6/"]})
|
|
94
|
+
rs.values[v.position] = v
|
|
95
|
+
assert model_codes(v) == {"8480-6"}, "the link to LOINC is a code; the fragment is not"
|
|
96
|
+
p = next(p for p in place(rs, mapping(tmp_path, [{"component": v.ct_id, "to": "/x:Code", "transform": "link"}]))[0]
|
|
97
|
+
if p.value.position == v.position)
|
|
98
|
+
assert p.text == "8480-6"
|
|
99
|
+
only = _value_with(rs, links={"http://www.w3.org/2004/02/skos/core#exactMatch": [iri]})
|
|
100
|
+
rs.values[only.position] = only
|
|
101
|
+
with pytest.raises(MappingError, match="links to no code"):
|
|
102
|
+
place(rs, mapping(tmp_path, [{"component": only.ct_id, "to": "/x:Code", "transform": "link"}]))
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def test_a_code_list_entry_still_binds_an_enumerated_value():
|
|
106
|
+
assert code_of(f"{UBL_LIST}#2") == CodeRef(UBL_LIST, "2")
|
|
107
|
+
assert code_of(f"{UBL_LIST}#2", code_lists=False) is None
|
|
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
|