From ed80a98383b9b1a4ae7f4df263e2c4aaa3d1fc8d Mon Sep 17 00:00:00 2001 From: vivek Date: Wed, 22 Nov 2023 21:37:57 +0530 Subject: [PATCH 1/3] Update sample_format_external_result_import URL --- public/External-Results-Template.csv | 3 +++ public/config.json | 2 +- src/Components/ExternalResult/ExternalResultUpload.tsx | 10 +++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 public/External-Results-Template.csv diff --git a/public/External-Results-Template.csv b/public/External-Results-Template.csv new file mode 100644 index 00000000000..3ab2afc65ba --- /dev/null +++ b/public/External-Results-Template.csv @@ -0,0 +1,3 @@ +District,srf id,name,age,age in,gender,mobile number,address,ward,local body,local body type,source,Sample Collection Date,result date,test type,lab name,sample type,patient status,Is Repeat,patient category,result +Ernakulam,00/EKM/0000,Bodhi CSN,24,years,m,8888888888,"CSN HQ +Kochi, Kerala ",7,Poothrikka,grama panchayath,Secondary contact aparna,2020-10-14,2020-10-14,Antigen,Karothukuzhi Laboratory,Ag-SD_Biosensor_Standard_Q_COVID-19_Ag_detection_kit,Asymptomatic,NO,Cat 17: All individuals who wish to get themselves tested,Negative \ No newline at end of file diff --git a/public/config.json b/public/config.json index 444362cfb20..f676f1dacd0 100644 --- a/public/config.json +++ b/public/config.json @@ -21,6 +21,6 @@ "kasp_string": "KASP", "kasp_full_string": "Karunya Arogya Suraksha Padhathi", "sample_format_asset_import": "https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=11JaEhNHdyCHth4YQs_44YaRlP77Rrqe81VSEfg1glko&exportFormat=xlsx", - "sample_format_external_result_import": "https://docs.google.com/spreadsheets/d/17VfgryA6OYSYgtQZeXU9mp7kNvLySeEawvnLBO_1nuE/export?format=csv&id=17VfgryA6OYSYgtQZeXU9mp7kNvLySeEawvnLBO_1nuE", + "sample_format_external_result_import": "../../External-Results-Template.csv", "enable_abdm": true } \ No newline at end of file diff --git a/src/Components/ExternalResult/ExternalResultUpload.tsx b/src/Components/ExternalResult/ExternalResultUpload.tsx index 20a2cec3341..1bc97f0302a 100644 --- a/src/Components/ExternalResult/ExternalResultUpload.tsx +++ b/src/Components/ExternalResult/ExternalResultUpload.tsx @@ -72,6 +72,13 @@ export default function ExternalResultUpload() { } }; + const handleDownload = () => { + const link = document.createElement("a"); + link.href = sample_format_external_result_import; + link.download = "sample_format"; + link.click(); + link.remove(); + }; return (
{" "} {t("sample_format")} From feab64d85a651f4b6e4f9989e26a50cbad66380c Mon Sep 17 00:00:00 2001 From: vivek Date: Sun, 26 Nov 2023 15:02:35 +0530 Subject: [PATCH 2/3] Fix file path in config.json and refactor handleDownload function in ExternalResultUpload.tsx --- public/config.json | 2 +- .../ExternalResult/ExternalResultUpload.tsx | 15 +++++++-------- src/Utils/utils.ts | 8 ++++++++ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/public/config.json b/public/config.json index f676f1dacd0..74e509fee59 100644 --- a/public/config.json +++ b/public/config.json @@ -21,6 +21,6 @@ "kasp_string": "KASP", "kasp_full_string": "Karunya Arogya Suraksha Padhathi", "sample_format_asset_import": "https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=11JaEhNHdyCHth4YQs_44YaRlP77Rrqe81VSEfg1glko&exportFormat=xlsx", - "sample_format_external_result_import": "../../External-Results-Template.csv", + "sample_format_external_result_import": "/External-Results-Template.csv", "enable_abdm": true } \ No newline at end of file diff --git a/src/Components/ExternalResult/ExternalResultUpload.tsx b/src/Components/ExternalResult/ExternalResultUpload.tsx index 1bc97f0302a..1ef73baa8a9 100644 --- a/src/Components/ExternalResult/ExternalResultUpload.tsx +++ b/src/Components/ExternalResult/ExternalResultUpload.tsx @@ -11,6 +11,7 @@ import useAppHistory from "../../Common/hooks/useAppHistory"; import request from "../../Utils/request/request"; import routes from "../../Redux/api"; import { IExternalResult } from "./models"; +import { downloadFile } from "../../Utils/utils"; export default function ExternalResultUpload() { const { sample_format_external_result_import } = useConfig(); @@ -72,13 +73,6 @@ export default function ExternalResultUpload() { } }; - const handleDownload = () => { - const link = document.createElement("a"); - link.href = sample_format_external_result_import; - link.download = "sample_format"; - link.click(); - link.remove(); - }; return (
+ downloadFile( + sample_format_external_result_import, + "sample_format" + ) + } > {" "} {t("sample_format")} diff --git a/src/Utils/utils.ts b/src/Utils/utils.ts index cd75fdba7e7..d88fdea3635 100644 --- a/src/Utils/utils.ts +++ b/src/Utils/utils.ts @@ -454,3 +454,11 @@ export const scrollTo = (id: string | boolean) => { const element = document.querySelector(`#${id}`); element?.scrollIntoView({ behavior: "smooth", block: "center" }); }; + +export const downloadFile = (url: string, name: string) => { + const link = document.createElement("a"); + link.href = url; + link.download = name; + link.click(); + link.remove(); +}; From 8ca0aadf05707e3b5fd629a73d050871522bd33e Mon Sep 17 00:00:00 2001 From: vivek Date: Fri, 1 Dec 2023 13:59:12 +0530 Subject: [PATCH 3/3] Fix download functionality in ExternalResultUpload component --- .../ExternalResult/ExternalResultUpload.tsx | 11 +++-------- src/Utils/utils.ts | 8 -------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/Components/ExternalResult/ExternalResultUpload.tsx b/src/Components/ExternalResult/ExternalResultUpload.tsx index 1ef73baa8a9..5a9262b2990 100644 --- a/src/Components/ExternalResult/ExternalResultUpload.tsx +++ b/src/Components/ExternalResult/ExternalResultUpload.tsx @@ -11,7 +11,6 @@ import useAppHistory from "../../Common/hooks/useAppHistory"; import request from "../../Utils/request/request"; import routes from "../../Redux/api"; import { IExternalResult } from "./models"; -import { downloadFile } from "../../Utils/utils"; export default function ExternalResultUpload() { const { sample_format_external_result_import } = useConfig(); @@ -112,13 +111,9 @@ export default function ExternalResultUpload() { /> - downloadFile( - sample_format_external_result_import, - "sample_format" - ) - } + href={sample_format_external_result_import} + target="_blank" + download > {" "} {t("sample_format")} diff --git a/src/Utils/utils.ts b/src/Utils/utils.ts index d88fdea3635..cd75fdba7e7 100644 --- a/src/Utils/utils.ts +++ b/src/Utils/utils.ts @@ -454,11 +454,3 @@ export const scrollTo = (id: string | boolean) => { const element = document.querySelector(`#${id}`); element?.scrollIntoView({ behavior: "smooth", block: "center" }); }; - -export const downloadFile = (url: string, name: string) => { - const link = document.createElement("a"); - link.href = url; - link.download = name; - link.click(); - link.remove(); -};