You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+69-6Lines changed: 69 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,30 @@
1
-
## Introduction
1
+
#Data Approval Extended
2
2
3
-
Data Approval App
3
+
**Data Approval Extended** (formerly *NHWA Approval Report*) is a DHIS2 app that lets authorised users review the state of dataset submissions across organisation units and periods, and drive them through a complete **complete → submit → approve** workflow backed by the native `dataApprovals` / `completeDataSetRegistrations` APIs and a mirror "approval" dataset (APVD) that stores per-element approved values and submission/approval timestamps.
4
+
5
+
The app is **generic**: any DHIS2 dataset can be registered from the in-app *DataSet Configurations* settings screen, pointed at its APVD dataset and SQL views, and given per-action permission groups. Configurations live in the DHIS2 dataStore (`dataset-approval` namespace) and can be edited at runtime without redeploying the app.
6
+
7
+
See the [user guide](docs/data-approval-user-guide.md) for the full end-user documentation — list columns, filters, the contextual row actions, per-dataset permission groups and the optional *DataElementGroups* flag.
8
+
9
+
## Requirements
10
+
11
+
- Node.js and Yarn (Classic).
12
+
- A DHIS2 instance compatible with `react-scripts@4` / `@dhis2/app-runtime@3.2.5`.
13
+
- Credentials for a DHIS2 user with enough privileges to create metadata (datasets, data elements, SQL views, dataStore entries) when running the setup scripts below.
4
14
5
15
## Initial setup
6
16
7
17
```
8
18
$ yarn install
9
19
```
10
20
21
+
Most tasks in this repo — the dev server, the build, and the setup scripts — read DHIS2 credentials from environment variables. Create a `.env.local` file at the repo root:
22
+
23
+
```
24
+
REACT_APP_DHIS2_BASE_URL=http://localhost:8080
25
+
REACT_APP_DHIS2_AUTH=admin:district
26
+
```
27
+
11
28
## Development
12
29
13
30
Start the development server at `http://localhost:8082` using `https://play.dhis2.org/2.34` as a backend:
@@ -16,11 +33,37 @@ Start the development server at `http://localhost:8082` using `https://play.dhis
Produces an installable app zip (`data-approval-extended.zip`) at the repo root. Drop it into **App Management** on any compatible DHIS2 instance to install or upgrade the app. `yarn build` runs `yarn localize` and `yarn test` via the `prebuild` hook before building, so a failing test will abort the build.
43
+
44
+
## End-to-end dataset setup
45
+
46
+
Before a dataset shows up in the app, three pieces of DHIS2 metadata must be in place:
47
+
48
+
1. An **approval (APVD) dataset** — a clone of the source dataset whose data elements carry the `-APVD` suffix, plus two date data elements that track when the data was submitted and when it was approved.
49
+
2. Two **SQL views** — one for current periods and one for old periods — that the app queries for the approval list.
50
+
3. A **DataSetConfiguration** entry in the dataStore that glues the two together and sets the permission groups.
51
+
52
+
Steps 1 and 2 are automated by the setup scripts described below. Step 3 can be done either by the same `generate-sqlviews --persist dhis` invocation (which creates a default configuration) or by hand from the in-app **DataSet Configurations** settings screen.
53
+
54
+
Typical end-to-end flow for a fresh dataset:
55
+
56
+
1. Populate `.env.local` with `REACT_APP_DHIS2_BASE_URL` and `REACT_APP_DHIS2_AUTH`.
57
+
2. Run `yarn run generate-dataset-approval`**without**`--post` to preview the APVD dataset that would be created, then re-run **with**`--post` to commit it.
58
+
3. Run `yarn run generate-sqlviews --persist dhis` to create the current-periods and old-periods SQL views in the instance (and a default `DataSetConfiguration`).
59
+
4. Open the app → *DataSet Configurations* → edit the newly created entry, adjust the *Submit Date* / *Approval Date* data elements if needed, and assign user groups / users to each permission (*Read*, *Complete*, *Incomplete*, *Submit*, *Revoke*, *Approve*). Save.
60
+
5. Open the main **Data Approval** list, apply filters and verify the rows for the new dataset appear with the expected statuses.
61
+
19
62
## Generate sql view for a dataSet
20
63
21
64
Script to generate necessary sqlViews for dataSets and create a DataSetConfiguration.
22
65
23
-
If you want to persist the sqlViews and configuration to DHIS2 please configure the following variables in your `.env` file:
66
+
If you want to persist the sqlViews and configuration to DHIS2 please configure the following variables in your `.env.local` file:
24
67
25
68
```
26
69
REACT_APP_DHIS2_BASE_URL=http://localhost:8080
@@ -48,11 +91,13 @@ Parameters:
48
91
49
92
When `--persist dhis` is used, the script also creates a DataSetConfiguration in the DHIS2 DataStore with `submitAndComplete: true`, `revokeAndIncomplete: true`, and empty permissions (only admin users have access to this dataSet. You can edit this in the settings page of the application).
50
93
94
+
When `--persist disk` is used, the generated SQL is written to files under the repo so you can review or hand-apply it, and a `sqlviews-import-report.json` file is written with the details of what would be created.
95
+
51
96
## Generate DataSet Approval metadata
52
97
53
98
Script to clone an existing DataSet and its DataElements with the `-APVD` suffix, generating a new approval DataSet and metadata file.
54
99
55
-
Make sure the following variables are configured in your `.env` file:
100
+
Make sure the following variables are configured in your `.env.local` file:
56
101
57
102
```
58
103
REACT_APP_DHIS2_BASE_URL=http://localhost:8080
@@ -65,16 +110,34 @@ Run the script:
65
110
yarn run generate-dataset-approval --dataSet MY_DS_CODE \
66
111
--dataElement-submission "MY_DS_CODE-Submission date module1-APVD" \
67
112
--dataElement-approval "MY_DS_CODE-Approval date module1-APVD" \
68
-
--persist
113
+
--post
69
114
```
70
115
71
116
Parameters:
72
117
73
118
-`--dataSet` (`-ds`): dataSet code of the original dataSet (required)
119
+
-`--dataElement-submission`: name/code of the data element that will store the submission timestamp (required)
120
+
-`--dataElement-approval`: name/code of the data element that will store the approval timestamp (required)
74
121
-`--post`: commit metadata to DHIS2 (default: validate only)
75
122
76
123
Notes:
77
124
125
+
- Without `--post` the script runs in **validate-only** (dry-run) mode, prints what it would create and exits without touching DHIS2 — so you can safely preview before committing.
78
126
- Writes a metadata JSON file named `<dataSetCode>_<timestamp>.json` in the current directory.
79
-
- Show dataElements without code and saves them to `warning_<dataSetCode>_<timestamp>.json`.
127
+
- Long names/codes are automatically trimmed to stay within DHIS2's length limits; the trimmed values are logged to `trimmed_names_<dataSetCode>_<timestamp>.json`.
128
+
- DataElements without a code are reported in `warnings_dataelements_<dataSetCode>_<timestamp>.json`.
80
129
- On validation/import errors, saves details to `errors_<dataSetCode>_<timestamp>.json`.
130
+
131
+
## Where configuration lives
132
+
133
+
-**DataSet configurations** are stored in the DHIS2 dataStore under the `dataset-approval` namespace, one entry per dataset, with keys of the form `DS_<id>`. Creating, editing and removing configurations is done either through the in-app *DataSet Configurations* settings screen or, for the initial default entry, automatically by `yarn run generate-sqlviews --persist dhis`.
134
+
-**Per-user column visibility** for the main Data Approval list is stored under the user dataStore namespace `nhwa-data-approval-status-user-columns`, so each user's gear-icon column layout is remembered across sessions.
135
+
-**Approval state** for each (dataset, orgUnit, period) row is tracked through DHIS2's native `dataApprovals` and `completeDataSetRegistrations` APIs, with submission and approval dates written as data values on the configured date dataElements of the APVD dataset (default COC).
136
+
137
+
## Other scripts
138
+
139
+
-`yarn lint` — ESLint over `src/`.
140
+
-`yarn test` — Jest (with `--passWithNoTests`).
141
+
-`yarn prettify` — Prettier over the repo.
142
+
-`yarn localize` — extract POT + regenerate i18n strings.
143
+
-`yarn approve-mal-datavalues` / `yarn check-data-differences` — legacy operator scripts kept around for ad-hoc DHIS2 interventions; see the script sources under `src/scripts/`.
0 commit comments