@openfn/language-dhis2 3.0.0-2 → 3.0.0-3
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.
- package/ast.json +99 -41
- package/lib/Adaptor.js +68 -47
- package/package.json +1 -1
package/ast.json
CHANGED
|
@@ -74,57 +74,57 @@
|
|
|
74
74
|
{
|
|
75
75
|
"title": "example",
|
|
76
76
|
"description": "create('programs', {\n name: 'name 20',\n shortName: 'n20',\n programType: 'WITHOUT_REGISTRATION',\n});",
|
|
77
|
-
"caption": "
|
|
77
|
+
"caption": "a program"
|
|
78
78
|
},
|
|
79
79
|
{
|
|
80
80
|
"title": "example",
|
|
81
81
|
"description": "create('events', {\n program: 'eBAyeGv0exc',\n orgUnit: 'DiszpKrYNg8',\n status: 'COMPLETED',\n});",
|
|
82
|
-
"caption": "
|
|
82
|
+
"caption": "an event"
|
|
83
83
|
},
|
|
84
84
|
{
|
|
85
85
|
"title": "example",
|
|
86
86
|
"description": "create('trackedEntityInstances', {\n orgUnit: 'TSyzvBiovKh',\n trackedEntityType: 'nEenWmSyUEp',\n attributes: [\n {\n attribute: 'w75KJ2mc4zz',\n value: 'Gigiwe',\n },\n ]\n});",
|
|
87
|
-
"caption": "
|
|
87
|
+
"caption": "a trackedEntityInstance"
|
|
88
88
|
},
|
|
89
89
|
{
|
|
90
90
|
"title": "example",
|
|
91
91
|
"description": "create('dataSets', { name: 'OpenFn Data Set', periodType: 'Monthly' });",
|
|
92
|
-
"caption": "
|
|
92
|
+
"caption": "a dataSet"
|
|
93
93
|
},
|
|
94
94
|
{
|
|
95
95
|
"title": "example",
|
|
96
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": "
|
|
97
|
+
"caption": "a dataSetNotification"
|
|
98
98
|
},
|
|
99
99
|
{
|
|
100
100
|
"title": "example",
|
|
101
101
|
"description": "create('dataElements', {\n aggregationType: 'SUM',\n domainType: 'AGGREGATE',\n valueType: 'NUMBER',\n name: 'Paracetamol',\n shortName: 'Para',\n});",
|
|
102
|
-
"caption": "
|
|
102
|
+
"caption": "a dataElement"
|
|
103
103
|
},
|
|
104
104
|
{
|
|
105
105
|
"title": "example",
|
|
106
106
|
"description": "create('dataElementGroups', {\n name: 'Data Element Group 1',\n dataElements: [],\n});",
|
|
107
|
-
"caption": "
|
|
107
|
+
"caption": "a dataElementGroup"
|
|
108
108
|
},
|
|
109
109
|
{
|
|
110
110
|
"title": "example",
|
|
111
111
|
"description": "create('dataElementGroupSets', {\n name: 'Data Element Group Set 4',\n dataDimension: true,\n shortName: 'DEGS4',\n dataElementGroups: [],\n});",
|
|
112
|
-
"caption": "
|
|
112
|
+
"caption": "a dataElementGroupSet"
|
|
113
113
|
},
|
|
114
114
|
{
|
|
115
115
|
"title": "example",
|
|
116
116
|
"description": "create('dataValueSets', {\n dataElement: 'f7n9E0hX8qk',\n period: '201401',\n orgUnit: 'DiszpKrYNg8',\n value: '12',\n});",
|
|
117
|
-
"caption": "
|
|
117
|
+
"caption": "a dataValueSet"
|
|
118
118
|
},
|
|
119
119
|
{
|
|
120
120
|
"title": "example",
|
|
121
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": "
|
|
122
|
+
"caption": "a dataValueSet with related dataValues"
|
|
123
123
|
},
|
|
124
124
|
{
|
|
125
125
|
"title": "example",
|
|
126
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": "
|
|
127
|
+
"caption": "an enrollment"
|
|
128
128
|
}
|
|
129
129
|
]
|
|
130
130
|
},
|
|
@@ -214,52 +214,52 @@
|
|
|
214
214
|
{
|
|
215
215
|
"title": "example",
|
|
216
216
|
"description": "update('programs', 'qAZJCrNJK8H', {\n name: '14e1aa02c3f0a31618e096f2c6d03bed',\n shortName: '14e1aa02',\n programType: 'WITHOUT_REGISTRATION',\n});",
|
|
217
|
-
"caption": "
|
|
217
|
+
"caption": "a program"
|
|
218
218
|
},
|
|
219
219
|
{
|
|
220
220
|
"title": "example",
|
|
221
221
|
"description": "update('events', 'PVqUD2hvU4E', {\n program: 'eBAyeGv0exc',\n orgUnit: 'Ngelehun CHC',\n status: 'COMPLETED',\n storedBy: 'admin',\n dataValues: [],\n});",
|
|
222
|
-
"caption": "an
|
|
222
|
+
"caption": "an event"
|
|
223
223
|
},
|
|
224
224
|
{
|
|
225
225
|
"title": "example",
|
|
226
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
|
|
227
|
+
"caption": "a trackedEntityInstance"
|
|
228
228
|
},
|
|
229
229
|
{
|
|
230
230
|
"title": "example",
|
|
231
231
|
"description": "update('dataSets', 'lyLU2wR22tC', { name: 'OpenFN Data Set', periodType: 'Weekly' });",
|
|
232
|
-
"caption": "
|
|
232
|
+
"caption": "a dataSet"
|
|
233
233
|
},
|
|
234
234
|
{
|
|
235
235
|
"title": "example",
|
|
236
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": "
|
|
237
|
+
"caption": "a dataSetNotification"
|
|
238
238
|
},
|
|
239
239
|
{
|
|
240
240
|
"title": "example",
|
|
241
241
|
"description": "update('dataElements', 'FTRrcoaog83', {\n aggregationType: 'SUM',\n domainType: 'AGGREGATE',\n valueType: 'NUMBER',\n name: 'Paracetamol',\n shortName: 'Para',\n});",
|
|
242
|
-
"caption": "
|
|
242
|
+
"caption": "a dataElement"
|
|
243
243
|
},
|
|
244
244
|
{
|
|
245
245
|
"title": "example",
|
|
246
246
|
"description": "update('dataElementGroups', 'QrprHT61XFk', {\n name: 'Data Element Group 1',\n dataElements: [],\n});",
|
|
247
|
-
"caption": "
|
|
247
|
+
"caption": "a dataElementGroup"
|
|
248
248
|
},
|
|
249
249
|
{
|
|
250
250
|
"title": "example",
|
|
251
251
|
"description": "update('dataElementGroupSets', 'VxWloRvAze8', {\n name: 'Data Element Group Set 4',\n dataDimension: true,\n shortName: 'DEGS4',\n dataElementGroups: [],\n});",
|
|
252
|
-
"caption": "
|
|
252
|
+
"caption": "a dataElementGroupSet"
|
|
253
253
|
},
|
|
254
254
|
{
|
|
255
255
|
"title": "example",
|
|
256
256
|
"description": "update('dataValueSets', 'AsQj6cDsUq4', {\n dataElement: 'f7n9E0hX8qk',\n period: '201401',\n orgUnit: 'DiszpKrYNg8',\n value: '12',\n});",
|
|
257
|
-
"caption": "
|
|
257
|
+
"caption": "a dataValueSet"
|
|
258
258
|
},
|
|
259
259
|
{
|
|
260
260
|
"title": "example",
|
|
261
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": "
|
|
262
|
+
"caption": "a dataValueSet with related dataValues"
|
|
263
263
|
},
|
|
264
264
|
{
|
|
265
265
|
"title": "example",
|
|
@@ -344,12 +344,17 @@
|
|
|
344
344
|
{
|
|
345
345
|
"title": "example",
|
|
346
346
|
"description": "get('dataValueSets', {\n dataSet: 'pBOMPrpg1QX',\n orgUnit: 'DiszpKrYNg8',\n period: '201401',\n fields: '*',\n});",
|
|
347
|
-
"caption": "
|
|
347
|
+
"caption": "all data values for the 'pBOMPrpg1QX' dataset"
|
|
348
348
|
},
|
|
349
349
|
{
|
|
350
350
|
"title": "example",
|
|
351
351
|
"description": "get('programs', { orgUnit: 'TSyzvBiovKh', fields: '*' });",
|
|
352
|
-
"caption": "
|
|
352
|
+
"caption": "all programs for an organization unit"
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
"title": "example",
|
|
356
|
+
"description": "get('trackedEntityInstances', {\n ou: 'DiszpKrYNg8',\n filters: ['flGbXLXCrEo:Eq:124'],\n});",
|
|
357
|
+
"caption": "a single tracked entity instance by a unique external ID"
|
|
353
358
|
}
|
|
354
359
|
]
|
|
355
360
|
},
|
|
@@ -403,7 +408,7 @@
|
|
|
403
408
|
{
|
|
404
409
|
"title": "example",
|
|
405
410
|
"description": "discover('post', '/trackedEntityInstances')",
|
|
406
|
-
"caption": "
|
|
411
|
+
"caption": "a list of parameters allowed on a given endpoint for specific http method"
|
|
407
412
|
}
|
|
408
413
|
]
|
|
409
414
|
},
|
|
@@ -530,15 +535,15 @@
|
|
|
530
535
|
},
|
|
531
536
|
{
|
|
532
537
|
"title": "example",
|
|
533
|
-
"description": "patch('dataElements', 'FTRrcoaog83'
|
|
534
|
-
"caption": "
|
|
538
|
+
"description": "patch('dataElements', 'FTRrcoaog83', { name: 'New Name' });",
|
|
539
|
+
"caption": "a dataElement"
|
|
535
540
|
}
|
|
536
541
|
]
|
|
537
542
|
},
|
|
538
543
|
"valid": true
|
|
539
544
|
},
|
|
540
545
|
{
|
|
541
|
-
"name": "
|
|
546
|
+
"name": "destroy",
|
|
542
547
|
"params": [
|
|
543
548
|
"resourceType",
|
|
544
549
|
"path",
|
|
@@ -661,18 +666,18 @@
|
|
|
661
666
|
},
|
|
662
667
|
{
|
|
663
668
|
"title": "example",
|
|
664
|
-
"description": "
|
|
665
|
-
"caption": "
|
|
669
|
+
"description": "destroy('trackedEntityInstances', 'LcRd6Nyaq7T');",
|
|
670
|
+
"caption": "a tracked entity instance"
|
|
666
671
|
}
|
|
667
672
|
]
|
|
668
673
|
},
|
|
669
674
|
"valid": true
|
|
670
675
|
},
|
|
671
676
|
{
|
|
672
|
-
"name": "
|
|
677
|
+
"name": "findAttributeValue",
|
|
673
678
|
"params": [
|
|
674
|
-
"
|
|
675
|
-
"
|
|
679
|
+
"trackedEntityInstance",
|
|
680
|
+
"attributeDisplayName"
|
|
676
681
|
],
|
|
677
682
|
"docs": {
|
|
678
683
|
"description": "Gets an attribute value by its case-insensitive display name",
|
|
@@ -684,7 +689,7 @@
|
|
|
684
689
|
},
|
|
685
690
|
{
|
|
686
691
|
"title": "example",
|
|
687
|
-
"description": "
|
|
692
|
+
"description": "findAttributeValue(state.data.trackedEntityInstances[0], 'first name')"
|
|
688
693
|
},
|
|
689
694
|
{
|
|
690
695
|
"title": "function",
|
|
@@ -698,7 +703,7 @@
|
|
|
698
703
|
"type": "NameExpression",
|
|
699
704
|
"name": "Object"
|
|
700
705
|
},
|
|
701
|
-
"name": "
|
|
706
|
+
"name": "trackedEntityInstance"
|
|
702
707
|
},
|
|
703
708
|
{
|
|
704
709
|
"title": "param",
|
|
@@ -707,7 +712,7 @@
|
|
|
707
712
|
"type": "NameExpression",
|
|
708
713
|
"name": "string"
|
|
709
714
|
},
|
|
710
|
-
"name": "
|
|
715
|
+
"name": "attributeDisplayName"
|
|
711
716
|
},
|
|
712
717
|
{
|
|
713
718
|
"title": "returns",
|
|
@@ -722,10 +727,10 @@
|
|
|
722
727
|
"valid": true
|
|
723
728
|
},
|
|
724
729
|
{
|
|
725
|
-
"name": "
|
|
730
|
+
"name": "attr",
|
|
726
731
|
"params": [
|
|
727
|
-
"
|
|
728
|
-
"
|
|
732
|
+
"attribute",
|
|
733
|
+
"value"
|
|
729
734
|
],
|
|
730
735
|
"docs": {
|
|
731
736
|
"description": "Converts an attribute ID and value into a DSHI2 attribute object",
|
|
@@ -737,7 +742,7 @@
|
|
|
737
742
|
},
|
|
738
743
|
{
|
|
739
744
|
"title": "example",
|
|
740
|
-
"description": "
|
|
745
|
+
"description": "attr('w75KJ2mc4zz', 'Elias')"
|
|
741
746
|
},
|
|
742
747
|
{
|
|
743
748
|
"title": "function",
|
|
@@ -751,7 +756,7 @@
|
|
|
751
756
|
"type": "NameExpression",
|
|
752
757
|
"name": "string"
|
|
753
758
|
},
|
|
754
|
-
"name": "
|
|
759
|
+
"name": "attribute"
|
|
755
760
|
},
|
|
756
761
|
{
|
|
757
762
|
"title": "param",
|
|
@@ -760,7 +765,60 @@
|
|
|
760
765
|
"type": "NameExpression",
|
|
761
766
|
"name": "string"
|
|
762
767
|
},
|
|
763
|
-
"name": "
|
|
768
|
+
"name": "value"
|
|
769
|
+
},
|
|
770
|
+
{
|
|
771
|
+
"title": "returns",
|
|
772
|
+
"description": null,
|
|
773
|
+
"type": {
|
|
774
|
+
"type": "NameExpression",
|
|
775
|
+
"name": "object"
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
]
|
|
779
|
+
},
|
|
780
|
+
"valid": true
|
|
781
|
+
},
|
|
782
|
+
{
|
|
783
|
+
"name": "dv",
|
|
784
|
+
"params": [
|
|
785
|
+
"dataElement",
|
|
786
|
+
"value"
|
|
787
|
+
],
|
|
788
|
+
"docs": {
|
|
789
|
+
"description": "Converts a dataElement and value into a DSHI2 dataValue object",
|
|
790
|
+
"tags": [
|
|
791
|
+
{
|
|
792
|
+
"title": "public",
|
|
793
|
+
"description": null,
|
|
794
|
+
"type": null
|
|
795
|
+
},
|
|
796
|
+
{
|
|
797
|
+
"title": "example",
|
|
798
|
+
"description": "dv('f7n9E0hX8qk', 12)"
|
|
799
|
+
},
|
|
800
|
+
{
|
|
801
|
+
"title": "function",
|
|
802
|
+
"description": null,
|
|
803
|
+
"name": null
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
"title": "param",
|
|
807
|
+
"description": "A data element ID.",
|
|
808
|
+
"type": {
|
|
809
|
+
"type": "NameExpression",
|
|
810
|
+
"name": "string"
|
|
811
|
+
},
|
|
812
|
+
"name": "dataElement"
|
|
813
|
+
},
|
|
814
|
+
{
|
|
815
|
+
"title": "param",
|
|
816
|
+
"description": "The value for that data element.",
|
|
817
|
+
"type": {
|
|
818
|
+
"type": "NameExpression",
|
|
819
|
+
"name": "string"
|
|
820
|
+
},
|
|
821
|
+
"name": "value"
|
|
764
822
|
},
|
|
765
823
|
{
|
|
766
824
|
"title": "returns",
|
package/lib/Adaptor.js
CHANGED
|
@@ -9,9 +9,10 @@ exports.update = update;
|
|
|
9
9
|
exports.get = get;
|
|
10
10
|
exports.discover = discover;
|
|
11
11
|
exports.patch = patch;
|
|
12
|
-
exports.
|
|
13
|
-
exports.
|
|
14
|
-
exports.
|
|
12
|
+
exports.destroy = destroy;
|
|
13
|
+
exports.findAttributeValue = findAttributeValue;
|
|
14
|
+
exports.attr = attr;
|
|
15
|
+
exports.dv = dv;
|
|
15
16
|
Object.defineProperty(exports, "field", {
|
|
16
17
|
enumerable: true,
|
|
17
18
|
get: function () {
|
|
@@ -201,19 +202,19 @@ _axios.default.interceptors.response.use(function (response) {
|
|
|
201
202
|
* @param {Object} [options] - Optional `options` to define URL parameters (E.g. `filters`, `dimensions` and `import parameters`), axios configurations (E.g. `auth`) and DHIS 2 api version to use.
|
|
202
203
|
* @param {function} [callback] - Optional callback to handle the response
|
|
203
204
|
* @returns {Operation}
|
|
204
|
-
* @example <caption
|
|
205
|
+
* @example <caption>a program</caption>
|
|
205
206
|
* create('programs', {
|
|
206
207
|
* name: 'name 20',
|
|
207
208
|
* shortName: 'n20',
|
|
208
209
|
* programType: 'WITHOUT_REGISTRATION',
|
|
209
210
|
* });
|
|
210
|
-
* @example <caption
|
|
211
|
+
* @example <caption>an event</caption>
|
|
211
212
|
* create('events', {
|
|
212
213
|
* program: 'eBAyeGv0exc',
|
|
213
214
|
* orgUnit: 'DiszpKrYNg8',
|
|
214
215
|
* status: 'COMPLETED',
|
|
215
216
|
* });
|
|
216
|
-
* @example <caption
|
|
217
|
+
* @example <caption>a trackedEntityInstance</caption>
|
|
217
218
|
* create('trackedEntityInstances', {
|
|
218
219
|
* orgUnit: 'TSyzvBiovKh',
|
|
219
220
|
* trackedEntityType: 'nEenWmSyUEp',
|
|
@@ -224,9 +225,9 @@ _axios.default.interceptors.response.use(function (response) {
|
|
|
224
225
|
* },
|
|
225
226
|
* ]
|
|
226
227
|
* });
|
|
227
|
-
* @example <caption
|
|
228
|
+
* @example <caption>a dataSet</caption>
|
|
228
229
|
* create('dataSets', { name: 'OpenFn Data Set', periodType: 'Monthly' });
|
|
229
|
-
* @example <caption
|
|
230
|
+
* @example <caption>a dataSetNotification</caption>
|
|
230
231
|
* create('dataSetNotificationTemplates', {
|
|
231
232
|
* dataSetNotificationTrigger: 'DATA_SET_COMPLETION',
|
|
232
233
|
* notificationRecipient: 'ORGANISATION_UNIT_CONTACT',
|
|
@@ -235,7 +236,7 @@ _axios.default.interceptors.response.use(function (response) {
|
|
|
235
236
|
* deliveryChannels: ['SMS'],
|
|
236
237
|
* dataSets: [],
|
|
237
238
|
* });
|
|
238
|
-
* @example <caption
|
|
239
|
+
* @example <caption>a dataElement</caption>
|
|
239
240
|
* create('dataElements', {
|
|
240
241
|
* aggregationType: 'SUM',
|
|
241
242
|
* domainType: 'AGGREGATE',
|
|
@@ -243,26 +244,26 @@ _axios.default.interceptors.response.use(function (response) {
|
|
|
243
244
|
* name: 'Paracetamol',
|
|
244
245
|
* shortName: 'Para',
|
|
245
246
|
* });
|
|
246
|
-
* @example <caption
|
|
247
|
+
* @example <caption>a dataElementGroup</caption>
|
|
247
248
|
* create('dataElementGroups', {
|
|
248
249
|
* name: 'Data Element Group 1',
|
|
249
250
|
* dataElements: [],
|
|
250
251
|
* });
|
|
251
|
-
* @example <caption
|
|
252
|
+
* @example <caption>a dataElementGroupSet</caption>
|
|
252
253
|
* create('dataElementGroupSets', {
|
|
253
254
|
* name: 'Data Element Group Set 4',
|
|
254
255
|
* dataDimension: true,
|
|
255
256
|
* shortName: 'DEGS4',
|
|
256
257
|
* dataElementGroups: [],
|
|
257
258
|
* });
|
|
258
|
-
* @example <caption
|
|
259
|
+
* @example <caption>a dataValueSet</caption>
|
|
259
260
|
* create('dataValueSets', {
|
|
260
261
|
* dataElement: 'f7n9E0hX8qk',
|
|
261
262
|
* period: '201401',
|
|
262
263
|
* orgUnit: 'DiszpKrYNg8',
|
|
263
264
|
* value: '12',
|
|
264
265
|
* });
|
|
265
|
-
* @example <caption
|
|
266
|
+
* @example <caption>a dataValueSet with related dataValues</caption>
|
|
266
267
|
* create('dataValueSets', {
|
|
267
268
|
* dataSet: 'pBOMPrpg1QX',
|
|
268
269
|
* completeDate: '2014-02-03',
|
|
@@ -283,7 +284,7 @@ _axios.default.interceptors.response.use(function (response) {
|
|
|
283
284
|
* },
|
|
284
285
|
* ],
|
|
285
286
|
* });
|
|
286
|
-
* @example <caption
|
|
287
|
+
* @example <caption>an enrollment</caption>
|
|
287
288
|
* create('enrollments', {
|
|
288
289
|
* trackedEntityInstance: 'bmshzEacgxa',
|
|
289
290
|
* orgUnit: 'TSyzvBiovKh',
|
|
@@ -331,13 +332,13 @@ function create(resourceType, data, options, callback) {
|
|
|
331
332
|
* @param {Object} [options] - Optional `options` to define URL parameters (E.g. `filters`, `dimensions` and `import parameters`), axios configurations (E.g. `auth`) and DHIS 2 api version to use.
|
|
332
333
|
* @param {function} [callback] - Optional callback to handle the response
|
|
333
334
|
* @returns {Operation}
|
|
334
|
-
* @example <caption
|
|
335
|
+
* @example <caption>a program</caption>
|
|
335
336
|
* update('programs', 'qAZJCrNJK8H', {
|
|
336
337
|
* name: '14e1aa02c3f0a31618e096f2c6d03bed',
|
|
337
338
|
* shortName: '14e1aa02',
|
|
338
339
|
* programType: 'WITHOUT_REGISTRATION',
|
|
339
340
|
* });
|
|
340
|
-
* @example <caption>an
|
|
341
|
+
* @example <caption>an event</caption>
|
|
341
342
|
* update('events', 'PVqUD2hvU4E', {
|
|
342
343
|
* program: 'eBAyeGv0exc',
|
|
343
344
|
* orgUnit: 'Ngelehun CHC',
|
|
@@ -345,7 +346,7 @@ function create(resourceType, data, options, callback) {
|
|
|
345
346
|
* storedBy: 'admin',
|
|
346
347
|
* dataValues: [],
|
|
347
348
|
* });
|
|
348
|
-
* @example <caption>a
|
|
349
|
+
* @example <caption>a trackedEntityInstance</caption>
|
|
349
350
|
* update('trackedEntityInstances', 'IeQfgUtGPq2', {
|
|
350
351
|
* created: '2015-08-06T21:12:37.256',
|
|
351
352
|
* orgUnit: 'TSyzvBiovKh',
|
|
@@ -385,9 +386,9 @@ function create(resourceType, data, options, callback) {
|
|
|
385
386
|
* },
|
|
386
387
|
* ],
|
|
387
388
|
* });
|
|
388
|
-
* @example <caption
|
|
389
|
+
* @example <caption>a dataSet</caption>
|
|
389
390
|
* update('dataSets', 'lyLU2wR22tC', { name: 'OpenFN Data Set', periodType: 'Weekly' });
|
|
390
|
-
* @example <caption
|
|
391
|
+
* @example <caption>a dataSetNotification</caption>
|
|
391
392
|
* update('dataSetNotificationTemplates', 'VbQBwdm1wVP', {
|
|
392
393
|
* dataSetNotificationTrigger: 'DATA_SET_COMPLETION',
|
|
393
394
|
* notificationRecipient: 'ORGANISATION_UNIT_CONTACT',
|
|
@@ -396,7 +397,7 @@ function create(resourceType, data, options, callback) {
|
|
|
396
397
|
* deliveryChannels: ['SMS'],
|
|
397
398
|
* dataSets: [],
|
|
398
399
|
* });
|
|
399
|
-
* @example <caption
|
|
400
|
+
* @example <caption>a dataElement</caption>
|
|
400
401
|
* update('dataElements', 'FTRrcoaog83', {
|
|
401
402
|
* aggregationType: 'SUM',
|
|
402
403
|
* domainType: 'AGGREGATE',
|
|
@@ -404,26 +405,26 @@ function create(resourceType, data, options, callback) {
|
|
|
404
405
|
* name: 'Paracetamol',
|
|
405
406
|
* shortName: 'Para',
|
|
406
407
|
* });
|
|
407
|
-
* @example <caption
|
|
408
|
+
* @example <caption>a dataElementGroup</caption>
|
|
408
409
|
* update('dataElementGroups', 'QrprHT61XFk', {
|
|
409
410
|
* name: 'Data Element Group 1',
|
|
410
411
|
* dataElements: [],
|
|
411
412
|
* });
|
|
412
|
-
* @example <caption
|
|
413
|
+
* @example <caption>a dataElementGroupSet</caption>
|
|
413
414
|
* update('dataElementGroupSets', 'VxWloRvAze8', {
|
|
414
415
|
* name: 'Data Element Group Set 4',
|
|
415
416
|
* dataDimension: true,
|
|
416
417
|
* shortName: 'DEGS4',
|
|
417
418
|
* dataElementGroups: [],
|
|
418
419
|
* });
|
|
419
|
-
* @example <caption
|
|
420
|
+
* @example <caption>a dataValueSet</caption>
|
|
420
421
|
* update('dataValueSets', 'AsQj6cDsUq4', {
|
|
421
422
|
* dataElement: 'f7n9E0hX8qk',
|
|
422
423
|
* period: '201401',
|
|
423
424
|
* orgUnit: 'DiszpKrYNg8',
|
|
424
425
|
* value: '12',
|
|
425
426
|
* });
|
|
426
|
-
* @example <caption
|
|
427
|
+
* @example <caption>a dataValueSet with related dataValues</caption>
|
|
427
428
|
* update('dataValueSets', 'Ix2HsbDMLea', {
|
|
428
429
|
* dataSet: 'pBOMPrpg1QX',
|
|
429
430
|
* completeDate: '2014-02-03',
|
|
@@ -492,15 +493,20 @@ function update(resourceType, path, data, options, callback) {
|
|
|
492
493
|
* @param {Object} [options] - Optional `options` to define URL parameters beyond filters, request configuration (e.g. `auth`) and DHIS2 api version to use.
|
|
493
494
|
* @param {function} [callback] - Optional callback to handle the response
|
|
494
495
|
* @returns {Operation} state
|
|
495
|
-
* @example <caption>
|
|
496
|
+
* @example <caption>all data values for the 'pBOMPrpg1QX' dataset</caption>
|
|
496
497
|
* get('dataValueSets', {
|
|
497
498
|
* dataSet: 'pBOMPrpg1QX',
|
|
498
499
|
* orgUnit: 'DiszpKrYNg8',
|
|
499
500
|
* period: '201401',
|
|
500
501
|
* fields: '*',
|
|
501
502
|
* });
|
|
502
|
-
* @example <caption>
|
|
503
|
+
* @example <caption>all programs for an organization unit</caption>
|
|
503
504
|
* get('programs', { orgUnit: 'TSyzvBiovKh', fields: '*' });
|
|
505
|
+
* @example <caption>a single tracked entity instance by a unique external ID</caption>
|
|
506
|
+
* get('trackedEntityInstances', {
|
|
507
|
+
* ou: 'DiszpKrYNg8',
|
|
508
|
+
* filters: ['flGbXLXCrEo:Eq:124'],
|
|
509
|
+
* });
|
|
504
510
|
*/
|
|
505
511
|
|
|
506
512
|
|
|
@@ -587,7 +593,7 @@ function get(resourceType, filters, options, callback) {
|
|
|
587
593
|
* @param {string} httpMethod - The HTTP to inspect parameter usage for a given endpoint, e.g., `get`, `post`,`put`,`patch`,`delete`
|
|
588
594
|
* @param {string} endpoint - The path for a given endpoint. E.g. `/trackedEntityInstances` or `/dataValueSets`
|
|
589
595
|
* @returns {Operation}
|
|
590
|
-
* @example <caption>
|
|
596
|
+
* @example <caption>a list of parameters allowed on a given endpoint for specific http method</caption>
|
|
591
597
|
* discover('post', '/trackedEntityInstances')
|
|
592
598
|
*/
|
|
593
599
|
|
|
@@ -650,11 +656,8 @@ function discover(httpMethod, endpoint) {
|
|
|
650
656
|
* @param {{apiVersion: number,operationName: string,responseType: string}} [options] - Optional options for update method. Defaults to `{operationName: 'patch', apiVersion: state.configuration.apiVersion, responseType: 'json'}`
|
|
651
657
|
* @param {function} [callback] - Optional callback to handle the response
|
|
652
658
|
* @returns {Operation}
|
|
653
|
-
* @example <caption>
|
|
654
|
-
* patch('dataElements', 'FTRrcoaog83',
|
|
655
|
-
* {
|
|
656
|
-
* name: 'New Name',
|
|
657
|
-
* });
|
|
659
|
+
* @example <caption>a dataElement</caption>
|
|
660
|
+
* patch('dataElements', 'FTRrcoaog83', { name: 'New Name' });
|
|
658
661
|
*/
|
|
659
662
|
// TODO: @Elias, can this be deleted in favor of update? How does DHIS2 handle PATCH vs PUT?
|
|
660
663
|
// I need to investigate on this. But I think DHIS 2 forces to send all properties back when we do an update. If that's confirmed then this may be needed.
|
|
@@ -720,13 +723,13 @@ function patch(resourceType, path, data, params, options, callback) {
|
|
|
720
723
|
* @param {{apiVersion: number,operationName: string,resourceType: string}} [options] - Optional `options` for `del` operation. Defaults to `{operationName: 'delete', apiVersion: state.configuration.apiVersion, responseType: 'json'}`
|
|
721
724
|
* @param {function} [callback] - Optional callback to handle the response
|
|
722
725
|
* @returns {Operation}
|
|
723
|
-
* @example <caption>
|
|
724
|
-
*
|
|
726
|
+
* @example <caption>a tracked entity instance</caption>
|
|
727
|
+
* destroy('trackedEntityInstances', 'LcRd6Nyaq7T');
|
|
725
728
|
*/
|
|
726
729
|
// TODO: @Elias, can this be implemented using the same pattern as update but without data?
|
|
727
730
|
|
|
728
731
|
|
|
729
|
-
function
|
|
732
|
+
function destroy(resourceType, path, data, params, options, callback) {
|
|
730
733
|
return state => {
|
|
731
734
|
var _options$operationNam2, _options4, _options$responseType2, _options5, _queryParams3, _queryParams4, _options$apiVersion2, _options6, _CONTENT_TYPES$respon2;
|
|
732
735
|
|
|
@@ -774,34 +777,52 @@ function del(resourceType, path, data, params, options, callback) {
|
|
|
774
777
|
* Gets an attribute value by its case-insensitive display name
|
|
775
778
|
* @public
|
|
776
779
|
* @example
|
|
777
|
-
*
|
|
780
|
+
* findAttributeValue(state.data.trackedEntityInstances[0], 'first name')
|
|
778
781
|
* @function
|
|
779
|
-
* @param {Object}
|
|
780
|
-
* @param {string}
|
|
782
|
+
* @param {Object} trackedEntityInstance - A tracked entity instance (TEI) object
|
|
783
|
+
* @param {string} attributeDisplayName - The 'displayName' to search for in the TEI's attributes
|
|
781
784
|
* @returns {string}
|
|
782
785
|
*/
|
|
783
786
|
|
|
784
787
|
|
|
785
|
-
function
|
|
786
|
-
var
|
|
788
|
+
function findAttributeValue(trackedEntityInstance, attributeDisplayName) {
|
|
789
|
+
var _trackedEntityInstanc, _trackedEntityInstanc2;
|
|
787
790
|
|
|
788
|
-
return
|
|
791
|
+
return trackedEntityInstance === null || trackedEntityInstance === void 0 ? void 0 : (_trackedEntityInstanc = trackedEntityInstance.attributes) === null || _trackedEntityInstanc === void 0 ? void 0 : (_trackedEntityInstanc2 = _trackedEntityInstanc.find(a => (a === null || a === void 0 ? void 0 : a.displayName.toLowerCase()) == attributeDisplayName.toLowerCase())) === null || _trackedEntityInstanc2 === void 0 ? void 0 : _trackedEntityInstanc2.value;
|
|
789
792
|
}
|
|
790
793
|
/**
|
|
791
794
|
* Converts an attribute ID and value into a DSHI2 attribute object
|
|
792
795
|
* @public
|
|
793
796
|
* @example
|
|
794
|
-
*
|
|
797
|
+
* attr('w75KJ2mc4zz', 'Elias')
|
|
798
|
+
* @function
|
|
799
|
+
* @param {string} attribute - A tracked entity instance (TEI) attribute ID.
|
|
800
|
+
* @param {string} value - The value for that attribute.
|
|
801
|
+
* @returns {object}
|
|
802
|
+
*/
|
|
803
|
+
|
|
804
|
+
|
|
805
|
+
function attr(attribute, value) {
|
|
806
|
+
return {
|
|
807
|
+
attribute,
|
|
808
|
+
value
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
/**
|
|
812
|
+
* Converts a dataElement and value into a DSHI2 dataValue object
|
|
813
|
+
* @public
|
|
814
|
+
* @example
|
|
815
|
+
* dv('f7n9E0hX8qk', 12)
|
|
795
816
|
* @function
|
|
796
|
-
* @param {string}
|
|
797
|
-
* @param {string}
|
|
817
|
+
* @param {string} dataElement - A data element ID.
|
|
818
|
+
* @param {string} value - The value for that data element.
|
|
798
819
|
* @returns {object}
|
|
799
820
|
*/
|
|
800
821
|
|
|
801
822
|
|
|
802
|
-
function
|
|
823
|
+
function dv(dataElement, value) {
|
|
803
824
|
return {
|
|
804
|
-
|
|
805
|
-
value
|
|
825
|
+
dataElement,
|
|
826
|
+
value
|
|
806
827
|
};
|
|
807
828
|
}
|