forked from MitchVDB-2468140/synthea-AT-implementation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMappingFIle.yml
More file actions
222 lines (193 loc) · 8.66 KB
/
MappingFIle.yml
File metadata and controls
222 lines (193 loc) · 8.66 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
---
name: AT-coreprofile-mapping
applicability: true
actions:
- name: Apply to AT Core Profiles
profiles:
- profile: https://fhir.hl7.at/r5-core-main/StructureDefinition-at-core-patient.html
applicability: Patient
- name: KeepResources
keep_resources:
- Patient
- Encounter
- Condition
- Procedure
- Observation
- DiagnosticReport
- CarePlan
- MedicationRequest
- name: create AT-Patient
create_resource:
- resourceType: Patient
based_on:
resource: Patient
fields:
- location: Patient.id
value: $getField([Patient.id])
- location: Patient.meta
value: $getField([Patient.meta[0]])
- location: Patient.text
value: $getField([Patient.text])
- location: Patient.identifier
value: $getField([Patient.identifier])
- location: Patient.active
value: $getField([Patient.active])
- location: Patient.name.family
value: $getField([Patient.name.family])
- location: Patient.name.given
value: $getField([Patient.name.given])
- location: Patient.name.prefix
value: $getField([Patient.name.prefix])
- location: Patient.telecom
value: $getField([Patient.telecom])
- location: Patient.gender
value: $getField([Patient.gender])
- location: Patient.birthDate
value: $getField([Patient.birthDate])
- location: Patient.address.use
value: "home"
- location: Patient.address.line
value: $getField([Patient.address.line])
- location: Patient.address.city
value: $getField([Patient.address.city])
- location: Patient.address.state
value: $getField([Patient.address.state])
- location: Patient.address.postalCode
value: $getField([Patient.address.postalCode])
- location: Patient.address.country
value: $getField([Patient.address.country])
- location: Patient.maritalStatus
value: $getField([Patient.maritalStatus])
- location: Patient.multipleBirth[x]
value: $getField([Patient.multipleBirth[x]])
- location: Patient.photo
value:
contentType: "image/jpeg"
url: "https://thispersondoesnotexist.tools/"
- location: Patient.contact
value: $getField([Patient.contact])
- location: Patient.communication.language.coding
value:
system: "urn:ietf:bcp:47"
code: "de"
- location: Patient.communication.preferred
value: "true"
- name: applyBoolean
execute_script:
- apply_to: bundle
function_name: applyBoolean
function: |
function applyBoolean(bundle) {
bundle.entry.forEach(entry => {
if (entry.resource.resourceType === "Patient") {
if (entry.resource.multipleBirthBoolean != "undefined") {
bundle.entry.filter(e => e.resource.resourceType === "Patient")
.forEach(patientEntry => {
patientEntry.resource.multipleBirthBoolean = entry.resource.multipleBirthBoolean;
if (entry.resource.multipleBirthBoolean){
patientEntry.resource.multipleBirthInteger = entry.resource.multipleBirthInteger;
}
});
}
if (entry.resource.deceasedBoolean != "undefined") {
bundle.entry.filter(e => e.resource.resourceType === "Patient")
.forEach(patientEntry => {
patientEntry.resource.deceased = entry.resource.deceased;
if (entry.resource.deceasedBoolean){
patientEntry.resource.deceasedDateTime = entry.resource.deceasedDateTime;
}
});
}
}
});
return bundle;
}
- name: applyIdentifier
execute_script:
- apply_to: resource
function_name: applyIdentifier
function: |
function applyIdentifier(resource, bundle) {
if (resource.resourceType === "Patient") {
const BufferedReader = Java.type("java.io.BufferedReader");
const FileReader = Java.type("java.io.FileReader");
const Math = Java.type("java.lang.Math");
// Read the JSON file content
const reader = new BufferedReader(new FileReader("src/main/resources/templates/mappings/AT-identifier.json"));
const jsonContent = reader.lines().toArray().join("");
reader.close();
const jsonObject = JSON.parse(jsonContent);
const getRandomNumber = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
const SocialSecurityNumber = { ...jsonObject[0], value: getRandomNumber(1e9, 1e10 - 1).toString() };
const PatientInternalIdentifier = { ...jsonObject[2], value: getRandomNumber(Math.pow(4, 3), Math.pow(4, 4) - 1).toString() };
resource.identifier = [SocialSecurityNumber, jsonObject[1], PatientInternalIdentifier];
return resource;
}
}
- name: applyExtensions
execute_script:
- apply_to: resource
function_name: applyExtensions
function: |
function applyExtensions(resource, bundle) {
const BufferedReader = Java.type("java.io.BufferedReader");
const FileReader = Java.type("java.io.FileReader");
const ArrayList = Java.type("java.util.ArrayList");
const Math = Java.type("java.lang.Math");
if (resource.resourceType === "Patient") {
const data = new ArrayList();
// Read JSON content from the extensions file
const readJsonFile = (filePath) => {
const reader = new BufferedReader(new FileReader(filePath));
const content = reader.lines().toArray().join("");
reader.close();
return JSON.parse(content);
};
const jsonObject = readJsonFile("src/main/resources/templates/mappings/AT-extensions.json");
const [PatientReligion, citizenship] = jsonObject;
// Read CSV content and populate data
const readCsvFile = (filePath) => {
const reader = new BufferedReader(new FileReader(filePath));
const lines = reader.lines().toArray();
reader.close();
return lines.map(line => line.split(","));
};
const religionData = readCsvFile("src/main/resources/AT-religion.csv");
// Select religion based on random number
const randomNumber = Math.random() * 100;
let chosenReligion = "Römisch-Katholisch";
let chosenReligionCode = 101;
let cumulativePercentage = 0;
for (const [code, name, percentage] of religionData) {
cumulativePercentage += parseFloat(percentage);
if (randomNumber <= cumulativePercentage) {
chosenReligionCode = code;
chosenReligion = name;
break;
}
}
PatientReligion.extension[0].valueCodeableConcept.coding[0].code = chosenReligionCode;
PatientReligion.extension[0].valueCodeableConcept.coding[0].display = chosenReligion;
resource.extension = [PatientReligion, citizenship];
}
return resource;
}
- name: replaceUSCorePatient
execute_script:
- apply_to: bundle
function_name: replaceUSCorePatient
function: |
function replaceUSCorePatient(bundle) {
const patientEntries = bundle.entry.filter(entry => entry.resource.resourceType === "Patient");
bundle.entry.forEach((entry, index) => {
if (entry.resource.resourceType === "Patient") {
const nextPatientIndex = patientEntries.indexOf(entry) + 1;
if (nextPatientIndex < patientEntries.length) {
entry.resource = patientEntries[nextPatientIndex].resource;
} else {
bundle.entry.splice(index, 1);
}
}
});
return bundle;
}