This repository was archived by the owner on May 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFHIRConceptMapFactory.py
More file actions
68 lines (50 loc) · 1.86 KB
/
FHIRConceptMapFactory.py
File metadata and controls
68 lines (50 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import OCLAPI
from fhir.resources.conceptmap import ConceptMap
from fhir.resources.conceptmap import ConceptMapGroup
from fhir.resources.conceptmap import ConceptMapGroupElement
from fhir.resources.conceptmap import ConceptMapGroupElementTarget
from fhir.resources.conceptmap import fhirdate
def build_from_dictionary(ocl_conceptmap):
source_system_url = ocl_conceptmap['extras']['source_code_system']
target_system_url = ocl_conceptmap['extras']['target_code_system']
mappings_url = ocl_conceptmap['mappings_url']
cm = ConceptMap()
date = fhirdate.FHIRDate(ocl_conceptmap['updated_on'])
cm.date = date
cm.description = ocl_conceptmap['description']
cm.experimental = False
cm.id = ocl_conceptmap['id']
cm.name = ocl_conceptmap['name']
cm.publisher = ocl_conceptmap['owner']
cm.status = 'active'
cm.title = ocl_conceptmap['full_name']
cm.sourceUri = source_system_url
cm.targetUri = target_system_url
mappings = OCLAPI.get(mappings_url)
group = ConceptMapGroup()
group.source = source_system_url
group.target = target_system_url
group_elements = []
for mapping in mappings:
e = ConceptMapGroupElement()
e.id = mapping['id']
e.code = mapping['from_concept_code']
e.display = mapping['from_concept_name']
t = ConceptMapGroupElementTarget()
t.code = mapping['to_concept_code']
t.display = mapping['to_concept_name']
t.equivalence = get_equivalence(mapping['map_type'])
e.target = [t]
group_elements.append(e)
group.element = group_elements
cm.group = [group]
return cm
def get_equivalence(map_type):
if (map_type == 'Same As'):
return 'equivalent'
#
# Put other value translations here
#
# default to 'relatedto'? Guess on my part - DT
else:
return 'relatedto'