@openfn/language-dhis2 2.0.11 → 3.0.0-4

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 +220 -2573
  3. package/lib/Adaptor.js +548 -1636
  4. package/lib/Client.js +48 -0
  5. package/lib/Utils.js +50 -183
  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 +6 -5
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 define URL parameters via params (E.g. `filter`, `dimension` and other import parameters), request config (E.g. `auth`) and the DHIS2 apiVersion.",
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,49 +163,30 @@
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"
170
+ },
171
+ "name": "path"
172
+ },
173
+ {
174
+ "title": "param",
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"
2241
179
  },
2242
- "name": "params"
180
+ "name": "data"
2243
181
  },
2244
182
  {
2245
183
  "title": "param",
2246
- "description": "`Optional` options for `getData` operation. Defaults to `{operationName: 'getData', apiVersion: state.configuration.apiVersion, responseType: 'json'}`.",
184
+ "description": "Optional `options` to define URL parameters via params (E.g. `filter`, `dimension` and other import parameters), request config (E.g. `auth`) and the DHIS2 apiVersion.",
2247
185
  "type": {
2248
186
  "type": "OptionalType",
2249
187
  "expression": {
2250
- "type": "RecordType",
2251
- "fields": [
2252
- {
2253
- "type": "FieldType",
2254
- "key": "apiVersion",
2255
- "value": {
2256
- "type": "NameExpression",
2257
- "name": "number"
2258
- }
2259
- },
2260
- {
2261
- "type": "FieldType",
2262
- "key": "operationName",
2263
- "value": {
2264
- "type": "NameExpression",
2265
- "name": "string"
2266
- }
2267
- },
2268
- {
2269
- "type": "FieldType",
2270
- "key": "responseType",
2271
- "value": {
2272
- "type": "NameExpression",
2273
- "name": "string"
2274
- }
2275
- }
2276
- ]
188
+ "type": "NameExpression",
189
+ "name": "Object"
2277
190
  }
2278
191
  },
2279
192
  "name": "options"
@@ -2292,7 +205,7 @@
2292
205
  },
