generated from OpenFn/project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
openfn-d52bd48e-451b-4a92-9aad-e7c62a7f0923-state.json
261 lines (261 loc) · 15 KB
/
openfn-d52bd48e-451b-4a92-9aad-e7c62a7f0923-state.json
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
{
"id": "d52bd48e-451b-4a92-9aad-e7c62a7f0923",
"name": "jembi-demo",
"description": null,
"inserted_at": "2024-06-11T20:09:59",
"updated_at": "2024-06-13T13:03:30",
"scheduled_deletion": null,
"dataclip_retention_period": null,
"history_retention_period": null,
"requires_mfa": false,
"retention_policy": "retain_all",
"workflows": {
"archive-cdr-to-ndr": {
"id": "51609280-6784-4d7f-abe1-bad0af87964f",
"name": "archive-cdr-to-ndr",
"inserted_at": "2024-06-12T10:36:15Z",
"updated_at": "2024-06-13T13:55:14Z",
"project_id": "d52bd48e-451b-4a92-9aad-e7c62a7f0923",
"deleted_at": null,
"lock_version": 104,
"triggers": {
"webhook": {
"enabled": true,
"id": "59ca9fad-78ca-46cb-84ae-8feb67214d65",
"type": "webhook"
}
},
"jobs": {
"Map-and-process-data": {
"id": "155ed6d7-1e29-412a-a011-07422459c1e5",
"name": "Map and process data",
"body": "fn(state => {\n // do some things to state\n return state;\n});",
"adaptor": "@openfn/language-common@latest"
},
"Validate-with-NDR-HAPI-FHIR": {
"id": "ac44aea9-d9cc-4588-9072-964db312916a",
"name": "Validate with NDR HAPI FHIR",
"body": "post('/Patient/$validate', {\n body: state.data,\n headers: {'content-type': 'application/json'},\n }); \n\n// create('/Patient/$validate', {\n// body: state.data,\n// headers: {'content-type': 'application/json'},\n// }); \n\n",
"adaptor": "@openfn/language-http@latest"
},
"Post-to-HAPI-FHIR": {
"id": "ba9a0e7d-81a2-4fb5-b376-a233b3738471",
"name": "Post to HAPI FHIR",
"body": "post(\"Patient\", {body: state.data, \n headers: {'content-type': 'application/json'}, \n errors: { 400: false }, \t\n parseAs: 'json',\n }, state => {\n //console.log('response ::', JSON.stringify(state.response, null,2));\n state.data.response = state.response; \n return state; \n }\n)\n\n// create(\"Patient\", {body: state.data, \n// headers: {'content-type': 'application/json'}},\n// )a\n\n// request(\"POST\",\"Patient\", {body: state.data, \n// headers: {'content-type': 'application/json'}});",
"adaptor": "@openfn/language-http@latest"
},
"Report-Error": {
"id": "41771ce6-2772-4750-b929-7adf87748cd4",
"name": "Report Error",
"body": "fn(state => {\n state.errorLog = {\n resource_id: state.data.id,\n failure_type: 'validation error',\n //data: state.references[0], //data we tried to create\n resource_type: state.references[0].resourceType,\n issue_code: state.data.issue[0].code,\n issue_detail: state.data.issue[0].details.text,\n issue_diagnostics: state.data.issue[0].diagnostics,\n issue_location: state.data.issue[0].location,\n last_updated: state.data.meta.lastUpdated,\n statusCode: state.data.response.statusCode,\n statusMessage: state.data.response.statusMessage\n }\n console.log('Error to log:: ', JSON.stringify(state.errorLog,null,2)); \n return state; \n});\n\n// insert('fhir_errors', \n// state => state.errorLog, \n// { logValues: true }\n// );\n\n//kafka mappings - don't think we need these\n// ts: state.request.ts,\n// topic: state.request.topic,\n// offset: state.request.offset,\n// partition: state.request.partition,\n// key: state.request.key,",
"adaptor": "@openfn/language-postgresql@latest"
}
},
"edges": {
"webhook->Map-and-process-data": {
"enabled": true,
"id": "232a2bb6-ed83-489a-8c54-8760f061682d",
"source_trigger_id": "59ca9fad-78ca-46cb-84ae-8feb67214d65",
"condition_type": "always",
"target_job_id": "155ed6d7-1e29-412a-a011-07422459c1e5"
},
"Map-and-process-data->Validate-with-NDR-HAPI-FHIR": {
"enabled": false,
"id": "85d72816-63ef-4a7e-90f5-ffd63bbc033d",
"source_job_id": "155ed6d7-1e29-412a-a011-07422459c1e5",
"condition_type": "on_job_success",
"target_job_id": "ac44aea9-d9cc-4588-9072-964db312916a"
},
"Post-to-HAPI-FHIR->Report-Error": {
"enabled": true,
"id": "f5dc9d61-497b-4a4f-ae76-2972c4efa574",
"source_job_id": "ba9a0e7d-81a2-4fb5-b376-a233b3738471",
"condition_type": "js_expression",
"condition_expression": "state.data.response.statusCode==400",
"condition_label": "failed?",
"target_job_id": "41771ce6-2772-4750-b929-7adf87748cd4"
},
"Map-and-process-data->Post-to-HAPI-FHIR": {
"enabled": true,
"id": "3f99f218-b538-4a95-98f1-9341f52f198a",
"source_job_id": "155ed6d7-1e29-412a-a011-07422459c1e5",
"condition_type": "on_job_success",
"target_job_id": "ba9a0e7d-81a2-4fb5-b376-a233b3738471"
}
}
},
"cdr-to-ndr": {
"id": "ad8f643a-6bda-453e-af48-aeb213069538",
"name": "cdr-to-ndr",
"inserted_at": "2024-06-13T08:12:03Z",
"updated_at": "2024-06-13T14:06:15Z",
"project_id": "d52bd48e-451b-4a92-9aad-e7c62a7f0923",
"deleted_at": null,
"lock_version": 48,
"triggers": {
"webhook": {
"enabled": true,
"id": "9308f827-2912-4368-8892-9a9d5ed53301",
"type": "webhook"
}
},
"jobs": {
"Analyze-Data": {
"id": "205bd35c-32e0-4cd0-964f-98d4c6729a8b",
"name": "Analyze Data",
"body": "fn(state => {\n const parsedData = JSON.parse(state.data.body); \n console.log(parsedData); \n state.resource = parsedData.entry[0].resource; \n console.log('show only the resource:: ', state.resource);\n return state; \n})",
"adaptor": "@openfn/language-common@latest"
},
"Create-Organization": {
"id": "52a8787c-fefe-42ce-96cb-84270d9d9da2",
"name": "Create Organization",
"body": "// Use pure JavaScript to add operations to your\n// step. Click Docs to see list of operations or visit\n// https://bit.ly/OFNJWG for our job writing guide\n// and example job codes.\ncreate(\"Organization\", $.organization)",
"adaptor": "@openfn/language-fhir@latest"
},
"Create-FHIR-Resource": {
"id": "75e04925-019d-4787-853a-54275fedd86f",
"name": "Create FHIR Resource",
"body": "post($.resource.resourceType, \n {\n body: $.mapped_resource, \n errors: { 400: false }, \t\n headers: {'content-type': 'application/json'},\n parseAs: 'json'\n },\n state => {\n state.data.response = state.response; \n return state; \n})",
"adaptor": "@openfn/language-http@latest"
},
"Create-Encounter": {
"id": "ac088906-4413-4222-8d94-eca91fdeb73a",
"name": "Create Encounter",
"body": "// Use pure JavaScript to add operations to your\n// step. Click Docs to see list of operations or visit\n// https://bit.ly/OFNJWG for our job writing guide\n// and example job codes.\n",
"adaptor": "@openfn/language-fhir@latest"
},
"Create-Condition": {
"id": "5f3abe70-39fe-466a-954f-6826b2469def",
"name": "Create Condition",
"body": "// Use pure JavaScript to add operations to your\n// step. Click Docs to see list of operations or visit\n// https://bit.ly/OFNJWG for our job writing guide\n// and example job codes.\n",
"adaptor": "@openfn/language-fhir@latest"
},
"Log-error": {
"id": "34a72fe3-d1e8-4a67-b06f-749d157ba61c",
"name": "Log error",
"body": "fn(state => {\n state.errorLog = {\n resource_id: state.data.id,\n failure_type: 'validation error',\n //data: state.references[0], //data we tried to create\n resource_type: state.references[0].resourceType,\n issue_code: state.data.issue[0].code,\n issue_detail: state.data.issue[0].details.text,\n issue_diagnostics: state.data.issue[0].diagnostics,\n issue_location: state.data.issue[0].location,\n last_updated: state.data.meta.lastUpdated,\n statusCode: state.data.response.statusCode,\n statusMessage: state.data.response.statusMessage\n }\n console.log('Error to log:: ', JSON.stringify(state.errorLog,null,2)); \n return state; \n});\n\n// insert('fhir_errors', \n// state => state.errorLog, \n// { logValues: true }\n// );\n\n//kafka mappings - don't think we need these\n// ts: state.request.ts,\n// topic: state.request.topic,\n// offset: state.request.offset,\n// partition: state.request.partition,\n// key: state.request.key,",
"adaptor": "@openfn/language-postgresql@latest"
},
"Map-Data": {
"id": "e4bad1bf-a006-405f-ae2e-681968c9ebf6",
"name": "Map Data",
"body": "fn(state=> {\n //Map CDR data to NDR FHIR IG\n const cdrData = state.resource;\n const mapped_resource = {\n resourceType: cdrData.resourceType,\n id: cdrData.id,\n identifier: cdrData.identifier?.map(id => ({\n type: id.system == \"http://cdr.aacahb.gov.et/MRN\"? {\n \"coding\": [\n {\n \"code\": \"MR\",\n \"display\": \"Medical record number\",\n \"system\": \"http://terminology.hl7.org/CodeSystem/v2-0203\"\n }\n ],\n \"text\": \"Medical record number\"\n } : undefined,\n system: id.system,\n value: id.value,\n })),\n active: cdrData.active,\n gender: cdrData.gender,\n birthDate: cdrData.birthDate,\n address: cdrData.address,\n managingOrganization: cdrData.managingOrganization,\n deceasedBoolean: cdrData.deceasedBoolean,\n text: cdrData.text\n };\n// returned the mapped fhir resource\n return {...state, mapped_resource}\n})",
"adaptor": "@openfn/language-common@latest"
},
"Remove-PIIs": {
"id": "a190cc21-e997-439d-a5ea-64895921eadb",
"name": "Remove PIIs",
"body": "fn(state=> {\n //Removig PII here before sending it to NDR\n delete state.resource.name;\n delete state.resource.telecom;\n delete state.resource.contact;\n delete state.resource.extension; //contains religion, occupation, education level, target pop group\n delete state.resource.maritalStatus; \n\n //only keeping birthdate and gender\n\n return state;\n})",
"adaptor": "@openfn/language-common@latest"
}
},
"edges": {
"webhook->Analyze-Data": {
"enabled": true,
"id": "0bf806f1-3c51-4a8b-be6e-66ba9075c0f6",
"source_trigger_id": "9308f827-2912-4368-8892-9a9d5ed53301",
"condition_type": "always",
"target_job_id": "205bd35c-32e0-4cd0-964f-98d4c6729a8b"
},
"Create-FHIR-Resource->Log-error": {
"enabled": true,
"id": "7b0d3bb6-1d12-4f74-8acb-3664797f3c49",
"source_job_id": "75e04925-019d-4787-853a-54275fedd86f",
"condition_type": "js_expression",
"condition_expression": "state.data.response.statusCode==400",
"condition_label": "failed?",
"target_job_id": "34a72fe3-d1e8-4a67-b06f-749d157ba61c"
},
"Map-Data->Create-FHIR-Resource": {
"enabled": true,
"id": "98f49aad-8f62-4bee-992f-ffa33bbf6ec9",
"source_job_id": "e4bad1bf-a006-405f-ae2e-681968c9ebf6",
"condition_type": "on_job_success",
"condition_expression": "!state.errors && state.data.resourceType == 'Patient'",
"condition_label": "is Patient?",
"target_job_id": "75e04925-019d-4787-853a-54275fedd86f"
},
"Analyze-Data->Remove-PIIs": {
"enabled": true,
"id": "de8295a8-a953-452a-a7d9-c9e4927eadcb",
"source_job_id": "205bd35c-32e0-4cd0-964f-98d4c6729a8b",
"condition_type": "on_job_success",
"target_job_id": "a190cc21-e997-439d-a5ea-64895921eadb"
},
"Remove-PIIs->Map-Data": {
"enabled": true,
"id": "fb0f5811-377e-42c7-b2fa-a12553fb34ab",
"source_job_id": "a190cc21-e997-439d-a5ea-64895921eadb",
"condition_type": "on_job_success",
"target_job_id": "e4bad1bf-a006-405f-ae2e-681968c9ebf6"
}
}
},
"test-patient-http": {
"id": "79930c19-1ce1-4144-82ab-e10d7652e2b5",
"name": "test-patient-http",
"inserted_at": "2024-06-13T11:39:36Z",
"updated_at": "2024-06-13T13:13:14Z",
"project_id": "d52bd48e-451b-4a92-9aad-e7c62a7f0923",
"deleted_at": null,
"lock_version": 8,
"triggers": {
"webhook": {
"enabled": true,
"id": "b8aaf960-b742-4e20-b474-45eb60583e92",
"type": "webhook"
}
},
"jobs": {
"Post-Patient": {
"id": "a3b64302-94f1-4cb5-9490-ba87eb6dd6c6",
"name": "Post Patient",
"body": "post(\"Patient\", {body: state.data, \n headers: {'content-type': 'application/json'}, \n parseAs: 'json',\n //errors: { 400: false }, \n })",
"adaptor": "@openfn/language-http@latest"
}
},
"edges": {
"webhook->Post-Patient": {
"enabled": true,
"id": "027a6d08-a98d-4f40-a803-5a1be5aee620",
"source_trigger_id": "b8aaf960-b742-4e20-b474-45eb60583e92",
"condition_type": "always",
"target_job_id": "a3b64302-94f1-4cb5-9490-ba87eb6dd6c6"
}
}
},
"test-patient-fhir": {
"id": "3a6803de-2cca-4a83-a93d-8f52e796dedf",
"name": "test-patient-fhir",
"inserted_at": "2024-06-13T13:13:36Z",
"updated_at": "2024-06-13T13:48:00Z",
"project_id": "d52bd48e-451b-4a92-9aad-e7c62a7f0923",
"deleted_at": null,
"lock_version": 20,
"triggers": {
"webhook": {
"enabled": true,
"id": "475edbcc-8730-4626-906b-4f2eb508502b",
"type": "webhook"
}
},
"jobs": {
"parse-json": {
"id": "c7b04b67-6c06-4281-a209-7bfa8fad44b4",
"name": "parse json",
"body": "fn(state => {\n const parsedData = JSON.parse(state.data.body); \n console.log(parsedData); \n state.resource = parsedData.entry[0].resource; \n console.log('show only the resource:: ', state.resource);\n return state; \n})\n\n\n//testing using create instead of post\n//create(\"Patient\", state => state.data)\n //headers: {'content-type': 'application/json'}, \n //errors: { 400: false }, \t\n //parseAs: 'json',\n// , state => {\n// //console.log('response ::', JSON.stringify(state.response, null,2));\n// state.data.response = state.response; \n// return state; \n// }",
"adaptor": "@openfn/language-common@latest"
}
},
"edges": {
"webhook->parse-json": {
"enabled": true,
"id": "d9197ef6-a544-4b15-9c88-559a1888ec93",
"source_trigger_id": "475edbcc-8730-4626-906b-4f2eb508502b",
"condition_type": "always",
"target_job_id": "c7b04b67-6c06-4281-a209-7bfa8fad44b4"
}
}
}
}
}