@openfn/language-dhis2 2.0.8 → 3.0.0-0

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.
Files changed (44) hide show
  1. package/README.md +39 -4
  2. package/ast.json +295 -2430
  3. package/lib/Adaptor.js +475 -1519
  4. package/lib/Client.js +32 -0
  5. package/lib/Utils.js +124 -175
  6. package/lib/index.js +4 -6
  7. package/node_modules/@openfn/language-common/node_modules/axios/package.json +20 -0
  8. package/node_modules/@openfn/language-common/node_modules/follow-redirects/package.json +20 -0
  9. package/node_modules/@openfn/language-common/node_modules/jsonpath-plus/package.json +20 -0
  10. package/node_modules/@openfn/language-common/node_modules/lodash/package.json +20 -0
  11. package/node_modules/@openfn/language-common/package.json +8 -4
  12. package/node_modules/axios/CHANGELOG.md +159 -8
  13. package/node_modules/axios/README.md +98 -6
  14. package/node_modules/axios/SECURITY.md +5 -0
  15. package/node_modules/axios/dist/axios.js +2101 -1582
  16. package/node_modules/axios/dist/axios.map +1 -1
  17. package/node_modules/axios/dist/axios.min.js +1 -2
  18. package/node_modules/axios/dist/axios.min.map +1 -1
  19. package/node_modules/axios/index.d.ts +76 -31
  20. package/node_modules/axios/lib/adapters/http.js +74 -14
  21. package/node_modules/axios/lib/adapters/xhr.js +66 -33
  22. package/node_modules/axios/lib/axios.js +6 -5
  23. package/node_modules/axios/lib/cancel/CancelToken.js +62 -0
  24. package/node_modules/axios/lib/core/Axios.js +60 -7
  25. package/node_modules/axios/lib/core/InterceptorManager.js +4 -2
  26. package/node_modules/axios/lib/core/README.md +1 -0
  27. package/node_modules/axios/lib/core/dispatchRequest.js +11 -3
  28. package/node_modules/axios/lib/core/enhanceError.js +2 -1
  29. package/node_modules/axios/lib/core/mergeConfig.js +50 -38
  30. package/node_modules/axios/lib/core/transformData.js +3 -1
  31. package/node_modules/axios/lib/defaults.js +48 -12
  32. package/node_modules/axios/lib/env/README.md +3 -0
  33. package/node_modules/axios/lib/env/data.js +3 -0
  34. package/node_modules/axios/lib/helpers/validator.js +82 -0
  35. package/node_modules/axios/lib/utils.js +1 -3
  36. package/node_modules/axios/package.json +37 -40
  37. package/node_modules/axios/tsconfig.json +14 -0
  38. package/node_modules/axios/tslint.json +6 -0
  39. package/node_modules/follow-redirects/README.md +1 -1
  40. package/node_modules/follow-redirects/debug.js +14 -8
  41. package/node_modules/follow-redirects/index.js +106 -41
  42. package/node_modules/follow-redirects/package.json +14 -17
  43. package/node_modules/lodash/package.json +2 -2
  44. package/package.json +5 -4