2293
206
  {
2294
207
  "title": "returns",
2295
- "description": "state",
208
+ "description": null,
2296
209
  "type": {
2297
210
  "type": "NameExpression",
2298
211
  "name": "Operation"
@@ -2300,141 +213,73 @@
2300
213
  },
2301
214
  {
2302
215
  "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)`"
2305
- }
2306
- ]
2307
- },
2308
- "valid": true
2309
- },
2310
- {
2311
- "name": "getMetadata",
2312
- "params": [
2313
- "resources",
2314
- "params",
2315
- "options",
2316
- "callback"
2317
- ],
2318
- "docs": {
2319
- "description": "Get metadata. A generic helper function to get metadata records from a given DHIS2 instance",
2320
- "tags": [
216
+ "description": "update('programs', 'qAZJCrNJK8H', {\n name: '14e1aa02c3f0a31618e096f2c6d03bed',\n shortName: '14e1aa02',\n programType: 'WITHOUT_REGISTRATION',\n});",
217
+ "caption": "a program"
218
+ },
2321
219
  {
2322
- "title": "public",
2323
- "description": null,
2324
- "type": null
220
+ "title": "example",
221
+ "description": "update('events', 'PVqUD2hvU4E', {\n program: 'eBAyeGv0exc',\n orgUnit: 'Ngelehun CHC',\n status: 'COMPLETED',\n storedBy: 'admin',\n dataValues: [],\n});",
222
+ "caption": "an event"
2325
223
  },
2326
224
  {
2327
- "title": "function",
2328
- "description": null,
2329
- "name": null
225
+ "title": "example",
226
+ "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});",
227
+ "caption": "a trackedEntityInstance"
2330
228
  },
2331
229
  {
2332
- "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"
230
+ "title": "example",
231
+ "description": "update('dataSets', 'lyLU2wR22tC', { name: 'OpenFN Data Set', periodType: 'Weekly' });",
232
+ "caption": "a dataSet"
2348
233
  },
2349
234
  {
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}",
2352
- "type": {
2353
- "type": "OptionalType",
2354
- "expression": {
2355
- "type": "NameExpression",
2356
- "name": "Object"
2357
- }
2358
- },
2359
- "name": "params"
235
+ "title": "example",
236
+ "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});",
237
+ "caption": "a dataSetNotification"
2360
238
  },
2361
239
  {
2362
- "title": "param",
2363
- "description": "Optional `options` for `getMetadata` operation. Defaults to `{operationName: 'getMetadata', apiVersion: state.configuration.apiVersion, responseType: 'json'}`",
2364
- "type": {
2365
- "type": "OptionalType",
2366
- "expression": {
2367
- "type": "RecordType",
2368
- "fields": [
2369
- {
2370
- "type": "FieldType",
2371
- "key": "apiVersion",
2372
- "value": {
2373
- "type": "NameExpression",
2374
- "name": "number"
2375
- }
2376
- },
2377
- {
2378
- "type": "FieldType",
2379
- "key": "operationName",
2380
- "value": {
2381
- "type": "NameExpression",
2382
- "name": "string"
2383
- }
2384
- },
2385
- {
2386
- "type": "FieldType",
2387
- "key": "resourceType",
2388
- "value": {
2389
- "type": "NameExpression",
2390
- "name": "string"
2391
- }
2392
- }
2393
- ]
2394
- }
2395
- },
2396
- "name": "options"
240
+ "title": "example",
241
+ "description": "update('dataElements', 'FTRrcoaog83', {\n aggregationType: 'SUM',\n domainType: 'AGGREGATE',\n valueType: 'NUMBER',\n name: 'Paracetamol',\n shortName: 'Para',\n});",
242
+ "caption": "a dataElement"
2397
243
  },
2398
244
  {
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"
245
+ "title": "example",
246
+ "description": "update('dataElementGroups', 'QrprHT61XFk', {\n name: 'Data Element Group 1',\n dataElements: [],\n});",
247
+ "caption": "a dataElementGroup"
2409
248
  },
2410
249
  {
2411
- "title": "returns",
2412
- "description": null,
2413
- "type": {
2414
- "type": "NameExpression",
2415
- "name": "Operation"
2416
- }
250
+ "title": "example",
251
+ "description": "update('dataElementGroupSets', 'VxWloRvAze8', {\n name: 'Data Element Group Set 4',\n dataDimension: true,\n shortName: 'DEGS4',\n dataElementGroups: [],\n});",
252
+ "caption": "a dataElementGroupSet"
253
+ },
254
+ {
255
+ "title": "example",
256
+ "description": "update('dataValueSets', 'AsQj6cDsUq4', {\n dataElement: 'f7n9E0hX8qk',\n period: '201401',\n orgUnit: 'DiszpKrYNg8',\n value: '12',\n});",
257
+ "caption": "a dataValueSet"
258
+ },
259
+ {
260
+ "title": "example",
261
+ "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});",
262
+ "caption": "a dataValueSet with related dataValues"
2417
263
  },
2418
264
  {
2419
265
  "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**"
266
+ "description": "update('enrollments', 'CmsHzercTBa' {\n trackedEntityInstance: 'bmshzEacgxa',\n orgUnit: 'TSyzvBiovKh',\n program: 'gZBxv9Ujxg0',\n enrollmentDate: '2013-10-17',\n incidentDate: '2013-10-17',\n});",
267
+ "caption": "a single enrollment"
2422
268
  }
2423
269
  ]
2424
270
  },
2425
271
  "valid": true
2426
272
  },
