@openfn/language-dhis2 6.0.1 → 6.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/README.md +86 -73
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,98 +1,107 @@
|
|
|
1
1
|
# Language DHIS2
|
|
2
2
|
|
|
3
|
-
An OpenFn language
|
|
4
|
-
|
|
5
|
-
[
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
An OpenFn language pack for building expressions and operations to work with the
|
|
4
|
+
[DHIS2 API](https://docs.dhis2.org/en/home.html). Commonly used via
|
|
5
|
+
[OpenFn.org](https://app.openfn.org) or manually with
|
|
6
|
+
[OpenFn CLI](https://github.com/OpenFn/kit).
|
|
7
|
+
|
|
8
|
+
## Table of Contents
|
|
9
|
+
|
|
10
|
+
1. [Getting Started](#getting-started)
|
|
11
|
+
2. [Important Note](#important-note)
|
|
12
|
+
3. [Configuration](#configuration)
|
|
13
|
+
4. [Helper Functions](#helper-functions)
|
|
14
|
+
5. [Development](#development)
|
|
15
|
+
- [Running Tests](#running-tests)
|
|
16
|
+
- [Unit Tests](#unit-tests)
|
|
17
|
+
- [Integration Tests](#integration-tests)
|
|
18
|
+
- [Troubleshooting Tests](#troubleshooting-tests)
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Getting Started
|
|
23
|
+
|
|
24
|
+
To use this package, execute commands via OpenFn/core from the root of the
|
|
25
|
+
repository:
|
|
8
26
|
|
|
9
27
|
```sh
|
|
10
|
-
|
|
11
|
-
-l ../language-dhis2 \
|
|
12
|
-
-e ./tmp/expression.js \
|
|
13
|
-
-s ./tmp/state.json \
|
|
14
|
-
-o ./tmp/output.json
|
|
28
|
+
openfn job.js -a dhis2 -s tmp/state.json
|
|
15
29
|
```
|
|
16
30
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
> API versions before 42 (2.42). For later API versions and the new tracker, use
|
|
20
|
-
> adaptor 6.0+. See
|
|
21
|
-
> [DHIS2 documentation](https://docs.dhis2.org/en/develop/using-the-api/dhis-core-version-master/tracker.html)
|
|
22
|
-
> for more information.
|
|
31
|
+
For installation and usage, see the
|
|
32
|
+
[docs site](https://docs.openfn.org/adaptors/packages/dhis2-docs).
|
|
23
33
|
|
|
24
|
-
|
|
34
|
+
---
|
|
25
35
|
|
|
26
|
-
|
|
27
|
-
full technical documentation.
|
|
36
|
+
## Important Note
|
|
28
37
|
|
|
29
|
-
|
|
30
|
-
the
|
|
31
|
-
[
|
|
32
|
-
|
|
38
|
+
- For DHIS2 API versions 2.42+ and the **new tracker**, use **adaptor 6.0+**.
|
|
39
|
+
Refer to the
|
|
40
|
+
[DHIS2 API documentation](https://docs.dhis2.org/en/develop/using-the-api/dhis-core-version-master/tracker.html)
|
|
41
|
+
for details.
|
|
42
|
+
- For **old tracker versions** and DHIS2 API versions **prior to 2.42**, use
|
|
43
|
+
**adaptor 5.0+**. But we highly recommend upgrading to the latest version.
|
|
33
44
|
|
|
34
|
-
|
|
45
|
+
---
|
|
35
46
|
|
|
36
|
-
|
|
37
|
-
official
|
|
38
|
-
[configuration-schema](https://docs.openfn.org/adaptors/packages/dhis2-configuration-schema/)
|
|
39
|
-
definition.
|
|
47
|
+
## Configuration
|
|
40
48
|
|
|
41
|
-
|
|
49
|
+
All required and optional properties for `state.configuration` are defined in
|
|
50
|
+
the official
|
|
51
|
+
[configuration-schema](https://docs.openfn.org/adaptors/packages/dhis2-configuration-schema/).
|
|
42
52
|
|
|
43
|
-
|
|
44
|
-
also contain integration tests which can be run with
|
|
45
|
-
`pnpm run integration-test`.)
|
|
53
|
+
Ensure you configure:
|
|
46
54
|
|
|
47
|
-
|
|
48
|
-
|
|
55
|
+
- **Username**: DHIS2 admin username
|
|
56
|
+
- **Password**: Corresponding DHIS2 admin password
|
|
57
|
+
- **Host URL**: URL of the DHIS2 instance
|
|
49
58
|
|
|
50
|
-
|
|
51
|
-
changes by running `pnpm build docs`
|
|
59
|
+
Example configuration:
|
|
52
60
|
|
|
53
|
-
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"username": "admin",
|
|
64
|
+
"password": "district",
|
|
65
|
+
"hostUrl": "https://play.dhis2.org/2.36.6"
|
|
66
|
+
}
|
|
67
|
+
```
|
|
54
68
|
|
|
55
|
-
|
|
56
|
-
such as:
|
|
69
|
+
---
|
|
57
70
|
|
|
58
|
-
|
|
59
|
-
> API?
|
|
71
|
+
## Helper Functions
|
|
60
72
|
|
|
61
|
-
|
|
73
|
+
Helper functions simplify common DHIS2 operations. View the
|
|
74
|
+
[complete function documentation](https://docs.openfn.org/adaptors/packages/dhis2-docs).
|
|
62
75
|
|
|
63
|
-
|
|
64
|
-
|
|
76
|
+
## Development
|
|
77
|
+
|
|
78
|
+
### Running Tests
|
|
79
|
+
|
|
80
|
+
To run unit and integration tests, use the following commands:
|
|
81
|
+
|
|
82
|
+
- **Unit Tests**: `pnpm test`
|
|
83
|
+
- **Integration Tests**: `pnpm test:integration`
|
|
65
84
|
|
|
66
|
-
|
|
85
|
+
_Note: Integration tests depend on a live DHIS2 instance._
|
|
67
86
|
|
|
68
|
-
|
|
69
|
-
|
|
87
|
+
### Unit Tests
|
|
88
|
+
|
|
89
|
+
Unit tests validate helper functions independently. For example:
|
|
70
90
|
|
|
71
|
-
|
|
91
|
+
- Does `create('events', payload)` perform a correct POST request?
|
|
72
92
|
|
|
73
|
-
|
|
74
|
-
> DHIS2 system?
|
|
93
|
+
Add new unit tests whenever helper functions are updated.
|
|
75
94
|
|
|
76
|
-
|
|
77
|
-
network I/O and a public connection to a DHIS2 "play" server so their timing and
|
|
78
|
-
performance is unpredictable. Consider adding an increased timeout, and
|
|
79
|
-
modifying the orgUnit, program, etc., IDs set in `globalState`.
|
|
95
|
+
### Integration Tests
|
|
80
96
|
|
|
81
|
-
|
|
97
|
+
Integration tests validate end-to-end behavior with a live DHIS2 instance.
|
|
98
|
+
Ensure your test environment includes:
|
|
82
99
|
|
|
83
|
-
-
|
|
84
|
-
|
|
85
|
-
|
|
100
|
+
- At least one **organisation unit**.
|
|
101
|
+
- One **program** and a corresponding **program stage**.
|
|
102
|
+
- A **tracked entity instance** enrolled in the program.
|
|
86
103
|
|
|
87
|
-
|
|
88
|
-
depend on the **configuration of a target DHIS2 instance**. Currently you need
|
|
89
|
-
to have at least one organisation unit with one program, one
|
|
90
|
-
trackedEntityInstance and one programStage in it. These components need to be
|
|
91
|
-
well configured for the integration tests to work. For example: the
|
|
92
|
-
trackedEntityInstance need to be enrolled to the program, which should be
|
|
93
|
-
created in that organisation unit and contains at least that programStage. If
|
|
94
|
-
the tests fail, you must adjust these attributes in the
|
|
95
|
-
[before hook](https://github.com/OpenFn/adaptors/tree/main/packages/dhis2/test/integration.js):
|
|
104
|
+
Modify `globalState` in `test/integration.js` as needed:
|
|
96
105
|
|
|
97
106
|
```javascript
|
|
98
107
|
before(done => {
|
|
@@ -111,10 +120,14 @@ before(done => {
|
|
|
111
120
|
});
|
|
112
121
|
```
|
|
113
122
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
123
|
+
### Troubleshooting Tests
|
|
124
|
+
|
|
125
|
+
- **Timeout Errors**: Increase the global timeout in `test/mocha.opts`.
|
|
126
|
+
- **Environment Issues**: Ensure DHIS2 components (programs, org units, etc.)
|
|
127
|
+
are correctly configured.
|
|
128
|
+
|
|
129
|
+
---
|
|
118
130
|
|
|
119
|
-
|
|
120
|
-
|
|
131
|
+
For further technical details, see the
|
|
132
|
+
[documentation](https://docs.openfn.org/adaptors/packages/dhis2-docs) or contact
|
|
133
|
+
the [OpenFn community](https://community.openfn.org).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfn/language-dhis2",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.3",
|
|
4
4
|
"description": "DHIS2 Language Pack for OpenFn",
|
|
5
5
|
"homepage": "https://docs.openfn.org",
|
|
6
6
|
"repository": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"axios": "^1.7.7",
|
|
29
29
|
"lodash": "^4.17.21",
|
|
30
30
|
"qs": "^6.11.0",
|
|
31
|
-
"@openfn/language-common": "2.
|
|
31
|
+
"@openfn/language-common": "2.2.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"assertion-error": "2.0.0",
|