Skip to content

Commit

Permalink
Merge pull request #307 from EyeSeeTea/development
Browse files Browse the repository at this point in the history
Release 1.6.21
  • Loading branch information
ifoche authored Nov 12, 2024
2 parents 62fc1b0 + 14edf82 commit bf75f59
Show file tree
Hide file tree
Showing 19 changed files with 541 additions and 54 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,11 @@ cypress/fixtures/

#vscode
.vscode/*

#script outputs
src/scripts/products_max_min_calculated_tons.json
src/scripts/substances_max_min_calculated_tons.json
src/scripts/error_response_report.json
src/scripts/d2_tracker_events_updated.json


6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "glass",
"description": "DHIS2 Glass App",
"version": "1.6.20",
"version": "1.6.21",
"license": "GPL-3.0",
"author": "EyeSeeTea team",
"homepage": ".",
Expand Down Expand Up @@ -120,7 +120,9 @@
"amr-agg-data-validation-ris": "npx ts-node -r dotenv/config src/scripts/amr_agg_data_validation.ts",
"amr-agg-data-reset-ris": "npx ts-node -r dotenv/config src/scripts/amr_agg_data_reset.ts",
"amr-agg-data-validation-sample": "npx ts-node -r dotenv/config src/scripts/amr_agg_data_validation_sample.ts",
"amr-agg-data-reset-sample": "npx ts-node -r dotenv/config src/scripts/amr_agg_data_reset_sample.ts"
"amr-agg-data-reset-sample": "npx ts-node -r dotenv/config src/scripts/amr_agg_data_reset_sample.ts",
"get-max-min-amc-calculated-tons": "npx ts-node -r dotenv/config src/scripts/get_max_min_amc_calculated_tons.ts",
"update-tons-to-kilograms": "npx ts-node -r dotenv/config src/scripts/update_autocalculated_and_manual_tons_to_kilograms.ts"
},
"manifest.webapp": {
"name": "glass",
Expand Down
2 changes: 1 addition & 1 deletion src/data/repositories/utils/importApiTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function importApiTracker(
request
)
).flatMap(response => {
console.debug(response.response.jobType);
console.debug(response.response);
return apiToFuture(api.system.waitFor("TRACKER_IMPORT_JOB", response.response.id)).map(result => {
if (result) return result;
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export type RawSubstanceConsumptionCalculated = {
data_status_autocalculated: number;
health_sector_autocalculated: string;
health_level_autocalculated: string;
tons_autocalculated: number;
kilograms_autocalculated: number;
packages_autocalculated: number;
atc_version_autocalculated: ATCVersionKey;
ddds_autocalculated: number;
Expand All @@ -78,7 +78,7 @@ export const RAW_SUBSTANCE_CONSUMPTION_CALCULATED_KEYS = [
"route_admin_autocalculated",
"salt_autocalculated",
"packages_autocalculated",
"tons_autocalculated",
"kilograms_autocalculated",
"atc_version_autocalculated",
"data_status_autocalculated",
"health_sector_autocalculated",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type SubstanceConsumptionCalculated = {
packages_autocalculated: number;
ddds_autocalculated: number;
atc_version_autocalculated: ATCVersionKey;
tons_autocalculated: number;
kilograms_autocalculated: number;
data_status_autocalculated: number;
health_sector_autocalculated: string;
health_level_autocalculated: string;
Expand All @@ -38,7 +38,7 @@ export const SUBSTANCE_CONSUMPTION_CALCULATED_KEYS = [
"packages_autocalculated",
"ddds_autocalculated",
"atc_version_autocalculated",
"tons_autocalculated",
"kilograms_autocalculated",
"data_status_autocalculated",
"health_sector_autocalculated",
"health_level_autocalculated",
Expand Down
11 changes: 6 additions & 5 deletions src/domain/usecases/data-entry/ImportBLTemplateEventProgram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import { Template } from "../../entities/Template";
import { ExcelReader } from "../../utils/ExcelReader";
import { InstanceRepository } from "../../repositories/InstanceRepository";
import { AMC_RAW_SUBSTANCE_CONSUMPTION_PROGRAM_ID } from "./amc/ImportAMCSubstanceLevelData";
import moment from "moment";
import { GlassATCDefaultRepository } from "../../../data/repositories/GlassATCDefaultRepository";
import { ListGlassATCLastVersionKeysByYear } from "../../entities/GlassAtcVersionData";
import moment from "moment";

const ATC_VERSION_DATA_ELEMENT_ID = "aCuWz3HZ5Ti";

Expand Down Expand Up @@ -206,14 +206,15 @@ export class ImportBLTemplateEventProgram {
): D2TrackerEvent[] {
return dataPackage.dataEntries.map(
({ id, orgUnit, period, attribute, dataValues, dataForm, coordinate }, index) => {
console.debug({ id, orgUnit, period, attribute, dataValues, dataForm, coordinate }, index);

const occurredAt =
dataForm === AMC_RAW_SUBSTANCE_CONSUMPTION_PROGRAM_ID
? moment(new Date(`${period.split("-").at(0)}-01-01`))
.toISOString()
.split("T")
.at(0) ?? period
? moment(new Date(new Date(period).getFullYear(), 0, 1)).format("YYYY-MM-DD") ?? period
: period;

console.debug(occurredAt);

return {
event: id || (index + 6).toString(),
program: dataForm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ function verifyCalculationResult(result: RawSubstanceConsumptionCalculated[], ty
expect(calculation.salt_autocalculated).toBe(expectedCalculation?.salt_autocalculated);
expect(calculation.year).toBe(expectedCalculation?.year);
expect(calculation.packages_autocalculated).toBe(expectedCalculation?.packages_autocalculated);
expect(calculation.tons_autocalculated).toBe(expectedCalculation?.tons_autocalculated);
expect(calculation.kilograms_autocalculated).toBe(expectedCalculation?.kilograms_autocalculated);
expect(calculation.ddds_autocalculated).toBe(expectedCalculation?.ddds_autocalculated);
expect(calculation.data_status_autocalculated).toBe(expectedCalculation?.data_status_autocalculated);
expect(calculation.health_sector_autocalculated).toBe(expectedCalculation?.health_sector_autocalculated);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function verifyCalculationResult(result: any[], type?: string) {
expect(calculation.packages_autocalculated).toBe(expectedCalculation?.packages_autocalculated);
expect(calculation.ddds_autocalculated).toBe(expectedCalculation?.ddds_autocalculated);
expect(calculation.atc_version_autocalculated).toBe(expectedCalculation?.atc_version_autocalculated);
expect(calculation.tons_autocalculated).toBe(expectedCalculation?.tons_autocalculated);
expect(calculation.kilograms_autocalculated).toBe(expectedCalculation?.kilograms_autocalculated);
expect(calculation.data_status_autocalculated).toBe(expectedCalculation?.data_status_autocalculated);
expect(calculation.health_sector_autocalculated).toBe(expectedCalculation?.health_sector_autocalculated);
expect(calculation.health_level_autocalculated).toBe(expectedCalculation?.health_level_autocalculated);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const calculationConsumptionSubstanceLevelBasic: SubstanceConsumptionCalc
packages_autocalculated: 151005,
ddds_autocalculated: 75502.5,
atc_version_autocalculated: "ATC-2023-v1",
tons_autocalculated: 0.0755025,
kilograms_autocalculated: 75.5025,
data_status_autocalculated: 1,
health_sector_autocalculated: "PUB",
health_level_autocalculated: "C",
Expand All @@ -31,7 +31,7 @@ export const calculationConsumptionSubstanceLevelBasic: SubstanceConsumptionCalc
packages_autocalculated: 152156,
ddds_autocalculated: 760780,
atc_version_autocalculated: "ATC-2023-v1",
tons_autocalculated: 0.76078,
kilograms_autocalculated: 760.78,
data_status_autocalculated: 1,
health_sector_autocalculated: "PUB",
health_level_autocalculated: "C",
Expand All @@ -51,7 +51,7 @@ export const calculationConsumptionSubstanceLevelBasic: SubstanceConsumptionCalc
packages_autocalculated: 152984,
ddds_autocalculated: 50994.6666666667,
atc_version_autocalculated: "ATC-2023-v1",
tons_autocalculated: 0.0509946666666667,
kilograms_autocalculated: 50.9946666666667,
data_status_autocalculated: 1,
health_sector_autocalculated: "PUB",
health_level_autocalculated: "C",
Expand All @@ -71,7 +71,7 @@ export const calculationConsumptionSubstanceLevelBasic: SubstanceConsumptionCalc
packages_autocalculated: 90169,
ddds_autocalculated: 846493.333333333,
atc_version_autocalculated: "ATC-2023-v1",
tons_autocalculated: 0.846493333333333,
kilograms_autocalculated: 846.493333333333,
data_status_autocalculated: 1,
health_sector_autocalculated: "PUB",
health_level_autocalculated: "C",
Expand All @@ -91,7 +91,7 @@ export const calculationConsumptionSubstanceLevelBasic: SubstanceConsumptionCalc
packages_autocalculated: 1545841,
ddds_autocalculated: 21641774,
atc_version_autocalculated: "ATC-2023-v1",
tons_autocalculated: 21.641774,
kilograms_autocalculated: 21641.774,
data_status_autocalculated: 1,
health_sector_autocalculated: "PUB",
health_level_autocalculated: "C",
Expand All @@ -111,7 +111,7 @@ export const calculationConsumptionSubstanceLevelBasic: SubstanceConsumptionCalc
packages_autocalculated: 1021561.548,
ddds_autocalculated: 510780.774,
atc_version_autocalculated: "ATC-2023-v1",
tons_autocalculated: 0.510780774,
kilograms_autocalculated: 510.780774,
data_status_autocalculated: 1,
health_sector_autocalculated: "PUB",
health_level_autocalculated: "C",
Expand All @@ -131,7 +131,7 @@ export const calculationConsumptionSubstanceLevelBasic: SubstanceConsumptionCalc
packages_autocalculated: 104843,
ddds_autocalculated: 1467802,
atc_version_autocalculated: "ATC-2023-v1",
tons_autocalculated: 1.467802,
kilograms_autocalculated: 1467.8020000000001,
data_status_autocalculated: 1,
health_sector_autocalculated: "PUB",
health_level_autocalculated: "C",
Expand All @@ -151,7 +151,7 @@ export const calculationConsumptionSubstanceLevelBasic: SubstanceConsumptionCalc
packages_autocalculated: 105151,
ddds_autocalculated: 17525.1666666667,
atc_version_autocalculated: "ATC-2023-v1",
tons_autocalculated: 0.0175251666666667,
kilograms_autocalculated: 17.5251666666667,
data_status_autocalculated: 1,
health_sector_autocalculated: "PUB",
health_level_autocalculated: "C",
Expand All @@ -171,7 +171,7 @@ export const calculationConsumptionSubstanceLevelBasic: SubstanceConsumptionCalc
packages_autocalculated: 15241,
ddds_autocalculated: 88905.8333333333,
atc_version_autocalculated: "ATC-2023-v1",
tons_autocalculated: 0.0889058333333333,
kilograms_autocalculated: 88.90583333333329,
data_status_autocalculated: 1,
health_sector_autocalculated: "PUB",
health_level_autocalculated: "C",
Expand All @@ -191,7 +191,7 @@ export const calculationConsumptionSubstanceLevelBasic: SubstanceConsumptionCalc
packages_autocalculated: 115145,
ddds_autocalculated: 287862.5,
atc_version_autocalculated: "ATC-2023-v1",
tons_autocalculated: 0.2878625,
kilograms_autocalculated: 287.8625,
data_status_autocalculated: 1,
health_sector_autocalculated: "PUB",
health_level_autocalculated: "C",
Expand All @@ -211,7 +211,7 @@ export const calculationConsumptionSubstanceLevelBasic: SubstanceConsumptionCalc
packages_autocalculated: 48,
ddds_autocalculated: 280,
atc_version_autocalculated: "ATC-2023-v1",
tons_autocalculated: 0.00028,
kilograms_autocalculated: 0.27999999999999997,
data_status_autocalculated: 1,
health_sector_autocalculated: "PUB",
health_level_autocalculated: "C",
Expand All @@ -231,7 +231,7 @@ export const calculationConsumptionSubstanceLevelBasic: SubstanceConsumptionCalc
packages_autocalculated: 1020,
ddds_autocalculated: 5100,
atc_version_autocalculated: "ATC-2023-v1",
tons_autocalculated: 0.0051,
kilograms_autocalculated: 5.1000000000000005,
data_status_autocalculated: 1,
health_sector_autocalculated: "PUB",
health_level_autocalculated: "C",
Expand All @@ -251,7 +251,7 @@ export const calculationConsumptionSubstanceLevelBasic: SubstanceConsumptionCalc
packages_autocalculated: 15151,
ddds_autocalculated: 5050.33333333333,
atc_version_autocalculated: "ATC-2023-v1",
tons_autocalculated: 0.00505033333333333,
kilograms_autocalculated: 5.05033333333333,
data_status_autocalculated: 1,
health_sector_autocalculated: "PUB",
health_level_autocalculated: "C",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"salt_autocalculated": "XXXX",
"year": "2020",
"packages_autocalculated": 50,
"tons_autocalculated": 0.000030000000000000004,
"kilograms_autocalculated": 0.030000000000000006,
"ddds_autocalculated": 8.333333333333334,
"data_status_autocalculated": 1,
"health_sector_autocalculated": "PUB",
Expand All @@ -26,7 +26,7 @@
"salt_autocalculated": "XXXX",
"year": "2020",
"packages_autocalculated": 108,
"tons_autocalculated": 0.00006480000000000002,
"kilograms_autocalculated": 0.06480000000000001,
"ddds_autocalculated": 18,
"data_status_autocalculated": 3,
"health_sector_autocalculated": "PUB",
Expand All @@ -46,7 +46,7 @@
"salt_autocalculated": "XXXX",
"year": "2020",
"packages_autocalculated": 73,
"tons_autocalculated": 0.00004380000000000001,
"kilograms_autocalculated": 0.043800000000000006,
"ddds_autocalculated": 12.166666666666668,
"data_status_autocalculated": 2,
"health_sector_autocalculated": "PUB",
Expand All @@ -66,7 +66,7 @@
"salt_autocalculated": "XXXX",
"year": "2020",
"packages_autocalculated": 45,
"tons_autocalculated": 0.000027000000000000002,
"kilograms_autocalculated": 0.027000000000000002,
"ddds_autocalculated": 7.500000000000001,
"data_status_autocalculated": 1,
"health_sector_autocalculated": "PUB",
Expand All @@ -86,7 +86,7 @@
"salt_autocalculated": "XXXX",
"year": "2020",
"packages_autocalculated": 18,
"tons_autocalculated": 0.0000108,
"kilograms_autocalculated": 0.0108,
"ddds_autocalculated": 3.0000000000000004,
"data_status_autocalculated": 3,
"health_sector_autocalculated": "PUB",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"salt_autocalculated": "XXXX",
"year": "2020",
"packages_autocalculated": 50,
"tons_autocalculated": 0.00025,
"kilograms_autocalculated": 0.25,
"ddds_autocalculated": 250,
"data_status_autocalculated": 1,
"health_sector_autocalculated": "PUB",
Expand All @@ -26,7 +26,7 @@
"salt_autocalculated": "XXXX",
"year": "2020",
"packages_autocalculated": 108,
"tons_autocalculated": 0.00054,
"kilograms_autocalculated": 0.54,
"ddds_autocalculated": 540,
"data_status_autocalculated": 3,
"health_sector_autocalculated": "PUB",
Expand All @@ -46,7 +46,7 @@
"salt_autocalculated": "XXXX",
"year": "2020",
"packages_autocalculated": 73,
"tons_autocalculated": 0.000365,
"kilograms_autocalculated": 0.365,
"ddds_autocalculated": 365,
"data_status_autocalculated": 2,
"health_sector_autocalculated": "PUB",
Expand All @@ -66,7 +66,7 @@
"salt_autocalculated": "XXXX",
"year": "2020",
"packages_autocalculated": 45,
"tons_autocalculated": 0.000225,
"kilograms_autocalculated": 0.225,
"ddds_autocalculated": 112.5,
"data_status_autocalculated": 1,
"health_sector_autocalculated": "PUB",
Expand All @@ -86,7 +86,7 @@
"salt_autocalculated": "XXXX",
"year": "2020",
"packages_autocalculated": 18,
"tons_autocalculated": 0.00009,
"kilograms_autocalculated": 0.09000000000000001,
"ddds_autocalculated": 45,
"data_status_autocalculated": 3,
"health_sector_autocalculated": "PUB",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"salt_autocalculated": "XXXX",
"year": "2020",
"packages_autocalculated": 50,
"tons_autocalculated": 0.00025,
"kilograms_autocalculated": 0.25,
"ddds_autocalculated": 166.66666666666669,
"data_status_autocalculated": 1,
"health_sector_autocalculated": "PUB",
Expand All @@ -26,7 +26,7 @@
"salt_autocalculated": "XXXX",
"year": "2020",
"packages_autocalculated": 108,
"tons_autocalculated": 0.00054,
"kilograms_autocalculated": 0.54,
"ddds_autocalculated": 360,
"data_status_autocalculated": 3,
"health_sector_autocalculated": "PUB",
Expand All @@ -46,7 +46,7 @@
"salt_autocalculated": "XXXX",
"year": "2020",
"packages_autocalculated": 73,
"tons_autocalculated": 0.000365,
"kilograms_autocalculated": 0.365,
"ddds_autocalculated": 243.33333333333334,
"data_status_autocalculated": 2,
"health_sector_autocalculated": "PUB",
Expand All @@ -66,7 +66,7 @@
"salt_autocalculated": "XXXX",
"year": "2020",
"packages_autocalculated": 45,
"tons_autocalculated": 0.000225,
"kilograms_autocalculated": 0.225,
"ddds_autocalculated": 150,
"data_status_autocalculated": 1,
"health_sector_autocalculated": "PUB",
Expand All @@ -86,7 +86,7 @@
"salt_autocalculated": "XXXX",
"year": "2020",
"packages_autocalculated": 18,
"tons_autocalculated": 0.00009,
"kilograms_autocalculated": 0.09000000000000001,
"ddds_autocalculated": 60,
"data_status_autocalculated": 3,
"health_sector_autocalculated": "PUB",
Expand Down
Loading

0 comments on commit bf75f59

Please sign in to comment.