2427
273
  {
2428
- "name": "create",
274
+ "name": "get",
2429
275
  "params": [
2430
276
  "resourceType",
2431
- "data",
277
+ "query",
2432
278
  "options",
2433
- "params",
2434
279
  "callback"
2435
280
  ],
2436
281
  "docs": {
2437
- "description": "create data. A generic helper method to create a record of any kind in DHIS2",
282
+ "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.`",
2438
283
  "tags": [
2439
284
  {
2440
285
  "title": "public",
@@ -2448,7 +293,7 @@
2448
293
  },
2449
294
  {
2450
295
  "title": "param",
2451
- "description": "Type of resource to create. E.g. `trackedEntityInstances`",
296
+ "description": "The type of resource to get(use its `plural` name). E.g. `dataElements`, `trackedEntityInstances`,`organisationUnits`, etc.",
2452
297
  "type": {
2453
298
  "type": "NameExpression",
2454
299
  "name": "string"
@@ -2457,16 +302,16 @@
2457
302
  },
2458
303
  {
2459
304
  "title": "param",
2460
- "description": "Data that will be used to create a given instance of resource",
305
+ "description": "A query object that will limit what resources are retrieved when converted into request params.",
2461
306
  "type": {
2462
307
  "type": "NameExpression",
2463
308
  "name": "Object"
2464
309
  },
2465
- "name": "data"
310
+ "name": "query"
2466
311
  },
2467
312
  {
2468
313
  "title": "param",
2469
- "description": "Optional `options` to control the behavior of the `create` operation.` Defaults to `{operationName: 'create', apiVersion: null, responseType: 'json'}`",
314
+ "description": "Optional `options` to define URL parameters via params beyond filters, request configuration (e.g. `auth`) and DHIS2 api version to use.",
2470
315
  "type": {
2471
316
  "type": "OptionalType",
2472
317
  "expression": {
@@ -2476,18 +321,6 @@
2476
321
  },
2477
322
  "name": "options"
2478
323
  },
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
324
  {
2492
325
  "title": "param",
2493
326
  "description": "Optional callback to handle the response",
@@ -2502,7 +335,7 @@
2502
335
  },
2503
336
  {
2504
337
  "title": "returns",
2505
- "description": null,
338
+ "description": "state",
2506
339
  "type": {
2507
340
  "type": "NameExpression",
2508
341
  "name": "Operation"
@@ -2510,25 +343,31 @@
2510
343
  },
2511
344
  {
2512
345
  "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`"
346
+ "description": "get('dataValueSets', {\n dataSet: 'pBOMPrpg1QX',\n orgUnit: 'DiszpKrYNg8',\n period: '201401',\n fields: '*',\n});",
347
+ "caption": "all data values for the 'pBOMPrpg1QX' dataset"
348
+ },
349
+ {
350
+ "title": "example",
351
+ "description": "get('programs', { orgUnit: 'TSyzvBiovKh', fields: '*' });",
352
+ "caption": "all programs for an organization unit"
353
+ },
354
+ {
355
+ "title": "example",
356
+ "description": "get('trackedEntityInstances', {\n ou: 'DiszpKrYNg8',\n filter: ['flGbXLXCrEo:Eq:124', 'w75KJ2mc4zz:Eq:John'],\n});",
357
+ "caption": "a single tracked entity instance by a unique external ID"
2515
358
  }
2516
359
  ]
2517
360
  },
2518
361
  "valid": true
2519
362
  },
2520
363
  {
2521
- "name": "update",
364
+ "name": "discover",
2522
365
  "params": [
2523
- "resourceType",
2524
- "path",
2525
- "data",
2526
- "params",
2527
- "options",
2528
- "callback"
366
+ "httpMethod",
367
+ "endpoint"
2529
368
  ],
2530
369
  "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`",
370
+ "description": "Discover `DHIS2` `api` `endpoint` `query parameters` and allowed `operators` for a given resource's endpoint.",
2532
371
  "tags": [
2533
372
  {
2534
373
  "title": "public",
@@ -2542,91 +381,21 @@
2542
381
  },
2543
382
  {
2544
383
  "title": "param",
2545
- "description": "The type of resource to be updated. E.g. `dataElements`, `organisationUnits`, etc.",
384
+ "description": "The HTTP to inspect parameter usage for a given endpoint, e.g., `get`, `post`,`put`,`patch`,`delete`",
2546
385
  "type": {
2547
386
  "type": "NameExpression",
2548
387
  "name": "string"
2549
388
  },
2550
- "name": "resourceType"
389
+ "name": "httpMethod"
2551
390
  },
2552
391
  {
2553
392
  "title": "param",
2554
- "description": "The `id` or `path` to the `object` to be updated. E.g. `FTRrcoaog83` or `FTRrcoaog83/{collection-name}/{object-id}`",
393
+ "description": "The path for a given endpoint. E.g. `/trackedEntityInstances` or `/dataValueSets`",
2555
394
  "type": {
2556
395
  "type": "NameExpression",
2557
396
  "name": "string"
2558
397
  },
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.",
2564
- "type": {
2565
- "type": "NameExpression",
2566
- "name": "Object"
2567
- },
2568
- "name": "data"
2569
- },
2570
- {
2571
- "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'}`",
2585
- "type": {
2586
- "type": "OptionalType",
2587
- "expression": {
2588
- "type": "RecordType",
2589
- "fields": [
2590
- {
2591
- "type": "FieldType",
2592
- "key": "apiVersion",
2593
- "value": {
2594
- "type": "NameExpression",
2595
- "name": "number"
2596
- }
2597
- },
2598
- {
2599
- "type": "FieldType",
2600
- "key": "operationName",
2601
- "value": {
2602
- "type": "NameExpression",
2603
- "name": "string"
2604
- }
2605
- },
2606
- {
2607
- "type": "FieldType",
2608
- "key": "resourceType",
2609
- "value": {
2610
- "type": "NameExpression",
2611
- "name": "string"
2612
- }
2613
- }
2614
- ]
2615
- }
2616
- },
2617
- "name": "options"
2618
- },
2619
- {
2620
- "title": "param",
2621
- "description": "Optional callback to handle the response",
2622
- "type": {
2623
- "type": "OptionalType",
2624
- "expression": {
2625
- "type": "NameExpression",
2626
- "name": "function"
2627
- }
2628
- },
2629
- "name": "callback"
398
+ "name": "endpoint"
2630
399
  },
2631
400
  {
2632
401
  "title": "returns",
@@ -2638,8 +407,8 @@
2638
407
  },
2639
408
  {
2640
409
  "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`"
410
+ "description": "discover('post', '/trackedEntityInstances')",
411
+ "caption": "a list of parameters allowed on a given endpoint for specific http method"
2643
412
  }
2644
413
  ]
2645
414
  },
@@ -2651,7 +420,6 @@
2651
420
  "resourceType",
2652
421
  "path",
2653
422
  "data",
2654
- "params",
2655
423
  "options",
2656
424
  "callback"
2657
425
  ],
@@ -2697,7 +465,7 @@
2697
465
  },
2698
466
  {
2699
467
  "title": "param",
2700
- "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}",
468
+ "description": "Optional configuration, including params for the update ({preheatCache: true, strategy: 'UPDATE', mergeMode: 'REPLACE'}). Defaults to `{operationName: 'patch', apiVersion: state.configuration.apiVersion, responseType: 'json'}`",
2701
469
  "type": {
2702
470
  "type": "OptionalType",
2703
471
  "expression": {
@@ -2705,43 +473,6 @@
2705
473
  "name": "Object"
2706
474
  }
2707
475
  },
2708
- "name": "params"
2709
- },
2710
- {
2711
- "title": "param",
2712
- "description": "Optional options for update method. Defaults to `{operationName: 'patch', apiVersion: state.configuration.apiVersion, responseType: 'json'}`",
2713
- "type": {
2714
- "type": "OptionalType",
2715
- "expression": {
2716
- "type": "RecordType",
2717
- "fields": [
2718
- {
2719
- "type": "FieldType",
2720
- "key": "apiVersion",
2721
- "value": {
2722
- "type": "NameExpression",
2723
- "name": "number"
2724
- }
2725
- },
2726
- {
2727
- "type": "FieldType",
2728
- "key": "operationName",
2729
- "value": {
2730
- "type": "NameExpression",
2731
- "name": "string"
2732
- }
2733
- },
2734
- {
2735
- "type": "FieldType",
2736
- "key": "responseType",
2737
- "value": {
2738
- "type": "NameExpression",
2739
- "name": "string"
2740
- }
2741
- }
2742
- ]
2743
- }
2744
- },
2745
476
  "name": "options"
2746
477
  },
2747
478
  {
@@ -2766,20 +497,19 @@
2766
497
  },
2767
498
  {
2768
499
  "title": "example",
2769
- "description": "patch('dataElements', 'FTRrcoaog83',\n{\n name: 'New Name',\n});",
2770
- "caption": "Example `patching` a `data element`"
500
+ "description": "patch('dataElements', 'FTRrcoaog83', { name: 'New Name' });",
501
+ "caption": "a dataElement"
2771
502
  }
2772
503
  ]
