Skip to content

Commit

Permalink
feat: add support for Outliers table vis type in DV (DHIS2-13858) (#1598
Browse files Browse the repository at this point in the history
)
  • Loading branch information
edoardo authored Mar 13, 2024
1 parent c463f66 commit d9b1ccd
Show file tree
Hide file tree
Showing 33 changed files with 1,313 additions and 673 deletions.
22 changes: 17 additions & 5 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2023-09-27T14:15:13.876Z\n"
"PO-Revision-Date: 2023-09-27T14:15:13.876Z\n"
"POT-Creation-Date: 2024-01-25T12:05:03.360Z\n"
"PO-Revision-Date: 2024-01-25T12:05:03.360Z\n"

msgid "view only"
msgstr "view only"
Expand Down Expand Up @@ -150,6 +150,9 @@ msgstr "Math operators"
msgid "Data Type"
msgstr "Data Type"

msgid "Only {{dataType}} can be used in {{visType}}"
msgstr "Only {{dataType}} can be used in {{visType}}"

msgid "All types"
msgstr "All types"

Expand Down Expand Up @@ -180,6 +183,9 @@ msgstr "No event data items found"
msgid "No program indicators found"
msgstr "No program indicators found"

msgid "No calculations found"
msgstr "No calculations found"

msgid "No indicators found for \"{{- searchTerm}}\""
msgstr "No indicators found for \"{{- searchTerm}}\""

Expand All @@ -192,6 +198,9 @@ msgstr "No event data items found for \"{{- searchTerm}}\""
msgid "No program indicators found for \"{{- searchTerm}}\""
msgstr "No program indicators found for \"{{- searchTerm}}\""

msgid "No calculations found for \"{{- searchTerm}}\""
msgstr "No calculations found for \"{{- searchTerm}}\""

msgid "Nothing found for \"{{- searchTerm}}\""
msgstr "Nothing found for \"{{- searchTerm}}\""

Expand Down Expand Up @@ -657,15 +666,15 @@ msgstr "Select year"
msgid "Period"
msgstr "Period"

msgid "Selected Periods"
msgstr "Selected Periods"

msgid "Relative periods"
msgstr "Relative periods"

msgid "Fixed periods"
msgstr "Fixed periods"

msgid "Selected Periods"
msgstr "Selected Periods"

msgid "No periods selected"
msgstr "No periods selected"

Expand Down Expand Up @@ -1167,6 +1176,9 @@ msgstr "Scatter"
msgid "Single value"
msgstr "Single value"

msgid "Outlier table"
msgstr "Outlier table"

