Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2910: Flutracking - percent fever & cough per postcode SOL-56 #2872

Merged
merged 25 commits into from
Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ccd40a1
psuh for biao to debug locally - not to merge
PShoe Jun 30, 2021
258e437
Merge branch 'dev' into 2910-prcnt-fever-cough-postcode
PShoe Jul 8, 2021
bb726b7
commit but do not merge
PShoe Jul 9, 2021
608a51d
Merge branch 'dev' into 2910-prcnt-fever-cough-postcode
PShoe Jul 9, 2021
2be758d
Update examples.http
PShoe Jul 9, 2021
c90713f
Update requestFromTupaiaConfigServer.js
PShoe Jul 9, 2021
2eeeeb0
Update requestFromTupaiaConfigServer.js
PShoe Jul 9, 2021
e217f4f
Update measureData.js
PShoe Jul 9, 2021
a4441fc
Update index.ts
PShoe Jul 9, 2021
0e414fc
Update index.ts
PShoe Jul 9, 2021
c6ef73e
Update 20210630053253-AddPostcodePercentFeverOverlayFlutracking-modif…
PShoe Jul 9, 2021
ada7430
Merge branch 'dev' into 2910-prcnt-fever-cough-postcode
PShoe Jul 12, 2021
8e6cc75
Merge branch 'dev' into 2910-prcnt-fever-cough-postcode
PShoe Jul 21, 2021
82a769e
Merge branch 'dev' into 2910-prcnt-fever-cough-postcode
PShoe Jul 21, 2021
ce62f2e
Add flu by postcode overlay via reports server
PShoe Jul 21, 2021
bd321d6
Adjust back to 0 percent min threshold
PShoe Jul 22, 2021
a3e0f3c
Merge branch 'dev' into 2910-prcnt-fever-cough-postcode
PShoe Jul 26, 2021
91517b1
Update yarn.lock
PShoe Jul 26, 2021
ad3aa81
Merge branch 'dev' into 2910-prcnt-fever-cough-postcode
PShoe Jul 27, 2021
582d83d
Update 20210630053253-AddPostcodePercentFeverOverlayFlutracking-modif…
PShoe Jul 28, 2021
723b74e
Update 20210630015116-FlutrackingPostcodeOverlayReportConfig-modifies…
PShoe Jul 28, 2021
c88430f
Merge branch 'dev' into 2910-prcnt-fever-cough-postcode
PShoe Jul 28, 2021
05415d4
Merge branch 'dev' into 2910-prcnt-fever-cough-postcode
PShoe Aug 3, 2021
5d2960d
Merge branch 'dev' into 2910-prcnt-fever-cough-postcode
PShoe Aug 10, 2021
2d574af
Merge branch 'dev' into 2910-prcnt-fever-cough-postcode
PShoe Aug 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
'use strict';

import { generateId, insertObject } from '../utilities';

var dbm;
var type;
var seed;