2773
504
  },
2774
505
  "valid": true
2775
506
  },
2776
507
  {
2777
- "name": "del",
508
+ "name": "destroy",
2778
509
  "params": [
2779
510
  "resourceType",
2780
511
  "path",
2781
512
  "data",
2782
- "params",
2783
513
  "options",
2784
514
  "callback"
2785
515
  ],
@@ -2828,19 +558,7 @@
2828
558
  },
2829
559
  {
2830
560
  "title": "param",
2831
- "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}",
2832
- "type": {
2833
- "type": "OptionalType",
2834
- "expression": {
2835
- "type": "NameExpression",
2836
- "name": "Object"
2837
- }
2838
- },
2839
- "name": "params"
2840
- },
2841
- {
2842
- "title": "param",
2843
- "description": "Optional `options` for `del` operation. Defaults to `{operationName: 'delete', apiVersion: state.configuration.apiVersion, responseType: 'json'}`",
561
+ "description": "Optional `options` for `del` operation including params 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}. Defaults to `{operationName: 'delete', apiVersion: state.configuration.apiVersion, responseType: 'json'}`",
2844
562
  "type": {
2845
563
  "type": "OptionalType",
2846
564
  "expression": {
@@ -2897,31 +615,31 @@
2897
615
  },
2898
616
  {
2899
617
  "title": "example",
2900
- "description": "del('trackedEntityInstances', 'LcRd6Nyaq7T');",
2901
- "caption": "Example`deleting` a `tracked entity instance`"
618
+ "description": "destroy('trackedEntityInstances', 'LcRd6Nyaq7T');",
619
+ "caption": "a tracked entity instance"
2902
620
  }
2903
621
  ]
2904
622
  },