package/ast.json CHANGED
@@ -1,2117 +1,15 @@
1
1
  {
2
2
  "operations": [
3
3
  {
4
- "name": "getTEIs",
5
- "params": [
6
- "params",
7
- "options",
8
- "callback"
9
- ],
10
- "docs": {
11
- "description": "Get Tracked Entity Instance(s).",
12
- "tags": [
13
- {
14
- "title": "public",
15
- "description": null,
16
- "type": null
17
- },
18
- {
19
- "title": "function",
20
- "description": null,
21
- "name": null
22
- },
23
- {
24
- "title": "param",
25
- "description": "Optional `query parameters` e.g. `{ou: 'DiszpKrYNg8', filters: ['lZGmxYbs97q':GT:5']}`. Run `discover` or see {@link https://docs.dhis2.org/2.34/en/dhis2_developer_manual/web-api.html DHIS2 docs} for more details on which params to use when querying tracked entities instances.",
26
- "type": {
27
- "type": "OptionalType",
28
- "expression": {
29
- "type": "NameExpression",
30
- "name": "Object"
31
- }
32
- },
33
- "name": "params"
34
- },
35
- {
36
- "title": "param",
37
- "description": "`Optional` options for `getTEIs` operation. Defaults to `{apiVersion: state.configuration.apiVersion, responseType: 'json'}`.",
38
- "type": {
39
- "type": "OptionalType",
40
- "expression": {
41
- "type": "RecordType",
42
- "fields": [
43
- {
44
- "type": "FieldType",
45
- "key": "apiVersion",
46
- "value": {
47
- "type": "NameExpression",
48
- "name": "number"
49
- }
50
- },
51
- {
52
- "type": "FieldType",
53
- "key": "responseType",
54
- "value": {
55
- "type": "NameExpression",
56
- "name": "string"
57
- }
58
- }
59
- ]
60
- }
61
- },
62
- "name": "options"
63
- },
64
- {
65
- "title": "param",
66
- "description": "Optional callback to handle the response.",
67
- "type": {
68
- "type": "OptionalType",
69
- "expression": {
70
- "type": "NameExpression",
71
- "name": "function"
72
- }
73
- },
74
- "name": "callback"
75
- },
76
- {
77
- "title": "returns",
78
- "description": null,
79
- "type": {
80
- "type": "NameExpression",
81
- "name": "Operation"
82
- }
83
- },
84
- {
85
- "title": "example",
86
- "description": "getTEIs({\n fields: '*',\n ou: 'CMqUILyVnBL',\n trackedEntityInstance: 'HNTA9qD6EEG',\n skipPaging: true,\n});",
87
- "caption": "- Example `getTEIs` `expression.js` for fetching a `single` `Tracked Entity Instance` with all the fields included."
88
- }
89
- ]
90
- },
91
- "valid": true
92
- },
93
- {
94
- "name": "upsertTEI",
95
- "params": [
96
- "uniqueAttributeId",
97
- "data",
98
- "options",
99
- "callback"
100
- ],
101
- "docs": {
102
- "description": "Update TEI if exists otherwise create.\n- Update if the record exists otherwise insert a new record.\n- This is useful for idempotency and duplicate record management.",
103
- "tags": [
104
- {
105
- "title": "public",
106
- "description": null,
107
- "type": null
108
- },
109
- {
110
- "title": "function",
111
- "description": null,
112
- "name": null
113
- },
114
- {
115
- "title": "param",
116
- "description": "Tracked Entity Instance unique identifier attribute used during matching.",
117
- "type": {
118
- "type": "NameExpression",
119
- "name": "string"
120
- },
121
- "name": "uniqueAttributeId"
122
- },
123
- {
124
- "title": "param",
125
- "description": "Payload data for new tracked entity instance or updated data for an existing tracked entity instance.",
126
- "type": {
127
- "type": "NameExpression",
128
- "name": "Object"
129
- },
130
- "name": "data"
131
- },
132
- {
133
- "title": "param",
134
- "description": "`Optional` options for `upsertTEI` operation. Defaults to `{apiVersion: state.configuration.apiVersion,strict: true,responseType: 'json'}`.",
135
- "type": {
136
- "type": "OptionalType",
137
- "expression": {
138
- "type": "RecordType",
139
- "fields": [
140
- {
141
- "type": "FieldType",
142
- "key": "apiVersion",
143
- "value": {
144
- "type": "NameExpression",
145
- "name": "number"
146
- }
147
- },
148
- {
149
- "type": "FieldType",
150
- "key": "strict",
151
- "value": {
152
- "type": "NameExpression",
153
- "name": "boolean"
154
- }
155
- },
156
- {
157
- "type": "FieldType",
158
- "key": "responseType",
159
- "value": {
160
- "type": "NameExpression",
161
- "name": "string"
162
- }
163
- }
164
- ]
165
- }
166
- },
167
- "name": "options"
168
- },
169
- {
170
- "title": "param",
171
- "description": "Optional `callback` to handle the response.",
172
- "type": {
173
- "type": "OptionalType",
174
- "expression": {
175
- "type": "NameExpression",
176
- "name": "function"
177
- }
178
- },
179
- "name": "callback"
180
- },
181
- {
182
- "title": "throws",
183
- "description": "Throws `RangeError` when `uniqueAttributeId` is `invalid` or `not unique`.",
184
- "type": {
185
- "type": "NameExpression",
186
- "name": "RangeError"
187
- }
188
- },
189
- {
190
- "title": "returns",
191
- "description": null,
192
- "type": {
193
- "type": "NameExpression",
194
- "name": "Operation"
195
- }
196
- },
197
- {
198
- "title": "example",
199
- "description": "upsertTEI('lZGmxYbs97q', {\n orgUnit: 'TSyzvBiovKh',\n trackedEntityType: 'nEenWmSyUEp',\n attributes: [\n {\n attribute: 'lZGmxYbs97q',\n value: '77790012',\n },\n {\n attribute: 'w75KJ2mc4zz',\n value: 'Gigiwe',\n },\n {\n attribute: 'zDhUuAYrxNC',\n value: 'Mwanza',\n },\n ],\n});",
200
- "caption": "- Example `expression.js` for upserting a tracked entity instance on attribute with Id `lZGmxYbs97q`."
201
- }
202
- ]
203
- },
204
- "valid": true
205
- },
206
- {
207
- "name": "createTEI",
208
- "params": [
209
- "data",
210
- "params",
211
- "options",
212
- "callback"
213
- ],
214
- "docs": {
215
- "description": "Create Tracked Entity Instance.",
216
- "tags": [
217
- {
218
- "title": "public",
219
- "description": null,
220
- "type": null
221
- },
222
- {
223
- "title": "function",
224
- "description": null,
225
- "name": null
226
- },
227
- {
228
- "title": "param",
229
- "description": "The update data containing new values.",
230
- "type": {
231
- "type": "NameExpression",
232
- "name": "Object"
233
- },
234
- "name": "data"
235
- },
236
- {
237
- "title": "param",
238
- "description": "Optional `import parameters` for a given a resource. E.g. `{dryRun: true, importStrategy: CREATE}` See {@link https://docs.dhis2.org/2.34/en/dhis2_developer_manual/web-api.html#import-parameters_1 DHIS2 Import parameters documentation} or run `discover`. Defauls to `DHIS2 default import parameters`.",
239
- "type": {
240
- "type": "OptionalType",
241
- "expression": {
242
- "type": "NameExpression",
243
- "name": "Object"
244
- }
245
- },
246
- "name": "params"
247
- },
248
- {
249
- "title": "param",
250
- "description": "`Optional` options for `createTEI` operation. Defaults to `{apiVersion: state.configuration.apiVersion,responseType: 'json'}`.",
251
- "type": {
252
- "type": "OptionalType",
253
- "expression": {
254
- "type": "RecordType",
255
- "fields": [
256
- {
257
- "type": "FieldType",
258
- "key": "apiVersion",
259
- "value": {
260
- "type": "NameExpression",
261
- "name": "number"
262
- }
263
- },
264
- {
265
- "type": "FieldType",
266
- "key": "responseType",
267
- "value": {
268
- "type": "NameExpression",
269
- "name": "string"
270
- }
271
- }
272
- ]
273
- }
274
- },
275
- "name": "options"
276
- },
277
- {
278
- "title": "param",
279
- "description": "Optional callback to handle the response.",
280
- "type": {
281
- "type": "OptionalType",
282
- "expression": {
283
- "type": "NameExpression",
284
- "name": "function"
285
- }
286
- },
287
- "name": "callback"
288
- },
289
- {
290
- "title": "returns",
291
- "description": null,
292
- "type": {
293
- "type": "NameExpression",
294
- "name": "Operation"
295
- }
296
- },
297
- {
298
- "title": "example",
299
- "description": "createTEI({\n orgUnit: 'TSyzvBiovKh',\n trackedEntityType: 'nEenWmSyUEp',\n attributes: [\n {\n attribute: 'lZGmxYbs97q',\n value: valUpsertTEI,\n },\n {\n attribute: 'w75KJ2mc4zz',\n value: 'Gigiwe',\n },\n ],\n enrollments: [\n {\n orgUnit: 'TSyzvBiovKh',\n program: 'fDd25txQckK',\n programState: 'lST1OZ5BDJ2',\n enrollmentDate: '2021-01-04',\n incidentDate: '2021-01-04',\n },\n ],\n});",
300
- "caption": "- Example `expression.js` of `createTEI`."
301
- }
302
- ]
303
- },
304
- "valid": true
305
- },
306
- {
307
- "name": "updateTEI",
308
- "params": [
309
- "path",
310
- "data",
311
- "params",
312
- "options",
313
- "callback"
314
- ],
315
- "docs": {
316
- "description": "Update a Tracked Entity Instance.",
317
- "tags": [
318
- {
319
- "title": "public",
320
- "description": null,
321
- "type": null
322
- },
323
- {
324
- "title": "function",
325
- "description": null,
326
- "name": null
327
- },
328
- {
329
- "title": "param",
330
- "description": "Path to the object being updated. This can be an `id` or path to an `object` in a `nested collection` on the object(E.g. `/api/{collection-object}/{collection-object-id}/{collection-name}/{object-id}`).",
331
- "type": {
332
- "type": "NameExpression",
333
- "name": "string"
334
- },
335
- "name": "path"
336
- },
337
- {
338
- "title": "param",
339
- "description": "The update data containing new values.",
340
- "type": {
341
- "type": "NameExpression",
342
- "name": "Object"
343
- },
344
- "name": "data"
345
- },
346
- {
347
- "title": "param",
348
- "description": "Optional `import parameters` for a given a resource. E.g. `{dryRun: true, importStrategy: CREATE, filters:[]}` See {@link https://docs.dhis2.org/2.34/en/dhis2_developer_manual/web-api.html#import-parameters_1 DHIS2 Import parameters documentation} or run `discover`. Defauls to `DHIS2 default import parameters`.",
349
- "type": {
350
- "type": "OptionalType",
351
- "expression": {
352
- "type": "NameExpression",
353
- "name": "Object"
354
- }
355
- },
356
- "name": "params"
357
- },
358
- {
359
- "title": "param",
360
- "description": "`Optional` options for `updateTEI` operation. Defaults to `{apiVersion: state.configuration.apiVersion,responseType: 'json'}`.",
361
- "type": {
362
- "type": "OptionalType",
363
- "expression": {
364
- "type": "RecordType",
365
- "fields": [
366
- {
367
- "type": "FieldType",
368
- "key": "apiVersion",
369
- "value": {
370
- "type": "NameExpression",
371
- "name": "number"
372
- }
373
- },
374
- {
375
- "type": "FieldType",
376
- "key": "responseType",
377
- "value": {
378
- "type": "NameExpression",
379
- "name": "string"
380
- }
381
- }
382
- ]
383
- }
384
- },
385
- "name": "options"
386
- },
387
- {
388
- "title": "param",
389
- "description": "Optional callback to handle the response.",
390
- "type": {
391
- "type": "OptionalType",
392
- "expression": {
393
- "type": "NameExpression",
394
- "name": "function"
395
- }
396
- },
397
- "name": "callback"
398
- },
399
- {
400
- "title": "returns",
401
- "description": null,
402
- "type": {
403
- "type": "NameExpression",
404
- "name": "Operation"
405
- }
406
- },
407
- {
408
- "title": "example",
409
- "description": "updateTEI('PVqUD2hvU4E', {\n orgUnit: 'TSyzvBiovKh',\n trackedEntityType: 'nEenWmSyUEp',\n attributes: [\n {\n attribute: 'lZGmxYbs97q',\n value: valUpsertTEI,\n },\n {\n attribute: 'w75KJ2mc4zz',\n value: 'Gigiwe',\n },\n ],\n enrollments: [\n {\n orgUnit: 'TSyzvBiovKh',\n program: 'fDd25txQckK',\n programState: 'lST1OZ5BDJ2',\n enrollmentDate: '2021-01-04',\n incidentDate: '2021-01-04',\n },\n ],\n});",
410
- "caption": "- Example `expression.js` of `updateTEI`."
411
- }
412
- ]
413
- },
414
- "valid": true
415
- },
416
- {
417
- "name": "getEvents",
418
- "params": [
419
- "params",
420
- "options",
421
- "callback"
422
- ],
423
- "docs": {
424
- "description": "Get annonymous events or tracker events.",
425
- "tags": [
426
- {
427
- "title": "public",
428
- "description": null,
429
- "type": null
430
- },
431
- {
432
- "title": "function",
433
- "description": null,
434
- "name": null
435
- },
436
- {
437
- "title": "param",
438
- "description": "`import` parameters for `getEvents`. See examples here",
439
- "type": {
440
- "type": "NameExpression",
441
- "name": "Object"
442
- },
443
- "name": "params"
444
- },
445
- {
446
- "title": "param",
447
- "description": "`Optional` options for `getEvents` operation. Defaults to `{apiVersion: state.configuration.apiVersion,responseType: 'json'}`.",
448
- "type": {
449
- "type": "OptionalType",
450
- "expression": {
451
- "type": "RecordType",
452
- "fields": [
453
- {
454
- "type": "FieldType",
455
- "key": "apiVersion",
456
- "value": {
457
- "type": "NameExpression",
458
- "name": "number"
459
- }
460
- },
461
- {
462
- "type": "FieldType",
463
- "key": "responseType",
464
- "value": {
465
- "type": "NameExpression",
466
- "name": "string"
467
- }
468
- }
469
- ]
470
- }
471
- },
472
- "name": "options"
473
- },
474
- {
475
- "title": "param",
476
- "description": "Optional callback to handle the response.",
477
- "type": {
478
- "type": "OptionalType",
479
- "expression": {
480
- "type": "NameExpression",
481
- "name": "function"
482
- }
483
- },
484
- "name": "callback"
485
- },
486
- {
487
- "title": "returns",
488
- "description": null,
489
- "type": {
490
- "type": "NameExpression",
491
- "name": "Operation"
492
- }
493
- },
494
- {
495
- "title": "example",
496
- "description": "getEvents({ orgUnit: 'YuQRtpLP10I', ouMode: 'CHILDREN' });",
497
- "caption": "- Query for `all events` with `children` of a certain `organisation unit`"
498
- }
499
- ]
500
- },
501
- "valid": true
502
- },
503
- {
504
- "name": "createEvents",
505
- "params": [
506
- "data",
507
- "params",
508
- "options",
509
- "callback"
510
- ],
511
- "docs": {
512
- "description": "Create DHIS2 Events\n- You will need a `program` which can be looked up using the `getPrograms` operation, an `orgUnit` which can be looked up using the `getMetadata` operation and passing `{organisationUnits: true}` as `resources` param, and a list of `valid data element identifiers` which can be looked up using the `getMetadata` passing `{dataElements: true}` as `resources` param.\n- For events with registration, a `tracked entity instance identifier is required`\n- For sending `events` to `programs with multiple stages`, you will need to also include the `programStage` identifier, the identifiers for `programStages` can be found in the `programStages` resource via a call to `getMetadata` operation.",
513
- "tags": [
514
- {
515
- "title": "public",
516
- "description": null,
517
- "type": null
518
- },
519
- {
520
- "title": "function",
521
- "description": null,
522
- "name": null
523
- },
524
- {
525
- "title": "param",
526
- "description": "The payload containing new values",
527
- "type": {
528
- "type": "NameExpression",
529
- "name": "Object"
530
- },
531
- "name": "data"
532
- },
533
- {
534
- "title": "param",
535
- "description": "Optional `import parameters` for events. E.g. `{dryRun: true, importStrategy: CREATE, filters:[]}` See {@link https://docs.dhis2.org/2.34/en/dhis2_developer_manual/web-api.html#events DHIS2 Event Import parameters documentation} or run `discover`. Defauls to `DHIS2 default import parameters`.",
536
- "type": {
537
- "type": "OptionalType",
538
- "expression": {
539
- "type": "NameExpression",
540
- "name": "Object"
541
- }
542
- },
543
- "name": "params"
544
- },
545
- {
546
- "title": "param",
547
- "description": "Optional `flags` for the behavior of the `createEvents` operation.Defaults to `{apiVersion: state.configuration.apiVersion,responseType: 'json'}`",
548
- "type": {
549
- "type": "OptionalType",
550
- "expression": {
551
- "type": "RecordType",
552
- "fields": [
553
- {
554
- "type": "FieldType",
555
- "key": "apiVersion",
556
- "value": {
557
- "type": "NameExpression",
558
- "name": "number"
559
- }
560
- },
561
- {
562
- "type": "FieldType",
563
- "key": "responseType",
564
- "value": {
565
- "type": "NameExpression",
566
- "name": "string"
567
- }
568
- }
569
- ]
570
- }
571
- },
572
- "name": "options"
573
- },
574
- {
575
- "title": "param",
576
- "description": "Optional callback to handle the response",
577
- "type": {
578
- "type": "OptionalType",
579
- "expression": {
580
- "type": "NameExpression",
581
- "name": "function"
582
- }
583
- },
584
- "name": "callback"
585
- },
586
- {
587
- "title": "returns",
588
- "description": "state",
589
- "type": {
590
- "type": "NameExpression",
591
- "name": "Operation"
592
- }
593
- },
594
- {
595
- "title": "example",
596
- "description": "createEvents({\n program: 'eBAyeGv0exc',\n orgUnit: 'DiszpKrYNg8',\n eventDate: date,\n status: 'COMPLETED',\n completedDate: date,\n storedBy: 'admin',\n coordinate: {\n latitude: 59.8,\n longitude: 10.9,\n },\n dataValues: [\n {\n dataElement: 'qrur9Dvnyt5',\n value: '33',\n },\n {\n dataElement: 'oZg33kd9taw',\n value: 'Male',\n },\n {\n dataElement: 'msodh3rEMJa',\n value: date,\n },\n ],\n});",
597
- "caption": "- Example `expression.js` of `createEvents` for a `single event` can look like this:"
598
- }
599
- ]
600
- },
601
- "valid": true
602
- },
603
- {
604
- "name": "updateEvents",
605
- "params": [
606
- "path",
607
- "data",
608
- "params",
609
- "options",
610
- "callback"
611
- ],
612
- "docs": {
613
- "description": "Update DHIS2 Event.\n- To update an existing event, the format of the payload is the same as that of `creating an event` via `createEvents` operations\n- But you should supply the `identifier` of the object you are updating\n- The payload has to contain `all`, even `non-modified`, `attributes`.\n- Attributes that were present before and are not present in the current payload any more will be removed by DHIS2.\n- If you do not want this behavior, please use `upsert` operation to upsert your events.",
614
- "tags": [
615
- {
616
- "title": "public",
617
- "description": null,
618
- "type": null
619
- },
620
- {
621
- "title": "function",
622
- "description": null,
623
- "name": null
624
- },
625
- {
626
- "title": "param",
627
- "description": "Path to the object being updated. This can be an `id` or path to an `object` in a `nested collection` on the object(E.g. `/api/{collection-object}/{collection-object-id}/{collection-name}/{object-id}`)",
628
- "type": {
629
- "type": "NameExpression",
630
- "name": "string"
631
- },
632
- "name": "path"
633
- },
634
- {
635
- "title": "param",
636
- "description": "The update data containing new values",
637
- "type": {
638
- "type": "NameExpression",
639
- "name": "Object"
640
- },
641
- "name": "data"
642
- },
643
- {
644
- "title": "param",
645
- "description": "Optional `import` parameters for `updateEvents`. E.g. `{dryRun: true, IdScheme: 'CODE'}. Defaults to DHIS2 `default params`",
646
- "type": {
647
- "type": "OptionalType",
648
- "expression": {
649
- "type": "NameExpression",
650
- "name": "Object"
651
- }
652
- },
653
- "name": "params"
654
- },
655
- {
656
- "title": "param",
657
- "description": "Optional `flags` for the behavior of the `updateEvents` operation.Defaults to `{apiVersion: state.configuration.apiVersion,responseType: 'json'}`",
658
- "type": {
659
- "type": "OptionalType",
660
- "expression": {
661
- "type": "RecordType",
662
- "fields": [
663
- {
664
- "type": "FieldType",
665
- "key": "apiVersion",
666
- "value": {
667
- "type": "NameExpression",
668
- "name": "number"
669
- }
670
- },
671
- {
672
- "type": "FieldType",
673
- "key": "responseType",
674
- "value": {
675
- "type": "NameExpression",
676
- "name": "string"
677
- }
678
- }
679
- ]
680
- }
681
- },
682
- "name": "options"
683
- },
684
- {
685
- "title": "param",
686
- "description": "Optional callback to handle the response",
687
- "type": {
688
- "type": "OptionalType",
689
- "expression": {
690
- "type": "NameExpression",
691
- "name": "function"
692
- }
693
- },
694
- "name": "callback"
695
- },
696
- {
697
- "title": "returns",
698
- "description": null,
699
- "type": {
700
- "type": "NameExpression",
701
- "name": "Operation"
702
- }
703
- },
704
- {
705
- "title": "example",
706
- "description": "updateEvents('PVqUD2hvU4E', { events: [\n {\n program: 'eBAyeGv0exc',\n orgUnit: 'DiszpKrYNg8',\n eventDate: date,\n status: 'COMPLETED',\n storedBy: 'admin',\n coordinate: {\n latitude: '59.8',\n longitude: '10.9',\n },\n dataValues: [\n {\n dataElement: 'qrur9Dvnyt5',\n value: '22',\n },\n {\n dataElement: 'oZg33kd9taw',\n value: 'Male',\n },\n ],\n }]\n});",
707
- "caption": "- Example `expression.js` of `updateEvents`"
708
- }
709
- ]
710
- },
711
- "valid": true
712
- },
713
- {
714
- "name": "getPrograms",
715
- "params": [
716
- "params",
717
- "options",
718
- "callback"
719
- ],
720
- "docs": {
721
- "description": "Get DHIS2 Tracker Programs.",
722
- "tags": [
723
- {
724
- "title": "public",
725
- "description": null,
726
- "type": null
727
- },
728
- {
729
- "title": "function",
730
- "description": null,
731
- "name": null
732
- },
733
- {
734
- "title": "param",
735
- "description": "`import` parameters for `getPrograms`. See {@link https://docs.dhis2.org/2.34/en/dhis2_developer_manual/web-api.html#tracker-web-api DHIS2 api documentation for allowed query parameters }",
736
- "type": {
737
- "type": "NameExpression",
738
- "name": "Object"
739
- },
740
- "name": "params"
741
- },
742
- {
743
- "title": "param",
744
- "description": "Optional `flags` for the behavior of the `getPrograms` operation.Defaults to `{apiVersion: state.configuration.apiVersion,responseType: 'json'}`",
745
- "type": {
746
- "type": "OptionalType",
747
- "expression": {
748
- "type": "RecordType",
749
- "fields": [
750
- {
751
- "type": "FieldType",
752
- "key": "apiVersion",
753
- "value": {
754
- "type": "NameExpression",
755
- "name": "number"
756
- }
757
- },
758
- {
759
- "type": "FieldType",
760
- "key": "responseType",
761
- "value": {
762
- "type": "NameExpression",
763
- "name": "string"
764
- }
765
- }
766
- ]
767
- }
768
- },
769
- "name": "options"
770
- },
771
- {
772
- "title": "param",
773
- "description": "Optional callback to handle the response",
774
- "type": {
775
- "type": "OptionalType",
776
- "expression": {
777
- "type": "NameExpression",
778
- "name": "function"
779
- }
780
- },
781
- "name": "callback"
782
- },
783
- {
784
- "title": "returns",
785
- "description": null,
786
- "type": {
787
- "type": "NameExpression",
788
- "name": "Operation"
789
- }
790
- },
791
- {
792
- "title": "example",
793
- "description": "getPrograms({ orgUnit: 'DiszpKrYNg8' , fields: '*' });",
794
- "caption": "- Query for `all programs` with a certain `organisation unit`"
795
- }
796
- ]
797
- },
798
- "valid": true
799
- },
800
- {
801
- "name": "createPrograms",
802
- "params": [
803
- "data",
804
- "params",
805
- "options",
806
- "callback"
807
- ],
808
- "docs": {
809
- "description": "Create a DHIS2 Tracker Program",
810
- "tags": [
811
- {
812
- "title": "public",
813
- "description": null,
814
- "type": null
815
- },
816
- {
817
- "title": "function",
818
- "description": null,
819
- "name": null
820
- },
821
- {
822
- "title": "param",
823
- "description": "The update data containing new values",
824
- "type": {
825
- "type": "NameExpression",
826
- "name": "Object"
827
- },
828
- "name": "data"
829
- },
830
- {
831
- "title": "param",
832
- "description": "Optional `import` parameters for `createPrograms`. E.g. `{dryRun: true, IdScheme: 'CODE'}. Defaults to DHIS2 `default params`",
833
- "type": {
834
- "type": "OptionalType",
835
- "expression": {
836
- "type": "NameExpression",
837
- "name": "Object"
838
- }
839
- },
840
- "name": "params"
841
- },
842
- {
843
- "title": "param",
844
- "description": "Optional `flags` for the behavior of the `getPrograms` operation.Defaults to `{apiVersion: state.configuration.apiVersion,responseType: 'json'}`",
845
- "type": {
846
- "type": "OptionalType",
847
- "expression": {
848
- "type": "RecordType",
849
- "fields": [
850
- {
851
- "type": "FieldType",
852
- "key": "apiVersion",
853
- "value": {
854
- "type": "NameExpression",
855
- "name": "number"
856
- }
857
- },
858
- {
859
- "type": "FieldType",
860
- "key": "responseType",
861
- "value": {
862
- "type": "NameExpression",
863
- "name": "string"
864
- }
865
- }
866
- ]
867
- }
868
- },
869
- "name": "options"
870
- },
871
- {
872
- "title": "param",
873
- "description": "Optional callback to handle the response",
874
- "type": {
875
- "type": "OptionalType",
876
- "expression": {
877
- "type": "NameExpression",
878
- "name": "function"
879
- }
880
- },
881
- "name": "callback"
882
- },
883
- {
884
- "title": "returns",
885
- "description": null,
886
- "type": {
887
- "type": "NameExpression",
888
- "name": "Operation"
889
- }
890
- },
891
- {
892
- "title": "example",
893
- "description": "createPrograms(state.data);",
894
- "caption": "- Example `expression.js` of `createPrograms` for a `single program` can look like this:"
895
- }
896
- ]
897
- },
898
- "valid": true
899
- },
900
- {
901
- "name": "updatePrograms",
902
- "params": [
903
- "path",
904
- "data",
905
- "params",
906
- "options",
907
- "callback"
908
- ],
909
- "docs": {
910
- "description": "Update DHIS2 Tracker Programs\n- To update an existing program, the format of the payload is the same as that of `creating an event` via `createEvents` operations\n- But you should supply the `identifier` of the object you are updating\n- The payload has to contain `all`, even `non-modified`, `attributes`.\n- Attributes that were present before and are not present in the current payload any more will be removed by DHIS2.\n- If you do not want this behavior, please use `upsert` operation to upsert your events.",
911
- "tags": [
912
- {
913
- "title": "public",
914
- "description": null,
915
- "type": null
916
- },
917
- {
918
- "title": "function",
919
- "description": null,
920
- "name": null
921
- },
922
- {
923
- "title": "param",
924
- "description": "Path to the object being updated. This can be an `id` or path to an `object` in a `nested collection` on the object(E.g. `/api/{collection-object}/{collection-object-id}/{collection-name}/{object-id}`)",
925
- "type": {
926
- "type": "NameExpression",
927
- "name": "string"
928
- },
929
- "name": "path"
930
- },
931
- {
932
- "title": "param",
933
- "description": "The update data containing new values",
934
- "type": {
935
- "type": "NameExpression",
936
- "name": "Object"
937
- },
938
- "name": "data"
939
- },
940
- {
941
- "title": "param",
942
- "description": "Optional `import` parameters for `updatePrograms`. E.g. `{dryRun: true, IdScheme: 'CODE'}. Defaults to DHIS2 `default params`",
943
- "type": {
944
- "type": "OptionalType",
945
- "expression": {
946
- "type": "NameExpression",
947
- "name": "Object"
948
- }
949
- },
950
- "name": "params"
951
- },
952
- {
953
- "title": "param",
954
- "description": "Optional `flags` for the behavior of the `getPrograms` operation.Defaults to `{apiVersion: state.configuration.apiVersion,responseType: 'json'}`",
955
- "type": {
956
- "type": "OptionalType",
957
- "expression": {
958
- "type": "RecordType",
959
- "fields": [
960
- {
961
- "type": "FieldType",
962
- "key": "apiVersion",
963
- "value": {
964
- "type": "NameExpression",
965
- "name": "number"
966
- }
967
- },
968
- {
969
- "type": "FieldType",
970
- "key": "responseType",
971
- "value": {
972
- "type": "NameExpression",
973
- "name": "string"
974
- }
975
- }
976
- ]
977
- }
978
- },
979
- "name": "options"
980
- },
981
- {
982
- "title": "param",
983
- "description": "Optional callback to handle the response",
984
- "type": {
985
- "type": "OptionalType",
986
- "expression": {
987
- "type": "NameExpression",
988
- "name": "function"
989
- }
990
- },
991
- "name": "callback"
992
- },
993
- {
994
- "title": "returns",
995
- "description": null,
996
- "type": {
997
- "type": "NameExpression",
998
- "name": "Operation"
999
- }
1000
- },
1001
- {
1002
- "title": "example",
1003
- "description": "updatePrograms('PVqUD2hvU4E', state.data);",
1004
- "caption": "- Example `expression.js` of `updatePrograms`"
1005
- }
1006
- ]
1007
- },
1008
- "valid": true
1009
- },
1010
- {
1011
- "name": "getEnrollments",
1012
- "params": [
1013
- "params",
1014
- "options",
1015
- "callback"
1016
- ],
1017
- "docs": {
1018
- "description": "Get DHIS2 Enrollments",
1019
- "tags": [
1020
- {
1021
- "title": "public",
1022
- "description": null,
1023
- "type": null
1024
- },
1025
- {
1026
- "title": "function",
1027
- "description": null,
1028
- "name": null
1029
- },
1030
- {
1031
- "title": "param",
1032
- "description": "`Query` parameters for `getEnrollments`. See {@link https://docs.dhis2.org/2.34/en/dhis2_developer_manual/web-api.html#enrollment-management here}",
1033
- "type": {
1034
- "type": "NameExpression",
1035
- "name": "Object"
1036
- },
1037
- "name": "params"
1038
- },
1039
- {
1040
- "title": "param",
1041
- "description": "Optional `flags` for the behavior of the `getEnrollments` operation.Defaults to `{apiVersion: state.configuration.apiVersion,responseType: 'json'}`",
1042
- "type": {
1043
- "type": "OptionalType",
1044
- "expression": {
1045
- "type": "RecordType",
1046
- "fields": [
1047
- {
1048
- "type": "FieldType",
1049
- "key": "apiVersion",
1050
- "value": {
1051
- "type": "NameExpression",
1052
- "name": "number"
1053
- }
1054
- },
1055
- {
1056
- "type": "FieldType",
1057
- "key": "responseType",
1058
- "value": {
1059
- "type": "NameExpression",
1060
- "name": "string"
1061
- }
1062
- }
1063
- ]
1064
- }
1065
- },
1066
- "name": "options"
1067
- },
1068
- {
1069
- "title": "param",
1070
- "description": "Optional callback to handle the response",
1071
- "type": {
1072
- "type": "OptionalType",
1073
- "expression": {
1074
- "type": "NameExpression",
1075
- "name": "function"
1076
- }
1077
- },
1078
- "name": "callback"
1079
- },
1080
- {
1081
- "title": "returns",
1082
- "description": null,
1083
- "type": {
1084
- "type": "NameExpression",
1085
- "name": "Operation"
1086
- }
1087
- },
1088
- {
1089
- "title": "example",
1090
- "description": "getEnrollments({\n ou: 'O6uvpzGd5pu',\n ouMode: 'DESCENDANTS',\n program: 'ur1Edk5Oe2n',\n fields: '*',\n});",
1091
- "caption": "- To constrain the response to `enrollments` which are part of a `specific program` you can include a `program query parameter`"
1092
- }
1093
- ]
1094
- },
1095
- "valid": true
1096
- },
1097
- {
1098
- "name": "enrollTEI",
1099
- "params": [
1100
- "data",
1101
- "params",
1102
- "options",
1103
- "callback"
1104
- ],
1105
- "docs": {
1106
- "description": "Enroll a TEI into a program\n- Enrolling a tracked entity instance into a program\n- For enrolling `persons` into a `program`, you will need to first get the `identifier of the person` from the `trackedEntityInstances resource` via the `getTEIs` operation.\n- Then, you will need to get the `program identifier` from the `programs` resource via the `getPrograms` operation.",
1107
- "tags": [
1108
- {
1109
- "title": "public",
1110
- "description": null,
1111
- "type": null
1112
- },
1113
- {
1114
- "title": "function",
1115
- "description": null,
1116
- "name": null
1117
- },
1118
- {
1119
- "title": "param",
1120
- "description": "The enrollment data. See example {@link https://docs.dhis2.org/2.34/en/dhis2_developer_manual/web-api.html#enrollment-management here }",
1121
- "type": {
1122
- "type": "NameExpression",
1123
- "name": "Object"
1124
- },
1125
- "name": "data"
1126
- },
1127
- {
1128
- "title": "param",
1129
- "description": "Optional `import` parameters for `createEnrollment`. E.g. `{dryRun: true, IdScheme: 'CODE'}. Defaults to DHIS2 `default params`",
1130
- "type": {
1131
- "type": "OptionalType",
1132
- "expression": {
1133
- "type": "NameExpression",
1134
- "name": "Object"
1135
- }
1136
- },
1137
- "name": "params"
1138
- },
1139
- {
1140
- "title": "param",
1141
- "description": "Optional `flags` for the behavior of the `enrollTEI` operation.Defaults to `{apiVersion: state.configuration.apiVersion,responseType: 'json'}`",
1142
- "type": {
1143
- "type": "OptionalType",
1144
- "expression": {
1145
- "type": "RecordType",
1146
- "fields": [
1147
- {
1148
- "type": "FieldType",
1149
- "key": "apiVersion",
1150
- "value": {
1151
- "type": "NameExpression",
1152
- "name": "number"
1153
- }
1154
- },
1155
- {
1156
- "type": "FieldType",
1157
- "key": "responseType",
1158
- "value": {
1159
- "type": "NameExpression",
1160
- "name": "string"
1161
- }
1162
- }
1163
- ]
1164
- }
1165
- },
1166
- "name": "options"
1167
- },
1168
- {
1169
- "title": "param",
1170
- "description": "Optional callback to handle the response",
1171
- "type": {
1172
- "type": "OptionalType",
1173
- "expression": {
1174
- "type": "NameExpression",
1175
- "name": "function"
1176
- }
1177
- },
1178
- "name": "callback"
1179
- },
1180
- {
1181
- "title": "returns",
1182
- "description": null,
1183
- "type": {
1184
- "type": "NameExpression",
1185
- "name": "Operation"
1186
- }
1187
- },
1188
- {
1189
- "title": "example",
1190
- "description": "enrollTEI({\n trackedEntity: 'tracked-entity-id',\n orgUnit: 'org-unit-id',\n attributes: [\n {\n attribute: 'attribute-id',\n value: 'attribute-value',\n },\n ],\n enrollments: [\n {\n orgUnit: 'org-unit-id',\n program: 'program-id',\n enrollmentDate: '2013-09-17',\n incidentDate: '2013-09-17',\n },\n ],\n});",
1191
- "caption": "- Example `expression.js` of `createEnrollment` of a `person` into a `program` can look like this:"
1192
- }
1193
- ]
1194
- },
1195
- "valid": true
1196
- },
1197
- {
1198
- "name": "updateEnrollments",
1199
- "params": [
1200
- "path",
1201
- "data",
1202
- "params",
1203
- "options",
1204
- "callback"
1205
- ],
1206
- "docs": {
1207
- "description": "Update a DHIS2 Enrollemts\n- To update an existing enrollment, the format of the payload is the same as that of `creating an event` via `createEvents` operations\n- But you should supply the `identifier` of the object you are updating\n- The payload has to contain `all`, even `non-modified`, `attributes`.\n- Attributes that were present before and are not present in the current payload any more will be removed by DHIS2.\n- If you do not want this behavior, please use `upsert` operation to upsert your events.",
1208
- "tags": [
1209
- {
1210
- "title": "public",
1211
- "description": null,
1212
- "type": null
1213
- },
1214
- {
1215
- "title": "function",
1216
- "description": null,
1217
- "name": null
1218
- },
1219
- {
1220
- "title": "param",
1221
- "description": "Path to the object being updated. This can be an `id` or path to an `object` in a `nested collection` on the object(E.g. `/api/{collection-object}/{collection-object-id}/{collection-name}/{object-id}`)",
1222
- "type": {
1223
- "type": "NameExpression",
1224
- "name": "string"
1225
- },
1226
- "name": "path"
1227
- },
1228
- {
1229
- "title": "param",
1230
- "description": "The update data containing new values",
1231
- "type": {
1232
- "type": "NameExpression",
1233
- "name": "Object"
1234
- },
1235
- "name": "data"
1236
- },
1237
- {
1238
- "title": "param",
1239
- "description": "Optional `import` parameters for `updateEnrollments`. E.g. `{dryRun: true, IdScheme: 'CODE'}. Defaults to DHIS2 `default params`",
1240
- "type": {
1241
- "type": "OptionalType",
1242
- "expression": {
1243
- "type": "NameExpression",
1244
- "name": "Object"
1245
- }
1246
- },
1247
- "name": "params"
1248
- },
1249
- {
1250
- "title": "param",
1251
- "description": "Optional `flags` for the behavior of the `updateEnrollments` operation.Defaults to `{apiVersion: state.configuration.apiVersion,responseType: 'json'}`",
1252
- "type": {
1253
- "type": "OptionalType",
1254
- "expression": {
1255
- "type": "RecordType",
1256
- "fields": [
1257
- {
1258
- "type": "FieldType",
1259
- "key": "apiVersion",
1260
- "value": {
1261
- "type": "NameExpression",
1262
- "name": "number"
1263
- }
1264
- },
1265
- {
1266
- "type": "FieldType",
1267
- "key": "responseType",
1268
- "value": {
1269
- "type": "NameExpression",
1270
- "name": "string"
1271
- }
1272
- }
1273
- ]
1274
- }
1275
- },
1276
- "name": "options"
1277
- },
1278
- {
1279
- "title": "param",
1280
- "description": "Optional callback to handle the response",
1281
- "type": {
1282
- "type": "OptionalType",
1283
- "expression": {
1284
- "type": "NameExpression",
1285
- "name": "function"
1286
- }
1287
- },
1288
- "name": "callback"
1289
- },
1290
- {
1291
- "title": "returns",
1292
- "description": null,
1293
- "type": {
1294
- "type": "NameExpression",
1295
- "name": "Operation"
1296
- }
1297
- },
1298
- {
1299
- "title": "example",
1300
- "description": "updateEnrollments('PVqUD2hvU4E', state.data);",
1301
- "caption": "- Example `expression.js` of `updateEnromments`"
1302
- }
1303
- ]
1304
- },
1305
- "valid": true
1306
- },
1307
- {
1308
- "name": "cancelEnrollment",
1309
- "params": [
1310
- "enrollmentId",
1311
- "params",
1312
- "options",
1313
- "callback"
1314
- ],
1315
- "docs": {
1316
- "description": "Cancel a DHIS2 Enrollment\n- To cancel an existing enrollment, you should supply the `enrollment identifier`(`enrollemt-id`)",
1317
- "tags": [
1318
- {
1319
- "title": "public",
1320
- "description": null,
1321
- "type": null
1322
- },
1323
- {
1324
- "title": "function",
1325
- "description": null,
1326
- "name": null
1327
- },
1328
- {
1329
- "title": "param",
1330
- "description": "The `enrollment-id` of the enrollment you wish to cancel",
1331
- "type": {
1332
- "type": "NameExpression",
1333
- "name": "string"
1334
- },
1335
- "name": "enrollmentId"
1336
- },
1337
- {
1338
- "title": "param",
1339
- "description": "Optional `import` parameters for `cancelEnrollment`. E.g. `{dryRun: true, IdScheme: 'CODE'}. Defaults to DHIS2 `default params`",
1340
- "type": {
1341
- "type": "OptionalType",
1342
- "expression": {
1343
- "type": "NameExpression",
1344
- "name": "Object"
1345
- }
1346
- },
1347
- "name": "params"
1348
- },
1349
- {
1350
- "title": "param",
1351
- "description": "Optional `flags` for the behavior of the `cancelEnrollment` operation.Defaults to `{apiVersion: state.configuration.apiVersion,responseType: 'json'}`",
1352
- "type": {
1353
- "type": "OptionalType",
1354
- "expression": {
1355
- "type": "RecordType",
1356
- "fields": [
1357
- {
1358
- "type": "FieldType",
1359
- "key": "apiVersion",
1360
- "value": {
1361
- "type": "NameExpression",
1362
- "name": "number"
1363
- }
1364
- },
1365
- {
1366
- "type": "FieldType",
1367
- "key": "responseType",
1368
- "value": {
1369
- "type": "NameExpression",
1370
- "name": "string"
1371
- }
1372
- }
1373
- ]
1374
- }
1375
- },
1376
- "name": "options"
1377
- },
1378
- {
1379
- "title": "param",
1380
- "description": "Optional callback to handle the response",
1381
- "type": {
1382
- "type": "OptionalType",
1383
- "expression": {
1384
- "type": "NameExpression",
1385
- "name": "function"
1386
- }
1387
- },
1388
- "name": "callback"
1389
- },
1390
- {
1391
- "title": "returns",
1392
- "description": null,
1393
- "type": {
1394
- "type": "NameExpression",
1395
- "name": "Operation"
1396
- }
1397
- },
1398
- {
1399
- "title": "example",
1400
- "description": "cancelEnrollments('PVqUD2hvU4E');",
1401
- "caption": "- Example `expression.js` of `cancelEnrollment`"
1402
- }
1403
- ]
1404
- },
1405
- "valid": true
1406
- },
1407
- {
1408
- "name": "completeEnrollment",
1409
- "params": [
1410
- "enrollmentId",
1411
- "params",
1412
- "options",
1413
- "callback"
1414
- ],
1415
- "docs": {
1416
- "description": "Complete a DHIS2 Enrollment\n- To complete an existing enrollment, you should supply the `enrollment identifier`(`enrollemt-id`)",
1417
- "tags": [
1418
- {
1419
- "title": "public",
1420
- "description": null,
1421
- "type": null
1422
- },
1423
- {
1424
- "title": "function",
1425
- "description": null,
1426
- "name": null
1427
- },
1428
- {
1429
- "title": "param",
1430
- "description": "The `enrollment-id` of the enrollment you wish to cancel",
1431
- "type": {
1432
- "type": "NameExpression",
1433
- "name": "string"
1434
- },
1435
- "name": "enrollmentId"
1436
- },
1437
- {
1438
- "title": "param",
1439
- "description": "Optional `import` parameters for `completeEnrollment`. E.g. `{dryRun: true, IdScheme: 'CODE'}. Defaults to DHIS2 `default params`",
1440
- "type": {
1441
- "type": "OptionalType",
1442
- "expression": {
1443
- "type": "NameExpression",
1444
- "name": "Object"
1445
- }
1446
- },
1447
- "name": "params"
1448
- },
1449
- {
1450
- "title": "param",
1451
- "description": "Optional `flags` for the behavior of the `completeEnrollment` operation.Defaults to `{apiVersion: state.configuration.apiVersion,responseType: 'json'}`",
1452
- "type": {
1453
- "type": "OptionalType",
1454
- "expression": {
1455
- "type": "RecordType",
1456
- "fields": [
1457
- {
1458
- "type": "FieldType",
1459
- "key": "apiVersion",
1460
- "value": {
1461
- "type": "NameExpression",
1462
- "name": "number"
1463
- }
1464
- },
1465
- {
1466
- "type": "FieldType",
1467
- "key": "responseType",
1468
- "value": {
1469
- "type": "NameExpression",
1470
- "name": "string"
1471
- }
1472
- }
1473
- ]
1474
- }
1475
- },
1476
- "name": "options"
1477
- },
1478
- {
1479
- "title": "param",
1480
- "description": "Optional callback to handle the response",
1481
- "type": {
1482
- "type": "OptionalType",
1483
- "expression": {
1484
- "type": "NameExpression",
1485
- "name": "function"
1486
- }
1487
- },
1488
- "name": "callback"
1489
- },
1490
- {
1491
- "title": "returns",
1492
- "description": null,
1493
- "type": {
1494
- "type": "NameExpression",
1495
- "name": "Operation"
1496
- }
1497
- },
1498
- {
1499
- "title": "example",
1500
- "description": "completeEnrollment('PVqUD2hvU4E');",
1501
- "caption": "- Example `expression.js` of `completeEnrollment`"
1502
- }
1503
- ]
1504
- },
1505
- "valid": true
1506
- },
1507
- {
1508
- "name": "getRelationships",
1509
- "params": [
1510
- "params",
1511
- "options",
1512
- "callback"
1513
- ],
1514
- "docs": {
1515
- "description": "Get DHIS2 Relationships(links) between two entities in tracker. These entities can be tracked entity instances, enrollments and events.\n- All the tracker operations, `getTEIs`, `getEnrollments` and `getEvents` also list their relationships if requested in the `field` filter.\n- To list all relationships, this requires you to provide the UID of the trackedEntityInstance, Enrollment or event that you want to list all the relationships for.",
1516
- "tags": [
1517
- {
1518
- "title": "public",
1519
- "description": null,
1520
- "type": null
1521
- },
1522
- {
1523
- "title": "function",
1524
- "description": null,
1525
- "name": null
1526
- },
1527
- {
1528
- "title": "param",
1529
- "description": "`Query` parameters for `getRelationships`. See examples {@link https://docs.dhis2.org/2.34/en/dhis2_developer_manual/web-api.html#relationships here}",
1530
- "type": {
1531
- "type": "NameExpression",
1532
- "name": "Object"
1533
- },
1534
- "name": "params"
1535
- },
1536
- {
1537
- "title": "param",
1538
- "description": "Optional `flags` for the behavior of the `getRelationships` operation.Defaults to `{apiVersion: state.configuration.apiVersion,responseType: 'json'}`",
1539
- "type": {
1540
- "type": "OptionalType",
1541
- "expression": {
1542
- "type": "RecordType",
1543
- "fields": [
1544
- {
1545
- "type": "FieldType",
1546
- "key": "apiVersion",
1547
- "value": {
1548
- "type": "NameExpression",
1549
- "name": "number"
1550
- }
1551
- },
1552
- {
1553
- "type": "FieldType",
1554
- "key": "responseType",
1555
- "value": {
1556
- "type": "NameExpression",
1557
- "name": "string"
1558
- }
1559
- }
1560
- ]
1561
- }
1562
- },
1563
- "name": "options"
1564
- },
1565
- {
1566
- "title": "param",
1567
- "description": "Optional callback to handle the response",
1568
- "type": {
1569
- "type": "OptionalType",
1570
- "expression": {
1571
- "type": "NameExpression",
1572
- "name": "function"
1573
- }
1574
- },
1575
- "name": "callback"
1576
- },
1577
- {
1578
- "title": "returns",
1579
- "description": null,
1580
- "type": {
1581
- "type": "NameExpression",
1582
- "name": "Operation"
1583
- }
1584
- },
1585
- {
1586
- "title": "example",
1587
- "description": "getRelationships({ tei: 'F8yKM85NbxW', fields: '*' });",
1588
- "caption": "- A query for `all relationships` associated with a `specific tracked entity instance` can look like this:"
1589
- }
1590
- ]
1591
- },
1592
- "valid": true
1593
- },
1594
- {
1595
- "name": "getDataValues",
1596
- "params": [
1597
- "params",
1598
- "options",
1599
- "callback"
1600
- ],
1601
- "docs": {
1602
- "description": "Get DHIS2 Data Values.\n- This operation retrives data values from DHIS2 Web API by interacting with the `dataValueSets` resource\n- Data values can be retrieved in XML, JSON and CSV format.",
1603
- "tags": [
1604
- {
1605
- "title": "public",
1606
- "description": null,
1607
- "type": null
1608
- },
1609
- {
1610
- "title": "function",
1611
- "description": null,
1612
- "name": null
1613
- },
1614
- {
1615
- "title": "param",
1616
- "description": "`Query` parameters for `getDataValues`. E.g. `{dataset: 'pBOMPrpg1QX', limit: 3, period: 2021, orgUnit: 'DiszpKrYNg8'} Run `discover` or see {@link https://docs.dhis2.org/2.34/en/dhis2_developer_manual/web-api.html#data-values DHIS2 API docs} for available `Data Value Set Query Parameters`.",
1617
- "type": {
1618
- "type": "NameExpression",
1619
- "name": "Object"
1620
- },
1621
- "name": "params"
1622
- },
1623
- {
1624
- "title": "param",
1625
- "description": "Optional `options` for `getDataValues` operation. Defaults to `{apiVersion: state.configuration.apiVersion, responseType: 'json'}`",
1626
- "type": {
1627
- "type": "OptionalType",
1628
- "expression": {
1629
- "type": "RecordType",
1630
- "fields": [
1631
- {
1632
- "type": "FieldType",
1633
- "key": "apiVersion",
1634
- "value": {
1635
- "type": "NameExpression",
1636
- "name": "number"
1637
- }
1638
- },
1639
- {
1640
- "type": "FieldType",
1641
- "key": "responseType",
1642
- "value": {
1643
- "type": "NameExpression",
1644
- "name": "string"
1645
- }
1646
- }
1647
- ]
1648
- }
1649
- },
1650
- "name": "options"
1651
- },
1652
- {
1653
- "title": "param",
1654
- "description": "Optional `callback` to handle the response",
1655
- "type": {
1656
- "type": "OptionalType",
1657
- "expression": {
1658
- "type": "NameExpression",
1659
- "name": "function"
1660
- }
1661
- },
1662
- "name": "callback"
1663
- },
1664
- {
1665
- "title": "returns",
1666
- "description": null,
1667
- "type": {
1668
- "type": "NameExpression",
1669
- "name": "Operation"
1670
- }
1671
- },
1672
- {
1673
- "title": "example",
1674
- "description": "getDataValues({\n orgUnit: 'DiszpKrYNg8',\n period: '202010',\n dataSet: 'pBOMPrpg1QX',\n limit: 2,\n});",
1675
- "caption": "- Example getting **two** `data values` associated with a specific `orgUnit`, `dataSet`, and `period `"
1676
- }
1677
- ]
1678
- },
1679
- "valid": true
1680
- },
1681
- {
1682
- "name": "createDataValues",
1683
- "params": [
1684
- "data",
1685
- "options",
1686
- "params",
1687
- "callback"
1688
- ],
1689
- "docs": {
1690
- "description": "Create DHIS2 Data Values\n- This is used to send aggregated data to DHIS2\n- A data value set represents a set of data values which have a relationship, usually from being captured off the same data entry form.\n- To send a set of related data values sharing the same period and organisation unit, we need to identify the period, the data set, the org unit (facility) and the data elements for which to report.\n- You can also use this operation to send large bulks of data values which don't necessarily are logically related.\n- To send data values that are not linked to a `dataSet`, you do not need to specify the dataSet and completeDate attributes. Instead, you will specify the period and orgUnit attributes on the individual data value elements instead of on the outer data value set element. This will enable us to send data values for various periods and organisation units",
1691
- "tags": [
1692
- {
1693
- "title": "public",
1694
- "description": null,
1695
- "type": null
1696
- },
1697
- {
1698
- "title": "function",
1699
- "description": null,
1700
- "name": null
1701
- },
1702
- {
1703
- "title": "param",
1704
- "description": "The `data values` to upload or create. See example shape.",
1705
- "type": {
1706
- "type": "NameExpression",
1707
- "name": "object"
1708
- },
1709
- "name": "data"
1710
- },
1711
- {
1712
- "title": "param",
1713
- "description": "Optional `flags` for the behavior of the `createDataVaues` operation.",
1714
- "type": {
1715
- "type": "OptionalType",
1716
- "expression": {
1717
- "type": "RecordType",
1718
- "fields": [
1719
- {
1720
- "type": "FieldType",
1721
- "key": "apiVersion",
1722
- "value": {
1723
- "type": "NameExpression",
1724
- "name": "number"
1725
- }
1726
- },
1727
- {
1728
- "type": "FieldType",
1729
- "key": "responseType",
1730
- "value": {
1731
- "type": "NameExpression",
1732
- "name": "string"
1733
- }
1734
- }
1735
- ]
1736
- }
1737
- },
1738
- "name": "options"
1739
- },
1740
- {
1741
- "title": "param",
1742
- "description": "Optional `import` parameters for `createDataValues`. E.g. `{dryRun: true, IdScheme: 'CODE'}. Defaults to DHIS2 `default params`. Run `discover` or visit {@link https://docs.dhis2.org/2.34/en/dhis2_developer_manual/web-api.html#data-values DHIS2 Docs API} to learn about available data values import parameters.",
1743
- "type": {
1744
- "type": "OptionalType",
1745
- "expression": {
1746
- "type": "NameExpression",
1747
- "name": "object"
1748
- }
1749
- },
1750
- "name": "params"
1751
- },
1752
- {
1753
- "title": "param",
1754
- "description": "Optional callback to handle the response",
1755
- "type": {
1756
- "type": "OptionalType",
1757
- "expression": {
1758
- "type": "NameExpression",
1759
- "name": "function"
1760
- }
1761
- },
1762
- "name": "callback"
1763
- },
1764
- {
1765
- "title": "returns",
1766
- "description": null,
1767
- "type": {
1768
- "type": "NameExpression",
1769
- "name": "Operation"
1770
- }
1771
- },
1772
- {
1773
- "title": "example",
1774
- "description": "createDataValues({\n dataSet: 'pBOMPrpg1QX',\n completeDate: '2014-02-03',\n period: '201401',\n orgUnit: 'DiszpKrYNg8',\n dataValues: [\n {\n dataElement: 'f7n9E0hX8qk',\n value: '1',\n },\n {\n dataElement: 'Ix2HsbDMLea',\n value: '2',\n },\n {\n dataElement: 'eY5ehpbEsB7',\n value: '3',\n },\n ],\n});",
1775
- "caption": "- Example `expression.js` of `createDataValues` for sending a set of related data values sharing the same period and organisation unit"
1776
- }
1777
- ]
1778
- },
1779
- "valid": true
1780
- },
1781
- {
1782
- "name": "generateDhis2UID",
1783
- "params": [
1784
- "options",
1785
- "callback"
1786
- ],
1787
- "docs": {
1788
- "description": "Generate valid, random DHIS2 identifiers\n- Useful for client generated Ids compatible with DHIS2",
1789
- "tags": [
1790
- {
1791
- "title": "public",
1792
- "description": null,
1793
- "type": null
1794
- },
1795
- {
1796
- "title": "function",
1797
- "description": null,
1798
- "name": null
1799
- },
1800
- {
1801
- "title": "param",
1802
- "description": "Optional `options` for `generateDhis2UID` operation. Defaults to `{apiVersion: state.configuration.apiVersion,limit: 1,responseType: 'json'}`",
1803
- "type": {
1804
- "type": "OptionalType",
1805
- "expression": {
1806
- "type": "RecordType",
1807
- "fields": [
1808
- {
1809
- "type": "FieldType",
1810
- "key": "apiVersion",
1811
- "value": {
1812
- "type": "NameExpression",
1813
- "name": "number"
1814
- }
1815
- },
1816
- {
1817
- "type": "FieldType",
1818
- "key": "limit",
1819
- "value": {
1820
- "type": "NameExpression",
1821
- "name": "number"
1822
- }
1823
- },
1824
- {
1825
- "type": "FieldType",
1826
- "key": "responseType",
1827
- "value": {
1828
- "type": "NameExpression",
1829
- "name": "string"
1830
- }
1831
- }
1832
- ]
1833
- }
1834
- },
1835
- "name": "options"
1836
- },
1837
- {
1838
- "title": "param",
1839
- "description": "Callback to handle response",
1840
- "type": {
1841
- "type": "OptionalType",
1842
- "expression": {
1843
- "type": "NameExpression",
1844
- "name": "function"
1845
- }
1846
- },
1847
- "name": "callback"
1848
- },
1849
- {
1850
- "title": "returns",
1851
- "description": null,
1852
- "type": {
1853
- "type": "NameExpression",
1854
- "name": "Operation"
1855
- }
1856
- },
1857
- {
1858
- "title": "example",
1859
- "description": "generateDhis2UID({limit: 3});",
1860
- "caption": "Example generating `three UIDs` from the DHIS2 server"
1861
- }
1862
- ]
1863
- },
1864
- "valid": true
1865
- },
1866
- {
1867
- "name": "discover",
1868
- "params": [
1869
- "httpMethod",
1870
- "endpoint"
1871
- ],
1872
- "docs": {
1873
- "description": "Discover `DHIS2` `api` `endpoint` `query parameters` and allowed `operators` for a given resource's endpoint.",
1874
- "tags": [
1875
- {
1876
- "title": "public",
1877
- "description": null,
1878
- "type": null
1879
- },
1880
- {
1881
- "title": "function",
1882
- "description": null,
1883
- "name": null
1884
- },
1885
- {
1886
- "title": "param",
1887
- "description": "The HTTP to inspect parameter usage for a given endpoint, e.g., `get`, `post`,`put`,`patch`,`delete`",
1888
- "type": {
1889
- "type": "NameExpression",
1890
- "name": "string"
1891
- },
1892
- "name": "httpMethod"
1893
- },
1894
- {
1895
- "title": "param",
1896
- "description": "The path for a given endpoint. E.g. `/trackedEntityInstances` or `/dataValueSets`",
1897
- "type": {
1898
- "type": "NameExpression",
1899
- "name": "string"
1900
- },
1901
- "name": "endpoint"
1902
- },
1903
- {
1904
- "title": "returns",
1905
- "description": null,
1906
- "type": {
1907
- "type": "NameExpression",
1908
- "name": "Operation"
1909
- }
1910
- },
1911
- {
1912
- "title": "example",
1913
- "description": "discover('post', '/trackedEntityInstances')",
1914
- "caption": "Example getting a list of `parameters allowed` on a given `endpoint` for specific `http method`"
1915
- }
1916
- ]
1917
- },
1918
- "valid": true
1919
- },
1920
- {
1921
- "name": "getAnalytics",
1922
- "params": [
1923
- "params",
1924
- "options",
1925
- "callback"
1926
- ],
1927
- "docs": {
1928
- "description": "Get analytical, aggregated data\n- The analytics resource is powerful as it lets you query and retrieve data aggregated along all available data dimensions.\n- For instance, you can ask the analytics resource to provide the aggregated data values for a set of data elements, periods and organisation units.\n- Also, you can retrieve the aggregated data for a combination of any number of dimensions based on data elements and organisation unit group sets.",
1929
- "tags": [
1930
- {
1931
- "title": "public",
1932
- "description": null,
1933
- "type": null
1934
- },
1935
- {
1936
- "title": "function",
1937
- "description": null,
1938
- "name": null
1939
- },
1940
- {
1941
- "title": "param",
1942
- "description": "Analytics `query parameters`, e.g. `{dx: 'fbfJHSPpUQD;cYeuwXTCPkU',filters: ['pe:2014Q1;2014Q2','ou:O6uvpzGd5pu;lc3eMKXaEfw']}`. Run `discover` or visit {@link https://docs.dhis2.org/2.34/en/dhis2_developer_manual/web-api.html#analytics DHIS2 API docs} to get the params available.",
1943
- "type": {
1944
- "type": "NameExpression",
1945
- "name": "Object"
1946
- },
1947
- "name": "params"
1948
- },
1949
- {
1950
- "title": "param",
1951
- "description": "`Optional` options for `getAnalytics` operation. Defaults to `{apiVersion: state.configuration.apiVersion, responseType: 'json'}`.",
1952
- "type": {
1953
- "type": "OptionalType",
1954
- "expression": {
1955
- "type": "RecordType",
1956
- "fields": [
1957
- {
1958
- "type": "FieldType",
1959
- "key": "apiVersion",
1960
- "value": {
1961
- "type": "NameExpression",
1962
- "name": "number"
1963
- }
1964
- },
1965
- {
1966
- "type": "FieldType",
1967
- "key": "responseType",
1968
- "value": {
1969
- "type": "NameExpression",
1970
- "name": "string"
1971
- }
1972
- }
1973
- ]
1974
- }
1975
- },
1976
- "name": "options"
1977
- },
1978
- {
1979
- "title": "param",
1980
- "description": "Callback to handle response",
1981
- "type": {
1982
- "type": "OptionalType",
1983
- "expression": {
1984
- "type": "NameExpression",
1985
- "name": "function"
1986
- }
1987
- },
1988
- "name": "callback"
1989
- },
1990
- {
1991
- "title": "returns",
1992
- "description": null,
1993
- "type": {
1994
- "type": "NameExpression",
1995
- "name": "Operation"
1996
- }
1997
- },
1998
- {
1999
- "title": "example",
2000
- "description": "getAnalytics({\n dimensions: [\n 'dx:fbfJHSPpUQD;cYeuwXTCPkU',\n 'pe:2014',\n 'ou:O6uvpzGd5pu;lc3eMKXaEfw',\n ],\n measureCriteria: 'GE:6500;LT:33000',\n});",
2001
- "caption": "Example getting only records where the data value is greater or equal to 6500 and less than 33000"
2002
- }
2003
- ]
2004
- },
2005
- "valid": true
2006
- },
2007
- {
2008
- "name": "getResources",
2009
- "params": [
2010
- "params",
2011
- "options",
2012
- "callback"
2013
- ],
2014
- "docs": {
2015
- "description": "Get DHIS2 api resources",
2016
- "tags": [
2017
- {
2018
- "title": "public",
2019
- "description": null,
2020
- "type": null
2021
- },
2022
- {
2023
- "title": "function",
2024
- "description": null,
2025
- "name": null
2026
- },
2027
- {
2028
- "title": "param",
2029
- "description": "The `optional` query parameters for this endpoint. E.g `{filter: 'singular:like:attribute'}`.",
2030
- "type": {
2031
- "type": "OptionalType",
2032
- "expression": {
2033
- "type": "NameExpression",
2034
- "name": "Object"
2035
- }
2036
- },
2037
- "name": "params"
2038
- },
2039
- {
2040
- "title": "param",
2041
- "description": "The `optional` options, specifiying the filter expression. E.g. `singular:eq:attribute`.",
2042
- "type": {
2043
- "type": "OptionalType",
2044
- "expression": {
2045
- "type": "RecordType",
2046
- "fields": [
2047
- {
2048
- "type": "FieldType",
2049
- "key": "filter",
2050
- "value": {
2051
- "type": "NameExpression",
2052
- "name": "string"
2053
- }
2054
- },
2055
- {
2056
- "type": "FieldType",
2057
- "key": "fields",
2058
- "value": {
2059
- "type": "NameExpression",
2060
- "name": "string"
2061
- }
2062
- },
2063
- {
2064
- "type": "FieldType",
2065
- "key": "responseType",
2066
- "value": {
2067
- "type": "NameExpression",
2068
- "name": "string"
2069
- }
2070
- }
2071
- ]
2072
- }
2073
- },
2074
- "name": "options"
2075
- },
2076
- {
2077
- "title": "param",
2078
- "description": "The `optional callback function that will be called to handle data returned by this function.",
2079
- "type": {
2080
- "type": "OptionalType",
2081
- "expression": {
2082
- "type": "NameExpression",
2083
- "name": "function"
2084
- }
2085
- },
2086
- "name": "callback"
2087
- },
2088
- {
2089
- "title": "returns",
2090
- "description": null,
2091
- "type": {
2092
- "type": "NameExpression",
2093
- "name": "Operation"
2094
- }
2095
- },
2096
- {
2097
- "title": "example",
2098
- "description": "getResources('dataElement', {\n filter: 'singular:eq:attribute',\n fields: '*',\n responseType: 'xml',\n});",
2099
- "caption": "Example getting a resource named `attribute`, in `xml` format, returning all the fields"
2100
- }
2101
- ]
2102
- },
2103
- "valid": true
2104
- },
2105
- {
2106
- "name": "getSchema",
4
+ "name": "create",
2107
5
  "params": [
2108
6
  "resourceType",
2109
- "params",
7
+ "data",
2110
8
  "options",
2111
9
  "callback"
2112
10
  ],
2113
11
  "docs": {
2114
- "description": "Get schema of a given resource type, in any data format supported by DHIS2",
12
+ "description": "Create a record",
2115
13
  "tags": [
2116
14
  {
2117
15
  "title": "public",
@@ -2125,7 +23,7 @@
2125
23
  },
2126
24
  {
2127
25
  "title": "param",
2128
- "description": "The type of resource to be updated(`singular` version of the `resource name`). E.g. `dataElement`, `organisationUnit`, etc. Run `getResources` to see available resources and their corresponding `singular` names.",
26
+ "description": "Type of resource to create. E.g. `trackedEntityInstances`, `programs`, `events`, ...",
2129
27
  "type": {
2130
28
  "type": "NameExpression",
2131
29
  "name": "string"
@@ -2134,45 +32,28 @@
2134
32
  },
2135
33
  {
2136
34
  "title": "param",
2137
- "description": "Optional `query parameters` for the `getSchema` operation. e.g. `{ fields: 'properties' ,skipPaging: true}`. Run`discover` or See {@link https://docs.dhis2.org/2.34/en/dhis2_developer_manual/web-api.html#metadata-export-examples DHIS2 API Docs}",
35
+ "description": "Data that will be used to create a given instance of resource. To create a single instance of a resource, `data` must be a javascript object, and to create multiple instances of a resources, `data` must be an array of javascript objects.",
2138
36
  "type": {
2139
37
  "type": "NameExpression",
2140
38
  "name": "Object"
2141
39
  },
2142
- "name": "params"
40
+ "name": "data"
2143
41
  },
2144
42
  {
2145
43
  "title": "param",
2146
- "description": "Optional options for `getSchema` method. Defaults to `{apiVersion: state.configuration.apiVersion, responseType: 'json'}`",
44
+ "description": "Optional `options` to control the behavior of the `create` operation and to pass `import parameters` E.g. `{dryRun: true, importStrategy: CREATE}` See {@link https://docs.dhis2.org/2.34/en/dhis2_developer_manual/web-api.html DHIS2 API documentation} or {@link discover}..` Defaults to `{operationName: 'create', apiVersion: null, responseType: 'json'}`",
2147
45
  "type": {
2148
46
  "type": "OptionalType",
2149
47
  "expression": {
2150
- "type": "RecordType",
2151
- "fields": [
2152
- {
2153
- "type": "FieldType",
2154
- "key": "apiVersion",
2155
- "value": {
2156
- "type": "NameExpression",
2157
- "name": "number"
2158
- }
2159
- },
2160
- {
2161
- "type": "FieldType",
2162
- "key": "resourceType",
2163
- "value": {
2164
- "type": "NameExpression",
2165
- "name": "string"
2166
- }
2167
- }
2168
- ]
48
+ "type": "NameExpression",
49
+ "name": "Object"
2169
50
  }
2170
51
  },
2171
52
  "name": "options"
2172
53
  },
2173
54
  {
2174
55
  "title": "param",
2175
- "description": "Optional `callback` to handle the response",
56
+ "description": "Optional callback to handle the response",
2176
57
  "type": {
2177
58
  "type": "OptionalType",
2178
59
  "expression": {
@@ -2192,23 +73,74 @@
2192
73
  },
2193
74
  {
2194
75
  "title": "example",
2195
- "description": "getSchema('dataElement', '{ fields: '*' }, { responseType: 'xml' });",
2196
- "caption": "Example getting the `schema` for `dataElement` in XML"
76
+ "description": "create('programs', {\n name: 'name 20',\n shortName: 'n20',\n programType: 'WITHOUT_REGISTRATION',\n});",
77
+ "caption": "-a `program`"
78
+ },
79
+ {
80
+ "title": "example",
81
+ "description": "create('events', {\n program: 'eBAyeGv0exc',\n orgUnit: 'DiszpKrYNg8',\n status: 'COMPLETED',\n});",
82
+ "caption": "-an `event`"
83
+ },
84
+ {
85
+ "title": "example",
86
+ "description": "create('trackedEntityInstances', {\n orgUnit: 'TSyzvBiovKh',\n trackedEntityType: 'nEenWmSyUEp',\n attributes: [\n {\n attribute: 'w75KJ2mc4zz',\n value: 'Gigiwe',\n },\n ]\n});",
87
+ "caption": "-a `trackedEntityInstance`"
88
+ },
89
+ {
90
+ "title": "example",
91
+ "description": "create('dataSets', { name: 'OpenFn Data Set', periodType: 'Monthly' });",
92
+ "caption": "-a `dataSet`"
93
+ },
94
+ {
95
+ "title": "example",
96
+ "description": "create('dataSetNotificationTemplates', {\n dataSetNotificationTrigger: 'DATA_SET_COMPLETION',\n notificationRecipient: 'ORGANISATION_UNIT_CONTACT',\n name: 'Notification',\n messageTemplate: 'Hello',\n deliveryChannels: ['SMS'],\n dataSets: [],\n});",
97
+ "caption": "-a `dataSetNotification`"
98
+ },
99
+ {
100
+ "title": "example",
101
+ "description": "create('dataElements', {\n aggregationType: 'SUM',\n domainType: 'AGGREGATE',\n valueType: 'NUMBER',\n name: 'Paracetamol',\n shortName: 'Para',\n});",
102
+ "caption": "-a `dataElement`"
103
+ },
104
+ {
105
+ "title": "example",
106
+ "description": "create('dataElementGroups', {\n name: 'Data Element Group 1',\n dataElements: [],\n});",
107
+ "caption": "-a `dataElementGroup`"
108
+ },
109
+ {
110
+ "title": "example",
111
+ "description": "create('dataElementGroupSets', {\n name: 'Data Element Group Set 4',\n dataDimension: true,\n shortName: 'DEGS4',\n dataElementGroups: [],\n});",
112
+ "caption": "-a `dataElementGroupSet`"
113
+ },
114
+ {
115
+ "title": "example",
116
+ "description": "create('dataValueSets', {\n dataElement: 'f7n9E0hX8qk',\n period: '201401',\n orgUnit: 'DiszpKrYNg8',\n value: '12',\n});",
117
+ "caption": "-a `dataValueSet`"
118
+ },
119
+ {
120
+ "title": "example",
121
+ "description": "create('dataValueSets', {\n dataSet: 'pBOMPrpg1QX',\n completeDate: '2014-02-03',\n period: '201401',\n orgUnit: 'DiszpKrYNg8',\n dataValues: [\n {\n dataElement: 'f7n9E0hX8qk',\n value: '1',\n },\n {\n dataElement: 'Ix2HsbDMLea',\n value: '2',\n },\n {\n dataElement: 'eY5ehpbEsB7',\n value: '3',\n },\n ],\n});",
122
+ "caption": "-a `dataValueSet` with related `dataValues`"
123
+ },
124
+ {
125
+ "title": "example",
126
+ "description": "create('enrollments', {\n trackedEntityInstance: 'bmshzEacgxa',\n orgUnit: 'TSyzvBiovKh',\n program: 'gZBxv9Ujxg0',\n enrollmentDate: '2013-09-17',\n incidentDate: '2013-09-17',\n});",
127
+ "caption": "-an `enrollment`"
2197
128
  }
2198
129
  ]
2199
130
  },
2200
131
  "valid": true
2201
132
  },
2202
133
  {
2203
- "name": "getData",
134
+ "name": "update",
2204
135
  "params": [
2205
136
  "resourceType",
2206
- "params",
137
+ "path",
138
+ "data",
2207
139
  "options",
2208
140
  "callback"
2209
141
  ],
2210
142
  "docs": {
2211
- "description": "Get data. Generic helper method for getting data of any kind from DHIS2.\n- This can be used to get `DataValueSets`,`events`,`trackedEntityInstances`,`etc.`",
143
+ "description": "Update data. A generic helper function to update a resource object of any type.\nUpdating an object requires to send `all required fields` or the `full body`",
2212
144
  "tags": [
2213
145
  {
2214
146
  "title": "public",
@@ -2222,7 +154,7 @@
2222
154
  },
2223
155
  {
2224
156
  "title": "param",
2225
- "description": "The type of resource to get(use its `plural` name). E.g. `dataElements`, `trackedEntityInstances`,`organisationUnits`, etc.",
157
+ "description": "The type of resource to be updated. E.g. `dataElements`, `organisationUnits`, etc.",
2226
158
  "type": {
2227
159
  "type": "NameExpression",
2228
160
  "name": "string"
@@ -2231,19 +163,25 @@
2231
163
  },
2232
164
  {
2233
165
  "title": "param",
2234
- "description": "Optional `query parameters` e.g. `{ou: 'DiszpKrYNg8'}`. Run `discover` or see {@link https://docs.dhis2.org/2.34/en/dhis2_developer_manual/web-api.html DHIS2 docs} for more details on which params to use for a given type of resource.",
166
+ "description": "The `id` or `path` to the `object` to be updated. E.g. `FTRrcoaog83` or `FTRrcoaog83/{collection-name}/{object-id}`",
2235
167
  "type": {
2236
- "type": "OptionalType",
2237
- "expression": {
2238
- "type": "NameExpression",
2239
- "name": "Object"
2240
- }
168
+ "type": "NameExpression",
169
+ "name": "string"
2241
170
  },
2242
- "name": "params"
171
+ "name": "path"
2243
172
  },
2244
173
  {
2245
174
  "title": "param",
2246
- "description": "`Optional` options for `getData` operation. Defaults to `{operationName: 'getData', apiVersion: state.configuration.apiVersion, responseType: 'json'}`.",
175
+ "description": "Data to update. It requires to send `all required fields` or the `full body`. If you want `partial updates`, use `patch` operation.",
176
+ "type": {
177
+ "type": "NameExpression",
178
+ "name": "Object"
179
+ },
180
+ "name": "data"
181
+ },
182
+ {
183
+ "title": "param",
184
+ "description": "Optional options for update method. Defaults to `{operationName: 'update', apiVersion: state.configuration.apiVersion, responseType: 'json'}`",
2247
185
  "type": {
2248
186
  "type": "OptionalType",
2249
187
  "expression": {
@@ -2267,7 +205,7 @@
2267
205
  },
2268
206
  {
2269
207
  "type": "FieldType",
2270
- "key": "responseType",
208
+ "key": "resourceType",
2271
209
  "value": {
2272
210
  "type": "NameExpression",
2273
211
  "name": "string"
@@ -2292,7 +230,7 @@
2292
230
  },
2293
231
  {
2294
232
  "title": "returns",
2295
- "description": "state",
233
+ "description": null,
2296
234
  "type": {
2297
235
  "type": "NameExpression",
2298
236
  "name": "Operation"
@@ -2300,23 +238,72 @@
2300
238
  },
2301
239
  {
2302
240
  "title": "example",
2303
- "description": "getData('trackedEntityInstances', {\n fields: '*',\n ou: 'DiszpKrYNg8',\n entityType: 'nEenWmSyUEp',\n trackedEntityInstance: 'dNpxRu1mWG5',\n});",
2304
- "caption": "Example getting one `trackedEntityInstance` with `Id` 'dNpxRu1mWG5' for a given `orgUnit(DiszpKrYNg8)`"
241
+ "description": "update('programs', 'qAZJCrNJK8H', {\n name: '14e1aa02c3f0a31618e096f2c6d03bed',\n shortName: '14e1aa02',\n programType: 'WITHOUT_REGISTRATION',\n});",
242
+ "caption": "-a program"
243
+ },
244
+ {
245
+ "title": "example",
246
+ "description": "update('events', 'PVqUD2hvU4E', {\n program: 'eBAyeGv0exc',\n orgUnit: 'Ngelehun CHC',\n status: 'COMPLETED',\n storedBy: 'admin',\n dataValues: [],\n});",
247
+ "caption": "an `event`"
248
+ },
249
+ {
250
+ "title": "example",
251
+ "description": "update('trackedEntityInstances', 'IeQfgUtGPq2', {\n created: '2015-08-06T21:12:37.256',\n orgUnit: 'TSyzvBiovKh',\n createdAtClient: '2015-08-06T21:12:37.256',\n trackedEntityInstance: 'IeQfgUtGPq2',\n lastUpdated: '2015-08-06T21:12:37.257',\n trackedEntityType: 'nEenWmSyUEp',\n inactive: false,\n deleted: false,\n featureType: 'NONE',\n programOwners: [\n {\n ownerOrgUnit: 'TSyzvBiovKh',\n program: 'IpHINAT79UW',\n trackedEntityInstance: 'IeQfgUtGPq2',\n },\n ],\n enrollments: [],\n relationships: [],\n attributes: [\n {\n lastUpdated: '2016-01-12T00:00:00.000',\n displayName: 'Last name',\n created: '2016-01-12T00:00:00.000',\n valueType: 'TEXT',\n attribute: 'zDhUuAYrxNC',\n value: 'Russell',\n },\n {\n lastUpdated: '2016-01-12T00:00:00.000',\n code: 'MMD_PER_NAM',\n displayName: 'First name',\n created: '2016-01-12T00:00:00.000',\n valueType: 'TEXT',\n attribute: 'w75KJ2mc4zz',\n value: 'Catherine',\n },\n ],\n});",
252
+ "caption": "a `trackedEntityInstance`"
253
+ },
254
+ {
255
+ "title": "example",
256
+ "description": "update('dataSets', 'lyLU2wR22tC', { name: 'OpenFN Data Set', periodType: 'Weekly' });",
257
+ "caption": "-a `dataSet`"
258
+ },
259
+ {
260
+ "title": "example",
261
+ "description": "update('dataSetNotificationTemplates', 'VbQBwdm1wVP', {\n dataSetNotificationTrigger: 'DATA_SET_COMPLETION',\n notificationRecipient: 'ORGANISATION_UNIT_CONTACT',\n name: 'Notification',\n messageTemplate: 'Hello Updated,\n deliveryChannels: ['SMS'],\n dataSets: [],\n});",
262
+ "caption": "-a `dataSetNotification`"
263
+ },
264
+ {
265
+ "title": "example",
266
+ "description": "update('dataElements', 'FTRrcoaog83', {\n aggregationType: 'SUM',\n domainType: 'AGGREGATE',\n valueType: 'NUMBER',\n name: 'Paracetamol',\n shortName: 'Para',\n});",
267
+ "caption": "-a `dataElement`"
268
+ },
269
+ {
270
+ "title": "example",
271
+ "description": "update('dataElementGroups', 'QrprHT61XFk', {\n name: 'Data Element Group 1',\n dataElements: [],\n});",
272
+ "caption": "-a `dataElementGroup`"
273
+ },
274
+ {
275
+ "title": "example",
276
+ "description": "update('dataElementGroupSets', 'VxWloRvAze8', {\n name: 'Data Element Group Set 4',\n dataDimension: true,\n shortName: 'DEGS4',\n dataElementGroups: [],\n});",
277
+ "caption": "-a `dataElementGroupSet`"
278
+ },
279
+ {
280
+ "title": "example",
281
+ "description": "update('dataValueSets', 'AsQj6cDsUq4', {\n dataElement: 'f7n9E0hX8qk',\n period: '201401',\n orgUnit: 'DiszpKrYNg8',\n value: '12',\n});",
282
+ "caption": "-a `dataValueSet`"
283
+ },
284
+ {
285
+ "title": "example",
286
+ "description": "update('dataValueSets', 'Ix2HsbDMLea', {\n dataSet: 'pBOMPrpg1QX',\n completeDate: '2014-02-03',\n period: '201401',\n orgUnit: 'DiszpKrYNg8',\n dataValues: [\n {\n dataElement: 'f7n9E0hX8qk',\n value: '1',\n },\n {\n dataElement: 'Ix2HsbDMLea',\n value: '2',\n },\n {\n dataElement: 'eY5ehpbEsB7',\n value: '3',\n },\n ],\n});",
287
+ "caption": "-a `dataValueSet` with related `dataValues`"
288
+ },
289
+ {
290
+ "title": "example",
291
+ "description": "update('enrollments', 'CmsHzercTBa' {\n trackedEntityInstance: 'bmshzEacgxa',\n orgUnit: 'TSyzvBiovKh',\n program: 'gZBxv9Ujxg0',\n enrollmentDate: '2013-10-17',\n incidentDate: '2013-10-17',\n});",
292
+ "caption": "a single enrollment"
2305
293
  }
2306
294
  ]
2307
295
  },
2308
296
  "valid": true
2309
297
  },
2310
298
  {
2311
- "name": "getMetadata",
299
+ "name": "get",
2312
300
  "params": [
2313
- "resources",
2314
- "params",
301
+ "resourceType",
2315
302
  "options",
2316
303
  "callback"
2317
304
  ],
2318
305
  "docs": {
2319
- "description": "Get metadata. A generic helper function to get metadata records from a given DHIS2 instance",
306
+ "description": "Get data. Generic helper method for getting data of any kind from DHIS2.\n- This can be used to get `DataValueSets`,`events`,`trackedEntityInstances`,`etc.`",
2320
307
  "tags": [
2321
308
  {
2322
309
  "title": "public",
@@ -2330,37 +317,16 @@
2330
317
  },
2331
318
  {
2332
319
  "title": "param",
2333
- "description": "Required. List of metadata resources to fetch. E.g. `['organisationUnits', 'attributes']` or like `'dataSets'` if you only want a single type of resource. See `getResources` to see the types of resources available.",
2334
- "type": {
2335
- "type": "TypeApplication",
2336
- "expression": {
2337
- "type": "NameExpression",
2338
- "name": "Array"
2339
- },
2340
- "applications": [
2341
- {
2342
- "type": "NameExpression",
2343
- "name": "string"
2344
- }
2345
- ]
2346
- },
2347
- "name": "resources"
2348
- },
2349
- {
2350
- "title": "param",
2351
- "description": "Optional `query parameters` e.g. `{filters: ['name:like:ANC'],fields:'*'}`. See `discover` or visit {@link https://docs.dhis2.org/2.34/en/dhis2_developer_manual/web-api.html#metadata-export DHIS2 API docs}",
320
+ "description": "The type of resource to get(use its `plural` name). E.g. `dataElements`, `trackedEntityInstances`,`organisationUnits`, etc.",
2352
321
  "type": {
2353
- "type": "OptionalType",
2354
- "expression": {
2355
- "type": "NameExpression",
2356
- "name": "Object"
2357
- }
322
+ "type": "NameExpression",
323
+ "name": "string"
2358
324
  },
2359
- "name": "params"
325
+ "name": "resourceType"
2360
326
  },
2361
327
  {
2362
328
  "title": "param",
2363
- "description": "Optional `options` for `getMetadata` operation. Defaults to `{operationName: 'getMetadata', apiVersion: state.configuration.apiVersion, responseType: 'json'}`",
329
+ "description": "`Optional` options for `getData` operation. Defaults to `{operationName: 'getData', apiVersion: state.configuration.apiVersion, responseType: 'json'}`.",
2364
330
  "type": {
2365
331
  "type": "OptionalType",
2366
332
  "expression": {
@@ -2384,7 +350,7 @@
2384
350
  },
2385
351
  {
2386
352
  "type": "FieldType",
2387
- "key": "resourceType",
353
+ "key": "responseType",
2388
354
  "value": {
2389
355
  "type": "NameExpression",
2390
356
  "name": "string"
@@ -2395,99 +361,6 @@
2395
361
  },
2396
362
  "name": "options"
2397
363
  },
2398
- {
2399
- "title": "param",
2400
- "description": "Optional `callback` to handle the response",
2401
- "type": {
2402
- "type": "OptionalType",
2403
- "expression": {
2404
- "type": "NameExpression",
2405
- "name": "function"
2406
- }
2407
- },
2408
- "name": "callback"
2409
- },
2410
- {
2411
- "title": "returns",
2412
- "description": null,
2413
- "type": {
2414
- "type": "NameExpression",
2415
- "name": "Operation"
2416
- }
2417
- },
2418
- {
2419
- "title": "example",
2420
- "description": "getMetadata(['dataElements', 'indicators'], {\n filters: ['name:like:ANC'],\n});",
2421
- "caption": "Example getting a list of `data elements` and `indicators` where `name` includes the word **ANC**"
2422
- }
2423
- ]
2424
- },
2425
- "valid": true
2426
- },
2427
- {
2428
- "name": "create",
2429
- "params": [
2430
- "resourceType",
2431
- "data",
2432
- "options",
2433
- "params",
2434
- "callback"
2435
- ],
2436
- "docs": {
2437
- "description": "create data. A generic helper method to create a record of any kind in DHIS2",
2438
- "tags": [
2439
- {
2440
- "title": "public",
2441
- "description": null,
2442
- "type": null
2443
- },
2444
- {
2445
- "title": "function",
2446
- "description": null,
2447
- "name": null
2448
- },
2449
- {
2450
- "title": "param",
2451
- "description": "Type of resource to create. E.g. `trackedEntityInstances`",
2452
- "type": {
2453
- "type": "NameExpression",
2454
- "name": "string"
2455
- },
2456
- "name": "resourceType"
2457
- },
2458
- {
2459
- "title": "param",
2460
- "description": "Data that will be used to create a given instance of resource",
2461
- "type": {
2462
- "type": "NameExpression",
2463
- "name": "Object"
2464
- },
2465
- "name": "data"
2466
- },
2467
- {
2468
- "title": "param",
2469
- "description": "Optional `options` to control the behavior of the `create` operation.` Defaults to `{operationName: 'create', apiVersion: null, responseType: 'json'}`",
2470
- "type": {
2471
- "type": "OptionalType",
2472
- "expression": {
2473
- "type": "NameExpression",
2474
- "name": "Object"
2475
- }
2476
- },
2477
- "name": "options"
2478
- },
2479
- {
2480
- "title": "param",
2481
- "description": "Optional `import parameters` for a given a resource. E.g. `{dryRun: true, importStrategy: CREATE}` See {@link https://docs.dhis2.org/2.34/en/dhis2_developer_manual/web-api.html DHIS2 API documentation} or {@link discover}. Defauls to `DHIS2 default params` for a given resource type.",
2482
- "type": {
2483
- "type": "OptionalType",
2484
- "expression": {
2485
- "type": "NameExpression",
2486
- "name": "Object"
2487
- }
2488
- },
2489
- "name": "params"
2490
- },
2491
364
  {
2492
365
  "title": "param",
2493
366
  "description": "Optional callback to handle the response",
@@ -2502,7 +375,7 @@
2502
375
  },
2503
376
  {
2504
377
  "title": "returns",
2505
- "description": null,
378
+ "description": "state",
2506
379
  "type": {
2507
380
  "type": "NameExpression",
2508
381
  "name": "Operation"
@@ -2510,25 +383,23 @@
2510
383
  },
2511
384
  {
2512
385
  "title": "example",
2513
- "description": "create('events', {\n program: 'eBAyeGv0exc',\n orgUnit: 'DiszpKrYNg8',\n eventDate: date,\n status: 'COMPLETED',\n completedDate: date,\n storedBy: 'admin',\n coordinate: {\n latitude: 59.8,\n longitude: 10.9,\n },\n dataValues: [\n {\n dataElement: 'qrur9Dvnyt5',\n value: '33',\n },\n {\n dataElement: 'oZg33kd9taw',\n value: 'Male',\n },\n {\n dataElement: 'msodh3rEMJa',\n value: date,\n },\n ],\n});",
2514
- "caption": "- Example `expression.js` of `create`"
386
+ "description": "getData('trackedEntityInstances', {\n fields: '*',\n ou: 'DiszpKrYNg8',\n entityType: 'nEenWmSyUEp',\n trackedEntityInstance: 'dNpxRu1mWG5',\n});",
387
+ "caption": "Example getting one `trackedEntityInstance` with `Id` 'dNpxRu1mWG5' for a given `orgUnit(DiszpKrYNg8)`"
2515
388
  }
2516
389
  ]
2517
390
  },
2518
391
  "valid": true
2519
392
  },
2520
393
  {
2521
- "name": "update",
394
+ "name": "upsert",
2522
395
  "params": [
2523
396
  "resourceType",
2524
- "path",
2525
397
  "data",
2526
- "params",
2527
398
  "options",
2528
399
  "callback"
2529
400
  ],
2530
401
  "docs": {
2531
- "description": "Update data. A generic helper function to update a resource object of any type.\n- It requires to send `all required fields` or the `full body`",
402
+ "description": "Upsert a record. A generic helper function used to atomically either insert a row, or on the basis of the row already existing, UPDATE that existing row instead.",
2532
403
  "tags": [
2533
404
  {
2534
405
  "title": "public",
@@ -2542,7 +413,7 @@
2542
413
  },
2543
414
  {
2544
415
  "title": "param",
2545
- "description": "The type of resource to be updated. E.g. `dataElements`, `organisationUnits`, etc.",
416
+ "description": "The type of a resource to `insert` or `update`. E.g. `trackedEntityInstances`",
2546
417
  "type": {
2547
418
  "type": "NameExpression",
2548
419
  "name": "string"
@@ -2551,16 +422,7 @@
2551
422
  },
2552
423
  {
2553
424
  "title": "param",
2554
- "description": "The `id` or `path` to the `object` to be updated. E.g. `FTRrcoaog83` or `FTRrcoaog83/{collection-name}/{object-id}`",
2555
- "type": {
2556
- "type": "NameExpression",
2557
- "name": "string"
2558
- },
2559
- "name": "path"
2560
- },
2561
- {
2562
- "title": "param",
2563
- "description": "Data to update. It requires to send `all required fields` or the `full body`. If you want `partial updates`, use `patch` operation.",
425
+ "description": "The update data containing new values",
2564
426
  "type": {
2565
427
  "type": "NameExpression",
2566
428
  "name": "Object"
@@ -2569,24 +431,20 @@
2569
431
  },
2570
432
  {
2571
433
  "title": "param",
2572
- "description": "Optional `update` parameters e.g. `{preheatCache: true, strategy: 'UPDATE', mergeMode: 'REPLACE'}`. Run `discover` or see {@link https://docs.dhis2.org/2.34/en/dhis2_developer_manual/web-api.html#create-update-parameters DHIS2 documentation}",
2573
- "type": {
2574
- "type": "OptionalType",
2575
- "expression": {
2576
- "type": "NameExpression",
2577
- "name": "Object"
2578
- }
2579
- },
2580
- "name": "params"
2581
- },
2582
- {
2583
- "title": "param",
2584
- "description": "Optional options for update method. Defaults to `{operationName: 'update', apiVersion: state.configuration.apiVersion, responseType: 'json'}`",
434
+ "description": "`Optional` options for `upsertTEI` operation. Defaults to `{replace: false, apiVersion: state.configuration.apiVersion,strict: true,responseType: 'json'}`.",
2585
435
  "type": {
2586
436
  "type": "OptionalType",
2587
437
  "expression": {
2588
438
  "type": "RecordType",
2589
439
  "fields": [
440
+ {
441
+ "type": "FieldType",
442
+ "key": "replace",
443
+ "value": {
444
+ "type": "NameExpression",
445
+ "name": "boolean"
446
+ }
447
+ },
2590
448
  {
2591
449
  "type": "FieldType",
2592
450
  "key": "apiVersion",
@@ -2597,15 +455,15 @@
2597
455
  },
2598
456
  {
2599
457
  "type": "FieldType",
2600
- "key": "operationName",
458
+ "key": "strict",
2601
459
  "value": {
2602
460
  "type": "NameExpression",
2603
- "name": "string"
461
+ "name": "boolean"
2604
462
  }
2605
463
  },
2606
464
  {
2607
465
  "type": "FieldType",
2608
- "key": "resourceType",
466
+ "key": "responseType",
2609
467
  "value": {
2610
468
  "type": "NameExpression",
2611
469
  "name": "string"
@@ -2628,6 +486,84 @@
2628
486
  },
2629
487
  "name": "callback"
2630
488
  },
489
+ {
490
+ "title": "throws",
491
+ "description": "Throws range error",
492
+ "type": {
493
+ "type": "NameExpression",
494
+ "name": "RangeError"
495
+ }
496
+ },
497
+ {
498
+ "title": "returns",
499
+ "description": null,
500
+ "type": {
501
+ "type": "NameExpression",
502
+ "name": "Operation"
503
+ }
504
+ },
505
+ {
506
+ "title": "example",
507
+ "description": "upsert(\n 'trackedEntityInstances',\n {\n attributeId: 'lZGmxYbs97q',\n attributeValue: state =>\n state.data.attributes.find(obj => obj.attribute === 'lZGmxYbs97q')\n .value,\n },\n state.data,\n { ou: 'TSyzvBiovKh' }\n);",
508
+ "caption": "Example `expression.js` of upsert"
509
+ },
510
+ {
511
+ "title": "todo",
512
+ "description": "Tweak/refine to mimic implementation based on the following inspiration: {@link https://sqlite.org/lang_upsert.html sqlite upsert} and {@link https://wiki.postgresql.org/wiki/UPSERT postgresql upsert}"
513
+ },
514
+ {
515
+ "title": "todo",
516
+ "description": "Test implementation for upserting metadata"
517
+ },
518
+ {
519
+ "title": "todo",
520
+ "description": "Test implementation for upserting data values"
521
+ },
522
+ {
523
+ "title": "todo",
524
+ "description": "Implement the updateCondition"
525
+ }
526
+ ]
527
+ },
528
+ "valid": true
529
+ },
530
+ {
531
+ "name": "discover",
532
+ "params": [
533
+ "httpMethod",
534
+ "endpoint"
535
+ ],
536
+ "docs": {
537
+ "description": "Discover `DHIS2` `api` `endpoint` `query parameters` and allowed `operators` for a given resource's endpoint.",
538
+ "tags": [
539
+ {
540
+ "title": "public",
541
+ "description": null,
542
+ "type": null
543
+ },
544
+ {
545
+ "title": "function",
546
+ "description": null,
547
+ "name": null
548
+ },
549
+ {
550
+ "title": "param",
551
+ "description": "The HTTP to inspect parameter usage for a given endpoint, e.g., `get`, `post`,`put`,`patch`,`delete`",
552
+ "type": {
553
+ "type": "NameExpression",
554
+ "name": "string"
555
+ },
556
+ "name": "httpMethod"
557
+ },
558
+ {
559
+ "title": "param",
560
+ "description": "The path for a given endpoint. E.g. `/trackedEntityInstances` or `/dataValueSets`",
561
+ "type": {
562
+ "type": "NameExpression",
563
+ "name": "string"
564
+ },
565
+ "name": "endpoint"
566
+ },
2631
567
  {
2632
568
  "title": "returns",
2633
569
  "description": null,
@@ -2638,8 +574,8 @@
2638
574
  },
2639
575
  {
2640
576
  "title": "example",
2641
- "description": "update('dataElements', 'FTRrcoaog83',\n{\n displayName: 'New display name',\n aggregationType: 'SUM',\n domainType: 'AGGREGATE',\n valueType: 'NUMBER',\n name: 'Accute Flaccid Paralysis (Deaths < 5 yrs)',\n shortName: 'Accute Flaccid Paral (Deaths < 5 yrs)',\n});",
2642
- "caption": "Example `updating` a `data element`"
577
+ "description": "discover('post', '/trackedEntityInstances')",
578
+ "caption": "Example getting a list of `parameters allowed` on a given `endpoint` for specific `http method`"
2643
579
  }
2644
580
  ]
2645
581
  },
@@ -2905,23 +841,23 @@
2905
841
  "valid": true
2906
842
  },
2907
843
  {
2908
- "name": "upsert",
844
+ "name": "attrVal",
2909
845
  "params": [
2910
- "resourceType",
2911
- "uniqueAttribute",
2912
- "data",
2913
- "params",
2914
- "options",
2915
- "callback"
846
+ "tei",
847
+ "attributeName"
2916
848
  ],
2917
849
  "docs": {
2918
- "description": "Upsert a record. A generic helper function used to atomically either insert a row, or on the basis of the row already existing, UPDATE that existing row instead.",
850
+ "description": "Gets an attribute value by its case-insensitive display name",
2919
851
  "tags": [
2920
852
  {
2921
853
  "title": "public",
2922
854
  "description": null,
2923
855
  "type": null
2924
856
  },
857
+ {
858
+ "title": "example",
859
+ "description": "attrVal(tei.attributes, 'first name')"
860
+ },
2925
861
  {
2926
862
  "title": "function",
2927
863
  "description": null,
@@ -2929,153 +865,82 @@
2929
865
  },
2930
866
  {
2931
867
  "title": "param",
2932
- "description": "The type of a resource to `insert` or `update`. E.g. `trackedEntityInstances`",
868
+ "description": "A tracked entity instance (TEI) object",
2933
869
  "type": {
2934
870
  "type": "NameExpression",
2935
- "name": "string"
871
+ "name": "Object"
2936
872
  },
2937
- "name": "resourceType"
873
+ "name": "tei"
2938
874
  },
2939
875
  {
2940
876
  "title": "param",
2941
- "description": "An object containing a `attributeId` and `attributeValue` which will be used to uniquely identify the record",
877
+ "description": "The 'displayName' to search for in the TEI's attributes",
2942
878
  "type": {
2943
- "type": "RecordType",
2944
- "fields": [
2945
- {
2946
- "type": "FieldType",
2947
- "key": "attributeId",
2948
- "value": {
2949
- "type": "NameExpression",
2950
- "name": "string"
2951
- }
2952
- },
2953
- {
2954
- "type": "FieldType",
2955
- "key": "attributeValue",
2956
- "value": {
2957
- "type": "NameExpression",
2958
- "name": "any"
2959
- }
2960
- }
2961
- ]
879
+ "type": "NameExpression",
880
+ "name": "string"
2962
881
  },
2963
- "name": "uniqueAttribute"
882
+ "name": "attributeName"
2964
883
  },
2965
884
  {
2966
- "title": "param",
2967
- "description": "The update data containing new values",
885
+ "title": "returns",
886
+ "description": null,
2968
887
  "type": {
2969
888
  "type": "NameExpression",
2970
- "name": "Object"
2971
- },
2972
- "name": "data"
889
+ "name": "string"
890
+ }
891
+ }
892
+ ]
893
+ },
894
+ "valid": true
895
+ },
896
+ {
897
+ "name": "attribute",
898
+ "params": [
899
+ "attributeId",
900
+ "attributeValue"
901
+ ],
902
+ "docs": {
903
+ "description": "Converts an attribute ID and value into a DSHI2 attribute object",
904
+ "tags": [
905
+ {
906
+ "title": "public",
907
+ "description": null,
908
+ "type": null
2973
909
  },
2974
910
  {
2975
- "title": "param",
2976
- "description": "Optional `import` parameters e.g. `{ou: 'lZGmxYbs97q', filters: ['w75KJ2mc4zz:EQ:Jane']}`",
2977
- "type": {
2978
- "type": "OptionalType",
2979
- "expression": {
2980
- "type": "NameExpression",
2981
- "name": "Object"
2982
- }
2983
- },
2984
- "name": "params"
911
+ "title": "example",
912
+ "description": "attribute('w75KJ2mc4zz', 'Elias')"
2985
913
  },
2986
914
  {
2987
- "title": "param",
2988
- "description": "`Optional` options for `upsertTEI` operation. Defaults to `{replace: false, apiVersion: state.configuration.apiVersion,strict: true,responseType: 'json'}`.",
2989
- "type": {
2990
- "type": "OptionalType",
2991
- "expression": {
2992
- "type": "RecordType",
2993
- "fields": [
2994
- {
2995
- "type": "FieldType",
2996
- "key": "replace",
2997
- "value": {
2998
- "type": "NameExpression",
2999
- "name": "boolean"
3000
- }
3001
- },
3002
- {
3003
- "type": "FieldType",
3004
- "key": "apiVersion",
3005
- "value": {
3006
- "type": "NameExpression",
3007
- "name": "number"
3008
- }
3009
- },
3010
- {
3011
- "type": "FieldType",
3012
- "key": "strict",
3013
- "value": {
3014
- "type": "NameExpression",
3015
- "name": "boolean"
3016
- }
3017
- },
3018
- {
3019
- "type": "FieldType",
3020
- "key": "responseType",
3021
- "value": {
3022
- "type": "NameExpression",
3023
- "name": "string"
3024
- }
3025
- }
3026
- ]
3027
- }
3028
- },
3029
- "name": "options"
915
+ "title": "function",
916
+ "description": null,
917
+ "name": null
3030
918
  },
3031
919
  {
3032
920
  "title": "param",
3033
- "description": "Optional callback to handle the response",
921
+ "description": "A tracked entity instance (TEI) attribute ID.",
3034
922
  "type": {
3035
- "type": "OptionalType",
3036
- "expression": {
3037
- "type": "NameExpression",
3038
- "name": "function"
3039
- }
923
+ "type": "NameExpression",
924
+ "name": "string"
3040
925
  },
3041
- "name": "callback"
926
+ "name": "attributeId"
3042
927
  },
3043
928
  {
3044
- "title": "throws",
3045
- "description": "Throws range error",
929
+ "title": "param",
930
+ "description": "The value for that attribute.",
3046
931
  "type": {
3047
932
  "type": "NameExpression",
3048
- "name": "RangeError"
3049
- }
933
+ "name": "string"
934
+ },
935
+ "name": "attributeValue"
3050
936
  },
3051
937
  {
3052
938
  "title": "returns",
3053
939
  "description": null,
3054
940
  "type": {
3055
941
  "type": "NameExpression",
3056
- "name": "Operation"
942
+ "name": "object"
3057
943
  }
3058
- },
3059
- {
3060
- "title": "example",
3061
- "description": "upsert(\n 'trackedEntityInstances',\n {\n attributeId: 'lZGmxYbs97q',\n attributeValue: state =>\n state.data.attributes.find(obj => obj.attribute === 'lZGmxYbs97q')\n .value,\n },\n state.data,\n { ou: 'TSyzvBiovKh' }\n);",
3062
- "caption": "- Example `expression.js` of upsert"
3063
- },
3064
- {
3065
- "title": "todo",
3066
- "description": "Tweak/refine to mimic implementation based on the following inspiration: {@link https://sqlite.org/lang_upsert.html sqlite upsert} and {@link https://wiki.postgresql.org/wiki/UPSERT postgresql upsert}"
3067
- },
3068
- {
3069
- "title": "todo",
3070
- "description": "Test implementation for upserting metadata"
3071
- },
3072
- {
3073
- "title": "todo",
3074
- "description": "Test implementation for upserting data values"
3075
- },
3076
- {
3077
- "title": "todo",
3078
- "description": "Implement the updateCondition"
3079
944
  }
3080
945
  ]
3081
946
  },