/**
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function (options, seedLink) {
dbm = options.dbmigrate;
type = dbm.dataType;
seed = seedLink;
};

const permissionGroupNameToId = async (db, name) => {
const record = await db.runSql(`SELECT id FROM permission_group WHERE name = '${name}'`);
return record.rows[0] && record.rows[0].id;
};

const REPORT = {
id: generateId(),
code: 'AU_Flutracking_Postcode_Percent_Report',
config: {
fetch: {
aggregations: [
{
type: 'RAW',
config: {
dataSourceEntityType: 'postcode',
},
},
],
dataElements: ['FWV_PC_004', 'FWV_PC_003'],
dataGroups: ['FPWV'],
},
transform: [
{
transform: 'select',
"'numerator'": '$row.FWV_PC_004',
"'denominator'": '$row.FWV_PC_003',
"'organisationUnitCode'": '$row.orgUnit',
},
{
transform: 'aggregate',
numerator: 'sum',
denominator: 'sum',
organisationUnitCode: 'group',
},
{
transform: 'select',
"'value'": 'divide($row.numerator, $row.denominator)',
"'Total respondents'": '$row.denominator',
"'Respondents reporting fever & cough'": '$row.numerator',
'...': ['organisationUnitCode'],
},
{
transform: 'filter',
where: "$row.value > '0.01'",
'...': ['organisationUnitCode'],
},
Copy link
Contributor Author

@PShoe PShoe Jul 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rohan-bes also need help with filtering 'No data' on report server side, not FE, trying exists() and other ideas but haven't gotten it working yet. Chat to you this am?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PShoe Do you find a way to filter 'No data'? I guess you do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rohan said it wasn't possible. So no, but also fine with the code as is. 👍

],
},
};

exports.up = async function (db) {
const permissionGroupId = await permissionGroupNameToId(db, 'Public');
await insertObject(db, 'report', { ...REPORT, permission_group_id: permissionGroupId });
};

exports.down = async function (db) {
return db.runSql(`
DELETE FROM "report" WHERE code = '${REPORT.code}';
`);
};

exports._meta = {
version: 1,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
'use strict';

import { insertObject, generateId } from '../utilities';

var dbm;
var type;
var seed;

/**
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function (options, seedLink) {
dbm = options.dbmigrate;
type = dbm.dataType;
seed = seedLink;
};

const MAP_OVERLAY = {
id: 'AU_Flutracking_Postcode_Fever_Percent',
name: '% fever and cough by postcode',
userGroup: 'Public',
dataElementCode: 'value',
isDataRegional: true,
measureBuilder: 'useReportServer',
measureBuilderConfig: {
dataSourceType: 'custom',
reportCode: 'AU_Flutracking_Postcode_Percent_Report',
},
presentationOptions: {
Copy link
Contributor Author

@PShoe PShoe Jul 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rohan-bes displayOnLevel: 'District' was removed as performance is looking slightly better. Can add back if needed.

hideByDefault: {
null: true,
},
icon: 'circle',
displayType: 'shaded-spectrum',
measureLevel: 'Postcode',
valueType: 'percentage',
scaleType: 'performance',
scaleColorScheme: 'default',
hideFromPopup: false,
hideFromMenu: false,
hideFromLegend: false,
linkedMeasures: null,
periodGranularity: 'one_week_at_a_time',
scaleBounds: {
right: {
max: 0.05,
},
left: {
max: 0.01,
},
},
measureConfig: {
$all: {
type: 'popup-only',
hideFromLegend: true,
measureLevel: 'Postcode',
},
},
},
countryCodes: '{"AU"}',
projectCodes: '{covidau}',
};

const getMapOverlayGroupId = async function (db, code) {
const results = await db.runSql(`select "id" from "map_overlay_group" where "code" = '${code}';`);

if (results.rows.length > 0) {
return results.rows[0].id;
}

throw new Error('MapOverlayGroup not found');
};

const mapOverlayGroupRelation = groupId => ({
id: generateId(),
map_overlay_group_id: groupId,
child_id: MAP_OVERLAY.id,
child_type: 'mapOverlay',
sort_order: 0,
});

const MAP_OVERLAY_GROUP_CODE = 'Flutracking_Australia';

exports.up = async function (db) {
await insertObject(db, 'mapOverlay', MAP_OVERLAY);
const mapOverlayGroupId = await getMapOverlayGroupId(db, MAP_OVERLAY_GROUP_CODE);
await insertObject(db, 'map_overlay_group_relation', mapOverlayGroupRelation(mapOverlayGroupId));
};

exports.down = function (db) {
return db.runSql(`
delete from "map_overlay_group_relation" where "child_id" = '${MAP_OVERLAY.id}';
delete from "mapOverlay" where "id" = '${MAP_OVERLAY.id}';
`);
};

exports._meta = {
version: 1,
};
2 changes: 1 addition & 1 deletion packages/report-server/examples.http
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ Authorization: {{authorization}}
}
]
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably revert this return change? Totally fine by me but it is up to you.