forked from SvenSommer/structure_comparer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mapper.py
59 lines (51 loc) · 2.21 KB
/
mapper.py
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
import json
def load_json_file(file_path):
"""
Lädt JSON-Daten aus einer Datei.
"""
with open(file_path, 'r') as file:
return json.load(file)
def map_medication_code_coding(kbv_medication, epa_medication):
"""
Mappt das Medication.code.coding-Element von einem KBV-Profil zum ePA-Profil.
"""
if 'code' in kbv_medication and 'coding' in kbv_medication['code']:
epa_medication['code'] = {'coding': []}
for coding in kbv_medication['code']['coding']:
epa_medication['code']['coding'].append({
'system': coding.get('system', ''),
'code': coding.get('code', ''),
'display': coding.get('display', '')
})
def map_medication_amount(kbv_medication, epa_medication):
"""
Mappt das Medication.amount-Element von einem KBV-Profil zum ePA-Profil.
"""
if 'amount' in kbv_medication:
epa_medication['amount'] = {
'numerator': {
'value': kbv_medication['amount'].get('numerator', {}).get('value', ''),
'unit': kbv_medication['amount'].get('numerator', {}).get('unit', ''),
'system': 'http://unitsofmeasure.org',
'code': kbv_medication['amount'].get('numerator', {}).get('code', '')
},
'denominator': {
'value': kbv_medication['amount'].get('denominator', {}).get('value', ''),
'unit': kbv_medication['amount'].get('denominator', {}).get('unit', ''),
'system': 'http://unitsofmeasure.org',
'code': kbv_medication['amount'].get('denominator', {}).get('code', '')
}
}
def main():
kbv_file_path = 'data/Instances/KBV_PR_ERP_Medication.json'
epa_file_path = 'data/Instances/example-epa-medication-2.json'
# Lade KBV- und ePA-Medikationsdaten
kbv_medication = load_json_file(kbv_file_path)
epa_medication = load_json_file(epa_file_path)
# Mapping durchführen
map_medication_code_coding(kbv_medication, epa_medication)
map_medication_amount(kbv_medication, epa_medication)
# Ergebnis ausgeben
print("Mapped ePA Medication:", json.dumps(epa_medication, indent=4))
if __name__ == "__main__":
main()