diff --git a/client/src/components/Form.vue b/client/src/components/Form.vue index ffbda83..6caa650 100644 --- a/client/src/components/Form.vue +++ b/client/src/components/Form.vue @@ -217,7 +217,7 @@ import FileSaver from "file-saver"; import apiService from "../services/apiService"; import { periods } from "../utils/enums/application"; import { RLS } from "../utils/types/rls"; -import { InitiativeTypes } from "../utils/types"; +import { HA, haMapping, InitiativeTypes } from "../utils/types"; import { useAuthStore } from "../stores/authStore"; import { getCurrentFiscalAndPeriod } from "../utils/helper"; @@ -233,7 +233,7 @@ const fiscalYears = ref([]); // Reactive selected values const selectedRLSEntries = ref([]); -const selectedHealthAuthority = ref(); +const selectedHealthAuthority = ref(); const selectedPCNCommunity = ref(); const selectedInitiativeName = ref(); const selectedFiscalYear = ref(); @@ -278,9 +278,22 @@ const mutation = useMutation({ reportingPeriod: String(selectedPeriod.value), }) .then((data) => { - const fileName = `${initiative.value}${selectedHealthAuthority.value}${ - selectedPeriod.value - }${String(selectedFiscalYear.value)}`.replace(/[^a-z0-9_-]/gi, "_"); + const today = new Date(); + const fileName = `HLTH.FinRpt.${ + haMapping[selectedHealthAuthority.value || "NotAvailable"] + }.${initiative.value?.toUpperCase()}.FY${String(selectedFiscalYear.value) + .substring(2) + .replace("/", "")}.${selectedPeriod.value}.${today.getFullYear()}${( + today.getMonth() + 1 + ) + .toString() + .padStart(2, "0")}${today + .getDate() + .toString() + .padStart(2, "0")}.${today + .getHours() + .toString() + .padStart(2, "0")}${today.getMinutes().toString().padStart(2, "0")}`; FileSaver.saveAs(data.data, `${fileName}.xlsm`); toast.success("Template downloaded successfully", { duration: 5000, @@ -337,7 +350,7 @@ watch( () => initiative.value, (newInitiative) => { if (!newInitiative) return; - selectedHealthAuthority.value = null; + selectedHealthAuthority.value = undefined; selectedPCNCommunity.value = []; selectedInitiativeName.value = []; } diff --git a/client/src/utils/types/index.ts b/client/src/utils/types/index.ts index 87a57c0..ae0d4b1 100644 --- a/client/src/utils/types/index.ts +++ b/client/src/utils/types/index.ts @@ -28,3 +28,14 @@ export type OtherFinancialSubmission = { export type FinancialSubmission = | PCNFinancialSubmission | OtherFinancialSubmission; + +export const haMapping = { + Fraser: "FHA", + Interior: "IHA", + "Vancouver Island": "VIHA", + Northern: "NHA", + "Vancouver Coastal": "VCHA", + NotAvailable: "N-A", +}; + +export type HA = keyof typeof haMapping; diff --git a/server/api/components/chefsService.ts b/server/api/components/chefsService.ts index 1b82e92..c930de7 100644 --- a/server/api/components/chefsService.ts +++ b/server/api/components/chefsService.ts @@ -169,7 +169,7 @@ export default function ChefsService() { switch (data.typeOfInitiative) { case "pcn": const pcnFields = - "healthAuthority,communityName,fiscalYear,periodReported,financialData"; + "healthAuthority,communityName,fiscalYear,periodReported,financialData,reasonForExceptionInPeriodReported"; const pcnUrl = `${env.CHEFS_API_URL}/forms/${env.CHEFS_PCN_FINANCIAL_FORM_ID}/submissions?deleted=false&draft=false&fields=${pcnFields}`; const pcnResponse = await fetch(pcnUrl, { headers: { @@ -216,7 +216,7 @@ export default function ChefsService() { return pcnReports; case "upcc": const upccFields = - "healthAuthority,communityName,upccName,fiscalYear,periodReported,financialData"; + "healthAuthority,communityName,upccName,fiscalYear,periodReported,financialData,reasonForExceptionInPeriodReported"; const upccUrl = `${env.CHEFS_API_URL}/forms/${env.CHEFS_UPCC_FINANCIAL_FORM_ID}/submissions?deleted=false&draft=false&fields=${upccFields}`; const upccResponse = await fetch(upccUrl, { headers: { @@ -264,7 +264,7 @@ export default function ChefsService() { return upccReports; case "nppcc": const nppccFields = - "healthAuthority,communityName,nppccName,fiscalYear,periodReported,financialData"; + "healthAuthority,communityName,nppccName,fiscalYear,periodReported,financialData,reasonForExceptionInPeriodReported"; const nppccUrl = `${env.CHEFS_API_URL}/forms/${env.CHEFS_NPPCC_FINANCIAL_FORM_ID}/submissions?deleted=false&draft=false&fields=${nppccFields}`; const nppccResponse = await fetch(nppccUrl, { headers: { @@ -312,7 +312,7 @@ export default function ChefsService() { return nppccReports; case "chc": const chcFields = - "healthAuthority,communityName,chcName,fiscalYear,periodReported,financialData"; + "healthAuthority,communityName,chcName,fiscalYear,periodReported,financialData,reasonForExceptionInPeriodReported"; const chcUrl = `${env.CHEFS_API_URL}/forms/${env.CHEFS_CHC_FINANCIAL_FORM_ID}/submissions?deleted=false&draft=false&fields=${chcFields}`; const chcResponse = await fetch(chcUrl, { headers: { diff --git a/server/api/utils/mapping.ts b/server/api/utils/mapping.ts index c10a13d..394f4d7 100644 --- a/server/api/utils/mapping.ts +++ b/server/api/utils/mapping.ts @@ -113,6 +113,8 @@ export default { } } + console.log(reportingSubmission); + return { submissionInformation: { healthAuthority: reportingSubmission.healthAuthority, diff --git a/server/api/utils/worksheet.ts b/server/api/utils/worksheet.ts index 23619e2..34279a8 100644 --- a/server/api/utils/worksheet.ts +++ b/server/api/utils/worksheet.ts @@ -184,12 +184,10 @@ export default { ); } if (initiative === "pcn") { - // Needs clarification on the following fields worksheet .cell(constants.PCN.notes + String(index)) .value(formatValue(item.submissionInformation.notes)); } else { - // Needs clarification on the following fields worksheet .cell( // @ts-expect-error - TS doesn't know that initiative is a valid key for constants @@ -198,6 +196,17 @@ export default { ) .value(formatValue(item.submissionInformation.notes)); } + worksheet + .cell( + constants[initiative.toUpperCase() as Initiative] + .reasonForExceptionInPeriodReported + String(index) + ) + .value( + formatValue( + item.submissionInformation.reasonForExceptionInPeriodReported, + true + ) + ); index = index + 1; } if (item.reporting.length > 0) { @@ -464,7 +473,6 @@ export default { .value(formatValue(item.budget.totalBudgetAllocation)); } - // Needs clarification on the following fields worksheet .cell(constants.PCN.otherItems + String(index)) .value(formatValue(report.otherItems));