2905
623
  "valid": true
2906
624
  },
2907
625
  {
2908
- "name": "upsert",
626
+ "name": "findAttributeValue",
2909
627
  "params": [
2910
- "resourceType",
2911
- "uniqueAttribute",
2912
- "data",
2913
- "params",
2914
- "options",
2915
- "callback"
628
+ "trackedEntityInstance",
629
+ "attributeDisplayName"
2916
630
  ],
2917
631
  "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.",
632
+ "description": "Gets an attribute value by its case-insensitive display name",
2919
633
  "tags": [
2920
634
  {
2921
635
  "title": "public",
2922
636
  "description": null,
2923
637
  "type": null
2924
638
  },
639
+ {
640
+ "title": "example",
641
+ "description": "findAttributeValue(state.data.trackedEntityInstances[0], 'first name')"
642
+ },
2925
643
  {
2926
644
  "title": "function",
2927
645
  "description": null,
@@ -2929,166 +647,95 @@
2929
647
  },
2930
648
  {
2931
649
  "title": "param",
2932
- "description": "The type of a resource to `insert` or `update`. E.g. `trackedEntityInstances`",
650
+ "description": "A tracked entity instance (TEI) object",
2933
651
  "type": {
2934
652
  "type": "NameExpression",
2935
- "name": "string"
653
+ "name": "Object"
2936
654
  },
2937
- "name": "resourceType"
655
+ "name": "trackedEntityInstance"
2938
656
  },
2939
657
  {
2940
658
  "title": "param",
2941
- "description": "An object containing a `attributeId` and `attributeValue` which will be used to uniquely identify the record",
659
+ "description": "The 'displayName' to search for in the TEI's attributes",
2942
660
  "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
- ]
661
+ "type": "NameExpression",
662
+ "name": "string"
2962
663
  },
2963
- "name": "uniqueAttribute"
664
+ "name": "attributeDisplayName"
2964
665
  },