msgid "All charts"
msgstr "All charts"

Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@dhis2/cli-app-scripts": "^9.0.1",
"@dhis2/cli-style": "^10.4.1",
"@dhis2/d2-i18n": "^1.1.0",
"@dhis2/ui": "^8.4.11",
"@dhis2/ui": "^9.2.0",
"@sambego/storybook-state": "^2.0.1",
"@storybook/addons": "^6.5.16",
"@storybook/preset-create-react-app": "^3.1.7",
Expand All @@ -52,7 +52,7 @@
"peerDependencies": {
"@dhis2/app-runtime": "^3",
"@dhis2/d2-i18n": "^1.1",
"@dhis2/ui": "^8.2.5",
"@dhis2/ui": "^9.2.0",
"prop-types": "^15",
"react": "^16.3",
"react-dom": "^16.3",
Expand All @@ -75,6 +75,9 @@
"react-beautiful-dnd": "^10.1.1",
"resize-observer-polyfill": "^1.5.1"
},
"resolutions": {
"@dhis2/ui": "^9.2.0"
},
"files": [
"build"
]
Expand Down
4 changes: 4 additions & 0 deletions src/__fixtures__/fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ export default (function x() {
require('./json/api/analytics/enrollments.json')
)

addFixture(
'/api/analytics/outlierDetection',
require('./json/api/analytics/outlierDetection.json')
)
return {
get: getFixture,
add: addFixture,
Expand Down
213 changes: 213 additions & 0 deletions src/__fixtures__/json/api/analytics/outlierDetection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
{
"headers": [
{
"name": "dxname",
"column": "Data name",
"valueType": "TEXT",
"type": "java.lang.String",
"hidden": false,
"meta": false
},
{
"name": "ouname",
"column": "Organisation unit name",
"valueType": "TEXT",
"type": "java.lang.String",
"hidden": false,
"meta": false
},
{
"name": "value",
"column": "Value",
"valueType": "NUMBER",
"type": "java.lang.Double",
"hidden": false,
"meta": false
},
{
"name": "absdev",
"column": "Absolute deviation",
"valueType": "NUMBER",
"type": "java.lang.Double",
"hidden": false,
"meta": false
},
{
"name": "modifiedzscore",
"column": "Modified zScore",
"valueType": "NUMBER",
"type": "java.lang.Double",
"hidden": false,
"meta": false
},
{
"name": "median",
"column": "Median",
"valueType": "NUMBER",
"type": "java.lang.Double",
"hidden": false,
"meta": false
},
{
"name": "lowerbound",
"column": "Lower boundary",
"valueType": "NUMBER",
"type": "java.lang.Double",
"hidden": false,
"meta": false
},
{
"name": "upperbound",
"column": "Upper boundary",
"valueType": "NUMBER",
"type": "java.lang.Double",
"hidden": false,
"meta": false
}
],
"metaData": {
"maxResults": 100,
"count": 13,
"orderBy": "mean_abs_dev",
"threshold": 3.0,
"algorithm": "MOD_Z_SCORE"
},
"rowContext": {

},
"rows": [
[
"ANC 2nd visit",
"UMC (Urban Centre) Hospital",
"1669.0",
"920.0",
"3.902767295597484",
"749.0",
"-290.93013894085743",
"1788.9301389408574"
],
[
"ANC 1st visit",
"Charlotte CHP",
"49.0",
"39.0",
"7.515857142857143",
"10.0",
"-23.948490393535913",
"43.94849039353591"
],
[
"ANC 2nd visit",
"Charlotte CHP",
"40.0",
"33.0",
"22.258499999999998",
"7.0",
"-30.86489139031037",
"44.86489139031037"
],
[
"ANC 2nd visit",
"Wilberforce CHC",
"56.0",
"24.5",
"3.004590909090909",
"31.5",
"-1.3890179239210454",
"64.38901792392105"
],
[
"ANC 1st visit",
"Deep Eye water MCHP",
"40.0",
"16.0",
"3.5973333333333333",
"24.0",
"4.850913859925324",
"43.14908614007467"
],
[
"ANC 2nd visit",
"Lion for Lion Clinic",
"30.0",
"16.0",
"3.5973333333333333",
"14.0",
"-5.620896815302167",
"33.62089681530217"
],
[
"ANC 2nd visit",
"Deep Eye water MCHP",
"33.0",
"14.5",
"3.9121",
"18.5",
"-3.4245866551686603",
"40.42458665516866"
],
[
"ANC 2nd visit",
"Blessed Mokaka East Clinic",
"2.0",
"13.0",
"4.38425",
"15.0",
"-3.417043736713012",
"33.41704373671301"
],
[
"ANC 2nd visit",
"Malambay CHP",
"15.0",
"12.0",
"5.396",
"3.0",
"-13.770509831248425",
"19.770509831248425"
],
[
"ANC 2nd visit",
"Wellbody MCHP",
"20.0",
"10.0",
"3.3725",
"10.0",
"-10.999999999999996",
"30.999999999999996"
],
[
"ANC 1st visit",
"Blessed Mokaka East Clinic",
"26.0",
"10.0",
"4.496666666666667",
"16.0",
"1.6734512181055958",
"30.326548781894402"
],
[
"ANC 1st visit",
"Murray Town CHC",
"18.0",
"9.0",
"6.0705",
"9.0",
"-2.43571205496543",
"20.43571205496543"
],
[
"ANC 2nd visit",
"Thompson Bay MCHP",
"11.0",
"6.0",
"4.047",
"5.0",
"-2.038266127580332",
"12.038266127580332"
]
],
"headerWidth": 8,
"width": 8,
"height": 13
}
28 changes: 27 additions & 1 deletion src/api/analytics/AnalyticsAggregate.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,38 @@ class AnalyticsAggregate extends AnalyticsBase {
* .withStartDate('2017-10-01')
* .withEndDate('2017-10-31');
*
* analytics.aggregate.getDebugSql(req);
* analytics.aggregate.getDebugSql(req)
* .then(console.log);
*/
getDebugSql(req) {
return this.fetch(req.withPath('debug/sql'))
}

/**
* @param {!AnalyticsRequest} req Request object
*
* @returns {Promise} Promise that resolves with the SQL statement used to query the database.
*
* @example
* const req = new analytics.request()
* .withParameters({
* dx: 'fbfJHSPpUQD,cYeuwXTCPkU',
* pe: 'THIS_YEAR',
* ou: 'USER_ORGUNIT,USER_ORGUNIT_CHILDREN',
* headers: 'dxname,pename,ouname,value,absdev,modifiedzscore,median,lowerbound,upperbound',
* algorithm: 'MODIFIED_Z_SCORE',
* maxResults: 100,
* threshold: 3,
orderBy: 'value',
sortOrder: 'desc',
* });
*
* analytics.aggregate.getOutliersData(req)
* .then(console.log);
*/
getOutliersData(req) {
return this.fetch(req.withPath('outlierDetection'))
}
}

export default AnalyticsAggregate
Loading

0 comments on commit d9b1ccd

Please sign in to comment.