2965
666
  {
2966
- "title": "param",
2967
- "description": "The update data containing new values",
667
+ "title": "returns",
668
+ "description": null,
2968
669
  "type": {
2969
670
  "type": "NameExpression",
2970
- "name": "Object"
2971
- },
2972
- "name": "data"
671
+ "name": "string"
672
+ }
673
+ }
674
+ ]
675
+ },
676
+ "valid": true
677
+ },
678
+ {
679
+ "name": "attr",
680
+ "params": [
681
+ "attribute",
682
+ "value"
683
+ ],
684
+ "docs": {
685
+ "description": "Converts an attribute ID and value into a DSHI2 attribute object",
686
+ "tags": [
687
+ {
688
+ "title": "public",
689
+ "description": null,
690
+ "type": null
2973
691
  },
2974
692
  {
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"
693
+ "title": "example",
694
+ "description": "attr('w75KJ2mc4zz', 'Elias')"
2985
695
  },
2986
696
  {
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"
697
+ "title": "function",
698
+ "description": null,
699
+ "name": null
3030
700
  },
3031
701
  {
3032
702
  "title": "param",
3033
- "description": "Optional callback to handle the response",
703
+ "description": "A tracked entity instance (TEI) attribute ID.",
3034
704
  "type": {
3035
- "type": "OptionalType",
3036
- "expression": {
3037
- "type": "NameExpression",
3038
- "name": "function"
3039
- }
705
+ "type": "NameExpression",
706
+ "name": "string"
3040
707
  },
3041
- "name": "callback"
708
+ "name": "attribute"
3042
709
  },
3043
710
  {
3044
- "title": "throws",
3045
- "description": "Throws range error",
711
+ "title": "param",
712
+ "description": "The value for that attribute.",
3046
713
  "type": {
3047
714
  "type": "NameExpression",
3048
- "name": "RangeError"
3049
- }
715
+ "name": "string"
716
+ },
717
+ "name": "value"
3050
718
  },
3051
719
  {
3052
720
  "title": "returns",
3053
721
  "description": null,
3054
722
  "type": {
3055
723
  "type": "NameExpression",
3056
- "name": "Operation"
724
+ "name": "object"
3057
725
  }
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
726
  }
3080
727
  ]
3081
728
  },
3082
729
  "valid": true
3083
730
  },
3084
731
  {
3085
- "name": "attrVal",
732
+ "name": "dv",
3086
733
  "params": [
3087
- "tei",
3088
- "attributeName"
734
+ "dataElement",
735
+ "value"
3089
736
  ],
3090
737
  "docs": {
3091
- "description": "Gets an attribute value by its case-insensitive display name",
738
+ "description": "Converts a dataElement and value into a DSHI2 dataValue object",
3092
739
  "tags": [
3093
740
  {
3094
741
  "title": "public",
@@ -3097,7 +744,7 @@
3097
744
  },
3098
745
  {
3099
746
  "title": "example",
3100
- "description": "valByName(tei.attributes, 'first name')"
747
+ "description": "dv('f7n9E0hX8qk', 12)"
3101
748
  },
3102
749
  {
3103
750
  "title": "function",
@@ -3106,28 +753,28 @@
3106
753
  },
3107
754
  {
3108
755
  "title": "param",
3109
- "description": "A tracked entity instance (TEI) object",
756
+ "description": "A data element ID.",
3110
757
  "type": {
3111
758
  "type": "NameExpression",
3112
- "name": "Object"
759
+ "name": "string"
3113
760
  },
3114
- "name": "tei"
761
+ "name": "dataElement"
3115
762
  },
3116
763
  {
3117
764
  "title": "param",
3118
- "description": "The 'displayName' to search for in the TEI's attributes",
765
+ "description": "The value for that data element.",
3119
766
  "type": {
3120
767
  "type": "NameExpression",
3121
768
  "name": "string"
3122
769
  },
3123
- "name": "attributeName"
770
+ "name": "value"
3124
771
  },
3125
772
  {
3126
773
  "title": "returns",
3127
774
  "description": null,
3128
775
  "type": {
3129
776
  "type": "NameExpression",
3130
- "name": "string"
777
+ "name": "object"
3131
778
  }
3132
779
  }
3133
780
  ]